mutation.go 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/contact"
  19. "wechat-api/ent/creditbalance"
  20. "wechat-api/ent/creditusage"
  21. "wechat-api/ent/custom_types"
  22. "wechat-api/ent/employee"
  23. "wechat-api/ent/employeeconfig"
  24. "wechat-api/ent/label"
  25. "wechat-api/ent/labelrelationship"
  26. "wechat-api/ent/labeltagging"
  27. "wechat-api/ent/message"
  28. "wechat-api/ent/messagerecords"
  29. "wechat-api/ent/msg"
  30. "wechat-api/ent/payrecharge"
  31. "wechat-api/ent/predicate"
  32. "wechat-api/ent/server"
  33. "wechat-api/ent/sopnode"
  34. "wechat-api/ent/sopstage"
  35. "wechat-api/ent/soptask"
  36. "wechat-api/ent/token"
  37. "wechat-api/ent/tutorial"
  38. "wechat-api/ent/usagedetail"
  39. "wechat-api/ent/usagestatisticday"
  40. "wechat-api/ent/usagestatistichour"
  41. "wechat-api/ent/usagestatisticmonth"
  42. "wechat-api/ent/usagetotal"
  43. "wechat-api/ent/whatsapp"
  44. "wechat-api/ent/whatsappchannel"
  45. "wechat-api/ent/workexperience"
  46. "wechat-api/ent/wpchatroom"
  47. "wechat-api/ent/wpchatroommember"
  48. "wechat-api/ent/wx"
  49. "wechat-api/ent/wxcard"
  50. "wechat-api/ent/wxcarduser"
  51. "wechat-api/ent/wxcardvisit"
  52. "wechat-api/ent/xunji"
  53. "wechat-api/ent/xunjiservice"
  54. "entgo.io/ent"
  55. "entgo.io/ent/dialect/sql"
  56. )
  57. const (
  58. // Operation types.
  59. OpCreate = ent.OpCreate
  60. OpDelete = ent.OpDelete
  61. OpDeleteOne = ent.OpDeleteOne
  62. OpUpdate = ent.OpUpdate
  63. OpUpdateOne = ent.OpUpdateOne
  64. // Node types.
  65. TypeAgent = "Agent"
  66. TypeAgentBase = "AgentBase"
  67. TypeAliyunAvatar = "AliyunAvatar"
  68. TypeAllocAgent = "AllocAgent"
  69. TypeApiKey = "ApiKey"
  70. TypeBatchMsg = "BatchMsg"
  71. TypeCategory = "Category"
  72. TypeChatRecords = "ChatRecords"
  73. TypeChatSession = "ChatSession"
  74. TypeContact = "Contact"
  75. TypeCreditBalance = "CreditBalance"
  76. TypeCreditUsage = "CreditUsage"
  77. TypeEmployee = "Employee"
  78. TypeEmployeeConfig = "EmployeeConfig"
  79. TypeLabel = "Label"
  80. TypeLabelRelationship = "LabelRelationship"
  81. TypeLabelTagging = "LabelTagging"
  82. TypeMessage = "Message"
  83. TypeMessageRecords = "MessageRecords"
  84. TypeMsg = "Msg"
  85. TypePayRecharge = "PayRecharge"
  86. TypeServer = "Server"
  87. TypeSopNode = "SopNode"
  88. TypeSopStage = "SopStage"
  89. TypeSopTask = "SopTask"
  90. TypeToken = "Token"
  91. TypeTutorial = "Tutorial"
  92. TypeUsageDetail = "UsageDetail"
  93. TypeUsageStatisticDay = "UsageStatisticDay"
  94. TypeUsageStatisticHour = "UsageStatisticHour"
  95. TypeUsageStatisticMonth = "UsageStatisticMonth"
  96. TypeUsageTotal = "UsageTotal"
  97. TypeWhatsapp = "Whatsapp"
  98. TypeWhatsappChannel = "WhatsappChannel"
  99. TypeWorkExperience = "WorkExperience"
  100. TypeWpChatroom = "WpChatroom"
  101. TypeWpChatroomMember = "WpChatroomMember"
  102. TypeWx = "Wx"
  103. TypeWxCard = "WxCard"
  104. TypeWxCardUser = "WxCardUser"
  105. TypeWxCardVisit = "WxCardVisit"
  106. TypeXunji = "Xunji"
  107. TypeXunjiService = "XunjiService"
  108. )
  109. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  110. type AgentMutation struct {
  111. config
  112. op Op
  113. typ string
  114. id *uint64
  115. created_at *time.Time
  116. updated_at *time.Time
  117. deleted_at *time.Time
  118. name *string
  119. role *string
  120. status *int
  121. addstatus *int
  122. background *string
  123. examples *string
  124. organization_id *uint64
  125. addorganization_id *int64
  126. dataset_id *string
  127. collection_id *string
  128. clearedFields map[string]struct{}
  129. wx_agent map[uint64]struct{}
  130. removedwx_agent map[uint64]struct{}
  131. clearedwx_agent bool
  132. token_agent map[uint64]struct{}
  133. removedtoken_agent map[uint64]struct{}
  134. clearedtoken_agent bool
  135. wa_agent map[uint64]struct{}
  136. removedwa_agent map[uint64]struct{}
  137. clearedwa_agent bool
  138. xjs_agent map[uint64]struct{}
  139. removedxjs_agent map[uint64]struct{}
  140. clearedxjs_agent bool
  141. key_agent map[uint64]struct{}
  142. removedkey_agent map[uint64]struct{}
  143. clearedkey_agent bool
  144. done bool
  145. oldValue func(context.Context) (*Agent, error)
  146. predicates []predicate.Agent
  147. }
  148. var _ ent.Mutation = (*AgentMutation)(nil)
  149. // agentOption allows management of the mutation configuration using functional options.
  150. type agentOption func(*AgentMutation)
  151. // newAgentMutation creates new mutation for the Agent entity.
  152. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  153. m := &AgentMutation{
  154. config: c,
  155. op: op,
  156. typ: TypeAgent,
  157. clearedFields: make(map[string]struct{}),
  158. }
  159. for _, opt := range opts {
  160. opt(m)
  161. }
  162. return m
  163. }
  164. // withAgentID sets the ID field of the mutation.
  165. func withAgentID(id uint64) agentOption {
  166. return func(m *AgentMutation) {
  167. var (
  168. err error
  169. once sync.Once
  170. value *Agent
  171. )
  172. m.oldValue = func(ctx context.Context) (*Agent, error) {
  173. once.Do(func() {
  174. if m.done {
  175. err = errors.New("querying old values post mutation is not allowed")
  176. } else {
  177. value, err = m.Client().Agent.Get(ctx, id)
  178. }
  179. })
  180. return value, err
  181. }
  182. m.id = &id
  183. }
  184. }
  185. // withAgent sets the old Agent of the mutation.
  186. func withAgent(node *Agent) agentOption {
  187. return func(m *AgentMutation) {
  188. m.oldValue = func(context.Context) (*Agent, error) {
  189. return node, nil
  190. }
  191. m.id = &node.ID
  192. }
  193. }
  194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  195. // executed in a transaction (ent.Tx), a transactional client is returned.
  196. func (m AgentMutation) Client() *Client {
  197. client := &Client{config: m.config}
  198. client.init()
  199. return client
  200. }
  201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  202. // it returns an error otherwise.
  203. func (m AgentMutation) Tx() (*Tx, error) {
  204. if _, ok := m.driver.(*txDriver); !ok {
  205. return nil, errors.New("ent: mutation is not running in a transaction")
  206. }
  207. tx := &Tx{config: m.config}
  208. tx.init()
  209. return tx, nil
  210. }
  211. // SetID sets the value of the id field. Note that this
  212. // operation is only accepted on creation of Agent entities.
  213. func (m *AgentMutation) SetID(id uint64) {
  214. m.id = &id
  215. }
  216. // ID returns the ID value in the mutation. Note that the ID is only available
  217. // if it was provided to the builder or after it was returned from the database.
  218. func (m *AgentMutation) ID() (id uint64, exists bool) {
  219. if m.id == nil {
  220. return
  221. }
  222. return *m.id, true
  223. }
  224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  225. // That means, if the mutation is applied within a transaction with an isolation level such
  226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  227. // or updated by the mutation.
  228. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  229. switch {
  230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  231. id, exists := m.ID()
  232. if exists {
  233. return []uint64{id}, nil
  234. }
  235. fallthrough
  236. case m.op.Is(OpUpdate | OpDelete):
  237. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  238. default:
  239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  240. }
  241. }
  242. // SetCreatedAt sets the "created_at" field.
  243. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  244. m.created_at = &t
  245. }
  246. // CreatedAt returns the value of the "created_at" field in the mutation.
  247. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  248. v := m.created_at
  249. if v == nil {
  250. return
  251. }
  252. return *v, true
  253. }
  254. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  255. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  257. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  258. if !m.op.Is(OpUpdateOne) {
  259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  260. }
  261. if m.id == nil || m.oldValue == nil {
  262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  263. }
  264. oldValue, err := m.oldValue(ctx)
  265. if err != nil {
  266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  267. }
  268. return oldValue.CreatedAt, nil
  269. }
  270. // ResetCreatedAt resets all changes to the "created_at" field.
  271. func (m *AgentMutation) ResetCreatedAt() {
  272. m.created_at = nil
  273. }
  274. // SetUpdatedAt sets the "updated_at" field.
  275. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  276. m.updated_at = &t
  277. }
  278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  279. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  280. v := m.updated_at
  281. if v == nil {
  282. return
  283. }
  284. return *v, true
  285. }
  286. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  287. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  289. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  290. if !m.op.Is(OpUpdateOne) {
  291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  292. }
  293. if m.id == nil || m.oldValue == nil {
  294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  295. }
  296. oldValue, err := m.oldValue(ctx)
  297. if err != nil {
  298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  299. }
  300. return oldValue.UpdatedAt, nil
  301. }
  302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  303. func (m *AgentMutation) ResetUpdatedAt() {
  304. m.updated_at = nil
  305. }
  306. // SetDeletedAt sets the "deleted_at" field.
  307. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  308. m.deleted_at = &t
  309. }
  310. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  311. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  312. v := m.deleted_at
  313. if v == nil {
  314. return
  315. }
  316. return *v, true
  317. }
  318. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  319. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  321. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  322. if !m.op.Is(OpUpdateOne) {
  323. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  324. }
  325. if m.id == nil || m.oldValue == nil {
  326. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  327. }
  328. oldValue, err := m.oldValue(ctx)
  329. if err != nil {
  330. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  331. }
  332. return oldValue.DeletedAt, nil
  333. }
  334. // ClearDeletedAt clears the value of the "deleted_at" field.
  335. func (m *AgentMutation) ClearDeletedAt() {
  336. m.deleted_at = nil
  337. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  338. }
  339. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  340. func (m *AgentMutation) DeletedAtCleared() bool {
  341. _, ok := m.clearedFields[agent.FieldDeletedAt]
  342. return ok
  343. }
  344. // ResetDeletedAt resets all changes to the "deleted_at" field.
  345. func (m *AgentMutation) ResetDeletedAt() {
  346. m.deleted_at = nil
  347. delete(m.clearedFields, agent.FieldDeletedAt)
  348. }
  349. // SetName sets the "name" field.
  350. func (m *AgentMutation) SetName(s string) {
  351. m.name = &s
  352. }
  353. // Name returns the value of the "name" field in the mutation.
  354. func (m *AgentMutation) Name() (r string, exists bool) {
  355. v := m.name
  356. if v == nil {
  357. return
  358. }
  359. return *v, true
  360. }
  361. // OldName returns the old "name" field's value of the Agent entity.
  362. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  364. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  365. if !m.op.Is(OpUpdateOne) {
  366. return v, errors.New("OldName is only allowed on UpdateOne operations")
  367. }
  368. if m.id == nil || m.oldValue == nil {
  369. return v, errors.New("OldName requires an ID field in the mutation")
  370. }
  371. oldValue, err := m.oldValue(ctx)
  372. if err != nil {
  373. return v, fmt.Errorf("querying old value for OldName: %w", err)
  374. }
  375. return oldValue.Name, nil
  376. }
  377. // ResetName resets all changes to the "name" field.
  378. func (m *AgentMutation) ResetName() {
  379. m.name = nil
  380. }
  381. // SetRole sets the "role" field.
  382. func (m *AgentMutation) SetRole(s string) {
  383. m.role = &s
  384. }
  385. // Role returns the value of the "role" field in the mutation.
  386. func (m *AgentMutation) Role() (r string, exists bool) {
  387. v := m.role
  388. if v == nil {
  389. return
  390. }
  391. return *v, true
  392. }
  393. // OldRole returns the old "role" field's value of the Agent entity.
  394. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  396. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  397. if !m.op.Is(OpUpdateOne) {
  398. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  399. }
  400. if m.id == nil || m.oldValue == nil {
  401. return v, errors.New("OldRole requires an ID field in the mutation")
  402. }
  403. oldValue, err := m.oldValue(ctx)
  404. if err != nil {
  405. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  406. }
  407. return oldValue.Role, nil
  408. }
  409. // ResetRole resets all changes to the "role" field.
  410. func (m *AgentMutation) ResetRole() {
  411. m.role = nil
  412. }
  413. // SetStatus sets the "status" field.
  414. func (m *AgentMutation) SetStatus(i int) {
  415. m.status = &i
  416. m.addstatus = nil
  417. }
  418. // Status returns the value of the "status" field in the mutation.
  419. func (m *AgentMutation) Status() (r int, exists bool) {
  420. v := m.status
  421. if v == nil {
  422. return
  423. }
  424. return *v, true
  425. }
  426. // OldStatus returns the old "status" field's value of the Agent entity.
  427. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  429. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  430. if !m.op.Is(OpUpdateOne) {
  431. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  432. }
  433. if m.id == nil || m.oldValue == nil {
  434. return v, errors.New("OldStatus requires an ID field in the mutation")
  435. }
  436. oldValue, err := m.oldValue(ctx)
  437. if err != nil {
  438. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  439. }
  440. return oldValue.Status, nil
  441. }
  442. // AddStatus adds i to the "status" field.
  443. func (m *AgentMutation) AddStatus(i int) {
  444. if m.addstatus != nil {
  445. *m.addstatus += i
  446. } else {
  447. m.addstatus = &i
  448. }
  449. }
  450. // AddedStatus returns the value that was added to the "status" field in this mutation.
  451. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  452. v := m.addstatus
  453. if v == nil {
  454. return
  455. }
  456. return *v, true
  457. }
  458. // ClearStatus clears the value of the "status" field.
  459. func (m *AgentMutation) ClearStatus() {
  460. m.status = nil
  461. m.addstatus = nil
  462. m.clearedFields[agent.FieldStatus] = struct{}{}
  463. }
  464. // StatusCleared returns if the "status" field was cleared in this mutation.
  465. func (m *AgentMutation) StatusCleared() bool {
  466. _, ok := m.clearedFields[agent.FieldStatus]
  467. return ok
  468. }
  469. // ResetStatus resets all changes to the "status" field.
  470. func (m *AgentMutation) ResetStatus() {
  471. m.status = nil
  472. m.addstatus = nil
  473. delete(m.clearedFields, agent.FieldStatus)
  474. }
  475. // SetBackground sets the "background" field.
  476. func (m *AgentMutation) SetBackground(s string) {
  477. m.background = &s
  478. }
  479. // Background returns the value of the "background" field in the mutation.
  480. func (m *AgentMutation) Background() (r string, exists bool) {
  481. v := m.background
  482. if v == nil {
  483. return
  484. }
  485. return *v, true
  486. }
  487. // OldBackground returns the old "background" field's value of the Agent entity.
  488. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  490. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  491. if !m.op.Is(OpUpdateOne) {
  492. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  493. }
  494. if m.id == nil || m.oldValue == nil {
  495. return v, errors.New("OldBackground requires an ID field in the mutation")
  496. }
  497. oldValue, err := m.oldValue(ctx)
  498. if err != nil {
  499. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  500. }
  501. return oldValue.Background, nil
  502. }
  503. // ClearBackground clears the value of the "background" field.
  504. func (m *AgentMutation) ClearBackground() {
  505. m.background = nil
  506. m.clearedFields[agent.FieldBackground] = struct{}{}
  507. }
  508. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  509. func (m *AgentMutation) BackgroundCleared() bool {
  510. _, ok := m.clearedFields[agent.FieldBackground]
  511. return ok
  512. }
  513. // ResetBackground resets all changes to the "background" field.
  514. func (m *AgentMutation) ResetBackground() {
  515. m.background = nil
  516. delete(m.clearedFields, agent.FieldBackground)
  517. }
  518. // SetExamples sets the "examples" field.
  519. func (m *AgentMutation) SetExamples(s string) {
  520. m.examples = &s
  521. }
  522. // Examples returns the value of the "examples" field in the mutation.
  523. func (m *AgentMutation) Examples() (r string, exists bool) {
  524. v := m.examples
  525. if v == nil {
  526. return
  527. }
  528. return *v, true
  529. }
  530. // OldExamples returns the old "examples" field's value of the Agent entity.
  531. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  533. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  534. if !m.op.Is(OpUpdateOne) {
  535. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  536. }
  537. if m.id == nil || m.oldValue == nil {
  538. return v, errors.New("OldExamples requires an ID field in the mutation")
  539. }
  540. oldValue, err := m.oldValue(ctx)
  541. if err != nil {
  542. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  543. }
  544. return oldValue.Examples, nil
  545. }
  546. // ClearExamples clears the value of the "examples" field.
  547. func (m *AgentMutation) ClearExamples() {
  548. m.examples = nil
  549. m.clearedFields[agent.FieldExamples] = struct{}{}
  550. }
  551. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  552. func (m *AgentMutation) ExamplesCleared() bool {
  553. _, ok := m.clearedFields[agent.FieldExamples]
  554. return ok
  555. }
  556. // ResetExamples resets all changes to the "examples" field.
  557. func (m *AgentMutation) ResetExamples() {
  558. m.examples = nil
  559. delete(m.clearedFields, agent.FieldExamples)
  560. }
  561. // SetOrganizationID sets the "organization_id" field.
  562. func (m *AgentMutation) SetOrganizationID(u uint64) {
  563. m.organization_id = &u
  564. m.addorganization_id = nil
  565. }
  566. // OrganizationID returns the value of the "organization_id" field in the mutation.
  567. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  568. v := m.organization_id
  569. if v == nil {
  570. return
  571. }
  572. return *v, true
  573. }
  574. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  575. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  577. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  578. if !m.op.Is(OpUpdateOne) {
  579. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  580. }
  581. if m.id == nil || m.oldValue == nil {
  582. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  583. }
  584. oldValue, err := m.oldValue(ctx)
  585. if err != nil {
  586. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  587. }
  588. return oldValue.OrganizationID, nil
  589. }
  590. // AddOrganizationID adds u to the "organization_id" field.
  591. func (m *AgentMutation) AddOrganizationID(u int64) {
  592. if m.addorganization_id != nil {
  593. *m.addorganization_id += u
  594. } else {
  595. m.addorganization_id = &u
  596. }
  597. }
  598. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  599. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  600. v := m.addorganization_id
  601. if v == nil {
  602. return
  603. }
  604. return *v, true
  605. }
  606. // ResetOrganizationID resets all changes to the "organization_id" field.
  607. func (m *AgentMutation) ResetOrganizationID() {
  608. m.organization_id = nil
  609. m.addorganization_id = nil
  610. }
  611. // SetDatasetID sets the "dataset_id" field.
  612. func (m *AgentMutation) SetDatasetID(s string) {
  613. m.dataset_id = &s
  614. }
  615. // DatasetID returns the value of the "dataset_id" field in the mutation.
  616. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  617. v := m.dataset_id
  618. if v == nil {
  619. return
  620. }
  621. return *v, true
  622. }
  623. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  624. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  626. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  627. if !m.op.Is(OpUpdateOne) {
  628. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  629. }
  630. if m.id == nil || m.oldValue == nil {
  631. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  632. }
  633. oldValue, err := m.oldValue(ctx)
  634. if err != nil {
  635. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  636. }
  637. return oldValue.DatasetID, nil
  638. }
  639. // ResetDatasetID resets all changes to the "dataset_id" field.
  640. func (m *AgentMutation) ResetDatasetID() {
  641. m.dataset_id = nil
  642. }
  643. // SetCollectionID sets the "collection_id" field.
  644. func (m *AgentMutation) SetCollectionID(s string) {
  645. m.collection_id = &s
  646. }
  647. // CollectionID returns the value of the "collection_id" field in the mutation.
  648. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  649. v := m.collection_id
  650. if v == nil {
  651. return
  652. }
  653. return *v, true
  654. }
  655. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  656. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  658. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  659. if !m.op.Is(OpUpdateOne) {
  660. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  661. }
  662. if m.id == nil || m.oldValue == nil {
  663. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  664. }
  665. oldValue, err := m.oldValue(ctx)
  666. if err != nil {
  667. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  668. }
  669. return oldValue.CollectionID, nil
  670. }
  671. // ResetCollectionID resets all changes to the "collection_id" field.
  672. func (m *AgentMutation) ResetCollectionID() {
  673. m.collection_id = nil
  674. }
  675. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  676. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  677. if m.wx_agent == nil {
  678. m.wx_agent = make(map[uint64]struct{})
  679. }
  680. for i := range ids {
  681. m.wx_agent[ids[i]] = struct{}{}
  682. }
  683. }
  684. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  685. func (m *AgentMutation) ClearWxAgent() {
  686. m.clearedwx_agent = true
  687. }
  688. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  689. func (m *AgentMutation) WxAgentCleared() bool {
  690. return m.clearedwx_agent
  691. }
  692. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  693. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  694. if m.removedwx_agent == nil {
  695. m.removedwx_agent = make(map[uint64]struct{})
  696. }
  697. for i := range ids {
  698. delete(m.wx_agent, ids[i])
  699. m.removedwx_agent[ids[i]] = struct{}{}
  700. }
  701. }
  702. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  703. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  704. for id := range m.removedwx_agent {
  705. ids = append(ids, id)
  706. }
  707. return
  708. }
  709. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  710. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  711. for id := range m.wx_agent {
  712. ids = append(ids, id)
  713. }
  714. return
  715. }
  716. // ResetWxAgent resets all changes to the "wx_agent" edge.
  717. func (m *AgentMutation) ResetWxAgent() {
  718. m.wx_agent = nil
  719. m.clearedwx_agent = false
  720. m.removedwx_agent = nil
  721. }
  722. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  723. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  724. if m.token_agent == nil {
  725. m.token_agent = make(map[uint64]struct{})
  726. }
  727. for i := range ids {
  728. m.token_agent[ids[i]] = struct{}{}
  729. }
  730. }
  731. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  732. func (m *AgentMutation) ClearTokenAgent() {
  733. m.clearedtoken_agent = true
  734. }
  735. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  736. func (m *AgentMutation) TokenAgentCleared() bool {
  737. return m.clearedtoken_agent
  738. }
  739. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  740. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  741. if m.removedtoken_agent == nil {
  742. m.removedtoken_agent = make(map[uint64]struct{})
  743. }
  744. for i := range ids {
  745. delete(m.token_agent, ids[i])
  746. m.removedtoken_agent[ids[i]] = struct{}{}
  747. }
  748. }
  749. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  750. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  751. for id := range m.removedtoken_agent {
  752. ids = append(ids, id)
  753. }
  754. return
  755. }
  756. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  757. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  758. for id := range m.token_agent {
  759. ids = append(ids, id)
  760. }
  761. return
  762. }
  763. // ResetTokenAgent resets all changes to the "token_agent" edge.
  764. func (m *AgentMutation) ResetTokenAgent() {
  765. m.token_agent = nil
  766. m.clearedtoken_agent = false
  767. m.removedtoken_agent = nil
  768. }
  769. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  770. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  771. if m.wa_agent == nil {
  772. m.wa_agent = make(map[uint64]struct{})
  773. }
  774. for i := range ids {
  775. m.wa_agent[ids[i]] = struct{}{}
  776. }
  777. }
  778. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  779. func (m *AgentMutation) ClearWaAgent() {
  780. m.clearedwa_agent = true
  781. }
  782. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  783. func (m *AgentMutation) WaAgentCleared() bool {
  784. return m.clearedwa_agent
  785. }
  786. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  787. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  788. if m.removedwa_agent == nil {
  789. m.removedwa_agent = make(map[uint64]struct{})
  790. }
  791. for i := range ids {
  792. delete(m.wa_agent, ids[i])
  793. m.removedwa_agent[ids[i]] = struct{}{}
  794. }
  795. }
  796. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  797. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  798. for id := range m.removedwa_agent {
  799. ids = append(ids, id)
  800. }
  801. return
  802. }
  803. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  804. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  805. for id := range m.wa_agent {
  806. ids = append(ids, id)
  807. }
  808. return
  809. }
  810. // ResetWaAgent resets all changes to the "wa_agent" edge.
  811. func (m *AgentMutation) ResetWaAgent() {
  812. m.wa_agent = nil
  813. m.clearedwa_agent = false
  814. m.removedwa_agent = nil
  815. }
  816. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  817. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  818. if m.xjs_agent == nil {
  819. m.xjs_agent = make(map[uint64]struct{})
  820. }
  821. for i := range ids {
  822. m.xjs_agent[ids[i]] = struct{}{}
  823. }
  824. }
  825. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  826. func (m *AgentMutation) ClearXjsAgent() {
  827. m.clearedxjs_agent = true
  828. }
  829. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  830. func (m *AgentMutation) XjsAgentCleared() bool {
  831. return m.clearedxjs_agent
  832. }
  833. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  834. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  835. if m.removedxjs_agent == nil {
  836. m.removedxjs_agent = make(map[uint64]struct{})
  837. }
  838. for i := range ids {
  839. delete(m.xjs_agent, ids[i])
  840. m.removedxjs_agent[ids[i]] = struct{}{}
  841. }
  842. }
  843. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  844. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  845. for id := range m.removedxjs_agent {
  846. ids = append(ids, id)
  847. }
  848. return
  849. }
  850. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  851. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  852. for id := range m.xjs_agent {
  853. ids = append(ids, id)
  854. }
  855. return
  856. }
  857. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  858. func (m *AgentMutation) ResetXjsAgent() {
  859. m.xjs_agent = nil
  860. m.clearedxjs_agent = false
  861. m.removedxjs_agent = nil
  862. }
  863. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  864. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  865. if m.key_agent == nil {
  866. m.key_agent = make(map[uint64]struct{})
  867. }
  868. for i := range ids {
  869. m.key_agent[ids[i]] = struct{}{}
  870. }
  871. }
  872. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  873. func (m *AgentMutation) ClearKeyAgent() {
  874. m.clearedkey_agent = true
  875. }
  876. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  877. func (m *AgentMutation) KeyAgentCleared() bool {
  878. return m.clearedkey_agent
  879. }
  880. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  881. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  882. if m.removedkey_agent == nil {
  883. m.removedkey_agent = make(map[uint64]struct{})
  884. }
  885. for i := range ids {
  886. delete(m.key_agent, ids[i])
  887. m.removedkey_agent[ids[i]] = struct{}{}
  888. }
  889. }
  890. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  891. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  892. for id := range m.removedkey_agent {
  893. ids = append(ids, id)
  894. }
  895. return
  896. }
  897. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  898. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  899. for id := range m.key_agent {
  900. ids = append(ids, id)
  901. }
  902. return
  903. }
  904. // ResetKeyAgent resets all changes to the "key_agent" edge.
  905. func (m *AgentMutation) ResetKeyAgent() {
  906. m.key_agent = nil
  907. m.clearedkey_agent = false
  908. m.removedkey_agent = nil
  909. }
  910. // Where appends a list predicates to the AgentMutation builder.
  911. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  912. m.predicates = append(m.predicates, ps...)
  913. }
  914. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  915. // users can use type-assertion to append predicates that do not depend on any generated package.
  916. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  917. p := make([]predicate.Agent, len(ps))
  918. for i := range ps {
  919. p[i] = ps[i]
  920. }
  921. m.Where(p...)
  922. }
  923. // Op returns the operation name.
  924. func (m *AgentMutation) Op() Op {
  925. return m.op
  926. }
  927. // SetOp allows setting the mutation operation.
  928. func (m *AgentMutation) SetOp(op Op) {
  929. m.op = op
  930. }
  931. // Type returns the node type of this mutation (Agent).
  932. func (m *AgentMutation) Type() string {
  933. return m.typ
  934. }
  935. // Fields returns all fields that were changed during this mutation. Note that in
  936. // order to get all numeric fields that were incremented/decremented, call
  937. // AddedFields().
  938. func (m *AgentMutation) Fields() []string {
  939. fields := make([]string, 0, 11)
  940. if m.created_at != nil {
  941. fields = append(fields, agent.FieldCreatedAt)
  942. }
  943. if m.updated_at != nil {
  944. fields = append(fields, agent.FieldUpdatedAt)
  945. }
  946. if m.deleted_at != nil {
  947. fields = append(fields, agent.FieldDeletedAt)
  948. }
  949. if m.name != nil {
  950. fields = append(fields, agent.FieldName)
  951. }
  952. if m.role != nil {
  953. fields = append(fields, agent.FieldRole)
  954. }
  955. if m.status != nil {
  956. fields = append(fields, agent.FieldStatus)
  957. }
  958. if m.background != nil {
  959. fields = append(fields, agent.FieldBackground)
  960. }
  961. if m.examples != nil {
  962. fields = append(fields, agent.FieldExamples)
  963. }
  964. if m.organization_id != nil {
  965. fields = append(fields, agent.FieldOrganizationID)
  966. }
  967. if m.dataset_id != nil {
  968. fields = append(fields, agent.FieldDatasetID)
  969. }
  970. if m.collection_id != nil {
  971. fields = append(fields, agent.FieldCollectionID)
  972. }
  973. return fields
  974. }
  975. // Field returns the value of a field with the given name. The second boolean
  976. // return value indicates that this field was not set, or was not defined in the
  977. // schema.
  978. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  979. switch name {
  980. case agent.FieldCreatedAt:
  981. return m.CreatedAt()
  982. case agent.FieldUpdatedAt:
  983. return m.UpdatedAt()
  984. case agent.FieldDeletedAt:
  985. return m.DeletedAt()
  986. case agent.FieldName:
  987. return m.Name()
  988. case agent.FieldRole:
  989. return m.Role()
  990. case agent.FieldStatus:
  991. return m.Status()
  992. case agent.FieldBackground:
  993. return m.Background()
  994. case agent.FieldExamples:
  995. return m.Examples()
  996. case agent.FieldOrganizationID:
  997. return m.OrganizationID()
  998. case agent.FieldDatasetID:
  999. return m.DatasetID()
  1000. case agent.FieldCollectionID:
  1001. return m.CollectionID()
  1002. }
  1003. return nil, false
  1004. }
  1005. // OldField returns the old value of the field from the database. An error is
  1006. // returned if the mutation operation is not UpdateOne, or the query to the
  1007. // database failed.
  1008. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1009. switch name {
  1010. case agent.FieldCreatedAt:
  1011. return m.OldCreatedAt(ctx)
  1012. case agent.FieldUpdatedAt:
  1013. return m.OldUpdatedAt(ctx)
  1014. case agent.FieldDeletedAt:
  1015. return m.OldDeletedAt(ctx)
  1016. case agent.FieldName:
  1017. return m.OldName(ctx)
  1018. case agent.FieldRole:
  1019. return m.OldRole(ctx)
  1020. case agent.FieldStatus:
  1021. return m.OldStatus(ctx)
  1022. case agent.FieldBackground:
  1023. return m.OldBackground(ctx)
  1024. case agent.FieldExamples:
  1025. return m.OldExamples(ctx)
  1026. case agent.FieldOrganizationID:
  1027. return m.OldOrganizationID(ctx)
  1028. case agent.FieldDatasetID:
  1029. return m.OldDatasetID(ctx)
  1030. case agent.FieldCollectionID:
  1031. return m.OldCollectionID(ctx)
  1032. }
  1033. return nil, fmt.Errorf("unknown Agent field %s", name)
  1034. }
  1035. // SetField sets the value of a field with the given name. It returns an error if
  1036. // the field is not defined in the schema, or if the type mismatched the field
  1037. // type.
  1038. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1039. switch name {
  1040. case agent.FieldCreatedAt:
  1041. v, ok := value.(time.Time)
  1042. if !ok {
  1043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1044. }
  1045. m.SetCreatedAt(v)
  1046. return nil
  1047. case agent.FieldUpdatedAt:
  1048. v, ok := value.(time.Time)
  1049. if !ok {
  1050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1051. }
  1052. m.SetUpdatedAt(v)
  1053. return nil
  1054. case agent.FieldDeletedAt:
  1055. v, ok := value.(time.Time)
  1056. if !ok {
  1057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1058. }
  1059. m.SetDeletedAt(v)
  1060. return nil
  1061. case agent.FieldName:
  1062. v, ok := value.(string)
  1063. if !ok {
  1064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1065. }
  1066. m.SetName(v)
  1067. return nil
  1068. case agent.FieldRole:
  1069. v, ok := value.(string)
  1070. if !ok {
  1071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1072. }
  1073. m.SetRole(v)
  1074. return nil
  1075. case agent.FieldStatus:
  1076. v, ok := value.(int)
  1077. if !ok {
  1078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1079. }
  1080. m.SetStatus(v)
  1081. return nil
  1082. case agent.FieldBackground:
  1083. v, ok := value.(string)
  1084. if !ok {
  1085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1086. }
  1087. m.SetBackground(v)
  1088. return nil
  1089. case agent.FieldExamples:
  1090. v, ok := value.(string)
  1091. if !ok {
  1092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1093. }
  1094. m.SetExamples(v)
  1095. return nil
  1096. case agent.FieldOrganizationID:
  1097. v, ok := value.(uint64)
  1098. if !ok {
  1099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1100. }
  1101. m.SetOrganizationID(v)
  1102. return nil
  1103. case agent.FieldDatasetID:
  1104. v, ok := value.(string)
  1105. if !ok {
  1106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1107. }
  1108. m.SetDatasetID(v)
  1109. return nil
  1110. case agent.FieldCollectionID:
  1111. v, ok := value.(string)
  1112. if !ok {
  1113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1114. }
  1115. m.SetCollectionID(v)
  1116. return nil
  1117. }
  1118. return fmt.Errorf("unknown Agent field %s", name)
  1119. }
  1120. // AddedFields returns all numeric fields that were incremented/decremented during
  1121. // this mutation.
  1122. func (m *AgentMutation) AddedFields() []string {
  1123. var fields []string
  1124. if m.addstatus != nil {
  1125. fields = append(fields, agent.FieldStatus)
  1126. }
  1127. if m.addorganization_id != nil {
  1128. fields = append(fields, agent.FieldOrganizationID)
  1129. }
  1130. return fields
  1131. }
  1132. // AddedField returns the numeric value that was incremented/decremented on a field
  1133. // with the given name. The second boolean return value indicates that this field
  1134. // was not set, or was not defined in the schema.
  1135. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1136. switch name {
  1137. case agent.FieldStatus:
  1138. return m.AddedStatus()
  1139. case agent.FieldOrganizationID:
  1140. return m.AddedOrganizationID()
  1141. }
  1142. return nil, false
  1143. }
  1144. // AddField adds the value to the field with the given name. It returns an error if
  1145. // the field is not defined in the schema, or if the type mismatched the field
  1146. // type.
  1147. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1148. switch name {
  1149. case agent.FieldStatus:
  1150. v, ok := value.(int)
  1151. if !ok {
  1152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1153. }
  1154. m.AddStatus(v)
  1155. return nil
  1156. case agent.FieldOrganizationID:
  1157. v, ok := value.(int64)
  1158. if !ok {
  1159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1160. }
  1161. m.AddOrganizationID(v)
  1162. return nil
  1163. }
  1164. return fmt.Errorf("unknown Agent numeric field %s", name)
  1165. }
  1166. // ClearedFields returns all nullable fields that were cleared during this
  1167. // mutation.
  1168. func (m *AgentMutation) ClearedFields() []string {
  1169. var fields []string
  1170. if m.FieldCleared(agent.FieldDeletedAt) {
  1171. fields = append(fields, agent.FieldDeletedAt)
  1172. }
  1173. if m.FieldCleared(agent.FieldStatus) {
  1174. fields = append(fields, agent.FieldStatus)
  1175. }
  1176. if m.FieldCleared(agent.FieldBackground) {
  1177. fields = append(fields, agent.FieldBackground)
  1178. }
  1179. if m.FieldCleared(agent.FieldExamples) {
  1180. fields = append(fields, agent.FieldExamples)
  1181. }
  1182. return fields
  1183. }
  1184. // FieldCleared returns a boolean indicating if a field with the given name was
  1185. // cleared in this mutation.
  1186. func (m *AgentMutation) FieldCleared(name string) bool {
  1187. _, ok := m.clearedFields[name]
  1188. return ok
  1189. }
  1190. // ClearField clears the value of the field with the given name. It returns an
  1191. // error if the field is not defined in the schema.
  1192. func (m *AgentMutation) ClearField(name string) error {
  1193. switch name {
  1194. case agent.FieldDeletedAt:
  1195. m.ClearDeletedAt()
  1196. return nil
  1197. case agent.FieldStatus:
  1198. m.ClearStatus()
  1199. return nil
  1200. case agent.FieldBackground:
  1201. m.ClearBackground()
  1202. return nil
  1203. case agent.FieldExamples:
  1204. m.ClearExamples()
  1205. return nil
  1206. }
  1207. return fmt.Errorf("unknown Agent nullable field %s", name)
  1208. }
  1209. // ResetField resets all changes in the mutation for the field with the given name.
  1210. // It returns an error if the field is not defined in the schema.
  1211. func (m *AgentMutation) ResetField(name string) error {
  1212. switch name {
  1213. case agent.FieldCreatedAt:
  1214. m.ResetCreatedAt()
  1215. return nil
  1216. case agent.FieldUpdatedAt:
  1217. m.ResetUpdatedAt()
  1218. return nil
  1219. case agent.FieldDeletedAt:
  1220. m.ResetDeletedAt()
  1221. return nil
  1222. case agent.FieldName:
  1223. m.ResetName()
  1224. return nil
  1225. case agent.FieldRole:
  1226. m.ResetRole()
  1227. return nil
  1228. case agent.FieldStatus:
  1229. m.ResetStatus()
  1230. return nil
  1231. case agent.FieldBackground:
  1232. m.ResetBackground()
  1233. return nil
  1234. case agent.FieldExamples:
  1235. m.ResetExamples()
  1236. return nil
  1237. case agent.FieldOrganizationID:
  1238. m.ResetOrganizationID()
  1239. return nil
  1240. case agent.FieldDatasetID:
  1241. m.ResetDatasetID()
  1242. return nil
  1243. case agent.FieldCollectionID:
  1244. m.ResetCollectionID()
  1245. return nil
  1246. }
  1247. return fmt.Errorf("unknown Agent field %s", name)
  1248. }
  1249. // AddedEdges returns all edge names that were set/added in this mutation.
  1250. func (m *AgentMutation) AddedEdges() []string {
  1251. edges := make([]string, 0, 5)
  1252. if m.wx_agent != nil {
  1253. edges = append(edges, agent.EdgeWxAgent)
  1254. }
  1255. if m.token_agent != nil {
  1256. edges = append(edges, agent.EdgeTokenAgent)
  1257. }
  1258. if m.wa_agent != nil {
  1259. edges = append(edges, agent.EdgeWaAgent)
  1260. }
  1261. if m.xjs_agent != nil {
  1262. edges = append(edges, agent.EdgeXjsAgent)
  1263. }
  1264. if m.key_agent != nil {
  1265. edges = append(edges, agent.EdgeKeyAgent)
  1266. }
  1267. return edges
  1268. }
  1269. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1270. // name in this mutation.
  1271. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1272. switch name {
  1273. case agent.EdgeWxAgent:
  1274. ids := make([]ent.Value, 0, len(m.wx_agent))
  1275. for id := range m.wx_agent {
  1276. ids = append(ids, id)
  1277. }
  1278. return ids
  1279. case agent.EdgeTokenAgent:
  1280. ids := make([]ent.Value, 0, len(m.token_agent))
  1281. for id := range m.token_agent {
  1282. ids = append(ids, id)
  1283. }
  1284. return ids
  1285. case agent.EdgeWaAgent:
  1286. ids := make([]ent.Value, 0, len(m.wa_agent))
  1287. for id := range m.wa_agent {
  1288. ids = append(ids, id)
  1289. }
  1290. return ids
  1291. case agent.EdgeXjsAgent:
  1292. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1293. for id := range m.xjs_agent {
  1294. ids = append(ids, id)
  1295. }
  1296. return ids
  1297. case agent.EdgeKeyAgent:
  1298. ids := make([]ent.Value, 0, len(m.key_agent))
  1299. for id := range m.key_agent {
  1300. ids = append(ids, id)
  1301. }
  1302. return ids
  1303. }
  1304. return nil
  1305. }
  1306. // RemovedEdges returns all edge names that were removed in this mutation.
  1307. func (m *AgentMutation) RemovedEdges() []string {
  1308. edges := make([]string, 0, 5)
  1309. if m.removedwx_agent != nil {
  1310. edges = append(edges, agent.EdgeWxAgent)
  1311. }
  1312. if m.removedtoken_agent != nil {
  1313. edges = append(edges, agent.EdgeTokenAgent)
  1314. }
  1315. if m.removedwa_agent != nil {
  1316. edges = append(edges, agent.EdgeWaAgent)
  1317. }
  1318. if m.removedxjs_agent != nil {
  1319. edges = append(edges, agent.EdgeXjsAgent)
  1320. }
  1321. if m.removedkey_agent != nil {
  1322. edges = append(edges, agent.EdgeKeyAgent)
  1323. }
  1324. return edges
  1325. }
  1326. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1327. // the given name in this mutation.
  1328. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1329. switch name {
  1330. case agent.EdgeWxAgent:
  1331. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1332. for id := range m.removedwx_agent {
  1333. ids = append(ids, id)
  1334. }
  1335. return ids
  1336. case agent.EdgeTokenAgent:
  1337. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1338. for id := range m.removedtoken_agent {
  1339. ids = append(ids, id)
  1340. }
  1341. return ids
  1342. case agent.EdgeWaAgent:
  1343. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1344. for id := range m.removedwa_agent {
  1345. ids = append(ids, id)
  1346. }
  1347. return ids
  1348. case agent.EdgeXjsAgent:
  1349. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1350. for id := range m.removedxjs_agent {
  1351. ids = append(ids, id)
  1352. }
  1353. return ids
  1354. case agent.EdgeKeyAgent:
  1355. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1356. for id := range m.removedkey_agent {
  1357. ids = append(ids, id)
  1358. }
  1359. return ids
  1360. }
  1361. return nil
  1362. }
  1363. // ClearedEdges returns all edge names that were cleared in this mutation.
  1364. func (m *AgentMutation) ClearedEdges() []string {
  1365. edges := make([]string, 0, 5)
  1366. if m.clearedwx_agent {
  1367. edges = append(edges, agent.EdgeWxAgent)
  1368. }
  1369. if m.clearedtoken_agent {
  1370. edges = append(edges, agent.EdgeTokenAgent)
  1371. }
  1372. if m.clearedwa_agent {
  1373. edges = append(edges, agent.EdgeWaAgent)
  1374. }
  1375. if m.clearedxjs_agent {
  1376. edges = append(edges, agent.EdgeXjsAgent)
  1377. }
  1378. if m.clearedkey_agent {
  1379. edges = append(edges, agent.EdgeKeyAgent)
  1380. }
  1381. return edges
  1382. }
  1383. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1384. // was cleared in this mutation.
  1385. func (m *AgentMutation) EdgeCleared(name string) bool {
  1386. switch name {
  1387. case agent.EdgeWxAgent:
  1388. return m.clearedwx_agent
  1389. case agent.EdgeTokenAgent:
  1390. return m.clearedtoken_agent
  1391. case agent.EdgeWaAgent:
  1392. return m.clearedwa_agent
  1393. case agent.EdgeXjsAgent:
  1394. return m.clearedxjs_agent
  1395. case agent.EdgeKeyAgent:
  1396. return m.clearedkey_agent
  1397. }
  1398. return false
  1399. }
  1400. // ClearEdge clears the value of the edge with the given name. It returns an error
  1401. // if that edge is not defined in the schema.
  1402. func (m *AgentMutation) ClearEdge(name string) error {
  1403. switch name {
  1404. }
  1405. return fmt.Errorf("unknown Agent unique edge %s", name)
  1406. }
  1407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1408. // It returns an error if the edge is not defined in the schema.
  1409. func (m *AgentMutation) ResetEdge(name string) error {
  1410. switch name {
  1411. case agent.EdgeWxAgent:
  1412. m.ResetWxAgent()
  1413. return nil
  1414. case agent.EdgeTokenAgent:
  1415. m.ResetTokenAgent()
  1416. return nil
  1417. case agent.EdgeWaAgent:
  1418. m.ResetWaAgent()
  1419. return nil
  1420. case agent.EdgeXjsAgent:
  1421. m.ResetXjsAgent()
  1422. return nil
  1423. case agent.EdgeKeyAgent:
  1424. m.ResetKeyAgent()
  1425. return nil
  1426. }
  1427. return fmt.Errorf("unknown Agent edge %s", name)
  1428. }
  1429. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1430. type AgentBaseMutation struct {
  1431. config
  1432. op Op
  1433. typ string
  1434. id *string
  1435. q *string
  1436. a *string
  1437. chunk_index *uint64
  1438. addchunk_index *int64
  1439. indexes *[]string
  1440. appendindexes []string
  1441. dataset_id *string
  1442. collection_id *string
  1443. source_name *string
  1444. can_write *[]bool
  1445. appendcan_write []bool
  1446. is_owner *[]bool
  1447. appendis_owner []bool
  1448. clearedFields map[string]struct{}
  1449. wx_agent map[uint64]struct{}
  1450. removedwx_agent map[uint64]struct{}
  1451. clearedwx_agent bool
  1452. done bool
  1453. oldValue func(context.Context) (*AgentBase, error)
  1454. predicates []predicate.AgentBase
  1455. }
  1456. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1457. // agentbaseOption allows management of the mutation configuration using functional options.
  1458. type agentbaseOption func(*AgentBaseMutation)
  1459. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1460. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1461. m := &AgentBaseMutation{
  1462. config: c,
  1463. op: op,
  1464. typ: TypeAgentBase,
  1465. clearedFields: make(map[string]struct{}),
  1466. }
  1467. for _, opt := range opts {
  1468. opt(m)
  1469. }
  1470. return m
  1471. }
  1472. // withAgentBaseID sets the ID field of the mutation.
  1473. func withAgentBaseID(id string) agentbaseOption {
  1474. return func(m *AgentBaseMutation) {
  1475. var (
  1476. err error
  1477. once sync.Once
  1478. value *AgentBase
  1479. )
  1480. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1481. once.Do(func() {
  1482. if m.done {
  1483. err = errors.New("querying old values post mutation is not allowed")
  1484. } else {
  1485. value, err = m.Client().AgentBase.Get(ctx, id)
  1486. }
  1487. })
  1488. return value, err
  1489. }
  1490. m.id = &id
  1491. }
  1492. }
  1493. // withAgentBase sets the old AgentBase of the mutation.
  1494. func withAgentBase(node *AgentBase) agentbaseOption {
  1495. return func(m *AgentBaseMutation) {
  1496. m.oldValue = func(context.Context) (*AgentBase, error) {
  1497. return node, nil
  1498. }
  1499. m.id = &node.ID
  1500. }
  1501. }
  1502. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1503. // executed in a transaction (ent.Tx), a transactional client is returned.
  1504. func (m AgentBaseMutation) Client() *Client {
  1505. client := &Client{config: m.config}
  1506. client.init()
  1507. return client
  1508. }
  1509. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1510. // it returns an error otherwise.
  1511. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1512. if _, ok := m.driver.(*txDriver); !ok {
  1513. return nil, errors.New("ent: mutation is not running in a transaction")
  1514. }
  1515. tx := &Tx{config: m.config}
  1516. tx.init()
  1517. return tx, nil
  1518. }
  1519. // SetID sets the value of the id field. Note that this
  1520. // operation is only accepted on creation of AgentBase entities.
  1521. func (m *AgentBaseMutation) SetID(id string) {
  1522. m.id = &id
  1523. }
  1524. // ID returns the ID value in the mutation. Note that the ID is only available
  1525. // if it was provided to the builder or after it was returned from the database.
  1526. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1527. if m.id == nil {
  1528. return
  1529. }
  1530. return *m.id, true
  1531. }
  1532. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1533. // That means, if the mutation is applied within a transaction with an isolation level such
  1534. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1535. // or updated by the mutation.
  1536. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1537. switch {
  1538. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1539. id, exists := m.ID()
  1540. if exists {
  1541. return []string{id}, nil
  1542. }
  1543. fallthrough
  1544. case m.op.Is(OpUpdate | OpDelete):
  1545. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1546. default:
  1547. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1548. }
  1549. }
  1550. // SetQ sets the "q" field.
  1551. func (m *AgentBaseMutation) SetQ(s string) {
  1552. m.q = &s
  1553. }
  1554. // Q returns the value of the "q" field in the mutation.
  1555. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1556. v := m.q
  1557. if v == nil {
  1558. return
  1559. }
  1560. return *v, true
  1561. }
  1562. // OldQ returns the old "q" field's value of the AgentBase entity.
  1563. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1565. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1566. if !m.op.Is(OpUpdateOne) {
  1567. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1568. }
  1569. if m.id == nil || m.oldValue == nil {
  1570. return v, errors.New("OldQ requires an ID field in the mutation")
  1571. }
  1572. oldValue, err := m.oldValue(ctx)
  1573. if err != nil {
  1574. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1575. }
  1576. return oldValue.Q, nil
  1577. }
  1578. // ClearQ clears the value of the "q" field.
  1579. func (m *AgentBaseMutation) ClearQ() {
  1580. m.q = nil
  1581. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1582. }
  1583. // QCleared returns if the "q" field was cleared in this mutation.
  1584. func (m *AgentBaseMutation) QCleared() bool {
  1585. _, ok := m.clearedFields[agentbase.FieldQ]
  1586. return ok
  1587. }
  1588. // ResetQ resets all changes to the "q" field.
  1589. func (m *AgentBaseMutation) ResetQ() {
  1590. m.q = nil
  1591. delete(m.clearedFields, agentbase.FieldQ)
  1592. }
  1593. // SetA sets the "a" field.
  1594. func (m *AgentBaseMutation) SetA(s string) {
  1595. m.a = &s
  1596. }
  1597. // A returns the value of the "a" field in the mutation.
  1598. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1599. v := m.a
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldA returns the old "a" field's value of the AgentBase entity.
  1606. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldA requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1618. }
  1619. return oldValue.A, nil
  1620. }
  1621. // ClearA clears the value of the "a" field.
  1622. func (m *AgentBaseMutation) ClearA() {
  1623. m.a = nil
  1624. m.clearedFields[agentbase.FieldA] = struct{}{}
  1625. }
  1626. // ACleared returns if the "a" field was cleared in this mutation.
  1627. func (m *AgentBaseMutation) ACleared() bool {
  1628. _, ok := m.clearedFields[agentbase.FieldA]
  1629. return ok
  1630. }
  1631. // ResetA resets all changes to the "a" field.
  1632. func (m *AgentBaseMutation) ResetA() {
  1633. m.a = nil
  1634. delete(m.clearedFields, agentbase.FieldA)
  1635. }
  1636. // SetChunkIndex sets the "chunk_index" field.
  1637. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1638. m.chunk_index = &u
  1639. m.addchunk_index = nil
  1640. }
  1641. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1642. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1643. v := m.chunk_index
  1644. if v == nil {
  1645. return
  1646. }
  1647. return *v, true
  1648. }
  1649. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1650. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1652. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1653. if !m.op.Is(OpUpdateOne) {
  1654. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1655. }
  1656. if m.id == nil || m.oldValue == nil {
  1657. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1658. }
  1659. oldValue, err := m.oldValue(ctx)
  1660. if err != nil {
  1661. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1662. }
  1663. return oldValue.ChunkIndex, nil
  1664. }
  1665. // AddChunkIndex adds u to the "chunk_index" field.
  1666. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1667. if m.addchunk_index != nil {
  1668. *m.addchunk_index += u
  1669. } else {
  1670. m.addchunk_index = &u
  1671. }
  1672. }
  1673. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1674. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1675. v := m.addchunk_index
  1676. if v == nil {
  1677. return
  1678. }
  1679. return *v, true
  1680. }
  1681. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1682. func (m *AgentBaseMutation) ResetChunkIndex() {
  1683. m.chunk_index = nil
  1684. m.addchunk_index = nil
  1685. }
  1686. // SetIndexes sets the "indexes" field.
  1687. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1688. m.indexes = &s
  1689. m.appendindexes = nil
  1690. }
  1691. // Indexes returns the value of the "indexes" field in the mutation.
  1692. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1693. v := m.indexes
  1694. if v == nil {
  1695. return
  1696. }
  1697. return *v, true
  1698. }
  1699. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1700. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1702. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1703. if !m.op.Is(OpUpdateOne) {
  1704. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1705. }
  1706. if m.id == nil || m.oldValue == nil {
  1707. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1708. }
  1709. oldValue, err := m.oldValue(ctx)
  1710. if err != nil {
  1711. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1712. }
  1713. return oldValue.Indexes, nil
  1714. }
  1715. // AppendIndexes adds s to the "indexes" field.
  1716. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1717. m.appendindexes = append(m.appendindexes, s...)
  1718. }
  1719. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1720. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1721. if len(m.appendindexes) == 0 {
  1722. return nil, false
  1723. }
  1724. return m.appendindexes, true
  1725. }
  1726. // ClearIndexes clears the value of the "indexes" field.
  1727. func (m *AgentBaseMutation) ClearIndexes() {
  1728. m.indexes = nil
  1729. m.appendindexes = nil
  1730. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1731. }
  1732. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1733. func (m *AgentBaseMutation) IndexesCleared() bool {
  1734. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1735. return ok
  1736. }
  1737. // ResetIndexes resets all changes to the "indexes" field.
  1738. func (m *AgentBaseMutation) ResetIndexes() {
  1739. m.indexes = nil
  1740. m.appendindexes = nil
  1741. delete(m.clearedFields, agentbase.FieldIndexes)
  1742. }
  1743. // SetDatasetID sets the "dataset_id" field.
  1744. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1745. m.dataset_id = &s
  1746. }
  1747. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1748. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1749. v := m.dataset_id
  1750. if v == nil {
  1751. return
  1752. }
  1753. return *v, true
  1754. }
  1755. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1756. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1758. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1759. if !m.op.Is(OpUpdateOne) {
  1760. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1761. }
  1762. if m.id == nil || m.oldValue == nil {
  1763. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1764. }
  1765. oldValue, err := m.oldValue(ctx)
  1766. if err != nil {
  1767. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1768. }
  1769. return oldValue.DatasetID, nil
  1770. }
  1771. // ClearDatasetID clears the value of the "dataset_id" field.
  1772. func (m *AgentBaseMutation) ClearDatasetID() {
  1773. m.dataset_id = nil
  1774. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1775. }
  1776. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1777. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1778. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1779. return ok
  1780. }
  1781. // ResetDatasetID resets all changes to the "dataset_id" field.
  1782. func (m *AgentBaseMutation) ResetDatasetID() {
  1783. m.dataset_id = nil
  1784. delete(m.clearedFields, agentbase.FieldDatasetID)
  1785. }
  1786. // SetCollectionID sets the "collection_id" field.
  1787. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1788. m.collection_id = &s
  1789. }
  1790. // CollectionID returns the value of the "collection_id" field in the mutation.
  1791. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1792. v := m.collection_id
  1793. if v == nil {
  1794. return
  1795. }
  1796. return *v, true
  1797. }
  1798. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1799. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1801. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1802. if !m.op.Is(OpUpdateOne) {
  1803. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1804. }
  1805. if m.id == nil || m.oldValue == nil {
  1806. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1807. }
  1808. oldValue, err := m.oldValue(ctx)
  1809. if err != nil {
  1810. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1811. }
  1812. return oldValue.CollectionID, nil
  1813. }
  1814. // ClearCollectionID clears the value of the "collection_id" field.
  1815. func (m *AgentBaseMutation) ClearCollectionID() {
  1816. m.collection_id = nil
  1817. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1818. }
  1819. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1820. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1821. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1822. return ok
  1823. }
  1824. // ResetCollectionID resets all changes to the "collection_id" field.
  1825. func (m *AgentBaseMutation) ResetCollectionID() {
  1826. m.collection_id = nil
  1827. delete(m.clearedFields, agentbase.FieldCollectionID)
  1828. }
  1829. // SetSourceName sets the "source_name" field.
  1830. func (m *AgentBaseMutation) SetSourceName(s string) {
  1831. m.source_name = &s
  1832. }
  1833. // SourceName returns the value of the "source_name" field in the mutation.
  1834. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1835. v := m.source_name
  1836. if v == nil {
  1837. return
  1838. }
  1839. return *v, true
  1840. }
  1841. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1842. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1844. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1845. if !m.op.Is(OpUpdateOne) {
  1846. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1847. }
  1848. if m.id == nil || m.oldValue == nil {
  1849. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1850. }
  1851. oldValue, err := m.oldValue(ctx)
  1852. if err != nil {
  1853. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1854. }
  1855. return oldValue.SourceName, nil
  1856. }
  1857. // ClearSourceName clears the value of the "source_name" field.
  1858. func (m *AgentBaseMutation) ClearSourceName() {
  1859. m.source_name = nil
  1860. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1861. }
  1862. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1863. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1864. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1865. return ok
  1866. }
  1867. // ResetSourceName resets all changes to the "source_name" field.
  1868. func (m *AgentBaseMutation) ResetSourceName() {
  1869. m.source_name = nil
  1870. delete(m.clearedFields, agentbase.FieldSourceName)
  1871. }
  1872. // SetCanWrite sets the "can_write" field.
  1873. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1874. m.can_write = &b
  1875. m.appendcan_write = nil
  1876. }
  1877. // CanWrite returns the value of the "can_write" field in the mutation.
  1878. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1879. v := m.can_write
  1880. if v == nil {
  1881. return
  1882. }
  1883. return *v, true
  1884. }
  1885. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1886. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1888. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1889. if !m.op.Is(OpUpdateOne) {
  1890. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1891. }
  1892. if m.id == nil || m.oldValue == nil {
  1893. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1894. }
  1895. oldValue, err := m.oldValue(ctx)
  1896. if err != nil {
  1897. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1898. }
  1899. return oldValue.CanWrite, nil
  1900. }
  1901. // AppendCanWrite adds b to the "can_write" field.
  1902. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1903. m.appendcan_write = append(m.appendcan_write, b...)
  1904. }
  1905. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1906. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1907. if len(m.appendcan_write) == 0 {
  1908. return nil, false
  1909. }
  1910. return m.appendcan_write, true
  1911. }
  1912. // ClearCanWrite clears the value of the "can_write" field.
  1913. func (m *AgentBaseMutation) ClearCanWrite() {
  1914. m.can_write = nil
  1915. m.appendcan_write = nil
  1916. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1917. }
  1918. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1919. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1920. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1921. return ok
  1922. }
  1923. // ResetCanWrite resets all changes to the "can_write" field.
  1924. func (m *AgentBaseMutation) ResetCanWrite() {
  1925. m.can_write = nil
  1926. m.appendcan_write = nil
  1927. delete(m.clearedFields, agentbase.FieldCanWrite)
  1928. }
  1929. // SetIsOwner sets the "is_owner" field.
  1930. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1931. m.is_owner = &b
  1932. m.appendis_owner = nil
  1933. }
  1934. // IsOwner returns the value of the "is_owner" field in the mutation.
  1935. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1936. v := m.is_owner
  1937. if v == nil {
  1938. return
  1939. }
  1940. return *v, true
  1941. }
  1942. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1943. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1945. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1946. if !m.op.Is(OpUpdateOne) {
  1947. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1948. }
  1949. if m.id == nil || m.oldValue == nil {
  1950. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1951. }
  1952. oldValue, err := m.oldValue(ctx)
  1953. if err != nil {
  1954. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1955. }
  1956. return oldValue.IsOwner, nil
  1957. }
  1958. // AppendIsOwner adds b to the "is_owner" field.
  1959. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1960. m.appendis_owner = append(m.appendis_owner, b...)
  1961. }
  1962. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1963. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1964. if len(m.appendis_owner) == 0 {
  1965. return nil, false
  1966. }
  1967. return m.appendis_owner, true
  1968. }
  1969. // ClearIsOwner clears the value of the "is_owner" field.
  1970. func (m *AgentBaseMutation) ClearIsOwner() {
  1971. m.is_owner = nil
  1972. m.appendis_owner = nil
  1973. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1974. }
  1975. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1976. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1977. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1978. return ok
  1979. }
  1980. // ResetIsOwner resets all changes to the "is_owner" field.
  1981. func (m *AgentBaseMutation) ResetIsOwner() {
  1982. m.is_owner = nil
  1983. m.appendis_owner = nil
  1984. delete(m.clearedFields, agentbase.FieldIsOwner)
  1985. }
  1986. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1987. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1988. if m.wx_agent == nil {
  1989. m.wx_agent = make(map[uint64]struct{})
  1990. }
  1991. for i := range ids {
  1992. m.wx_agent[ids[i]] = struct{}{}
  1993. }
  1994. }
  1995. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1996. func (m *AgentBaseMutation) ClearWxAgent() {
  1997. m.clearedwx_agent = true
  1998. }
  1999. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2000. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2001. return m.clearedwx_agent
  2002. }
  2003. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2004. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2005. if m.removedwx_agent == nil {
  2006. m.removedwx_agent = make(map[uint64]struct{})
  2007. }
  2008. for i := range ids {
  2009. delete(m.wx_agent, ids[i])
  2010. m.removedwx_agent[ids[i]] = struct{}{}
  2011. }
  2012. }
  2013. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2014. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2015. for id := range m.removedwx_agent {
  2016. ids = append(ids, id)
  2017. }
  2018. return
  2019. }
  2020. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2021. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2022. for id := range m.wx_agent {
  2023. ids = append(ids, id)
  2024. }
  2025. return
  2026. }
  2027. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2028. func (m *AgentBaseMutation) ResetWxAgent() {
  2029. m.wx_agent = nil
  2030. m.clearedwx_agent = false
  2031. m.removedwx_agent = nil
  2032. }
  2033. // Where appends a list predicates to the AgentBaseMutation builder.
  2034. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2035. m.predicates = append(m.predicates, ps...)
  2036. }
  2037. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2038. // users can use type-assertion to append predicates that do not depend on any generated package.
  2039. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2040. p := make([]predicate.AgentBase, len(ps))
  2041. for i := range ps {
  2042. p[i] = ps[i]
  2043. }
  2044. m.Where(p...)
  2045. }
  2046. // Op returns the operation name.
  2047. func (m *AgentBaseMutation) Op() Op {
  2048. return m.op
  2049. }
  2050. // SetOp allows setting the mutation operation.
  2051. func (m *AgentBaseMutation) SetOp(op Op) {
  2052. m.op = op
  2053. }
  2054. // Type returns the node type of this mutation (AgentBase).
  2055. func (m *AgentBaseMutation) Type() string {
  2056. return m.typ
  2057. }
  2058. // Fields returns all fields that were changed during this mutation. Note that in
  2059. // order to get all numeric fields that were incremented/decremented, call
  2060. // AddedFields().
  2061. func (m *AgentBaseMutation) Fields() []string {
  2062. fields := make([]string, 0, 9)
  2063. if m.q != nil {
  2064. fields = append(fields, agentbase.FieldQ)
  2065. }
  2066. if m.a != nil {
  2067. fields = append(fields, agentbase.FieldA)
  2068. }
  2069. if m.chunk_index != nil {
  2070. fields = append(fields, agentbase.FieldChunkIndex)
  2071. }
  2072. if m.indexes != nil {
  2073. fields = append(fields, agentbase.FieldIndexes)
  2074. }
  2075. if m.dataset_id != nil {
  2076. fields = append(fields, agentbase.FieldDatasetID)
  2077. }
  2078. if m.collection_id != nil {
  2079. fields = append(fields, agentbase.FieldCollectionID)
  2080. }
  2081. if m.source_name != nil {
  2082. fields = append(fields, agentbase.FieldSourceName)
  2083. }
  2084. if m.can_write != nil {
  2085. fields = append(fields, agentbase.FieldCanWrite)
  2086. }
  2087. if m.is_owner != nil {
  2088. fields = append(fields, agentbase.FieldIsOwner)
  2089. }
  2090. return fields
  2091. }
  2092. // Field returns the value of a field with the given name. The second boolean
  2093. // return value indicates that this field was not set, or was not defined in the
  2094. // schema.
  2095. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2096. switch name {
  2097. case agentbase.FieldQ:
  2098. return m.Q()
  2099. case agentbase.FieldA:
  2100. return m.A()
  2101. case agentbase.FieldChunkIndex:
  2102. return m.ChunkIndex()
  2103. case agentbase.FieldIndexes:
  2104. return m.Indexes()
  2105. case agentbase.FieldDatasetID:
  2106. return m.DatasetID()
  2107. case agentbase.FieldCollectionID:
  2108. return m.CollectionID()
  2109. case agentbase.FieldSourceName:
  2110. return m.SourceName()
  2111. case agentbase.FieldCanWrite:
  2112. return m.CanWrite()
  2113. case agentbase.FieldIsOwner:
  2114. return m.IsOwner()
  2115. }
  2116. return nil, false
  2117. }
  2118. // OldField returns the old value of the field from the database. An error is
  2119. // returned if the mutation operation is not UpdateOne, or the query to the
  2120. // database failed.
  2121. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2122. switch name {
  2123. case agentbase.FieldQ:
  2124. return m.OldQ(ctx)
  2125. case agentbase.FieldA:
  2126. return m.OldA(ctx)
  2127. case agentbase.FieldChunkIndex:
  2128. return m.OldChunkIndex(ctx)
  2129. case agentbase.FieldIndexes:
  2130. return m.OldIndexes(ctx)
  2131. case agentbase.FieldDatasetID:
  2132. return m.OldDatasetID(ctx)
  2133. case agentbase.FieldCollectionID:
  2134. return m.OldCollectionID(ctx)
  2135. case agentbase.FieldSourceName:
  2136. return m.OldSourceName(ctx)
  2137. case agentbase.FieldCanWrite:
  2138. return m.OldCanWrite(ctx)
  2139. case agentbase.FieldIsOwner:
  2140. return m.OldIsOwner(ctx)
  2141. }
  2142. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2143. }
  2144. // SetField sets the value of a field with the given name. It returns an error if
  2145. // the field is not defined in the schema, or if the type mismatched the field
  2146. // type.
  2147. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2148. switch name {
  2149. case agentbase.FieldQ:
  2150. v, ok := value.(string)
  2151. if !ok {
  2152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2153. }
  2154. m.SetQ(v)
  2155. return nil
  2156. case agentbase.FieldA:
  2157. v, ok := value.(string)
  2158. if !ok {
  2159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2160. }
  2161. m.SetA(v)
  2162. return nil
  2163. case agentbase.FieldChunkIndex:
  2164. v, ok := value.(uint64)
  2165. if !ok {
  2166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2167. }
  2168. m.SetChunkIndex(v)
  2169. return nil
  2170. case agentbase.FieldIndexes:
  2171. v, ok := value.([]string)
  2172. if !ok {
  2173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2174. }
  2175. m.SetIndexes(v)
  2176. return nil
  2177. case agentbase.FieldDatasetID:
  2178. v, ok := value.(string)
  2179. if !ok {
  2180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2181. }
  2182. m.SetDatasetID(v)
  2183. return nil
  2184. case agentbase.FieldCollectionID:
  2185. v, ok := value.(string)
  2186. if !ok {
  2187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2188. }
  2189. m.SetCollectionID(v)
  2190. return nil
  2191. case agentbase.FieldSourceName:
  2192. v, ok := value.(string)
  2193. if !ok {
  2194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2195. }
  2196. m.SetSourceName(v)
  2197. return nil
  2198. case agentbase.FieldCanWrite:
  2199. v, ok := value.([]bool)
  2200. if !ok {
  2201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2202. }
  2203. m.SetCanWrite(v)
  2204. return nil
  2205. case agentbase.FieldIsOwner:
  2206. v, ok := value.([]bool)
  2207. if !ok {
  2208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2209. }
  2210. m.SetIsOwner(v)
  2211. return nil
  2212. }
  2213. return fmt.Errorf("unknown AgentBase field %s", name)
  2214. }
  2215. // AddedFields returns all numeric fields that were incremented/decremented during
  2216. // this mutation.
  2217. func (m *AgentBaseMutation) AddedFields() []string {
  2218. var fields []string
  2219. if m.addchunk_index != nil {
  2220. fields = append(fields, agentbase.FieldChunkIndex)
  2221. }
  2222. return fields
  2223. }
  2224. // AddedField returns the numeric value that was incremented/decremented on a field
  2225. // with the given name. The second boolean return value indicates that this field
  2226. // was not set, or was not defined in the schema.
  2227. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2228. switch name {
  2229. case agentbase.FieldChunkIndex:
  2230. return m.AddedChunkIndex()
  2231. }
  2232. return nil, false
  2233. }
  2234. // AddField adds the value to the field with the given name. It returns an error if
  2235. // the field is not defined in the schema, or if the type mismatched the field
  2236. // type.
  2237. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2238. switch name {
  2239. case agentbase.FieldChunkIndex:
  2240. v, ok := value.(int64)
  2241. if !ok {
  2242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2243. }
  2244. m.AddChunkIndex(v)
  2245. return nil
  2246. }
  2247. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2248. }
  2249. // ClearedFields returns all nullable fields that were cleared during this
  2250. // mutation.
  2251. func (m *AgentBaseMutation) ClearedFields() []string {
  2252. var fields []string
  2253. if m.FieldCleared(agentbase.FieldQ) {
  2254. fields = append(fields, agentbase.FieldQ)
  2255. }
  2256. if m.FieldCleared(agentbase.FieldA) {
  2257. fields = append(fields, agentbase.FieldA)
  2258. }
  2259. if m.FieldCleared(agentbase.FieldIndexes) {
  2260. fields = append(fields, agentbase.FieldIndexes)
  2261. }
  2262. if m.FieldCleared(agentbase.FieldDatasetID) {
  2263. fields = append(fields, agentbase.FieldDatasetID)
  2264. }
  2265. if m.FieldCleared(agentbase.FieldCollectionID) {
  2266. fields = append(fields, agentbase.FieldCollectionID)
  2267. }
  2268. if m.FieldCleared(agentbase.FieldSourceName) {
  2269. fields = append(fields, agentbase.FieldSourceName)
  2270. }
  2271. if m.FieldCleared(agentbase.FieldCanWrite) {
  2272. fields = append(fields, agentbase.FieldCanWrite)
  2273. }
  2274. if m.FieldCleared(agentbase.FieldIsOwner) {
  2275. fields = append(fields, agentbase.FieldIsOwner)
  2276. }
  2277. return fields
  2278. }
  2279. // FieldCleared returns a boolean indicating if a field with the given name was
  2280. // cleared in this mutation.
  2281. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2282. _, ok := m.clearedFields[name]
  2283. return ok
  2284. }
  2285. // ClearField clears the value of the field with the given name. It returns an
  2286. // error if the field is not defined in the schema.
  2287. func (m *AgentBaseMutation) ClearField(name string) error {
  2288. switch name {
  2289. case agentbase.FieldQ:
  2290. m.ClearQ()
  2291. return nil
  2292. case agentbase.FieldA:
  2293. m.ClearA()
  2294. return nil
  2295. case agentbase.FieldIndexes:
  2296. m.ClearIndexes()
  2297. return nil
  2298. case agentbase.FieldDatasetID:
  2299. m.ClearDatasetID()
  2300. return nil
  2301. case agentbase.FieldCollectionID:
  2302. m.ClearCollectionID()
  2303. return nil
  2304. case agentbase.FieldSourceName:
  2305. m.ClearSourceName()
  2306. return nil
  2307. case agentbase.FieldCanWrite:
  2308. m.ClearCanWrite()
  2309. return nil
  2310. case agentbase.FieldIsOwner:
  2311. m.ClearIsOwner()
  2312. return nil
  2313. }
  2314. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2315. }
  2316. // ResetField resets all changes in the mutation for the field with the given name.
  2317. // It returns an error if the field is not defined in the schema.
  2318. func (m *AgentBaseMutation) ResetField(name string) error {
  2319. switch name {
  2320. case agentbase.FieldQ:
  2321. m.ResetQ()
  2322. return nil
  2323. case agentbase.FieldA:
  2324. m.ResetA()
  2325. return nil
  2326. case agentbase.FieldChunkIndex:
  2327. m.ResetChunkIndex()
  2328. return nil
  2329. case agentbase.FieldIndexes:
  2330. m.ResetIndexes()
  2331. return nil
  2332. case agentbase.FieldDatasetID:
  2333. m.ResetDatasetID()
  2334. return nil
  2335. case agentbase.FieldCollectionID:
  2336. m.ResetCollectionID()
  2337. return nil
  2338. case agentbase.FieldSourceName:
  2339. m.ResetSourceName()
  2340. return nil
  2341. case agentbase.FieldCanWrite:
  2342. m.ResetCanWrite()
  2343. return nil
  2344. case agentbase.FieldIsOwner:
  2345. m.ResetIsOwner()
  2346. return nil
  2347. }
  2348. return fmt.Errorf("unknown AgentBase field %s", name)
  2349. }
  2350. // AddedEdges returns all edge names that were set/added in this mutation.
  2351. func (m *AgentBaseMutation) AddedEdges() []string {
  2352. edges := make([]string, 0, 1)
  2353. if m.wx_agent != nil {
  2354. edges = append(edges, agentbase.EdgeWxAgent)
  2355. }
  2356. return edges
  2357. }
  2358. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2359. // name in this mutation.
  2360. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2361. switch name {
  2362. case agentbase.EdgeWxAgent:
  2363. ids := make([]ent.Value, 0, len(m.wx_agent))
  2364. for id := range m.wx_agent {
  2365. ids = append(ids, id)
  2366. }
  2367. return ids
  2368. }
  2369. return nil
  2370. }
  2371. // RemovedEdges returns all edge names that were removed in this mutation.
  2372. func (m *AgentBaseMutation) RemovedEdges() []string {
  2373. edges := make([]string, 0, 1)
  2374. if m.removedwx_agent != nil {
  2375. edges = append(edges, agentbase.EdgeWxAgent)
  2376. }
  2377. return edges
  2378. }
  2379. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2380. // the given name in this mutation.
  2381. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2382. switch name {
  2383. case agentbase.EdgeWxAgent:
  2384. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2385. for id := range m.removedwx_agent {
  2386. ids = append(ids, id)
  2387. }
  2388. return ids
  2389. }
  2390. return nil
  2391. }
  2392. // ClearedEdges returns all edge names that were cleared in this mutation.
  2393. func (m *AgentBaseMutation) ClearedEdges() []string {
  2394. edges := make([]string, 0, 1)
  2395. if m.clearedwx_agent {
  2396. edges = append(edges, agentbase.EdgeWxAgent)
  2397. }
  2398. return edges
  2399. }
  2400. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2401. // was cleared in this mutation.
  2402. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2403. switch name {
  2404. case agentbase.EdgeWxAgent:
  2405. return m.clearedwx_agent
  2406. }
  2407. return false
  2408. }
  2409. // ClearEdge clears the value of the edge with the given name. It returns an error
  2410. // if that edge is not defined in the schema.
  2411. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2412. switch name {
  2413. }
  2414. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2415. }
  2416. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2417. // It returns an error if the edge is not defined in the schema.
  2418. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2419. switch name {
  2420. case agentbase.EdgeWxAgent:
  2421. m.ResetWxAgent()
  2422. return nil
  2423. }
  2424. return fmt.Errorf("unknown AgentBase edge %s", name)
  2425. }
  2426. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2427. type AliyunAvatarMutation struct {
  2428. config
  2429. op Op
  2430. typ string
  2431. id *uint64
  2432. created_at *time.Time
  2433. updated_at *time.Time
  2434. deleted_at *time.Time
  2435. user_id *uint64
  2436. adduser_id *int64
  2437. biz_id *string
  2438. access_key_id *string
  2439. access_key_secret *string
  2440. app_id *string
  2441. tenant_id *uint64
  2442. addtenant_id *int64
  2443. response *string
  2444. token *string
  2445. session_id *string
  2446. clearedFields map[string]struct{}
  2447. done bool
  2448. oldValue func(context.Context) (*AliyunAvatar, error)
  2449. predicates []predicate.AliyunAvatar
  2450. }
  2451. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2452. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2453. type aliyunavatarOption func(*AliyunAvatarMutation)
  2454. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2455. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2456. m := &AliyunAvatarMutation{
  2457. config: c,
  2458. op: op,
  2459. typ: TypeAliyunAvatar,
  2460. clearedFields: make(map[string]struct{}),
  2461. }
  2462. for _, opt := range opts {
  2463. opt(m)
  2464. }
  2465. return m
  2466. }
  2467. // withAliyunAvatarID sets the ID field of the mutation.
  2468. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2469. return func(m *AliyunAvatarMutation) {
  2470. var (
  2471. err error
  2472. once sync.Once
  2473. value *AliyunAvatar
  2474. )
  2475. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2476. once.Do(func() {
  2477. if m.done {
  2478. err = errors.New("querying old values post mutation is not allowed")
  2479. } else {
  2480. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2481. }
  2482. })
  2483. return value, err
  2484. }
  2485. m.id = &id
  2486. }
  2487. }
  2488. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2489. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2490. return func(m *AliyunAvatarMutation) {
  2491. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2492. return node, nil
  2493. }
  2494. m.id = &node.ID
  2495. }
  2496. }
  2497. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2498. // executed in a transaction (ent.Tx), a transactional client is returned.
  2499. func (m AliyunAvatarMutation) Client() *Client {
  2500. client := &Client{config: m.config}
  2501. client.init()
  2502. return client
  2503. }
  2504. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2505. // it returns an error otherwise.
  2506. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2507. if _, ok := m.driver.(*txDriver); !ok {
  2508. return nil, errors.New("ent: mutation is not running in a transaction")
  2509. }
  2510. tx := &Tx{config: m.config}
  2511. tx.init()
  2512. return tx, nil
  2513. }
  2514. // SetID sets the value of the id field. Note that this
  2515. // operation is only accepted on creation of AliyunAvatar entities.
  2516. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2517. m.id = &id
  2518. }
  2519. // ID returns the ID value in the mutation. Note that the ID is only available
  2520. // if it was provided to the builder or after it was returned from the database.
  2521. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2522. if m.id == nil {
  2523. return
  2524. }
  2525. return *m.id, true
  2526. }
  2527. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2528. // That means, if the mutation is applied within a transaction with an isolation level such
  2529. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2530. // or updated by the mutation.
  2531. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2532. switch {
  2533. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2534. id, exists := m.ID()
  2535. if exists {
  2536. return []uint64{id}, nil
  2537. }
  2538. fallthrough
  2539. case m.op.Is(OpUpdate | OpDelete):
  2540. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2541. default:
  2542. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2543. }
  2544. }
  2545. // SetCreatedAt sets the "created_at" field.
  2546. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2547. m.created_at = &t
  2548. }
  2549. // CreatedAt returns the value of the "created_at" field in the mutation.
  2550. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2551. v := m.created_at
  2552. if v == nil {
  2553. return
  2554. }
  2555. return *v, true
  2556. }
  2557. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2558. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2560. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2561. if !m.op.Is(OpUpdateOne) {
  2562. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2563. }
  2564. if m.id == nil || m.oldValue == nil {
  2565. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2566. }
  2567. oldValue, err := m.oldValue(ctx)
  2568. if err != nil {
  2569. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2570. }
  2571. return oldValue.CreatedAt, nil
  2572. }
  2573. // ResetCreatedAt resets all changes to the "created_at" field.
  2574. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2575. m.created_at = nil
  2576. }
  2577. // SetUpdatedAt sets the "updated_at" field.
  2578. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2579. m.updated_at = &t
  2580. }
  2581. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2582. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2583. v := m.updated_at
  2584. if v == nil {
  2585. return
  2586. }
  2587. return *v, true
  2588. }
  2589. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2590. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2592. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2593. if !m.op.Is(OpUpdateOne) {
  2594. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2595. }
  2596. if m.id == nil || m.oldValue == nil {
  2597. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2598. }
  2599. oldValue, err := m.oldValue(ctx)
  2600. if err != nil {
  2601. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2602. }
  2603. return oldValue.UpdatedAt, nil
  2604. }
  2605. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2606. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2607. m.updated_at = nil
  2608. }
  2609. // SetDeletedAt sets the "deleted_at" field.
  2610. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2611. m.deleted_at = &t
  2612. }
  2613. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2614. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2615. v := m.deleted_at
  2616. if v == nil {
  2617. return
  2618. }
  2619. return *v, true
  2620. }
  2621. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2622. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2624. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2625. if !m.op.Is(OpUpdateOne) {
  2626. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2627. }
  2628. if m.id == nil || m.oldValue == nil {
  2629. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2630. }
  2631. oldValue, err := m.oldValue(ctx)
  2632. if err != nil {
  2633. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2634. }
  2635. return oldValue.DeletedAt, nil
  2636. }
  2637. // ClearDeletedAt clears the value of the "deleted_at" field.
  2638. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2639. m.deleted_at = nil
  2640. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2641. }
  2642. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2643. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2644. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2645. return ok
  2646. }
  2647. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2648. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2649. m.deleted_at = nil
  2650. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2651. }
  2652. // SetUserID sets the "user_id" field.
  2653. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2654. m.user_id = &u
  2655. m.adduser_id = nil
  2656. }
  2657. // UserID returns the value of the "user_id" field in the mutation.
  2658. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2659. v := m.user_id
  2660. if v == nil {
  2661. return
  2662. }
  2663. return *v, true
  2664. }
  2665. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2666. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2668. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2669. if !m.op.Is(OpUpdateOne) {
  2670. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2671. }
  2672. if m.id == nil || m.oldValue == nil {
  2673. return v, errors.New("OldUserID requires an ID field in the mutation")
  2674. }
  2675. oldValue, err := m.oldValue(ctx)
  2676. if err != nil {
  2677. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2678. }
  2679. return oldValue.UserID, nil
  2680. }
  2681. // AddUserID adds u to the "user_id" field.
  2682. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2683. if m.adduser_id != nil {
  2684. *m.adduser_id += u
  2685. } else {
  2686. m.adduser_id = &u
  2687. }
  2688. }
  2689. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2690. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2691. v := m.adduser_id
  2692. if v == nil {
  2693. return
  2694. }
  2695. return *v, true
  2696. }
  2697. // ResetUserID resets all changes to the "user_id" field.
  2698. func (m *AliyunAvatarMutation) ResetUserID() {
  2699. m.user_id = nil
  2700. m.adduser_id = nil
  2701. }
  2702. // SetBizID sets the "biz_id" field.
  2703. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2704. m.biz_id = &s
  2705. }
  2706. // BizID returns the value of the "biz_id" field in the mutation.
  2707. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2708. v := m.biz_id
  2709. if v == nil {
  2710. return
  2711. }
  2712. return *v, true
  2713. }
  2714. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2715. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2717. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2718. if !m.op.Is(OpUpdateOne) {
  2719. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2720. }
  2721. if m.id == nil || m.oldValue == nil {
  2722. return v, errors.New("OldBizID requires an ID field in the mutation")
  2723. }
  2724. oldValue, err := m.oldValue(ctx)
  2725. if err != nil {
  2726. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2727. }
  2728. return oldValue.BizID, nil
  2729. }
  2730. // ResetBizID resets all changes to the "biz_id" field.
  2731. func (m *AliyunAvatarMutation) ResetBizID() {
  2732. m.biz_id = nil
  2733. }
  2734. // SetAccessKeyID sets the "access_key_id" field.
  2735. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2736. m.access_key_id = &s
  2737. }
  2738. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2739. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2740. v := m.access_key_id
  2741. if v == nil {
  2742. return
  2743. }
  2744. return *v, true
  2745. }
  2746. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2747. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2749. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2750. if !m.op.Is(OpUpdateOne) {
  2751. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2752. }
  2753. if m.id == nil || m.oldValue == nil {
  2754. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2755. }
  2756. oldValue, err := m.oldValue(ctx)
  2757. if err != nil {
  2758. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2759. }
  2760. return oldValue.AccessKeyID, nil
  2761. }
  2762. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2763. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2764. m.access_key_id = nil
  2765. }
  2766. // SetAccessKeySecret sets the "access_key_secret" field.
  2767. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2768. m.access_key_secret = &s
  2769. }
  2770. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2771. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2772. v := m.access_key_secret
  2773. if v == nil {
  2774. return
  2775. }
  2776. return *v, true
  2777. }
  2778. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2779. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2781. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2782. if !m.op.Is(OpUpdateOne) {
  2783. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2784. }
  2785. if m.id == nil || m.oldValue == nil {
  2786. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2787. }
  2788. oldValue, err := m.oldValue(ctx)
  2789. if err != nil {
  2790. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2791. }
  2792. return oldValue.AccessKeySecret, nil
  2793. }
  2794. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2795. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2796. m.access_key_secret = nil
  2797. }
  2798. // SetAppID sets the "app_id" field.
  2799. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2800. m.app_id = &s
  2801. }
  2802. // AppID returns the value of the "app_id" field in the mutation.
  2803. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2804. v := m.app_id
  2805. if v == nil {
  2806. return
  2807. }
  2808. return *v, true
  2809. }
  2810. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2811. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2813. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2814. if !m.op.Is(OpUpdateOne) {
  2815. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2816. }
  2817. if m.id == nil || m.oldValue == nil {
  2818. return v, errors.New("OldAppID requires an ID field in the mutation")
  2819. }
  2820. oldValue, err := m.oldValue(ctx)
  2821. if err != nil {
  2822. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2823. }
  2824. return oldValue.AppID, nil
  2825. }
  2826. // ClearAppID clears the value of the "app_id" field.
  2827. func (m *AliyunAvatarMutation) ClearAppID() {
  2828. m.app_id = nil
  2829. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2830. }
  2831. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2832. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2833. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2834. return ok
  2835. }
  2836. // ResetAppID resets all changes to the "app_id" field.
  2837. func (m *AliyunAvatarMutation) ResetAppID() {
  2838. m.app_id = nil
  2839. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2840. }
  2841. // SetTenantID sets the "tenant_id" field.
  2842. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2843. m.tenant_id = &u
  2844. m.addtenant_id = nil
  2845. }
  2846. // TenantID returns the value of the "tenant_id" field in the mutation.
  2847. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2848. v := m.tenant_id
  2849. if v == nil {
  2850. return
  2851. }
  2852. return *v, true
  2853. }
  2854. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2855. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2857. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2858. if !m.op.Is(OpUpdateOne) {
  2859. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2860. }
  2861. if m.id == nil || m.oldValue == nil {
  2862. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2863. }
  2864. oldValue, err := m.oldValue(ctx)
  2865. if err != nil {
  2866. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2867. }
  2868. return oldValue.TenantID, nil
  2869. }
  2870. // AddTenantID adds u to the "tenant_id" field.
  2871. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2872. if m.addtenant_id != nil {
  2873. *m.addtenant_id += u
  2874. } else {
  2875. m.addtenant_id = &u
  2876. }
  2877. }
  2878. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2879. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2880. v := m.addtenant_id
  2881. if v == nil {
  2882. return
  2883. }
  2884. return *v, true
  2885. }
  2886. // ResetTenantID resets all changes to the "tenant_id" field.
  2887. func (m *AliyunAvatarMutation) ResetTenantID() {
  2888. m.tenant_id = nil
  2889. m.addtenant_id = nil
  2890. }
  2891. // SetResponse sets the "response" field.
  2892. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2893. m.response = &s
  2894. }
  2895. // Response returns the value of the "response" field in the mutation.
  2896. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2897. v := m.response
  2898. if v == nil {
  2899. return
  2900. }
  2901. return *v, true
  2902. }
  2903. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2904. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2906. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2907. if !m.op.Is(OpUpdateOne) {
  2908. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2909. }
  2910. if m.id == nil || m.oldValue == nil {
  2911. return v, errors.New("OldResponse requires an ID field in the mutation")
  2912. }
  2913. oldValue, err := m.oldValue(ctx)
  2914. if err != nil {
  2915. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2916. }
  2917. return oldValue.Response, nil
  2918. }
  2919. // ResetResponse resets all changes to the "response" field.
  2920. func (m *AliyunAvatarMutation) ResetResponse() {
  2921. m.response = nil
  2922. }
  2923. // SetToken sets the "token" field.
  2924. func (m *AliyunAvatarMutation) SetToken(s string) {
  2925. m.token = &s
  2926. }
  2927. // Token returns the value of the "token" field in the mutation.
  2928. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2929. v := m.token
  2930. if v == nil {
  2931. return
  2932. }
  2933. return *v, true
  2934. }
  2935. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2936. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2938. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2939. if !m.op.Is(OpUpdateOne) {
  2940. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2941. }
  2942. if m.id == nil || m.oldValue == nil {
  2943. return v, errors.New("OldToken requires an ID field in the mutation")
  2944. }
  2945. oldValue, err := m.oldValue(ctx)
  2946. if err != nil {
  2947. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2948. }
  2949. return oldValue.Token, nil
  2950. }
  2951. // ResetToken resets all changes to the "token" field.
  2952. func (m *AliyunAvatarMutation) ResetToken() {
  2953. m.token = nil
  2954. }
  2955. // SetSessionID sets the "session_id" field.
  2956. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2957. m.session_id = &s
  2958. }
  2959. // SessionID returns the value of the "session_id" field in the mutation.
  2960. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2961. v := m.session_id
  2962. if v == nil {
  2963. return
  2964. }
  2965. return *v, true
  2966. }
  2967. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2968. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2970. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2971. if !m.op.Is(OpUpdateOne) {
  2972. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2973. }
  2974. if m.id == nil || m.oldValue == nil {
  2975. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2976. }
  2977. oldValue, err := m.oldValue(ctx)
  2978. if err != nil {
  2979. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2980. }
  2981. return oldValue.SessionID, nil
  2982. }
  2983. // ResetSessionID resets all changes to the "session_id" field.
  2984. func (m *AliyunAvatarMutation) ResetSessionID() {
  2985. m.session_id = nil
  2986. }
  2987. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2988. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2989. m.predicates = append(m.predicates, ps...)
  2990. }
  2991. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2992. // users can use type-assertion to append predicates that do not depend on any generated package.
  2993. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2994. p := make([]predicate.AliyunAvatar, len(ps))
  2995. for i := range ps {
  2996. p[i] = ps[i]
  2997. }
  2998. m.Where(p...)
  2999. }
  3000. // Op returns the operation name.
  3001. func (m *AliyunAvatarMutation) Op() Op {
  3002. return m.op
  3003. }
  3004. // SetOp allows setting the mutation operation.
  3005. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3006. m.op = op
  3007. }
  3008. // Type returns the node type of this mutation (AliyunAvatar).
  3009. func (m *AliyunAvatarMutation) Type() string {
  3010. return m.typ
  3011. }
  3012. // Fields returns all fields that were changed during this mutation. Note that in
  3013. // order to get all numeric fields that were incremented/decremented, call
  3014. // AddedFields().
  3015. func (m *AliyunAvatarMutation) Fields() []string {
  3016. fields := make([]string, 0, 12)
  3017. if m.created_at != nil {
  3018. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3019. }
  3020. if m.updated_at != nil {
  3021. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3022. }
  3023. if m.deleted_at != nil {
  3024. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3025. }
  3026. if m.user_id != nil {
  3027. fields = append(fields, aliyunavatar.FieldUserID)
  3028. }
  3029. if m.biz_id != nil {
  3030. fields = append(fields, aliyunavatar.FieldBizID)
  3031. }
  3032. if m.access_key_id != nil {
  3033. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3034. }
  3035. if m.access_key_secret != nil {
  3036. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3037. }
  3038. if m.app_id != nil {
  3039. fields = append(fields, aliyunavatar.FieldAppID)
  3040. }
  3041. if m.tenant_id != nil {
  3042. fields = append(fields, aliyunavatar.FieldTenantID)
  3043. }
  3044. if m.response != nil {
  3045. fields = append(fields, aliyunavatar.FieldResponse)
  3046. }
  3047. if m.token != nil {
  3048. fields = append(fields, aliyunavatar.FieldToken)
  3049. }
  3050. if m.session_id != nil {
  3051. fields = append(fields, aliyunavatar.FieldSessionID)
  3052. }
  3053. return fields
  3054. }
  3055. // Field returns the value of a field with the given name. The second boolean
  3056. // return value indicates that this field was not set, or was not defined in the
  3057. // schema.
  3058. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3059. switch name {
  3060. case aliyunavatar.FieldCreatedAt:
  3061. return m.CreatedAt()
  3062. case aliyunavatar.FieldUpdatedAt:
  3063. return m.UpdatedAt()
  3064. case aliyunavatar.FieldDeletedAt:
  3065. return m.DeletedAt()
  3066. case aliyunavatar.FieldUserID:
  3067. return m.UserID()
  3068. case aliyunavatar.FieldBizID:
  3069. return m.BizID()
  3070. case aliyunavatar.FieldAccessKeyID:
  3071. return m.AccessKeyID()
  3072. case aliyunavatar.FieldAccessKeySecret:
  3073. return m.AccessKeySecret()
  3074. case aliyunavatar.FieldAppID:
  3075. return m.AppID()
  3076. case aliyunavatar.FieldTenantID:
  3077. return m.TenantID()
  3078. case aliyunavatar.FieldResponse:
  3079. return m.Response()
  3080. case aliyunavatar.FieldToken:
  3081. return m.Token()
  3082. case aliyunavatar.FieldSessionID:
  3083. return m.SessionID()
  3084. }
  3085. return nil, false
  3086. }
  3087. // OldField returns the old value of the field from the database. An error is
  3088. // returned if the mutation operation is not UpdateOne, or the query to the
  3089. // database failed.
  3090. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3091. switch name {
  3092. case aliyunavatar.FieldCreatedAt:
  3093. return m.OldCreatedAt(ctx)
  3094. case aliyunavatar.FieldUpdatedAt:
  3095. return m.OldUpdatedAt(ctx)
  3096. case aliyunavatar.FieldDeletedAt:
  3097. return m.OldDeletedAt(ctx)
  3098. case aliyunavatar.FieldUserID:
  3099. return m.OldUserID(ctx)
  3100. case aliyunavatar.FieldBizID:
  3101. return m.OldBizID(ctx)
  3102. case aliyunavatar.FieldAccessKeyID:
  3103. return m.OldAccessKeyID(ctx)
  3104. case aliyunavatar.FieldAccessKeySecret:
  3105. return m.OldAccessKeySecret(ctx)
  3106. case aliyunavatar.FieldAppID:
  3107. return m.OldAppID(ctx)
  3108. case aliyunavatar.FieldTenantID:
  3109. return m.OldTenantID(ctx)
  3110. case aliyunavatar.FieldResponse:
  3111. return m.OldResponse(ctx)
  3112. case aliyunavatar.FieldToken:
  3113. return m.OldToken(ctx)
  3114. case aliyunavatar.FieldSessionID:
  3115. return m.OldSessionID(ctx)
  3116. }
  3117. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3118. }
  3119. // SetField sets the value of a field with the given name. It returns an error if
  3120. // the field is not defined in the schema, or if the type mismatched the field
  3121. // type.
  3122. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3123. switch name {
  3124. case aliyunavatar.FieldCreatedAt:
  3125. v, ok := value.(time.Time)
  3126. if !ok {
  3127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3128. }
  3129. m.SetCreatedAt(v)
  3130. return nil
  3131. case aliyunavatar.FieldUpdatedAt:
  3132. v, ok := value.(time.Time)
  3133. if !ok {
  3134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3135. }
  3136. m.SetUpdatedAt(v)
  3137. return nil
  3138. case aliyunavatar.FieldDeletedAt:
  3139. v, ok := value.(time.Time)
  3140. if !ok {
  3141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3142. }
  3143. m.SetDeletedAt(v)
  3144. return nil
  3145. case aliyunavatar.FieldUserID:
  3146. v, ok := value.(uint64)
  3147. if !ok {
  3148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3149. }
  3150. m.SetUserID(v)
  3151. return nil
  3152. case aliyunavatar.FieldBizID:
  3153. v, ok := value.(string)
  3154. if !ok {
  3155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3156. }
  3157. m.SetBizID(v)
  3158. return nil
  3159. case aliyunavatar.FieldAccessKeyID:
  3160. v, ok := value.(string)
  3161. if !ok {
  3162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3163. }
  3164. m.SetAccessKeyID(v)
  3165. return nil
  3166. case aliyunavatar.FieldAccessKeySecret:
  3167. v, ok := value.(string)
  3168. if !ok {
  3169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3170. }
  3171. m.SetAccessKeySecret(v)
  3172. return nil
  3173. case aliyunavatar.FieldAppID:
  3174. v, ok := value.(string)
  3175. if !ok {
  3176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3177. }
  3178. m.SetAppID(v)
  3179. return nil
  3180. case aliyunavatar.FieldTenantID:
  3181. v, ok := value.(uint64)
  3182. if !ok {
  3183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3184. }
  3185. m.SetTenantID(v)
  3186. return nil
  3187. case aliyunavatar.FieldResponse:
  3188. v, ok := value.(string)
  3189. if !ok {
  3190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3191. }
  3192. m.SetResponse(v)
  3193. return nil
  3194. case aliyunavatar.FieldToken:
  3195. v, ok := value.(string)
  3196. if !ok {
  3197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3198. }
  3199. m.SetToken(v)
  3200. return nil
  3201. case aliyunavatar.FieldSessionID:
  3202. v, ok := value.(string)
  3203. if !ok {
  3204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3205. }
  3206. m.SetSessionID(v)
  3207. return nil
  3208. }
  3209. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3210. }
  3211. // AddedFields returns all numeric fields that were incremented/decremented during
  3212. // this mutation.
  3213. func (m *AliyunAvatarMutation) AddedFields() []string {
  3214. var fields []string
  3215. if m.adduser_id != nil {
  3216. fields = append(fields, aliyunavatar.FieldUserID)
  3217. }
  3218. if m.addtenant_id != nil {
  3219. fields = append(fields, aliyunavatar.FieldTenantID)
  3220. }
  3221. return fields
  3222. }
  3223. // AddedField returns the numeric value that was incremented/decremented on a field
  3224. // with the given name. The second boolean return value indicates that this field
  3225. // was not set, or was not defined in the schema.
  3226. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3227. switch name {
  3228. case aliyunavatar.FieldUserID:
  3229. return m.AddedUserID()
  3230. case aliyunavatar.FieldTenantID:
  3231. return m.AddedTenantID()
  3232. }
  3233. return nil, false
  3234. }
  3235. // AddField adds the value to the field with the given name. It returns an error if
  3236. // the field is not defined in the schema, or if the type mismatched the field
  3237. // type.
  3238. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3239. switch name {
  3240. case aliyunavatar.FieldUserID:
  3241. v, ok := value.(int64)
  3242. if !ok {
  3243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3244. }
  3245. m.AddUserID(v)
  3246. return nil
  3247. case aliyunavatar.FieldTenantID:
  3248. v, ok := value.(int64)
  3249. if !ok {
  3250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3251. }
  3252. m.AddTenantID(v)
  3253. return nil
  3254. }
  3255. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3256. }
  3257. // ClearedFields returns all nullable fields that were cleared during this
  3258. // mutation.
  3259. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3260. var fields []string
  3261. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3262. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3263. }
  3264. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3265. fields = append(fields, aliyunavatar.FieldAppID)
  3266. }
  3267. return fields
  3268. }
  3269. // FieldCleared returns a boolean indicating if a field with the given name was
  3270. // cleared in this mutation.
  3271. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3272. _, ok := m.clearedFields[name]
  3273. return ok
  3274. }
  3275. // ClearField clears the value of the field with the given name. It returns an
  3276. // error if the field is not defined in the schema.
  3277. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3278. switch name {
  3279. case aliyunavatar.FieldDeletedAt:
  3280. m.ClearDeletedAt()
  3281. return nil
  3282. case aliyunavatar.FieldAppID:
  3283. m.ClearAppID()
  3284. return nil
  3285. }
  3286. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3287. }
  3288. // ResetField resets all changes in the mutation for the field with the given name.
  3289. // It returns an error if the field is not defined in the schema.
  3290. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3291. switch name {
  3292. case aliyunavatar.FieldCreatedAt:
  3293. m.ResetCreatedAt()
  3294. return nil
  3295. case aliyunavatar.FieldUpdatedAt:
  3296. m.ResetUpdatedAt()
  3297. return nil
  3298. case aliyunavatar.FieldDeletedAt:
  3299. m.ResetDeletedAt()
  3300. return nil
  3301. case aliyunavatar.FieldUserID:
  3302. m.ResetUserID()
  3303. return nil
  3304. case aliyunavatar.FieldBizID:
  3305. m.ResetBizID()
  3306. return nil
  3307. case aliyunavatar.FieldAccessKeyID:
  3308. m.ResetAccessKeyID()
  3309. return nil
  3310. case aliyunavatar.FieldAccessKeySecret:
  3311. m.ResetAccessKeySecret()
  3312. return nil
  3313. case aliyunavatar.FieldAppID:
  3314. m.ResetAppID()
  3315. return nil
  3316. case aliyunavatar.FieldTenantID:
  3317. m.ResetTenantID()
  3318. return nil
  3319. case aliyunavatar.FieldResponse:
  3320. m.ResetResponse()
  3321. return nil
  3322. case aliyunavatar.FieldToken:
  3323. m.ResetToken()
  3324. return nil
  3325. case aliyunavatar.FieldSessionID:
  3326. m.ResetSessionID()
  3327. return nil
  3328. }
  3329. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3330. }
  3331. // AddedEdges returns all edge names that were set/added in this mutation.
  3332. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3333. edges := make([]string, 0, 0)
  3334. return edges
  3335. }
  3336. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3337. // name in this mutation.
  3338. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3339. return nil
  3340. }
  3341. // RemovedEdges returns all edge names that were removed in this mutation.
  3342. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3343. edges := make([]string, 0, 0)
  3344. return edges
  3345. }
  3346. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3347. // the given name in this mutation.
  3348. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3349. return nil
  3350. }
  3351. // ClearedEdges returns all edge names that were cleared in this mutation.
  3352. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3353. edges := make([]string, 0, 0)
  3354. return edges
  3355. }
  3356. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3357. // was cleared in this mutation.
  3358. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3359. return false
  3360. }
  3361. // ClearEdge clears the value of the edge with the given name. It returns an error
  3362. // if that edge is not defined in the schema.
  3363. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3364. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3365. }
  3366. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3367. // It returns an error if the edge is not defined in the schema.
  3368. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3369. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3370. }
  3371. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3372. type AllocAgentMutation struct {
  3373. config
  3374. op Op
  3375. typ string
  3376. id *uint64
  3377. created_at *time.Time
  3378. updated_at *time.Time
  3379. deleted_at *time.Time
  3380. user_id *string
  3381. organization_id *uint64
  3382. addorganization_id *int64
  3383. agents *[]uint64
  3384. appendagents []uint64
  3385. status *int
  3386. addstatus *int
  3387. clearedFields map[string]struct{}
  3388. done bool
  3389. oldValue func(context.Context) (*AllocAgent, error)
  3390. predicates []predicate.AllocAgent
  3391. }
  3392. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3393. // allocagentOption allows management of the mutation configuration using functional options.
  3394. type allocagentOption func(*AllocAgentMutation)
  3395. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3396. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3397. m := &AllocAgentMutation{
  3398. config: c,
  3399. op: op,
  3400. typ: TypeAllocAgent,
  3401. clearedFields: make(map[string]struct{}),
  3402. }
  3403. for _, opt := range opts {
  3404. opt(m)
  3405. }
  3406. return m
  3407. }
  3408. // withAllocAgentID sets the ID field of the mutation.
  3409. func withAllocAgentID(id uint64) allocagentOption {
  3410. return func(m *AllocAgentMutation) {
  3411. var (
  3412. err error
  3413. once sync.Once
  3414. value *AllocAgent
  3415. )
  3416. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3417. once.Do(func() {
  3418. if m.done {
  3419. err = errors.New("querying old values post mutation is not allowed")
  3420. } else {
  3421. value, err = m.Client().AllocAgent.Get(ctx, id)
  3422. }
  3423. })
  3424. return value, err
  3425. }
  3426. m.id = &id
  3427. }
  3428. }
  3429. // withAllocAgent sets the old AllocAgent of the mutation.
  3430. func withAllocAgent(node *AllocAgent) allocagentOption {
  3431. return func(m *AllocAgentMutation) {
  3432. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3433. return node, nil
  3434. }
  3435. m.id = &node.ID
  3436. }
  3437. }
  3438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3439. // executed in a transaction (ent.Tx), a transactional client is returned.
  3440. func (m AllocAgentMutation) Client() *Client {
  3441. client := &Client{config: m.config}
  3442. client.init()
  3443. return client
  3444. }
  3445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3446. // it returns an error otherwise.
  3447. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3448. if _, ok := m.driver.(*txDriver); !ok {
  3449. return nil, errors.New("ent: mutation is not running in a transaction")
  3450. }
  3451. tx := &Tx{config: m.config}
  3452. tx.init()
  3453. return tx, nil
  3454. }
  3455. // SetID sets the value of the id field. Note that this
  3456. // operation is only accepted on creation of AllocAgent entities.
  3457. func (m *AllocAgentMutation) SetID(id uint64) {
  3458. m.id = &id
  3459. }
  3460. // ID returns the ID value in the mutation. Note that the ID is only available
  3461. // if it was provided to the builder or after it was returned from the database.
  3462. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3463. if m.id == nil {
  3464. return
  3465. }
  3466. return *m.id, true
  3467. }
  3468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3469. // That means, if the mutation is applied within a transaction with an isolation level such
  3470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3471. // or updated by the mutation.
  3472. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3473. switch {
  3474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3475. id, exists := m.ID()
  3476. if exists {
  3477. return []uint64{id}, nil
  3478. }
  3479. fallthrough
  3480. case m.op.Is(OpUpdate | OpDelete):
  3481. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3482. default:
  3483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3484. }
  3485. }
  3486. // SetCreatedAt sets the "created_at" field.
  3487. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3488. m.created_at = &t
  3489. }
  3490. // CreatedAt returns the value of the "created_at" field in the mutation.
  3491. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3492. v := m.created_at
  3493. if v == nil {
  3494. return
  3495. }
  3496. return *v, true
  3497. }
  3498. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3499. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3501. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3502. if !m.op.Is(OpUpdateOne) {
  3503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3504. }
  3505. if m.id == nil || m.oldValue == nil {
  3506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3507. }
  3508. oldValue, err := m.oldValue(ctx)
  3509. if err != nil {
  3510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3511. }
  3512. return oldValue.CreatedAt, nil
  3513. }
  3514. // ResetCreatedAt resets all changes to the "created_at" field.
  3515. func (m *AllocAgentMutation) ResetCreatedAt() {
  3516. m.created_at = nil
  3517. }
  3518. // SetUpdatedAt sets the "updated_at" field.
  3519. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3520. m.updated_at = &t
  3521. }
  3522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3523. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3524. v := m.updated_at
  3525. if v == nil {
  3526. return
  3527. }
  3528. return *v, true
  3529. }
  3530. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3531. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3533. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3534. if !m.op.Is(OpUpdateOne) {
  3535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3536. }
  3537. if m.id == nil || m.oldValue == nil {
  3538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3539. }
  3540. oldValue, err := m.oldValue(ctx)
  3541. if err != nil {
  3542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3543. }
  3544. return oldValue.UpdatedAt, nil
  3545. }
  3546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3547. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3548. m.updated_at = nil
  3549. }
  3550. // SetDeletedAt sets the "deleted_at" field.
  3551. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3552. m.deleted_at = &t
  3553. }
  3554. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3555. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3556. v := m.deleted_at
  3557. if v == nil {
  3558. return
  3559. }
  3560. return *v, true
  3561. }
  3562. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3563. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3565. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3566. if !m.op.Is(OpUpdateOne) {
  3567. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3568. }
  3569. if m.id == nil || m.oldValue == nil {
  3570. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3571. }
  3572. oldValue, err := m.oldValue(ctx)
  3573. if err != nil {
  3574. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3575. }
  3576. return oldValue.DeletedAt, nil
  3577. }
  3578. // ClearDeletedAt clears the value of the "deleted_at" field.
  3579. func (m *AllocAgentMutation) ClearDeletedAt() {
  3580. m.deleted_at = nil
  3581. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3582. }
  3583. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3584. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3585. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3586. return ok
  3587. }
  3588. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3589. func (m *AllocAgentMutation) ResetDeletedAt() {
  3590. m.deleted_at = nil
  3591. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3592. }
  3593. // SetUserID sets the "user_id" field.
  3594. func (m *AllocAgentMutation) SetUserID(s string) {
  3595. m.user_id = &s
  3596. }
  3597. // UserID returns the value of the "user_id" field in the mutation.
  3598. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3599. v := m.user_id
  3600. if v == nil {
  3601. return
  3602. }
  3603. return *v, true
  3604. }
  3605. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3606. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3608. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3609. if !m.op.Is(OpUpdateOne) {
  3610. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3611. }
  3612. if m.id == nil || m.oldValue == nil {
  3613. return v, errors.New("OldUserID requires an ID field in the mutation")
  3614. }
  3615. oldValue, err := m.oldValue(ctx)
  3616. if err != nil {
  3617. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3618. }
  3619. return oldValue.UserID, nil
  3620. }
  3621. // ClearUserID clears the value of the "user_id" field.
  3622. func (m *AllocAgentMutation) ClearUserID() {
  3623. m.user_id = nil
  3624. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3625. }
  3626. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3627. func (m *AllocAgentMutation) UserIDCleared() bool {
  3628. _, ok := m.clearedFields[allocagent.FieldUserID]
  3629. return ok
  3630. }
  3631. // ResetUserID resets all changes to the "user_id" field.
  3632. func (m *AllocAgentMutation) ResetUserID() {
  3633. m.user_id = nil
  3634. delete(m.clearedFields, allocagent.FieldUserID)
  3635. }
  3636. // SetOrganizationID sets the "organization_id" field.
  3637. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3638. m.organization_id = &u
  3639. m.addorganization_id = nil
  3640. }
  3641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3642. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3643. v := m.organization_id
  3644. if v == nil {
  3645. return
  3646. }
  3647. return *v, true
  3648. }
  3649. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3650. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3652. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3653. if !m.op.Is(OpUpdateOne) {
  3654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3655. }
  3656. if m.id == nil || m.oldValue == nil {
  3657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3658. }
  3659. oldValue, err := m.oldValue(ctx)
  3660. if err != nil {
  3661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3662. }
  3663. return oldValue.OrganizationID, nil
  3664. }
  3665. // AddOrganizationID adds u to the "organization_id" field.
  3666. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3667. if m.addorganization_id != nil {
  3668. *m.addorganization_id += u
  3669. } else {
  3670. m.addorganization_id = &u
  3671. }
  3672. }
  3673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3674. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3675. v := m.addorganization_id
  3676. if v == nil {
  3677. return
  3678. }
  3679. return *v, true
  3680. }
  3681. // ClearOrganizationID clears the value of the "organization_id" field.
  3682. func (m *AllocAgentMutation) ClearOrganizationID() {
  3683. m.organization_id = nil
  3684. m.addorganization_id = nil
  3685. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3686. }
  3687. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3688. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3689. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3690. return ok
  3691. }
  3692. // ResetOrganizationID resets all changes to the "organization_id" field.
  3693. func (m *AllocAgentMutation) ResetOrganizationID() {
  3694. m.organization_id = nil
  3695. m.addorganization_id = nil
  3696. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3697. }
  3698. // SetAgents sets the "agents" field.
  3699. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3700. m.agents = &u
  3701. m.appendagents = nil
  3702. }
  3703. // Agents returns the value of the "agents" field in the mutation.
  3704. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3705. v := m.agents
  3706. if v == nil {
  3707. return
  3708. }
  3709. return *v, true
  3710. }
  3711. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3712. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3714. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3715. if !m.op.Is(OpUpdateOne) {
  3716. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3717. }
  3718. if m.id == nil || m.oldValue == nil {
  3719. return v, errors.New("OldAgents requires an ID field in the mutation")
  3720. }
  3721. oldValue, err := m.oldValue(ctx)
  3722. if err != nil {
  3723. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3724. }
  3725. return oldValue.Agents, nil
  3726. }
  3727. // AppendAgents adds u to the "agents" field.
  3728. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3729. m.appendagents = append(m.appendagents, u...)
  3730. }
  3731. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3732. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3733. if len(m.appendagents) == 0 {
  3734. return nil, false
  3735. }
  3736. return m.appendagents, true
  3737. }
  3738. // ResetAgents resets all changes to the "agents" field.
  3739. func (m *AllocAgentMutation) ResetAgents() {
  3740. m.agents = nil
  3741. m.appendagents = nil
  3742. }
  3743. // SetStatus sets the "status" field.
  3744. func (m *AllocAgentMutation) SetStatus(i int) {
  3745. m.status = &i
  3746. m.addstatus = nil
  3747. }
  3748. // Status returns the value of the "status" field in the mutation.
  3749. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3750. v := m.status
  3751. if v == nil {
  3752. return
  3753. }
  3754. return *v, true
  3755. }
  3756. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3757. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3759. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3760. if !m.op.Is(OpUpdateOne) {
  3761. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3762. }
  3763. if m.id == nil || m.oldValue == nil {
  3764. return v, errors.New("OldStatus requires an ID field in the mutation")
  3765. }
  3766. oldValue, err := m.oldValue(ctx)
  3767. if err != nil {
  3768. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3769. }
  3770. return oldValue.Status, nil
  3771. }
  3772. // AddStatus adds i to the "status" field.
  3773. func (m *AllocAgentMutation) AddStatus(i int) {
  3774. if m.addstatus != nil {
  3775. *m.addstatus += i
  3776. } else {
  3777. m.addstatus = &i
  3778. }
  3779. }
  3780. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3781. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3782. v := m.addstatus
  3783. if v == nil {
  3784. return
  3785. }
  3786. return *v, true
  3787. }
  3788. // ClearStatus clears the value of the "status" field.
  3789. func (m *AllocAgentMutation) ClearStatus() {
  3790. m.status = nil
  3791. m.addstatus = nil
  3792. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3793. }
  3794. // StatusCleared returns if the "status" field was cleared in this mutation.
  3795. func (m *AllocAgentMutation) StatusCleared() bool {
  3796. _, ok := m.clearedFields[allocagent.FieldStatus]
  3797. return ok
  3798. }
  3799. // ResetStatus resets all changes to the "status" field.
  3800. func (m *AllocAgentMutation) ResetStatus() {
  3801. m.status = nil
  3802. m.addstatus = nil
  3803. delete(m.clearedFields, allocagent.FieldStatus)
  3804. }
  3805. // Where appends a list predicates to the AllocAgentMutation builder.
  3806. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3807. m.predicates = append(m.predicates, ps...)
  3808. }
  3809. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3810. // users can use type-assertion to append predicates that do not depend on any generated package.
  3811. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3812. p := make([]predicate.AllocAgent, len(ps))
  3813. for i := range ps {
  3814. p[i] = ps[i]
  3815. }
  3816. m.Where(p...)
  3817. }
  3818. // Op returns the operation name.
  3819. func (m *AllocAgentMutation) Op() Op {
  3820. return m.op
  3821. }
  3822. // SetOp allows setting the mutation operation.
  3823. func (m *AllocAgentMutation) SetOp(op Op) {
  3824. m.op = op
  3825. }
  3826. // Type returns the node type of this mutation (AllocAgent).
  3827. func (m *AllocAgentMutation) Type() string {
  3828. return m.typ
  3829. }
  3830. // Fields returns all fields that were changed during this mutation. Note that in
  3831. // order to get all numeric fields that were incremented/decremented, call
  3832. // AddedFields().
  3833. func (m *AllocAgentMutation) Fields() []string {
  3834. fields := make([]string, 0, 7)
  3835. if m.created_at != nil {
  3836. fields = append(fields, allocagent.FieldCreatedAt)
  3837. }
  3838. if m.updated_at != nil {
  3839. fields = append(fields, allocagent.FieldUpdatedAt)
  3840. }
  3841. if m.deleted_at != nil {
  3842. fields = append(fields, allocagent.FieldDeletedAt)
  3843. }
  3844. if m.user_id != nil {
  3845. fields = append(fields, allocagent.FieldUserID)
  3846. }
  3847. if m.organization_id != nil {
  3848. fields = append(fields, allocagent.FieldOrganizationID)
  3849. }
  3850. if m.agents != nil {
  3851. fields = append(fields, allocagent.FieldAgents)
  3852. }
  3853. if m.status != nil {
  3854. fields = append(fields, allocagent.FieldStatus)
  3855. }
  3856. return fields
  3857. }
  3858. // Field returns the value of a field with the given name. The second boolean
  3859. // return value indicates that this field was not set, or was not defined in the
  3860. // schema.
  3861. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3862. switch name {
  3863. case allocagent.FieldCreatedAt:
  3864. return m.CreatedAt()
  3865. case allocagent.FieldUpdatedAt:
  3866. return m.UpdatedAt()
  3867. case allocagent.FieldDeletedAt:
  3868. return m.DeletedAt()
  3869. case allocagent.FieldUserID:
  3870. return m.UserID()
  3871. case allocagent.FieldOrganizationID:
  3872. return m.OrganizationID()
  3873. case allocagent.FieldAgents:
  3874. return m.Agents()
  3875. case allocagent.FieldStatus:
  3876. return m.Status()
  3877. }
  3878. return nil, false
  3879. }
  3880. // OldField returns the old value of the field from the database. An error is
  3881. // returned if the mutation operation is not UpdateOne, or the query to the
  3882. // database failed.
  3883. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3884. switch name {
  3885. case allocagent.FieldCreatedAt:
  3886. return m.OldCreatedAt(ctx)
  3887. case allocagent.FieldUpdatedAt:
  3888. return m.OldUpdatedAt(ctx)
  3889. case allocagent.FieldDeletedAt:
  3890. return m.OldDeletedAt(ctx)
  3891. case allocagent.FieldUserID:
  3892. return m.OldUserID(ctx)
  3893. case allocagent.FieldOrganizationID:
  3894. return m.OldOrganizationID(ctx)
  3895. case allocagent.FieldAgents:
  3896. return m.OldAgents(ctx)
  3897. case allocagent.FieldStatus:
  3898. return m.OldStatus(ctx)
  3899. }
  3900. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3901. }
  3902. // SetField sets the value of a field with the given name. It returns an error if
  3903. // the field is not defined in the schema, or if the type mismatched the field
  3904. // type.
  3905. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3906. switch name {
  3907. case allocagent.FieldCreatedAt:
  3908. v, ok := value.(time.Time)
  3909. if !ok {
  3910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3911. }
  3912. m.SetCreatedAt(v)
  3913. return nil
  3914. case allocagent.FieldUpdatedAt:
  3915. v, ok := value.(time.Time)
  3916. if !ok {
  3917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3918. }
  3919. m.SetUpdatedAt(v)
  3920. return nil
  3921. case allocagent.FieldDeletedAt:
  3922. v, ok := value.(time.Time)
  3923. if !ok {
  3924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3925. }
  3926. m.SetDeletedAt(v)
  3927. return nil
  3928. case allocagent.FieldUserID:
  3929. v, ok := value.(string)
  3930. if !ok {
  3931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3932. }
  3933. m.SetUserID(v)
  3934. return nil
  3935. case allocagent.FieldOrganizationID:
  3936. v, ok := value.(uint64)
  3937. if !ok {
  3938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3939. }
  3940. m.SetOrganizationID(v)
  3941. return nil
  3942. case allocagent.FieldAgents:
  3943. v, ok := value.([]uint64)
  3944. if !ok {
  3945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3946. }
  3947. m.SetAgents(v)
  3948. return nil
  3949. case allocagent.FieldStatus:
  3950. v, ok := value.(int)
  3951. if !ok {
  3952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3953. }
  3954. m.SetStatus(v)
  3955. return nil
  3956. }
  3957. return fmt.Errorf("unknown AllocAgent field %s", name)
  3958. }
  3959. // AddedFields returns all numeric fields that were incremented/decremented during
  3960. // this mutation.
  3961. func (m *AllocAgentMutation) AddedFields() []string {
  3962. var fields []string
  3963. if m.addorganization_id != nil {
  3964. fields = append(fields, allocagent.FieldOrganizationID)
  3965. }
  3966. if m.addstatus != nil {
  3967. fields = append(fields, allocagent.FieldStatus)
  3968. }
  3969. return fields
  3970. }
  3971. // AddedField returns the numeric value that was incremented/decremented on a field
  3972. // with the given name. The second boolean return value indicates that this field
  3973. // was not set, or was not defined in the schema.
  3974. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3975. switch name {
  3976. case allocagent.FieldOrganizationID:
  3977. return m.AddedOrganizationID()
  3978. case allocagent.FieldStatus:
  3979. return m.AddedStatus()
  3980. }
  3981. return nil, false
  3982. }
  3983. // AddField adds the value to the field with the given name. It returns an error if
  3984. // the field is not defined in the schema, or if the type mismatched the field
  3985. // type.
  3986. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3987. switch name {
  3988. case allocagent.FieldOrganizationID:
  3989. v, ok := value.(int64)
  3990. if !ok {
  3991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3992. }
  3993. m.AddOrganizationID(v)
  3994. return nil
  3995. case allocagent.FieldStatus:
  3996. v, ok := value.(int)
  3997. if !ok {
  3998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3999. }
  4000. m.AddStatus(v)
  4001. return nil
  4002. }
  4003. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4004. }
  4005. // ClearedFields returns all nullable fields that were cleared during this
  4006. // mutation.
  4007. func (m *AllocAgentMutation) ClearedFields() []string {
  4008. var fields []string
  4009. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4010. fields = append(fields, allocagent.FieldDeletedAt)
  4011. }
  4012. if m.FieldCleared(allocagent.FieldUserID) {
  4013. fields = append(fields, allocagent.FieldUserID)
  4014. }
  4015. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4016. fields = append(fields, allocagent.FieldOrganizationID)
  4017. }
  4018. if m.FieldCleared(allocagent.FieldStatus) {
  4019. fields = append(fields, allocagent.FieldStatus)
  4020. }
  4021. return fields
  4022. }
  4023. // FieldCleared returns a boolean indicating if a field with the given name was
  4024. // cleared in this mutation.
  4025. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4026. _, ok := m.clearedFields[name]
  4027. return ok
  4028. }
  4029. // ClearField clears the value of the field with the given name. It returns an
  4030. // error if the field is not defined in the schema.
  4031. func (m *AllocAgentMutation) ClearField(name string) error {
  4032. switch name {
  4033. case allocagent.FieldDeletedAt:
  4034. m.ClearDeletedAt()
  4035. return nil
  4036. case allocagent.FieldUserID:
  4037. m.ClearUserID()
  4038. return nil
  4039. case allocagent.FieldOrganizationID:
  4040. m.ClearOrganizationID()
  4041. return nil
  4042. case allocagent.FieldStatus:
  4043. m.ClearStatus()
  4044. return nil
  4045. }
  4046. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4047. }
  4048. // ResetField resets all changes in the mutation for the field with the given name.
  4049. // It returns an error if the field is not defined in the schema.
  4050. func (m *AllocAgentMutation) ResetField(name string) error {
  4051. switch name {
  4052. case allocagent.FieldCreatedAt:
  4053. m.ResetCreatedAt()
  4054. return nil
  4055. case allocagent.FieldUpdatedAt:
  4056. m.ResetUpdatedAt()
  4057. return nil
  4058. case allocagent.FieldDeletedAt:
  4059. m.ResetDeletedAt()
  4060. return nil
  4061. case allocagent.FieldUserID:
  4062. m.ResetUserID()
  4063. return nil
  4064. case allocagent.FieldOrganizationID:
  4065. m.ResetOrganizationID()
  4066. return nil
  4067. case allocagent.FieldAgents:
  4068. m.ResetAgents()
  4069. return nil
  4070. case allocagent.FieldStatus:
  4071. m.ResetStatus()
  4072. return nil
  4073. }
  4074. return fmt.Errorf("unknown AllocAgent field %s", name)
  4075. }
  4076. // AddedEdges returns all edge names that were set/added in this mutation.
  4077. func (m *AllocAgentMutation) AddedEdges() []string {
  4078. edges := make([]string, 0, 0)
  4079. return edges
  4080. }
  4081. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4082. // name in this mutation.
  4083. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4084. return nil
  4085. }
  4086. // RemovedEdges returns all edge names that were removed in this mutation.
  4087. func (m *AllocAgentMutation) RemovedEdges() []string {
  4088. edges := make([]string, 0, 0)
  4089. return edges
  4090. }
  4091. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4092. // the given name in this mutation.
  4093. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4094. return nil
  4095. }
  4096. // ClearedEdges returns all edge names that were cleared in this mutation.
  4097. func (m *AllocAgentMutation) ClearedEdges() []string {
  4098. edges := make([]string, 0, 0)
  4099. return edges
  4100. }
  4101. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4102. // was cleared in this mutation.
  4103. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4104. return false
  4105. }
  4106. // ClearEdge clears the value of the edge with the given name. It returns an error
  4107. // if that edge is not defined in the schema.
  4108. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4109. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4110. }
  4111. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4112. // It returns an error if the edge is not defined in the schema.
  4113. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4114. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4115. }
  4116. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4117. type ApiKeyMutation struct {
  4118. config
  4119. op Op
  4120. typ string
  4121. id *uint64
  4122. created_at *time.Time
  4123. updated_at *time.Time
  4124. deleted_at *time.Time
  4125. title *string
  4126. key *string
  4127. organization_id *uint64
  4128. addorganization_id *int64
  4129. custom_agent_base *string
  4130. custom_agent_key *string
  4131. openai_base *string
  4132. openai_key *string
  4133. clearedFields map[string]struct{}
  4134. agent *uint64
  4135. clearedagent bool
  4136. done bool
  4137. oldValue func(context.Context) (*ApiKey, error)
  4138. predicates []predicate.ApiKey
  4139. }
  4140. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4141. // apikeyOption allows management of the mutation configuration using functional options.
  4142. type apikeyOption func(*ApiKeyMutation)
  4143. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4144. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4145. m := &ApiKeyMutation{
  4146. config: c,
  4147. op: op,
  4148. typ: TypeApiKey,
  4149. clearedFields: make(map[string]struct{}),
  4150. }
  4151. for _, opt := range opts {
  4152. opt(m)
  4153. }
  4154. return m
  4155. }
  4156. // withApiKeyID sets the ID field of the mutation.
  4157. func withApiKeyID(id uint64) apikeyOption {
  4158. return func(m *ApiKeyMutation) {
  4159. var (
  4160. err error
  4161. once sync.Once
  4162. value *ApiKey
  4163. )
  4164. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4165. once.Do(func() {
  4166. if m.done {
  4167. err = errors.New("querying old values post mutation is not allowed")
  4168. } else {
  4169. value, err = m.Client().ApiKey.Get(ctx, id)
  4170. }
  4171. })
  4172. return value, err
  4173. }
  4174. m.id = &id
  4175. }
  4176. }
  4177. // withApiKey sets the old ApiKey of the mutation.
  4178. func withApiKey(node *ApiKey) apikeyOption {
  4179. return func(m *ApiKeyMutation) {
  4180. m.oldValue = func(context.Context) (*ApiKey, error) {
  4181. return node, nil
  4182. }
  4183. m.id = &node.ID
  4184. }
  4185. }
  4186. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4187. // executed in a transaction (ent.Tx), a transactional client is returned.
  4188. func (m ApiKeyMutation) Client() *Client {
  4189. client := &Client{config: m.config}
  4190. client.init()
  4191. return client
  4192. }
  4193. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4194. // it returns an error otherwise.
  4195. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4196. if _, ok := m.driver.(*txDriver); !ok {
  4197. return nil, errors.New("ent: mutation is not running in a transaction")
  4198. }
  4199. tx := &Tx{config: m.config}
  4200. tx.init()
  4201. return tx, nil
  4202. }
  4203. // SetID sets the value of the id field. Note that this
  4204. // operation is only accepted on creation of ApiKey entities.
  4205. func (m *ApiKeyMutation) SetID(id uint64) {
  4206. m.id = &id
  4207. }
  4208. // ID returns the ID value in the mutation. Note that the ID is only available
  4209. // if it was provided to the builder or after it was returned from the database.
  4210. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4211. if m.id == nil {
  4212. return
  4213. }
  4214. return *m.id, true
  4215. }
  4216. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4217. // That means, if the mutation is applied within a transaction with an isolation level such
  4218. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4219. // or updated by the mutation.
  4220. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4221. switch {
  4222. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4223. id, exists := m.ID()
  4224. if exists {
  4225. return []uint64{id}, nil
  4226. }
  4227. fallthrough
  4228. case m.op.Is(OpUpdate | OpDelete):
  4229. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4230. default:
  4231. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4232. }
  4233. }
  4234. // SetCreatedAt sets the "created_at" field.
  4235. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4236. m.created_at = &t
  4237. }
  4238. // CreatedAt returns the value of the "created_at" field in the mutation.
  4239. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4240. v := m.created_at
  4241. if v == nil {
  4242. return
  4243. }
  4244. return *v, true
  4245. }
  4246. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4247. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4249. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4250. if !m.op.Is(OpUpdateOne) {
  4251. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4252. }
  4253. if m.id == nil || m.oldValue == nil {
  4254. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4255. }
  4256. oldValue, err := m.oldValue(ctx)
  4257. if err != nil {
  4258. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4259. }
  4260. return oldValue.CreatedAt, nil
  4261. }
  4262. // ResetCreatedAt resets all changes to the "created_at" field.
  4263. func (m *ApiKeyMutation) ResetCreatedAt() {
  4264. m.created_at = nil
  4265. }
  4266. // SetUpdatedAt sets the "updated_at" field.
  4267. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4268. m.updated_at = &t
  4269. }
  4270. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4271. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4272. v := m.updated_at
  4273. if v == nil {
  4274. return
  4275. }
  4276. return *v, true
  4277. }
  4278. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4279. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4281. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4282. if !m.op.Is(OpUpdateOne) {
  4283. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4284. }
  4285. if m.id == nil || m.oldValue == nil {
  4286. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4287. }
  4288. oldValue, err := m.oldValue(ctx)
  4289. if err != nil {
  4290. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4291. }
  4292. return oldValue.UpdatedAt, nil
  4293. }
  4294. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4295. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4296. m.updated_at = nil
  4297. }
  4298. // SetDeletedAt sets the "deleted_at" field.
  4299. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4300. m.deleted_at = &t
  4301. }
  4302. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4303. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4304. v := m.deleted_at
  4305. if v == nil {
  4306. return
  4307. }
  4308. return *v, true
  4309. }
  4310. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4311. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4313. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4314. if !m.op.Is(OpUpdateOne) {
  4315. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4316. }
  4317. if m.id == nil || m.oldValue == nil {
  4318. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4319. }
  4320. oldValue, err := m.oldValue(ctx)
  4321. if err != nil {
  4322. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4323. }
  4324. return oldValue.DeletedAt, nil
  4325. }
  4326. // ClearDeletedAt clears the value of the "deleted_at" field.
  4327. func (m *ApiKeyMutation) ClearDeletedAt() {
  4328. m.deleted_at = nil
  4329. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4330. }
  4331. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4332. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4333. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4334. return ok
  4335. }
  4336. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4337. func (m *ApiKeyMutation) ResetDeletedAt() {
  4338. m.deleted_at = nil
  4339. delete(m.clearedFields, apikey.FieldDeletedAt)
  4340. }
  4341. // SetTitle sets the "title" field.
  4342. func (m *ApiKeyMutation) SetTitle(s string) {
  4343. m.title = &s
  4344. }
  4345. // Title returns the value of the "title" field in the mutation.
  4346. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4347. v := m.title
  4348. if v == nil {
  4349. return
  4350. }
  4351. return *v, true
  4352. }
  4353. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4354. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4356. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4357. if !m.op.Is(OpUpdateOne) {
  4358. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4359. }
  4360. if m.id == nil || m.oldValue == nil {
  4361. return v, errors.New("OldTitle requires an ID field in the mutation")
  4362. }
  4363. oldValue, err := m.oldValue(ctx)
  4364. if err != nil {
  4365. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4366. }
  4367. return oldValue.Title, nil
  4368. }
  4369. // ClearTitle clears the value of the "title" field.
  4370. func (m *ApiKeyMutation) ClearTitle() {
  4371. m.title = nil
  4372. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4373. }
  4374. // TitleCleared returns if the "title" field was cleared in this mutation.
  4375. func (m *ApiKeyMutation) TitleCleared() bool {
  4376. _, ok := m.clearedFields[apikey.FieldTitle]
  4377. return ok
  4378. }
  4379. // ResetTitle resets all changes to the "title" field.
  4380. func (m *ApiKeyMutation) ResetTitle() {
  4381. m.title = nil
  4382. delete(m.clearedFields, apikey.FieldTitle)
  4383. }
  4384. // SetKey sets the "key" field.
  4385. func (m *ApiKeyMutation) SetKey(s string) {
  4386. m.key = &s
  4387. }
  4388. // Key returns the value of the "key" field in the mutation.
  4389. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4390. v := m.key
  4391. if v == nil {
  4392. return
  4393. }
  4394. return *v, true
  4395. }
  4396. // OldKey returns the old "key" field's value of the ApiKey entity.
  4397. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4399. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4400. if !m.op.Is(OpUpdateOne) {
  4401. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4402. }
  4403. if m.id == nil || m.oldValue == nil {
  4404. return v, errors.New("OldKey requires an ID field in the mutation")
  4405. }
  4406. oldValue, err := m.oldValue(ctx)
  4407. if err != nil {
  4408. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4409. }
  4410. return oldValue.Key, nil
  4411. }
  4412. // ClearKey clears the value of the "key" field.
  4413. func (m *ApiKeyMutation) ClearKey() {
  4414. m.key = nil
  4415. m.clearedFields[apikey.FieldKey] = struct{}{}
  4416. }
  4417. // KeyCleared returns if the "key" field was cleared in this mutation.
  4418. func (m *ApiKeyMutation) KeyCleared() bool {
  4419. _, ok := m.clearedFields[apikey.FieldKey]
  4420. return ok
  4421. }
  4422. // ResetKey resets all changes to the "key" field.
  4423. func (m *ApiKeyMutation) ResetKey() {
  4424. m.key = nil
  4425. delete(m.clearedFields, apikey.FieldKey)
  4426. }
  4427. // SetOrganizationID sets the "organization_id" field.
  4428. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4429. m.organization_id = &u
  4430. m.addorganization_id = nil
  4431. }
  4432. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4433. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4434. v := m.organization_id
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4441. // If the ApiKey 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 *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  4453. }
  4454. return oldValue.OrganizationID, nil
  4455. }
  4456. // AddOrganizationID adds u to the "organization_id" field.
  4457. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4458. if m.addorganization_id != nil {
  4459. *m.addorganization_id += u
  4460. } else {
  4461. m.addorganization_id = &u
  4462. }
  4463. }
  4464. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4465. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4466. v := m.addorganization_id
  4467. if v == nil {
  4468. return
  4469. }
  4470. return *v, true
  4471. }
  4472. // ResetOrganizationID resets all changes to the "organization_id" field.
  4473. func (m *ApiKeyMutation) ResetOrganizationID() {
  4474. m.organization_id = nil
  4475. m.addorganization_id = nil
  4476. }
  4477. // SetAgentID sets the "agent_id" field.
  4478. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4479. m.agent = &u
  4480. }
  4481. // AgentID returns the value of the "agent_id" field in the mutation.
  4482. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4483. v := m.agent
  4484. if v == nil {
  4485. return
  4486. }
  4487. return *v, true
  4488. }
  4489. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4490. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4492. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4493. if !m.op.Is(OpUpdateOne) {
  4494. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4495. }
  4496. if m.id == nil || m.oldValue == nil {
  4497. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4498. }
  4499. oldValue, err := m.oldValue(ctx)
  4500. if err != nil {
  4501. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4502. }
  4503. return oldValue.AgentID, nil
  4504. }
  4505. // ResetAgentID resets all changes to the "agent_id" field.
  4506. func (m *ApiKeyMutation) ResetAgentID() {
  4507. m.agent = nil
  4508. }
  4509. // SetCustomAgentBase sets the "custom_agent_base" field.
  4510. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4511. m.custom_agent_base = &s
  4512. }
  4513. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4514. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4515. v := m.custom_agent_base
  4516. if v == nil {
  4517. return
  4518. }
  4519. return *v, true
  4520. }
  4521. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4522. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4524. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4525. if !m.op.Is(OpUpdateOne) {
  4526. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4527. }
  4528. if m.id == nil || m.oldValue == nil {
  4529. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4530. }
  4531. oldValue, err := m.oldValue(ctx)
  4532. if err != nil {
  4533. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4534. }
  4535. return oldValue.CustomAgentBase, nil
  4536. }
  4537. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4538. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4539. m.custom_agent_base = nil
  4540. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4541. }
  4542. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4543. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4544. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4545. return ok
  4546. }
  4547. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4548. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4549. m.custom_agent_base = nil
  4550. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4551. }
  4552. // SetCustomAgentKey sets the "custom_agent_key" field.
  4553. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4554. m.custom_agent_key = &s
  4555. }
  4556. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4557. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4558. v := m.custom_agent_key
  4559. if v == nil {
  4560. return
  4561. }
  4562. return *v, true
  4563. }
  4564. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4565. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4567. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4568. if !m.op.Is(OpUpdateOne) {
  4569. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4570. }
  4571. if m.id == nil || m.oldValue == nil {
  4572. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4573. }
  4574. oldValue, err := m.oldValue(ctx)
  4575. if err != nil {
  4576. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4577. }
  4578. return oldValue.CustomAgentKey, nil
  4579. }
  4580. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4581. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4582. m.custom_agent_key = nil
  4583. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4584. }
  4585. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4586. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4587. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4588. return ok
  4589. }
  4590. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4591. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4592. m.custom_agent_key = nil
  4593. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4594. }
  4595. // SetOpenaiBase sets the "openai_base" field.
  4596. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4597. m.openai_base = &s
  4598. }
  4599. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4600. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4601. v := m.openai_base
  4602. if v == nil {
  4603. return
  4604. }
  4605. return *v, true
  4606. }
  4607. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4608. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4610. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4611. if !m.op.Is(OpUpdateOne) {
  4612. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4613. }
  4614. if m.id == nil || m.oldValue == nil {
  4615. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4616. }
  4617. oldValue, err := m.oldValue(ctx)
  4618. if err != nil {
  4619. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4620. }
  4621. return oldValue.OpenaiBase, nil
  4622. }
  4623. // ClearOpenaiBase clears the value of the "openai_base" field.
  4624. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4625. m.openai_base = nil
  4626. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4627. }
  4628. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4629. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4630. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4631. return ok
  4632. }
  4633. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4634. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4635. m.openai_base = nil
  4636. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4637. }
  4638. // SetOpenaiKey sets the "openai_key" field.
  4639. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4640. m.openai_key = &s
  4641. }
  4642. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4643. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4644. v := m.openai_key
  4645. if v == nil {
  4646. return
  4647. }
  4648. return *v, true
  4649. }
  4650. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4651. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4653. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4654. if !m.op.Is(OpUpdateOne) {
  4655. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4656. }
  4657. if m.id == nil || m.oldValue == nil {
  4658. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4659. }
  4660. oldValue, err := m.oldValue(ctx)
  4661. if err != nil {
  4662. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4663. }
  4664. return oldValue.OpenaiKey, nil
  4665. }
  4666. // ClearOpenaiKey clears the value of the "openai_key" field.
  4667. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4668. m.openai_key = nil
  4669. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4670. }
  4671. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4672. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4673. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4674. return ok
  4675. }
  4676. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4677. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4678. m.openai_key = nil
  4679. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4680. }
  4681. // ClearAgent clears the "agent" edge to the Agent entity.
  4682. func (m *ApiKeyMutation) ClearAgent() {
  4683. m.clearedagent = true
  4684. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4685. }
  4686. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4687. func (m *ApiKeyMutation) AgentCleared() bool {
  4688. return m.clearedagent
  4689. }
  4690. // AgentIDs returns the "agent" edge IDs in the mutation.
  4691. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4692. // AgentID instead. It exists only for internal usage by the builders.
  4693. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4694. if id := m.agent; id != nil {
  4695. ids = append(ids, *id)
  4696. }
  4697. return
  4698. }
  4699. // ResetAgent resets all changes to the "agent" edge.
  4700. func (m *ApiKeyMutation) ResetAgent() {
  4701. m.agent = nil
  4702. m.clearedagent = false
  4703. }
  4704. // Where appends a list predicates to the ApiKeyMutation builder.
  4705. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4706. m.predicates = append(m.predicates, ps...)
  4707. }
  4708. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4709. // users can use type-assertion to append predicates that do not depend on any generated package.
  4710. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4711. p := make([]predicate.ApiKey, len(ps))
  4712. for i := range ps {
  4713. p[i] = ps[i]
  4714. }
  4715. m.Where(p...)
  4716. }
  4717. // Op returns the operation name.
  4718. func (m *ApiKeyMutation) Op() Op {
  4719. return m.op
  4720. }
  4721. // SetOp allows setting the mutation operation.
  4722. func (m *ApiKeyMutation) SetOp(op Op) {
  4723. m.op = op
  4724. }
  4725. // Type returns the node type of this mutation (ApiKey).
  4726. func (m *ApiKeyMutation) Type() string {
  4727. return m.typ
  4728. }
  4729. // Fields returns all fields that were changed during this mutation. Note that in
  4730. // order to get all numeric fields that were incremented/decremented, call
  4731. // AddedFields().
  4732. func (m *ApiKeyMutation) Fields() []string {
  4733. fields := make([]string, 0, 11)
  4734. if m.created_at != nil {
  4735. fields = append(fields, apikey.FieldCreatedAt)
  4736. }
  4737. if m.updated_at != nil {
  4738. fields = append(fields, apikey.FieldUpdatedAt)
  4739. }
  4740. if m.deleted_at != nil {
  4741. fields = append(fields, apikey.FieldDeletedAt)
  4742. }
  4743. if m.title != nil {
  4744. fields = append(fields, apikey.FieldTitle)
  4745. }
  4746. if m.key != nil {
  4747. fields = append(fields, apikey.FieldKey)
  4748. }
  4749. if m.organization_id != nil {
  4750. fields = append(fields, apikey.FieldOrganizationID)
  4751. }
  4752. if m.agent != nil {
  4753. fields = append(fields, apikey.FieldAgentID)
  4754. }
  4755. if m.custom_agent_base != nil {
  4756. fields = append(fields, apikey.FieldCustomAgentBase)
  4757. }
  4758. if m.custom_agent_key != nil {
  4759. fields = append(fields, apikey.FieldCustomAgentKey)
  4760. }
  4761. if m.openai_base != nil {
  4762. fields = append(fields, apikey.FieldOpenaiBase)
  4763. }
  4764. if m.openai_key != nil {
  4765. fields = append(fields, apikey.FieldOpenaiKey)
  4766. }
  4767. return fields
  4768. }
  4769. // Field returns the value of a field with the given name. The second boolean
  4770. // return value indicates that this field was not set, or was not defined in the
  4771. // schema.
  4772. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4773. switch name {
  4774. case apikey.FieldCreatedAt:
  4775. return m.CreatedAt()
  4776. case apikey.FieldUpdatedAt:
  4777. return m.UpdatedAt()
  4778. case apikey.FieldDeletedAt:
  4779. return m.DeletedAt()
  4780. case apikey.FieldTitle:
  4781. return m.Title()
  4782. case apikey.FieldKey:
  4783. return m.Key()
  4784. case apikey.FieldOrganizationID:
  4785. return m.OrganizationID()
  4786. case apikey.FieldAgentID:
  4787. return m.AgentID()
  4788. case apikey.FieldCustomAgentBase:
  4789. return m.CustomAgentBase()
  4790. case apikey.FieldCustomAgentKey:
  4791. return m.CustomAgentKey()
  4792. case apikey.FieldOpenaiBase:
  4793. return m.OpenaiBase()
  4794. case apikey.FieldOpenaiKey:
  4795. return m.OpenaiKey()
  4796. }
  4797. return nil, false
  4798. }
  4799. // OldField returns the old value of the field from the database. An error is
  4800. // returned if the mutation operation is not UpdateOne, or the query to the
  4801. // database failed.
  4802. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4803. switch name {
  4804. case apikey.FieldCreatedAt:
  4805. return m.OldCreatedAt(ctx)
  4806. case apikey.FieldUpdatedAt:
  4807. return m.OldUpdatedAt(ctx)
  4808. case apikey.FieldDeletedAt:
  4809. return m.OldDeletedAt(ctx)
  4810. case apikey.FieldTitle:
  4811. return m.OldTitle(ctx)
  4812. case apikey.FieldKey:
  4813. return m.OldKey(ctx)
  4814. case apikey.FieldOrganizationID:
  4815. return m.OldOrganizationID(ctx)
  4816. case apikey.FieldAgentID:
  4817. return m.OldAgentID(ctx)
  4818. case apikey.FieldCustomAgentBase:
  4819. return m.OldCustomAgentBase(ctx)
  4820. case apikey.FieldCustomAgentKey:
  4821. return m.OldCustomAgentKey(ctx)
  4822. case apikey.FieldOpenaiBase:
  4823. return m.OldOpenaiBase(ctx)
  4824. case apikey.FieldOpenaiKey:
  4825. return m.OldOpenaiKey(ctx)
  4826. }
  4827. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4828. }
  4829. // SetField sets the value of a field with the given name. It returns an error if
  4830. // the field is not defined in the schema, or if the type mismatched the field
  4831. // type.
  4832. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4833. switch name {
  4834. case apikey.FieldCreatedAt:
  4835. v, ok := value.(time.Time)
  4836. if !ok {
  4837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4838. }
  4839. m.SetCreatedAt(v)
  4840. return nil
  4841. case apikey.FieldUpdatedAt:
  4842. v, ok := value.(time.Time)
  4843. if !ok {
  4844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4845. }
  4846. m.SetUpdatedAt(v)
  4847. return nil
  4848. case apikey.FieldDeletedAt:
  4849. v, ok := value.(time.Time)
  4850. if !ok {
  4851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4852. }
  4853. m.SetDeletedAt(v)
  4854. return nil
  4855. case apikey.FieldTitle:
  4856. v, ok := value.(string)
  4857. if !ok {
  4858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4859. }
  4860. m.SetTitle(v)
  4861. return nil
  4862. case apikey.FieldKey:
  4863. v, ok := value.(string)
  4864. if !ok {
  4865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4866. }
  4867. m.SetKey(v)
  4868. return nil
  4869. case apikey.FieldOrganizationID:
  4870. v, ok := value.(uint64)
  4871. if !ok {
  4872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4873. }
  4874. m.SetOrganizationID(v)
  4875. return nil
  4876. case apikey.FieldAgentID:
  4877. v, ok := value.(uint64)
  4878. if !ok {
  4879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4880. }
  4881. m.SetAgentID(v)
  4882. return nil
  4883. case apikey.FieldCustomAgentBase:
  4884. v, ok := value.(string)
  4885. if !ok {
  4886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4887. }
  4888. m.SetCustomAgentBase(v)
  4889. return nil
  4890. case apikey.FieldCustomAgentKey:
  4891. v, ok := value.(string)
  4892. if !ok {
  4893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4894. }
  4895. m.SetCustomAgentKey(v)
  4896. return nil
  4897. case apikey.FieldOpenaiBase:
  4898. v, ok := value.(string)
  4899. if !ok {
  4900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4901. }
  4902. m.SetOpenaiBase(v)
  4903. return nil
  4904. case apikey.FieldOpenaiKey:
  4905. v, ok := value.(string)
  4906. if !ok {
  4907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4908. }
  4909. m.SetOpenaiKey(v)
  4910. return nil
  4911. }
  4912. return fmt.Errorf("unknown ApiKey field %s", name)
  4913. }
  4914. // AddedFields returns all numeric fields that were incremented/decremented during
  4915. // this mutation.
  4916. func (m *ApiKeyMutation) AddedFields() []string {
  4917. var fields []string
  4918. if m.addorganization_id != nil {
  4919. fields = append(fields, apikey.FieldOrganizationID)
  4920. }
  4921. return fields
  4922. }
  4923. // AddedField returns the numeric value that was incremented/decremented on a field
  4924. // with the given name. The second boolean return value indicates that this field
  4925. // was not set, or was not defined in the schema.
  4926. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4927. switch name {
  4928. case apikey.FieldOrganizationID:
  4929. return m.AddedOrganizationID()
  4930. }
  4931. return nil, false
  4932. }
  4933. // AddField adds the value to the field with the given name. It returns an error if
  4934. // the field is not defined in the schema, or if the type mismatched the field
  4935. // type.
  4936. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4937. switch name {
  4938. case apikey.FieldOrganizationID:
  4939. v, ok := value.(int64)
  4940. if !ok {
  4941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4942. }
  4943. m.AddOrganizationID(v)
  4944. return nil
  4945. }
  4946. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4947. }
  4948. // ClearedFields returns all nullable fields that were cleared during this
  4949. // mutation.
  4950. func (m *ApiKeyMutation) ClearedFields() []string {
  4951. var fields []string
  4952. if m.FieldCleared(apikey.FieldDeletedAt) {
  4953. fields = append(fields, apikey.FieldDeletedAt)
  4954. }
  4955. if m.FieldCleared(apikey.FieldTitle) {
  4956. fields = append(fields, apikey.FieldTitle)
  4957. }
  4958. if m.FieldCleared(apikey.FieldKey) {
  4959. fields = append(fields, apikey.FieldKey)
  4960. }
  4961. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4962. fields = append(fields, apikey.FieldCustomAgentBase)
  4963. }
  4964. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4965. fields = append(fields, apikey.FieldCustomAgentKey)
  4966. }
  4967. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4968. fields = append(fields, apikey.FieldOpenaiBase)
  4969. }
  4970. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4971. fields = append(fields, apikey.FieldOpenaiKey)
  4972. }
  4973. return fields
  4974. }
  4975. // FieldCleared returns a boolean indicating if a field with the given name was
  4976. // cleared in this mutation.
  4977. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4978. _, ok := m.clearedFields[name]
  4979. return ok
  4980. }
  4981. // ClearField clears the value of the field with the given name. It returns an
  4982. // error if the field is not defined in the schema.
  4983. func (m *ApiKeyMutation) ClearField(name string) error {
  4984. switch name {
  4985. case apikey.FieldDeletedAt:
  4986. m.ClearDeletedAt()
  4987. return nil
  4988. case apikey.FieldTitle:
  4989. m.ClearTitle()
  4990. return nil
  4991. case apikey.FieldKey:
  4992. m.ClearKey()
  4993. return nil
  4994. case apikey.FieldCustomAgentBase:
  4995. m.ClearCustomAgentBase()
  4996. return nil
  4997. case apikey.FieldCustomAgentKey:
  4998. m.ClearCustomAgentKey()
  4999. return nil
  5000. case apikey.FieldOpenaiBase:
  5001. m.ClearOpenaiBase()
  5002. return nil
  5003. case apikey.FieldOpenaiKey:
  5004. m.ClearOpenaiKey()
  5005. return nil
  5006. }
  5007. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5008. }
  5009. // ResetField resets all changes in the mutation for the field with the given name.
  5010. // It returns an error if the field is not defined in the schema.
  5011. func (m *ApiKeyMutation) ResetField(name string) error {
  5012. switch name {
  5013. case apikey.FieldCreatedAt:
  5014. m.ResetCreatedAt()
  5015. return nil
  5016. case apikey.FieldUpdatedAt:
  5017. m.ResetUpdatedAt()
  5018. return nil
  5019. case apikey.FieldDeletedAt:
  5020. m.ResetDeletedAt()
  5021. return nil
  5022. case apikey.FieldTitle:
  5023. m.ResetTitle()
  5024. return nil
  5025. case apikey.FieldKey:
  5026. m.ResetKey()
  5027. return nil
  5028. case apikey.FieldOrganizationID:
  5029. m.ResetOrganizationID()
  5030. return nil
  5031. case apikey.FieldAgentID:
  5032. m.ResetAgentID()
  5033. return nil
  5034. case apikey.FieldCustomAgentBase:
  5035. m.ResetCustomAgentBase()
  5036. return nil
  5037. case apikey.FieldCustomAgentKey:
  5038. m.ResetCustomAgentKey()
  5039. return nil
  5040. case apikey.FieldOpenaiBase:
  5041. m.ResetOpenaiBase()
  5042. return nil
  5043. case apikey.FieldOpenaiKey:
  5044. m.ResetOpenaiKey()
  5045. return nil
  5046. }
  5047. return fmt.Errorf("unknown ApiKey field %s", name)
  5048. }
  5049. // AddedEdges returns all edge names that were set/added in this mutation.
  5050. func (m *ApiKeyMutation) AddedEdges() []string {
  5051. edges := make([]string, 0, 1)
  5052. if m.agent != nil {
  5053. edges = append(edges, apikey.EdgeAgent)
  5054. }
  5055. return edges
  5056. }
  5057. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5058. // name in this mutation.
  5059. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5060. switch name {
  5061. case apikey.EdgeAgent:
  5062. if id := m.agent; id != nil {
  5063. return []ent.Value{*id}
  5064. }
  5065. }
  5066. return nil
  5067. }
  5068. // RemovedEdges returns all edge names that were removed in this mutation.
  5069. func (m *ApiKeyMutation) RemovedEdges() []string {
  5070. edges := make([]string, 0, 1)
  5071. return edges
  5072. }
  5073. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5074. // the given name in this mutation.
  5075. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5076. return nil
  5077. }
  5078. // ClearedEdges returns all edge names that were cleared in this mutation.
  5079. func (m *ApiKeyMutation) ClearedEdges() []string {
  5080. edges := make([]string, 0, 1)
  5081. if m.clearedagent {
  5082. edges = append(edges, apikey.EdgeAgent)
  5083. }
  5084. return edges
  5085. }
  5086. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5087. // was cleared in this mutation.
  5088. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5089. switch name {
  5090. case apikey.EdgeAgent:
  5091. return m.clearedagent
  5092. }
  5093. return false
  5094. }
  5095. // ClearEdge clears the value of the edge with the given name. It returns an error
  5096. // if that edge is not defined in the schema.
  5097. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5098. switch name {
  5099. case apikey.EdgeAgent:
  5100. m.ClearAgent()
  5101. return nil
  5102. }
  5103. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5104. }
  5105. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5106. // It returns an error if the edge is not defined in the schema.
  5107. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5108. switch name {
  5109. case apikey.EdgeAgent:
  5110. m.ResetAgent()
  5111. return nil
  5112. }
  5113. return fmt.Errorf("unknown ApiKey edge %s", name)
  5114. }
  5115. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5116. type BatchMsgMutation struct {
  5117. config
  5118. op Op
  5119. typ string
  5120. id *uint64
  5121. created_at *time.Time
  5122. updated_at *time.Time
  5123. deleted_at *time.Time
  5124. status *uint8
  5125. addstatus *int8
  5126. batch_no *string
  5127. task_name *string
  5128. fromwxid *string
  5129. msg *string
  5130. tag *string
  5131. tagids *string
  5132. total *int32
  5133. addtotal *int32
  5134. success *int32
  5135. addsuccess *int32
  5136. fail *int32
  5137. addfail *int32
  5138. start_time *time.Time
  5139. stop_time *time.Time
  5140. send_time *time.Time
  5141. _type *int32
  5142. add_type *int32
  5143. organization_id *uint64
  5144. addorganization_id *int64
  5145. ctype *uint64
  5146. addctype *int64
  5147. cc *string
  5148. phone *string
  5149. template_name *string
  5150. template_code *string
  5151. lang *string
  5152. clearedFields map[string]struct{}
  5153. done bool
  5154. oldValue func(context.Context) (*BatchMsg, error)
  5155. predicates []predicate.BatchMsg
  5156. }
  5157. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5158. // batchmsgOption allows management of the mutation configuration using functional options.
  5159. type batchmsgOption func(*BatchMsgMutation)
  5160. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5161. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5162. m := &BatchMsgMutation{
  5163. config: c,
  5164. op: op,
  5165. typ: TypeBatchMsg,
  5166. clearedFields: make(map[string]struct{}),
  5167. }
  5168. for _, opt := range opts {
  5169. opt(m)
  5170. }
  5171. return m
  5172. }
  5173. // withBatchMsgID sets the ID field of the mutation.
  5174. func withBatchMsgID(id uint64) batchmsgOption {
  5175. return func(m *BatchMsgMutation) {
  5176. var (
  5177. err error
  5178. once sync.Once
  5179. value *BatchMsg
  5180. )
  5181. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5182. once.Do(func() {
  5183. if m.done {
  5184. err = errors.New("querying old values post mutation is not allowed")
  5185. } else {
  5186. value, err = m.Client().BatchMsg.Get(ctx, id)
  5187. }
  5188. })
  5189. return value, err
  5190. }
  5191. m.id = &id
  5192. }
  5193. }
  5194. // withBatchMsg sets the old BatchMsg of the mutation.
  5195. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5196. return func(m *BatchMsgMutation) {
  5197. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5198. return node, nil
  5199. }
  5200. m.id = &node.ID
  5201. }
  5202. }
  5203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5204. // executed in a transaction (ent.Tx), a transactional client is returned.
  5205. func (m BatchMsgMutation) Client() *Client {
  5206. client := &Client{config: m.config}
  5207. client.init()
  5208. return client
  5209. }
  5210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5211. // it returns an error otherwise.
  5212. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5213. if _, ok := m.driver.(*txDriver); !ok {
  5214. return nil, errors.New("ent: mutation is not running in a transaction")
  5215. }
  5216. tx := &Tx{config: m.config}
  5217. tx.init()
  5218. return tx, nil
  5219. }
  5220. // SetID sets the value of the id field. Note that this
  5221. // operation is only accepted on creation of BatchMsg entities.
  5222. func (m *BatchMsgMutation) SetID(id uint64) {
  5223. m.id = &id
  5224. }
  5225. // ID returns the ID value in the mutation. Note that the ID is only available
  5226. // if it was provided to the builder or after it was returned from the database.
  5227. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5228. if m.id == nil {
  5229. return
  5230. }
  5231. return *m.id, true
  5232. }
  5233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5234. // That means, if the mutation is applied within a transaction with an isolation level such
  5235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5236. // or updated by the mutation.
  5237. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5238. switch {
  5239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5240. id, exists := m.ID()
  5241. if exists {
  5242. return []uint64{id}, nil
  5243. }
  5244. fallthrough
  5245. case m.op.Is(OpUpdate | OpDelete):
  5246. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5247. default:
  5248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5249. }
  5250. }
  5251. // SetCreatedAt sets the "created_at" field.
  5252. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5253. m.created_at = &t
  5254. }
  5255. // CreatedAt returns the value of the "created_at" field in the mutation.
  5256. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5257. v := m.created_at
  5258. if v == nil {
  5259. return
  5260. }
  5261. return *v, true
  5262. }
  5263. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5264. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5266. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5267. if !m.op.Is(OpUpdateOne) {
  5268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5269. }
  5270. if m.id == nil || m.oldValue == nil {
  5271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5272. }
  5273. oldValue, err := m.oldValue(ctx)
  5274. if err != nil {
  5275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5276. }
  5277. return oldValue.CreatedAt, nil
  5278. }
  5279. // ResetCreatedAt resets all changes to the "created_at" field.
  5280. func (m *BatchMsgMutation) ResetCreatedAt() {
  5281. m.created_at = nil
  5282. }
  5283. // SetUpdatedAt sets the "updated_at" field.
  5284. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5285. m.updated_at = &t
  5286. }
  5287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5288. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5289. v := m.updated_at
  5290. if v == nil {
  5291. return
  5292. }
  5293. return *v, true
  5294. }
  5295. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5296. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5298. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5299. if !m.op.Is(OpUpdateOne) {
  5300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5301. }
  5302. if m.id == nil || m.oldValue == nil {
  5303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5304. }
  5305. oldValue, err := m.oldValue(ctx)
  5306. if err != nil {
  5307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5308. }
  5309. return oldValue.UpdatedAt, nil
  5310. }
  5311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5312. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5313. m.updated_at = nil
  5314. }
  5315. // SetDeletedAt sets the "deleted_at" field.
  5316. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5317. m.deleted_at = &t
  5318. }
  5319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5320. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5321. v := m.deleted_at
  5322. if v == nil {
  5323. return
  5324. }
  5325. return *v, true
  5326. }
  5327. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5328. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5330. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5331. if !m.op.Is(OpUpdateOne) {
  5332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5333. }
  5334. if m.id == nil || m.oldValue == nil {
  5335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5336. }
  5337. oldValue, err := m.oldValue(ctx)
  5338. if err != nil {
  5339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5340. }
  5341. return oldValue.DeletedAt, nil
  5342. }
  5343. // ClearDeletedAt clears the value of the "deleted_at" field.
  5344. func (m *BatchMsgMutation) ClearDeletedAt() {
  5345. m.deleted_at = nil
  5346. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5347. }
  5348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5349. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5350. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5351. return ok
  5352. }
  5353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5354. func (m *BatchMsgMutation) ResetDeletedAt() {
  5355. m.deleted_at = nil
  5356. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5357. }
  5358. // SetStatus sets the "status" field.
  5359. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5360. m.status = &u
  5361. m.addstatus = nil
  5362. }
  5363. // Status returns the value of the "status" field in the mutation.
  5364. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5365. v := m.status
  5366. if v == nil {
  5367. return
  5368. }
  5369. return *v, true
  5370. }
  5371. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5372. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5374. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5375. if !m.op.Is(OpUpdateOne) {
  5376. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5377. }
  5378. if m.id == nil || m.oldValue == nil {
  5379. return v, errors.New("OldStatus requires an ID field in the mutation")
  5380. }
  5381. oldValue, err := m.oldValue(ctx)
  5382. if err != nil {
  5383. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5384. }
  5385. return oldValue.Status, nil
  5386. }
  5387. // AddStatus adds u to the "status" field.
  5388. func (m *BatchMsgMutation) AddStatus(u int8) {
  5389. if m.addstatus != nil {
  5390. *m.addstatus += u
  5391. } else {
  5392. m.addstatus = &u
  5393. }
  5394. }
  5395. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5396. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5397. v := m.addstatus
  5398. if v == nil {
  5399. return
  5400. }
  5401. return *v, true
  5402. }
  5403. // ClearStatus clears the value of the "status" field.
  5404. func (m *BatchMsgMutation) ClearStatus() {
  5405. m.status = nil
  5406. m.addstatus = nil
  5407. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5408. }
  5409. // StatusCleared returns if the "status" field was cleared in this mutation.
  5410. func (m *BatchMsgMutation) StatusCleared() bool {
  5411. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5412. return ok
  5413. }
  5414. // ResetStatus resets all changes to the "status" field.
  5415. func (m *BatchMsgMutation) ResetStatus() {
  5416. m.status = nil
  5417. m.addstatus = nil
  5418. delete(m.clearedFields, batchmsg.FieldStatus)
  5419. }
  5420. // SetBatchNo sets the "batch_no" field.
  5421. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5422. m.batch_no = &s
  5423. }
  5424. // BatchNo returns the value of the "batch_no" field in the mutation.
  5425. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5426. v := m.batch_no
  5427. if v == nil {
  5428. return
  5429. }
  5430. return *v, true
  5431. }
  5432. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5433. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5435. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5436. if !m.op.Is(OpUpdateOne) {
  5437. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5438. }
  5439. if m.id == nil || m.oldValue == nil {
  5440. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5441. }
  5442. oldValue, err := m.oldValue(ctx)
  5443. if err != nil {
  5444. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5445. }
  5446. return oldValue.BatchNo, nil
  5447. }
  5448. // ClearBatchNo clears the value of the "batch_no" field.
  5449. func (m *BatchMsgMutation) ClearBatchNo() {
  5450. m.batch_no = nil
  5451. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5452. }
  5453. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5454. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5455. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5456. return ok
  5457. }
  5458. // ResetBatchNo resets all changes to the "batch_no" field.
  5459. func (m *BatchMsgMutation) ResetBatchNo() {
  5460. m.batch_no = nil
  5461. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5462. }
  5463. // SetTaskName sets the "task_name" field.
  5464. func (m *BatchMsgMutation) SetTaskName(s string) {
  5465. m.task_name = &s
  5466. }
  5467. // TaskName returns the value of the "task_name" field in the mutation.
  5468. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5469. v := m.task_name
  5470. if v == nil {
  5471. return
  5472. }
  5473. return *v, true
  5474. }
  5475. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5476. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5478. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5479. if !m.op.Is(OpUpdateOne) {
  5480. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5481. }
  5482. if m.id == nil || m.oldValue == nil {
  5483. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5484. }
  5485. oldValue, err := m.oldValue(ctx)
  5486. if err != nil {
  5487. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5488. }
  5489. return oldValue.TaskName, nil
  5490. }
  5491. // ClearTaskName clears the value of the "task_name" field.
  5492. func (m *BatchMsgMutation) ClearTaskName() {
  5493. m.task_name = nil
  5494. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5495. }
  5496. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5497. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5498. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5499. return ok
  5500. }
  5501. // ResetTaskName resets all changes to the "task_name" field.
  5502. func (m *BatchMsgMutation) ResetTaskName() {
  5503. m.task_name = nil
  5504. delete(m.clearedFields, batchmsg.FieldTaskName)
  5505. }
  5506. // SetFromwxid sets the "fromwxid" field.
  5507. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5508. m.fromwxid = &s
  5509. }
  5510. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5511. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5512. v := m.fromwxid
  5513. if v == nil {
  5514. return
  5515. }
  5516. return *v, true
  5517. }
  5518. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5519. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5521. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5522. if !m.op.Is(OpUpdateOne) {
  5523. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5524. }
  5525. if m.id == nil || m.oldValue == nil {
  5526. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5527. }
  5528. oldValue, err := m.oldValue(ctx)
  5529. if err != nil {
  5530. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5531. }
  5532. return oldValue.Fromwxid, nil
  5533. }
  5534. // ClearFromwxid clears the value of the "fromwxid" field.
  5535. func (m *BatchMsgMutation) ClearFromwxid() {
  5536. m.fromwxid = nil
  5537. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5538. }
  5539. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5540. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5541. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5542. return ok
  5543. }
  5544. // ResetFromwxid resets all changes to the "fromwxid" field.
  5545. func (m *BatchMsgMutation) ResetFromwxid() {
  5546. m.fromwxid = nil
  5547. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5548. }
  5549. // SetMsg sets the "msg" field.
  5550. func (m *BatchMsgMutation) SetMsg(s string) {
  5551. m.msg = &s
  5552. }
  5553. // Msg returns the value of the "msg" field in the mutation.
  5554. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5555. v := m.msg
  5556. if v == nil {
  5557. return
  5558. }
  5559. return *v, true
  5560. }
  5561. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5562. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5564. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5565. if !m.op.Is(OpUpdateOne) {
  5566. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5567. }
  5568. if m.id == nil || m.oldValue == nil {
  5569. return v, errors.New("OldMsg requires an ID field in the mutation")
  5570. }
  5571. oldValue, err := m.oldValue(ctx)
  5572. if err != nil {
  5573. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5574. }
  5575. return oldValue.Msg, nil
  5576. }
  5577. // ClearMsg clears the value of the "msg" field.
  5578. func (m *BatchMsgMutation) ClearMsg() {
  5579. m.msg = nil
  5580. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5581. }
  5582. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5583. func (m *BatchMsgMutation) MsgCleared() bool {
  5584. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5585. return ok
  5586. }
  5587. // ResetMsg resets all changes to the "msg" field.
  5588. func (m *BatchMsgMutation) ResetMsg() {
  5589. m.msg = nil
  5590. delete(m.clearedFields, batchmsg.FieldMsg)
  5591. }
  5592. // SetTag sets the "tag" field.
  5593. func (m *BatchMsgMutation) SetTag(s string) {
  5594. m.tag = &s
  5595. }
  5596. // Tag returns the value of the "tag" field in the mutation.
  5597. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5598. v := m.tag
  5599. if v == nil {
  5600. return
  5601. }
  5602. return *v, true
  5603. }
  5604. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5605. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5607. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5608. if !m.op.Is(OpUpdateOne) {
  5609. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5610. }
  5611. if m.id == nil || m.oldValue == nil {
  5612. return v, errors.New("OldTag requires an ID field in the mutation")
  5613. }
  5614. oldValue, err := m.oldValue(ctx)
  5615. if err != nil {
  5616. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5617. }
  5618. return oldValue.Tag, nil
  5619. }
  5620. // ClearTag clears the value of the "tag" field.
  5621. func (m *BatchMsgMutation) ClearTag() {
  5622. m.tag = nil
  5623. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5624. }
  5625. // TagCleared returns if the "tag" field was cleared in this mutation.
  5626. func (m *BatchMsgMutation) TagCleared() bool {
  5627. _, ok := m.clearedFields[batchmsg.FieldTag]
  5628. return ok
  5629. }
  5630. // ResetTag resets all changes to the "tag" field.
  5631. func (m *BatchMsgMutation) ResetTag() {
  5632. m.tag = nil
  5633. delete(m.clearedFields, batchmsg.FieldTag)
  5634. }
  5635. // SetTagids sets the "tagids" field.
  5636. func (m *BatchMsgMutation) SetTagids(s string) {
  5637. m.tagids = &s
  5638. }
  5639. // Tagids returns the value of the "tagids" field in the mutation.
  5640. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5641. v := m.tagids
  5642. if v == nil {
  5643. return
  5644. }
  5645. return *v, true
  5646. }
  5647. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5650. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5651. if !m.op.Is(OpUpdateOne) {
  5652. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5653. }
  5654. if m.id == nil || m.oldValue == nil {
  5655. return v, errors.New("OldTagids requires an ID field in the mutation")
  5656. }
  5657. oldValue, err := m.oldValue(ctx)
  5658. if err != nil {
  5659. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5660. }
  5661. return oldValue.Tagids, nil
  5662. }
  5663. // ClearTagids clears the value of the "tagids" field.
  5664. func (m *BatchMsgMutation) ClearTagids() {
  5665. m.tagids = nil
  5666. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5667. }
  5668. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5669. func (m *BatchMsgMutation) TagidsCleared() bool {
  5670. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5671. return ok
  5672. }
  5673. // ResetTagids resets all changes to the "tagids" field.
  5674. func (m *BatchMsgMutation) ResetTagids() {
  5675. m.tagids = nil
  5676. delete(m.clearedFields, batchmsg.FieldTagids)
  5677. }
  5678. // SetTotal sets the "total" field.
  5679. func (m *BatchMsgMutation) SetTotal(i int32) {
  5680. m.total = &i
  5681. m.addtotal = nil
  5682. }
  5683. // Total returns the value of the "total" field in the mutation.
  5684. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5685. v := m.total
  5686. if v == nil {
  5687. return
  5688. }
  5689. return *v, true
  5690. }
  5691. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5692. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5694. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5695. if !m.op.Is(OpUpdateOne) {
  5696. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5697. }
  5698. if m.id == nil || m.oldValue == nil {
  5699. return v, errors.New("OldTotal requires an ID field in the mutation")
  5700. }
  5701. oldValue, err := m.oldValue(ctx)
  5702. if err != nil {
  5703. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5704. }
  5705. return oldValue.Total, nil
  5706. }
  5707. // AddTotal adds i to the "total" field.
  5708. func (m *BatchMsgMutation) AddTotal(i int32) {
  5709. if m.addtotal != nil {
  5710. *m.addtotal += i
  5711. } else {
  5712. m.addtotal = &i
  5713. }
  5714. }
  5715. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5716. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5717. v := m.addtotal
  5718. if v == nil {
  5719. return
  5720. }
  5721. return *v, true
  5722. }
  5723. // ClearTotal clears the value of the "total" field.
  5724. func (m *BatchMsgMutation) ClearTotal() {
  5725. m.total = nil
  5726. m.addtotal = nil
  5727. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5728. }
  5729. // TotalCleared returns if the "total" field was cleared in this mutation.
  5730. func (m *BatchMsgMutation) TotalCleared() bool {
  5731. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5732. return ok
  5733. }
  5734. // ResetTotal resets all changes to the "total" field.
  5735. func (m *BatchMsgMutation) ResetTotal() {
  5736. m.total = nil
  5737. m.addtotal = nil
  5738. delete(m.clearedFields, batchmsg.FieldTotal)
  5739. }
  5740. // SetSuccess sets the "success" field.
  5741. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5742. m.success = &i
  5743. m.addsuccess = nil
  5744. }
  5745. // Success returns the value of the "success" field in the mutation.
  5746. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5747. v := m.success
  5748. if v == nil {
  5749. return
  5750. }
  5751. return *v, true
  5752. }
  5753. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5754. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5756. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5757. if !m.op.Is(OpUpdateOne) {
  5758. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5759. }
  5760. if m.id == nil || m.oldValue == nil {
  5761. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5762. }
  5763. oldValue, err := m.oldValue(ctx)
  5764. if err != nil {
  5765. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5766. }
  5767. return oldValue.Success, nil
  5768. }
  5769. // AddSuccess adds i to the "success" field.
  5770. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5771. if m.addsuccess != nil {
  5772. *m.addsuccess += i
  5773. } else {
  5774. m.addsuccess = &i
  5775. }
  5776. }
  5777. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5778. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5779. v := m.addsuccess
  5780. if v == nil {
  5781. return
  5782. }
  5783. return *v, true
  5784. }
  5785. // ClearSuccess clears the value of the "success" field.
  5786. func (m *BatchMsgMutation) ClearSuccess() {
  5787. m.success = nil
  5788. m.addsuccess = nil
  5789. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5790. }
  5791. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5792. func (m *BatchMsgMutation) SuccessCleared() bool {
  5793. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5794. return ok
  5795. }
  5796. // ResetSuccess resets all changes to the "success" field.
  5797. func (m *BatchMsgMutation) ResetSuccess() {
  5798. m.success = nil
  5799. m.addsuccess = nil
  5800. delete(m.clearedFields, batchmsg.FieldSuccess)
  5801. }
  5802. // SetFail sets the "fail" field.
  5803. func (m *BatchMsgMutation) SetFail(i int32) {
  5804. m.fail = &i
  5805. m.addfail = nil
  5806. }
  5807. // Fail returns the value of the "fail" field in the mutation.
  5808. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5809. v := m.fail
  5810. if v == nil {
  5811. return
  5812. }
  5813. return *v, true
  5814. }
  5815. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5816. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5818. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5819. if !m.op.Is(OpUpdateOne) {
  5820. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5821. }
  5822. if m.id == nil || m.oldValue == nil {
  5823. return v, errors.New("OldFail requires an ID field in the mutation")
  5824. }
  5825. oldValue, err := m.oldValue(ctx)
  5826. if err != nil {
  5827. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5828. }
  5829. return oldValue.Fail, nil
  5830. }
  5831. // AddFail adds i to the "fail" field.
  5832. func (m *BatchMsgMutation) AddFail(i int32) {
  5833. if m.addfail != nil {
  5834. *m.addfail += i
  5835. } else {
  5836. m.addfail = &i
  5837. }
  5838. }
  5839. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5840. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5841. v := m.addfail
  5842. if v == nil {
  5843. return
  5844. }
  5845. return *v, true
  5846. }
  5847. // ClearFail clears the value of the "fail" field.
  5848. func (m *BatchMsgMutation) ClearFail() {
  5849. m.fail = nil
  5850. m.addfail = nil
  5851. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5852. }
  5853. // FailCleared returns if the "fail" field was cleared in this mutation.
  5854. func (m *BatchMsgMutation) FailCleared() bool {
  5855. _, ok := m.clearedFields[batchmsg.FieldFail]
  5856. return ok
  5857. }
  5858. // ResetFail resets all changes to the "fail" field.
  5859. func (m *BatchMsgMutation) ResetFail() {
  5860. m.fail = nil
  5861. m.addfail = nil
  5862. delete(m.clearedFields, batchmsg.FieldFail)
  5863. }
  5864. // SetStartTime sets the "start_time" field.
  5865. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5866. m.start_time = &t
  5867. }
  5868. // StartTime returns the value of the "start_time" field in the mutation.
  5869. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5870. v := m.start_time
  5871. if v == nil {
  5872. return
  5873. }
  5874. return *v, true
  5875. }
  5876. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5877. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5879. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5880. if !m.op.Is(OpUpdateOne) {
  5881. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5882. }
  5883. if m.id == nil || m.oldValue == nil {
  5884. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5885. }
  5886. oldValue, err := m.oldValue(ctx)
  5887. if err != nil {
  5888. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5889. }
  5890. return oldValue.StartTime, nil
  5891. }
  5892. // ClearStartTime clears the value of the "start_time" field.
  5893. func (m *BatchMsgMutation) ClearStartTime() {
  5894. m.start_time = nil
  5895. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5896. }
  5897. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5898. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5899. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5900. return ok
  5901. }
  5902. // ResetStartTime resets all changes to the "start_time" field.
  5903. func (m *BatchMsgMutation) ResetStartTime() {
  5904. m.start_time = nil
  5905. delete(m.clearedFields, batchmsg.FieldStartTime)
  5906. }
  5907. // SetStopTime sets the "stop_time" field.
  5908. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5909. m.stop_time = &t
  5910. }
  5911. // StopTime returns the value of the "stop_time" field in the mutation.
  5912. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5913. v := m.stop_time
  5914. if v == nil {
  5915. return
  5916. }
  5917. return *v, true
  5918. }
  5919. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5920. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5922. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5923. if !m.op.Is(OpUpdateOne) {
  5924. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5925. }
  5926. if m.id == nil || m.oldValue == nil {
  5927. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5928. }
  5929. oldValue, err := m.oldValue(ctx)
  5930. if err != nil {
  5931. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5932. }
  5933. return oldValue.StopTime, nil
  5934. }
  5935. // ClearStopTime clears the value of the "stop_time" field.
  5936. func (m *BatchMsgMutation) ClearStopTime() {
  5937. m.stop_time = nil
  5938. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5939. }
  5940. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5941. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5942. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5943. return ok
  5944. }
  5945. // ResetStopTime resets all changes to the "stop_time" field.
  5946. func (m *BatchMsgMutation) ResetStopTime() {
  5947. m.stop_time = nil
  5948. delete(m.clearedFields, batchmsg.FieldStopTime)
  5949. }
  5950. // SetSendTime sets the "send_time" field.
  5951. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5952. m.send_time = &t
  5953. }
  5954. // SendTime returns the value of the "send_time" field in the mutation.
  5955. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5956. v := m.send_time
  5957. if v == nil {
  5958. return
  5959. }
  5960. return *v, true
  5961. }
  5962. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5963. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5965. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5966. if !m.op.Is(OpUpdateOne) {
  5967. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5968. }
  5969. if m.id == nil || m.oldValue == nil {
  5970. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5971. }
  5972. oldValue, err := m.oldValue(ctx)
  5973. if err != nil {
  5974. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5975. }
  5976. return oldValue.SendTime, nil
  5977. }
  5978. // ClearSendTime clears the value of the "send_time" field.
  5979. func (m *BatchMsgMutation) ClearSendTime() {
  5980. m.send_time = nil
  5981. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5982. }
  5983. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5984. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5985. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5986. return ok
  5987. }
  5988. // ResetSendTime resets all changes to the "send_time" field.
  5989. func (m *BatchMsgMutation) ResetSendTime() {
  5990. m.send_time = nil
  5991. delete(m.clearedFields, batchmsg.FieldSendTime)
  5992. }
  5993. // SetType sets the "type" field.
  5994. func (m *BatchMsgMutation) SetType(i int32) {
  5995. m._type = &i
  5996. m.add_type = nil
  5997. }
  5998. // GetType returns the value of the "type" field in the mutation.
  5999. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6000. v := m._type
  6001. if v == nil {
  6002. return
  6003. }
  6004. return *v, true
  6005. }
  6006. // OldType returns the old "type" field's value of the BatchMsg entity.
  6007. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6009. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6010. if !m.op.Is(OpUpdateOne) {
  6011. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6012. }
  6013. if m.id == nil || m.oldValue == nil {
  6014. return v, errors.New("OldType requires an ID field in the mutation")
  6015. }
  6016. oldValue, err := m.oldValue(ctx)
  6017. if err != nil {
  6018. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6019. }
  6020. return oldValue.Type, nil
  6021. }
  6022. // AddType adds i to the "type" field.
  6023. func (m *BatchMsgMutation) AddType(i int32) {
  6024. if m.add_type != nil {
  6025. *m.add_type += i
  6026. } else {
  6027. m.add_type = &i
  6028. }
  6029. }
  6030. // AddedType returns the value that was added to the "type" field in this mutation.
  6031. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6032. v := m.add_type
  6033. if v == nil {
  6034. return
  6035. }
  6036. return *v, true
  6037. }
  6038. // ClearType clears the value of the "type" field.
  6039. func (m *BatchMsgMutation) ClearType() {
  6040. m._type = nil
  6041. m.add_type = nil
  6042. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6043. }
  6044. // TypeCleared returns if the "type" field was cleared in this mutation.
  6045. func (m *BatchMsgMutation) TypeCleared() bool {
  6046. _, ok := m.clearedFields[batchmsg.FieldType]
  6047. return ok
  6048. }
  6049. // ResetType resets all changes to the "type" field.
  6050. func (m *BatchMsgMutation) ResetType() {
  6051. m._type = nil
  6052. m.add_type = nil
  6053. delete(m.clearedFields, batchmsg.FieldType)
  6054. }
  6055. // SetOrganizationID sets the "organization_id" field.
  6056. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6057. m.organization_id = &u
  6058. m.addorganization_id = nil
  6059. }
  6060. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6061. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6062. v := m.organization_id
  6063. if v == nil {
  6064. return
  6065. }
  6066. return *v, true
  6067. }
  6068. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6069. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6071. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6072. if !m.op.Is(OpUpdateOne) {
  6073. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6074. }
  6075. if m.id == nil || m.oldValue == nil {
  6076. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6077. }
  6078. oldValue, err := m.oldValue(ctx)
  6079. if err != nil {
  6080. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6081. }
  6082. return oldValue.OrganizationID, nil
  6083. }
  6084. // AddOrganizationID adds u to the "organization_id" field.
  6085. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6086. if m.addorganization_id != nil {
  6087. *m.addorganization_id += u
  6088. } else {
  6089. m.addorganization_id = &u
  6090. }
  6091. }
  6092. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6093. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6094. v := m.addorganization_id
  6095. if v == nil {
  6096. return
  6097. }
  6098. return *v, true
  6099. }
  6100. // ResetOrganizationID resets all changes to the "organization_id" field.
  6101. func (m *BatchMsgMutation) ResetOrganizationID() {
  6102. m.organization_id = nil
  6103. m.addorganization_id = nil
  6104. }
  6105. // SetCtype sets the "ctype" field.
  6106. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6107. m.ctype = &u
  6108. m.addctype = nil
  6109. }
  6110. // Ctype returns the value of the "ctype" field in the mutation.
  6111. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6112. v := m.ctype
  6113. if v == nil {
  6114. return
  6115. }
  6116. return *v, true
  6117. }
  6118. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6119. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6121. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6122. if !m.op.Is(OpUpdateOne) {
  6123. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6124. }
  6125. if m.id == nil || m.oldValue == nil {
  6126. return v, errors.New("OldCtype requires an ID field in the mutation")
  6127. }
  6128. oldValue, err := m.oldValue(ctx)
  6129. if err != nil {
  6130. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6131. }
  6132. return oldValue.Ctype, nil
  6133. }
  6134. // AddCtype adds u to the "ctype" field.
  6135. func (m *BatchMsgMutation) AddCtype(u int64) {
  6136. if m.addctype != nil {
  6137. *m.addctype += u
  6138. } else {
  6139. m.addctype = &u
  6140. }
  6141. }
  6142. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6143. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6144. v := m.addctype
  6145. if v == nil {
  6146. return
  6147. }
  6148. return *v, true
  6149. }
  6150. // ResetCtype resets all changes to the "ctype" field.
  6151. func (m *BatchMsgMutation) ResetCtype() {
  6152. m.ctype = nil
  6153. m.addctype = nil
  6154. }
  6155. // SetCc sets the "cc" field.
  6156. func (m *BatchMsgMutation) SetCc(s string) {
  6157. m.cc = &s
  6158. }
  6159. // Cc returns the value of the "cc" field in the mutation.
  6160. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6161. v := m.cc
  6162. if v == nil {
  6163. return
  6164. }
  6165. return *v, true
  6166. }
  6167. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6168. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6170. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6171. if !m.op.Is(OpUpdateOne) {
  6172. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6173. }
  6174. if m.id == nil || m.oldValue == nil {
  6175. return v, errors.New("OldCc requires an ID field in the mutation")
  6176. }
  6177. oldValue, err := m.oldValue(ctx)
  6178. if err != nil {
  6179. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6180. }
  6181. return oldValue.Cc, nil
  6182. }
  6183. // ClearCc clears the value of the "cc" field.
  6184. func (m *BatchMsgMutation) ClearCc() {
  6185. m.cc = nil
  6186. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6187. }
  6188. // CcCleared returns if the "cc" field was cleared in this mutation.
  6189. func (m *BatchMsgMutation) CcCleared() bool {
  6190. _, ok := m.clearedFields[batchmsg.FieldCc]
  6191. return ok
  6192. }
  6193. // ResetCc resets all changes to the "cc" field.
  6194. func (m *BatchMsgMutation) ResetCc() {
  6195. m.cc = nil
  6196. delete(m.clearedFields, batchmsg.FieldCc)
  6197. }
  6198. // SetPhone sets the "phone" field.
  6199. func (m *BatchMsgMutation) SetPhone(s string) {
  6200. m.phone = &s
  6201. }
  6202. // Phone returns the value of the "phone" field in the mutation.
  6203. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6204. v := m.phone
  6205. if v == nil {
  6206. return
  6207. }
  6208. return *v, true
  6209. }
  6210. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6211. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6213. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6214. if !m.op.Is(OpUpdateOne) {
  6215. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6216. }
  6217. if m.id == nil || m.oldValue == nil {
  6218. return v, errors.New("OldPhone requires an ID field in the mutation")
  6219. }
  6220. oldValue, err := m.oldValue(ctx)
  6221. if err != nil {
  6222. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6223. }
  6224. return oldValue.Phone, nil
  6225. }
  6226. // ClearPhone clears the value of the "phone" field.
  6227. func (m *BatchMsgMutation) ClearPhone() {
  6228. m.phone = nil
  6229. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6230. }
  6231. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6232. func (m *BatchMsgMutation) PhoneCleared() bool {
  6233. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6234. return ok
  6235. }
  6236. // ResetPhone resets all changes to the "phone" field.
  6237. func (m *BatchMsgMutation) ResetPhone() {
  6238. m.phone = nil
  6239. delete(m.clearedFields, batchmsg.FieldPhone)
  6240. }
  6241. // SetTemplateName sets the "template_name" field.
  6242. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6243. m.template_name = &s
  6244. }
  6245. // TemplateName returns the value of the "template_name" field in the mutation.
  6246. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6247. v := m.template_name
  6248. if v == nil {
  6249. return
  6250. }
  6251. return *v, true
  6252. }
  6253. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6254. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6256. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6257. if !m.op.Is(OpUpdateOne) {
  6258. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6259. }
  6260. if m.id == nil || m.oldValue == nil {
  6261. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6262. }
  6263. oldValue, err := m.oldValue(ctx)
  6264. if err != nil {
  6265. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6266. }
  6267. return oldValue.TemplateName, nil
  6268. }
  6269. // ClearTemplateName clears the value of the "template_name" field.
  6270. func (m *BatchMsgMutation) ClearTemplateName() {
  6271. m.template_name = nil
  6272. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6273. }
  6274. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6275. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6276. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6277. return ok
  6278. }
  6279. // ResetTemplateName resets all changes to the "template_name" field.
  6280. func (m *BatchMsgMutation) ResetTemplateName() {
  6281. m.template_name = nil
  6282. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6283. }
  6284. // SetTemplateCode sets the "template_code" field.
  6285. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6286. m.template_code = &s
  6287. }
  6288. // TemplateCode returns the value of the "template_code" field in the mutation.
  6289. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6290. v := m.template_code
  6291. if v == nil {
  6292. return
  6293. }
  6294. return *v, true
  6295. }
  6296. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6297. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6299. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6300. if !m.op.Is(OpUpdateOne) {
  6301. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6302. }
  6303. if m.id == nil || m.oldValue == nil {
  6304. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6305. }
  6306. oldValue, err := m.oldValue(ctx)
  6307. if err != nil {
  6308. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6309. }
  6310. return oldValue.TemplateCode, nil
  6311. }
  6312. // ClearTemplateCode clears the value of the "template_code" field.
  6313. func (m *BatchMsgMutation) ClearTemplateCode() {
  6314. m.template_code = nil
  6315. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6316. }
  6317. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6318. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6319. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6320. return ok
  6321. }
  6322. // ResetTemplateCode resets all changes to the "template_code" field.
  6323. func (m *BatchMsgMutation) ResetTemplateCode() {
  6324. m.template_code = nil
  6325. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6326. }
  6327. // SetLang sets the "lang" field.
  6328. func (m *BatchMsgMutation) SetLang(s string) {
  6329. m.lang = &s
  6330. }
  6331. // Lang returns the value of the "lang" field in the mutation.
  6332. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6333. v := m.lang
  6334. if v == nil {
  6335. return
  6336. }
  6337. return *v, true
  6338. }
  6339. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6340. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6342. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6343. if !m.op.Is(OpUpdateOne) {
  6344. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6345. }
  6346. if m.id == nil || m.oldValue == nil {
  6347. return v, errors.New("OldLang requires an ID field in the mutation")
  6348. }
  6349. oldValue, err := m.oldValue(ctx)
  6350. if err != nil {
  6351. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6352. }
  6353. return oldValue.Lang, nil
  6354. }
  6355. // ClearLang clears the value of the "lang" field.
  6356. func (m *BatchMsgMutation) ClearLang() {
  6357. m.lang = nil
  6358. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6359. }
  6360. // LangCleared returns if the "lang" field was cleared in this mutation.
  6361. func (m *BatchMsgMutation) LangCleared() bool {
  6362. _, ok := m.clearedFields[batchmsg.FieldLang]
  6363. return ok
  6364. }
  6365. // ResetLang resets all changes to the "lang" field.
  6366. func (m *BatchMsgMutation) ResetLang() {
  6367. m.lang = nil
  6368. delete(m.clearedFields, batchmsg.FieldLang)
  6369. }
  6370. // Where appends a list predicates to the BatchMsgMutation builder.
  6371. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6372. m.predicates = append(m.predicates, ps...)
  6373. }
  6374. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6375. // users can use type-assertion to append predicates that do not depend on any generated package.
  6376. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6377. p := make([]predicate.BatchMsg, len(ps))
  6378. for i := range ps {
  6379. p[i] = ps[i]
  6380. }
  6381. m.Where(p...)
  6382. }
  6383. // Op returns the operation name.
  6384. func (m *BatchMsgMutation) Op() Op {
  6385. return m.op
  6386. }
  6387. // SetOp allows setting the mutation operation.
  6388. func (m *BatchMsgMutation) SetOp(op Op) {
  6389. m.op = op
  6390. }
  6391. // Type returns the node type of this mutation (BatchMsg).
  6392. func (m *BatchMsgMutation) Type() string {
  6393. return m.typ
  6394. }
  6395. // Fields returns all fields that were changed during this mutation. Note that in
  6396. // order to get all numeric fields that were incremented/decremented, call
  6397. // AddedFields().
  6398. func (m *BatchMsgMutation) Fields() []string {
  6399. fields := make([]string, 0, 24)
  6400. if m.created_at != nil {
  6401. fields = append(fields, batchmsg.FieldCreatedAt)
  6402. }
  6403. if m.updated_at != nil {
  6404. fields = append(fields, batchmsg.FieldUpdatedAt)
  6405. }
  6406. if m.deleted_at != nil {
  6407. fields = append(fields, batchmsg.FieldDeletedAt)
  6408. }
  6409. if m.status != nil {
  6410. fields = append(fields, batchmsg.FieldStatus)
  6411. }
  6412. if m.batch_no != nil {
  6413. fields = append(fields, batchmsg.FieldBatchNo)
  6414. }
  6415. if m.task_name != nil {
  6416. fields = append(fields, batchmsg.FieldTaskName)
  6417. }
  6418. if m.fromwxid != nil {
  6419. fields = append(fields, batchmsg.FieldFromwxid)
  6420. }
  6421. if m.msg != nil {
  6422. fields = append(fields, batchmsg.FieldMsg)
  6423. }
  6424. if m.tag != nil {
  6425. fields = append(fields, batchmsg.FieldTag)
  6426. }
  6427. if m.tagids != nil {
  6428. fields = append(fields, batchmsg.FieldTagids)
  6429. }
  6430. if m.total != nil {
  6431. fields = append(fields, batchmsg.FieldTotal)
  6432. }
  6433. if m.success != nil {
  6434. fields = append(fields, batchmsg.FieldSuccess)
  6435. }
  6436. if m.fail != nil {
  6437. fields = append(fields, batchmsg.FieldFail)
  6438. }
  6439. if m.start_time != nil {
  6440. fields = append(fields, batchmsg.FieldStartTime)
  6441. }
  6442. if m.stop_time != nil {
  6443. fields = append(fields, batchmsg.FieldStopTime)
  6444. }
  6445. if m.send_time != nil {
  6446. fields = append(fields, batchmsg.FieldSendTime)
  6447. }
  6448. if m._type != nil {
  6449. fields = append(fields, batchmsg.FieldType)
  6450. }
  6451. if m.organization_id != nil {
  6452. fields = append(fields, batchmsg.FieldOrganizationID)
  6453. }
  6454. if m.ctype != nil {
  6455. fields = append(fields, batchmsg.FieldCtype)
  6456. }
  6457. if m.cc != nil {
  6458. fields = append(fields, batchmsg.FieldCc)
  6459. }
  6460. if m.phone != nil {
  6461. fields = append(fields, batchmsg.FieldPhone)
  6462. }
  6463. if m.template_name != nil {
  6464. fields = append(fields, batchmsg.FieldTemplateName)
  6465. }
  6466. if m.template_code != nil {
  6467. fields = append(fields, batchmsg.FieldTemplateCode)
  6468. }
  6469. if m.lang != nil {
  6470. fields = append(fields, batchmsg.FieldLang)
  6471. }
  6472. return fields
  6473. }
  6474. // Field returns the value of a field with the given name. The second boolean
  6475. // return value indicates that this field was not set, or was not defined in the
  6476. // schema.
  6477. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6478. switch name {
  6479. case batchmsg.FieldCreatedAt:
  6480. return m.CreatedAt()
  6481. case batchmsg.FieldUpdatedAt:
  6482. return m.UpdatedAt()
  6483. case batchmsg.FieldDeletedAt:
  6484. return m.DeletedAt()
  6485. case batchmsg.FieldStatus:
  6486. return m.Status()
  6487. case batchmsg.FieldBatchNo:
  6488. return m.BatchNo()
  6489. case batchmsg.FieldTaskName:
  6490. return m.TaskName()
  6491. case batchmsg.FieldFromwxid:
  6492. return m.Fromwxid()
  6493. case batchmsg.FieldMsg:
  6494. return m.Msg()
  6495. case batchmsg.FieldTag:
  6496. return m.Tag()
  6497. case batchmsg.FieldTagids:
  6498. return m.Tagids()
  6499. case batchmsg.FieldTotal:
  6500. return m.Total()
  6501. case batchmsg.FieldSuccess:
  6502. return m.Success()
  6503. case batchmsg.FieldFail:
  6504. return m.Fail()
  6505. case batchmsg.FieldStartTime:
  6506. return m.StartTime()
  6507. case batchmsg.FieldStopTime:
  6508. return m.StopTime()
  6509. case batchmsg.FieldSendTime:
  6510. return m.SendTime()
  6511. case batchmsg.FieldType:
  6512. return m.GetType()
  6513. case batchmsg.FieldOrganizationID:
  6514. return m.OrganizationID()
  6515. case batchmsg.FieldCtype:
  6516. return m.Ctype()
  6517. case batchmsg.FieldCc:
  6518. return m.Cc()
  6519. case batchmsg.FieldPhone:
  6520. return m.Phone()
  6521. case batchmsg.FieldTemplateName:
  6522. return m.TemplateName()
  6523. case batchmsg.FieldTemplateCode:
  6524. return m.TemplateCode()
  6525. case batchmsg.FieldLang:
  6526. return m.Lang()
  6527. }
  6528. return nil, false
  6529. }
  6530. // OldField returns the old value of the field from the database. An error is
  6531. // returned if the mutation operation is not UpdateOne, or the query to the
  6532. // database failed.
  6533. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6534. switch name {
  6535. case batchmsg.FieldCreatedAt:
  6536. return m.OldCreatedAt(ctx)
  6537. case batchmsg.FieldUpdatedAt:
  6538. return m.OldUpdatedAt(ctx)
  6539. case batchmsg.FieldDeletedAt:
  6540. return m.OldDeletedAt(ctx)
  6541. case batchmsg.FieldStatus:
  6542. return m.OldStatus(ctx)
  6543. case batchmsg.FieldBatchNo:
  6544. return m.OldBatchNo(ctx)
  6545. case batchmsg.FieldTaskName:
  6546. return m.OldTaskName(ctx)
  6547. case batchmsg.FieldFromwxid:
  6548. return m.OldFromwxid(ctx)
  6549. case batchmsg.FieldMsg:
  6550. return m.OldMsg(ctx)
  6551. case batchmsg.FieldTag:
  6552. return m.OldTag(ctx)
  6553. case batchmsg.FieldTagids:
  6554. return m.OldTagids(ctx)
  6555. case batchmsg.FieldTotal:
  6556. return m.OldTotal(ctx)
  6557. case batchmsg.FieldSuccess:
  6558. return m.OldSuccess(ctx)
  6559. case batchmsg.FieldFail:
  6560. return m.OldFail(ctx)
  6561. case batchmsg.FieldStartTime:
  6562. return m.OldStartTime(ctx)
  6563. case batchmsg.FieldStopTime:
  6564. return m.OldStopTime(ctx)
  6565. case batchmsg.FieldSendTime:
  6566. return m.OldSendTime(ctx)
  6567. case batchmsg.FieldType:
  6568. return m.OldType(ctx)
  6569. case batchmsg.FieldOrganizationID:
  6570. return m.OldOrganizationID(ctx)
  6571. case batchmsg.FieldCtype:
  6572. return m.OldCtype(ctx)
  6573. case batchmsg.FieldCc:
  6574. return m.OldCc(ctx)
  6575. case batchmsg.FieldPhone:
  6576. return m.OldPhone(ctx)
  6577. case batchmsg.FieldTemplateName:
  6578. return m.OldTemplateName(ctx)
  6579. case batchmsg.FieldTemplateCode:
  6580. return m.OldTemplateCode(ctx)
  6581. case batchmsg.FieldLang:
  6582. return m.OldLang(ctx)
  6583. }
  6584. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6585. }
  6586. // SetField sets the value of a field with the given name. It returns an error if
  6587. // the field is not defined in the schema, or if the type mismatched the field
  6588. // type.
  6589. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6590. switch name {
  6591. case batchmsg.FieldCreatedAt:
  6592. v, ok := value.(time.Time)
  6593. if !ok {
  6594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6595. }
  6596. m.SetCreatedAt(v)
  6597. return nil
  6598. case batchmsg.FieldUpdatedAt:
  6599. v, ok := value.(time.Time)
  6600. if !ok {
  6601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6602. }
  6603. m.SetUpdatedAt(v)
  6604. return nil
  6605. case batchmsg.FieldDeletedAt:
  6606. v, ok := value.(time.Time)
  6607. if !ok {
  6608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6609. }
  6610. m.SetDeletedAt(v)
  6611. return nil
  6612. case batchmsg.FieldStatus:
  6613. v, ok := value.(uint8)
  6614. if !ok {
  6615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6616. }
  6617. m.SetStatus(v)
  6618. return nil
  6619. case batchmsg.FieldBatchNo:
  6620. v, ok := value.(string)
  6621. if !ok {
  6622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6623. }
  6624. m.SetBatchNo(v)
  6625. return nil
  6626. case batchmsg.FieldTaskName:
  6627. v, ok := value.(string)
  6628. if !ok {
  6629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6630. }
  6631. m.SetTaskName(v)
  6632. return nil
  6633. case batchmsg.FieldFromwxid:
  6634. v, ok := value.(string)
  6635. if !ok {
  6636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6637. }
  6638. m.SetFromwxid(v)
  6639. return nil
  6640. case batchmsg.FieldMsg:
  6641. v, ok := value.(string)
  6642. if !ok {
  6643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6644. }
  6645. m.SetMsg(v)
  6646. return nil
  6647. case batchmsg.FieldTag:
  6648. v, ok := value.(string)
  6649. if !ok {
  6650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6651. }
  6652. m.SetTag(v)
  6653. return nil
  6654. case batchmsg.FieldTagids:
  6655. v, ok := value.(string)
  6656. if !ok {
  6657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6658. }
  6659. m.SetTagids(v)
  6660. return nil
  6661. case batchmsg.FieldTotal:
  6662. v, ok := value.(int32)
  6663. if !ok {
  6664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6665. }
  6666. m.SetTotal(v)
  6667. return nil
  6668. case batchmsg.FieldSuccess:
  6669. v, ok := value.(int32)
  6670. if !ok {
  6671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6672. }
  6673. m.SetSuccess(v)
  6674. return nil
  6675. case batchmsg.FieldFail:
  6676. v, ok := value.(int32)
  6677. if !ok {
  6678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6679. }
  6680. m.SetFail(v)
  6681. return nil
  6682. case batchmsg.FieldStartTime:
  6683. v, ok := value.(time.Time)
  6684. if !ok {
  6685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6686. }
  6687. m.SetStartTime(v)
  6688. return nil
  6689. case batchmsg.FieldStopTime:
  6690. v, ok := value.(time.Time)
  6691. if !ok {
  6692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6693. }
  6694. m.SetStopTime(v)
  6695. return nil
  6696. case batchmsg.FieldSendTime:
  6697. v, ok := value.(time.Time)
  6698. if !ok {
  6699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6700. }
  6701. m.SetSendTime(v)
  6702. return nil
  6703. case batchmsg.FieldType:
  6704. v, ok := value.(int32)
  6705. if !ok {
  6706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6707. }
  6708. m.SetType(v)
  6709. return nil
  6710. case batchmsg.FieldOrganizationID:
  6711. v, ok := value.(uint64)
  6712. if !ok {
  6713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6714. }
  6715. m.SetOrganizationID(v)
  6716. return nil
  6717. case batchmsg.FieldCtype:
  6718. v, ok := value.(uint64)
  6719. if !ok {
  6720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6721. }
  6722. m.SetCtype(v)
  6723. return nil
  6724. case batchmsg.FieldCc:
  6725. v, ok := value.(string)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.SetCc(v)
  6730. return nil
  6731. case batchmsg.FieldPhone:
  6732. v, ok := value.(string)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.SetPhone(v)
  6737. return nil
  6738. case batchmsg.FieldTemplateName:
  6739. v, ok := value.(string)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.SetTemplateName(v)
  6744. return nil
  6745. case batchmsg.FieldTemplateCode:
  6746. v, ok := value.(string)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.SetTemplateCode(v)
  6751. return nil
  6752. case batchmsg.FieldLang:
  6753. v, ok := value.(string)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.SetLang(v)
  6758. return nil
  6759. }
  6760. return fmt.Errorf("unknown BatchMsg field %s", name)
  6761. }
  6762. // AddedFields returns all numeric fields that were incremented/decremented during
  6763. // this mutation.
  6764. func (m *BatchMsgMutation) AddedFields() []string {
  6765. var fields []string
  6766. if m.addstatus != nil {
  6767. fields = append(fields, batchmsg.FieldStatus)
  6768. }
  6769. if m.addtotal != nil {
  6770. fields = append(fields, batchmsg.FieldTotal)
  6771. }
  6772. if m.addsuccess != nil {
  6773. fields = append(fields, batchmsg.FieldSuccess)
  6774. }
  6775. if m.addfail != nil {
  6776. fields = append(fields, batchmsg.FieldFail)
  6777. }
  6778. if m.add_type != nil {
  6779. fields = append(fields, batchmsg.FieldType)
  6780. }
  6781. if m.addorganization_id != nil {
  6782. fields = append(fields, batchmsg.FieldOrganizationID)
  6783. }
  6784. if m.addctype != nil {
  6785. fields = append(fields, batchmsg.FieldCtype)
  6786. }
  6787. return fields
  6788. }
  6789. // AddedField returns the numeric value that was incremented/decremented on a field
  6790. // with the given name. The second boolean return value indicates that this field
  6791. // was not set, or was not defined in the schema.
  6792. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6793. switch name {
  6794. case batchmsg.FieldStatus:
  6795. return m.AddedStatus()
  6796. case batchmsg.FieldTotal:
  6797. return m.AddedTotal()
  6798. case batchmsg.FieldSuccess:
  6799. return m.AddedSuccess()
  6800. case batchmsg.FieldFail:
  6801. return m.AddedFail()
  6802. case batchmsg.FieldType:
  6803. return m.AddedType()
  6804. case batchmsg.FieldOrganizationID:
  6805. return m.AddedOrganizationID()
  6806. case batchmsg.FieldCtype:
  6807. return m.AddedCtype()
  6808. }
  6809. return nil, false
  6810. }
  6811. // AddField adds the value to the field with the given name. It returns an error if
  6812. // the field is not defined in the schema, or if the type mismatched the field
  6813. // type.
  6814. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6815. switch name {
  6816. case batchmsg.FieldStatus:
  6817. v, ok := value.(int8)
  6818. if !ok {
  6819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6820. }
  6821. m.AddStatus(v)
  6822. return nil
  6823. case batchmsg.FieldTotal:
  6824. v, ok := value.(int32)
  6825. if !ok {
  6826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6827. }
  6828. m.AddTotal(v)
  6829. return nil
  6830. case batchmsg.FieldSuccess:
  6831. v, ok := value.(int32)
  6832. if !ok {
  6833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6834. }
  6835. m.AddSuccess(v)
  6836. return nil
  6837. case batchmsg.FieldFail:
  6838. v, ok := value.(int32)
  6839. if !ok {
  6840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6841. }
  6842. m.AddFail(v)
  6843. return nil
  6844. case batchmsg.FieldType:
  6845. v, ok := value.(int32)
  6846. if !ok {
  6847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6848. }
  6849. m.AddType(v)
  6850. return nil
  6851. case batchmsg.FieldOrganizationID:
  6852. v, ok := value.(int64)
  6853. if !ok {
  6854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6855. }
  6856. m.AddOrganizationID(v)
  6857. return nil
  6858. case batchmsg.FieldCtype:
  6859. v, ok := value.(int64)
  6860. if !ok {
  6861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6862. }
  6863. m.AddCtype(v)
  6864. return nil
  6865. }
  6866. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6867. }
  6868. // ClearedFields returns all nullable fields that were cleared during this
  6869. // mutation.
  6870. func (m *BatchMsgMutation) ClearedFields() []string {
  6871. var fields []string
  6872. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6873. fields = append(fields, batchmsg.FieldDeletedAt)
  6874. }
  6875. if m.FieldCleared(batchmsg.FieldStatus) {
  6876. fields = append(fields, batchmsg.FieldStatus)
  6877. }
  6878. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6879. fields = append(fields, batchmsg.FieldBatchNo)
  6880. }
  6881. if m.FieldCleared(batchmsg.FieldTaskName) {
  6882. fields = append(fields, batchmsg.FieldTaskName)
  6883. }
  6884. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6885. fields = append(fields, batchmsg.FieldFromwxid)
  6886. }
  6887. if m.FieldCleared(batchmsg.FieldMsg) {
  6888. fields = append(fields, batchmsg.FieldMsg)
  6889. }
  6890. if m.FieldCleared(batchmsg.FieldTag) {
  6891. fields = append(fields, batchmsg.FieldTag)
  6892. }
  6893. if m.FieldCleared(batchmsg.FieldTagids) {
  6894. fields = append(fields, batchmsg.FieldTagids)
  6895. }
  6896. if m.FieldCleared(batchmsg.FieldTotal) {
  6897. fields = append(fields, batchmsg.FieldTotal)
  6898. }
  6899. if m.FieldCleared(batchmsg.FieldSuccess) {
  6900. fields = append(fields, batchmsg.FieldSuccess)
  6901. }
  6902. if m.FieldCleared(batchmsg.FieldFail) {
  6903. fields = append(fields, batchmsg.FieldFail)
  6904. }
  6905. if m.FieldCleared(batchmsg.FieldStartTime) {
  6906. fields = append(fields, batchmsg.FieldStartTime)
  6907. }
  6908. if m.FieldCleared(batchmsg.FieldStopTime) {
  6909. fields = append(fields, batchmsg.FieldStopTime)
  6910. }
  6911. if m.FieldCleared(batchmsg.FieldSendTime) {
  6912. fields = append(fields, batchmsg.FieldSendTime)
  6913. }
  6914. if m.FieldCleared(batchmsg.FieldType) {
  6915. fields = append(fields, batchmsg.FieldType)
  6916. }
  6917. if m.FieldCleared(batchmsg.FieldCc) {
  6918. fields = append(fields, batchmsg.FieldCc)
  6919. }
  6920. if m.FieldCleared(batchmsg.FieldPhone) {
  6921. fields = append(fields, batchmsg.FieldPhone)
  6922. }
  6923. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6924. fields = append(fields, batchmsg.FieldTemplateName)
  6925. }
  6926. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6927. fields = append(fields, batchmsg.FieldTemplateCode)
  6928. }
  6929. if m.FieldCleared(batchmsg.FieldLang) {
  6930. fields = append(fields, batchmsg.FieldLang)
  6931. }
  6932. return fields
  6933. }
  6934. // FieldCleared returns a boolean indicating if a field with the given name was
  6935. // cleared in this mutation.
  6936. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6937. _, ok := m.clearedFields[name]
  6938. return ok
  6939. }
  6940. // ClearField clears the value of the field with the given name. It returns an
  6941. // error if the field is not defined in the schema.
  6942. func (m *BatchMsgMutation) ClearField(name string) error {
  6943. switch name {
  6944. case batchmsg.FieldDeletedAt:
  6945. m.ClearDeletedAt()
  6946. return nil
  6947. case batchmsg.FieldStatus:
  6948. m.ClearStatus()
  6949. return nil
  6950. case batchmsg.FieldBatchNo:
  6951. m.ClearBatchNo()
  6952. return nil
  6953. case batchmsg.FieldTaskName:
  6954. m.ClearTaskName()
  6955. return nil
  6956. case batchmsg.FieldFromwxid:
  6957. m.ClearFromwxid()
  6958. return nil
  6959. case batchmsg.FieldMsg:
  6960. m.ClearMsg()
  6961. return nil
  6962. case batchmsg.FieldTag:
  6963. m.ClearTag()
  6964. return nil
  6965. case batchmsg.FieldTagids:
  6966. m.ClearTagids()
  6967. return nil
  6968. case batchmsg.FieldTotal:
  6969. m.ClearTotal()
  6970. return nil
  6971. case batchmsg.FieldSuccess:
  6972. m.ClearSuccess()
  6973. return nil
  6974. case batchmsg.FieldFail:
  6975. m.ClearFail()
  6976. return nil
  6977. case batchmsg.FieldStartTime:
  6978. m.ClearStartTime()
  6979. return nil
  6980. case batchmsg.FieldStopTime:
  6981. m.ClearStopTime()
  6982. return nil
  6983. case batchmsg.FieldSendTime:
  6984. m.ClearSendTime()
  6985. return nil
  6986. case batchmsg.FieldType:
  6987. m.ClearType()
  6988. return nil
  6989. case batchmsg.FieldCc:
  6990. m.ClearCc()
  6991. return nil
  6992. case batchmsg.FieldPhone:
  6993. m.ClearPhone()
  6994. return nil
  6995. case batchmsg.FieldTemplateName:
  6996. m.ClearTemplateName()
  6997. return nil
  6998. case batchmsg.FieldTemplateCode:
  6999. m.ClearTemplateCode()
  7000. return nil
  7001. case batchmsg.FieldLang:
  7002. m.ClearLang()
  7003. return nil
  7004. }
  7005. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7006. }
  7007. // ResetField resets all changes in the mutation for the field with the given name.
  7008. // It returns an error if the field is not defined in the schema.
  7009. func (m *BatchMsgMutation) ResetField(name string) error {
  7010. switch name {
  7011. case batchmsg.FieldCreatedAt:
  7012. m.ResetCreatedAt()
  7013. return nil
  7014. case batchmsg.FieldUpdatedAt:
  7015. m.ResetUpdatedAt()
  7016. return nil
  7017. case batchmsg.FieldDeletedAt:
  7018. m.ResetDeletedAt()
  7019. return nil
  7020. case batchmsg.FieldStatus:
  7021. m.ResetStatus()
  7022. return nil
  7023. case batchmsg.FieldBatchNo:
  7024. m.ResetBatchNo()
  7025. return nil
  7026. case batchmsg.FieldTaskName:
  7027. m.ResetTaskName()
  7028. return nil
  7029. case batchmsg.FieldFromwxid:
  7030. m.ResetFromwxid()
  7031. return nil
  7032. case batchmsg.FieldMsg:
  7033. m.ResetMsg()
  7034. return nil
  7035. case batchmsg.FieldTag:
  7036. m.ResetTag()
  7037. return nil
  7038. case batchmsg.FieldTagids:
  7039. m.ResetTagids()
  7040. return nil
  7041. case batchmsg.FieldTotal:
  7042. m.ResetTotal()
  7043. return nil
  7044. case batchmsg.FieldSuccess:
  7045. m.ResetSuccess()
  7046. return nil
  7047. case batchmsg.FieldFail:
  7048. m.ResetFail()
  7049. return nil
  7050. case batchmsg.FieldStartTime:
  7051. m.ResetStartTime()
  7052. return nil
  7053. case batchmsg.FieldStopTime:
  7054. m.ResetStopTime()
  7055. return nil
  7056. case batchmsg.FieldSendTime:
  7057. m.ResetSendTime()
  7058. return nil
  7059. case batchmsg.FieldType:
  7060. m.ResetType()
  7061. return nil
  7062. case batchmsg.FieldOrganizationID:
  7063. m.ResetOrganizationID()
  7064. return nil
  7065. case batchmsg.FieldCtype:
  7066. m.ResetCtype()
  7067. return nil
  7068. case batchmsg.FieldCc:
  7069. m.ResetCc()
  7070. return nil
  7071. case batchmsg.FieldPhone:
  7072. m.ResetPhone()
  7073. return nil
  7074. case batchmsg.FieldTemplateName:
  7075. m.ResetTemplateName()
  7076. return nil
  7077. case batchmsg.FieldTemplateCode:
  7078. m.ResetTemplateCode()
  7079. return nil
  7080. case batchmsg.FieldLang:
  7081. m.ResetLang()
  7082. return nil
  7083. }
  7084. return fmt.Errorf("unknown BatchMsg field %s", name)
  7085. }
  7086. // AddedEdges returns all edge names that were set/added in this mutation.
  7087. func (m *BatchMsgMutation) AddedEdges() []string {
  7088. edges := make([]string, 0, 0)
  7089. return edges
  7090. }
  7091. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7092. // name in this mutation.
  7093. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7094. return nil
  7095. }
  7096. // RemovedEdges returns all edge names that were removed in this mutation.
  7097. func (m *BatchMsgMutation) RemovedEdges() []string {
  7098. edges := make([]string, 0, 0)
  7099. return edges
  7100. }
  7101. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7102. // the given name in this mutation.
  7103. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7104. return nil
  7105. }
  7106. // ClearedEdges returns all edge names that were cleared in this mutation.
  7107. func (m *BatchMsgMutation) ClearedEdges() []string {
  7108. edges := make([]string, 0, 0)
  7109. return edges
  7110. }
  7111. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7112. // was cleared in this mutation.
  7113. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7114. return false
  7115. }
  7116. // ClearEdge clears the value of the edge with the given name. It returns an error
  7117. // if that edge is not defined in the schema.
  7118. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7119. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7120. }
  7121. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7122. // It returns an error if the edge is not defined in the schema.
  7123. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7124. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7125. }
  7126. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7127. type CategoryMutation struct {
  7128. config
  7129. op Op
  7130. typ string
  7131. id *uint64
  7132. created_at *time.Time
  7133. updated_at *time.Time
  7134. deleted_at *time.Time
  7135. name *string
  7136. organization_id *uint64
  7137. addorganization_id *int64
  7138. clearedFields map[string]struct{}
  7139. done bool
  7140. oldValue func(context.Context) (*Category, error)
  7141. predicates []predicate.Category
  7142. }
  7143. var _ ent.Mutation = (*CategoryMutation)(nil)
  7144. // categoryOption allows management of the mutation configuration using functional options.
  7145. type categoryOption func(*CategoryMutation)
  7146. // newCategoryMutation creates new mutation for the Category entity.
  7147. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7148. m := &CategoryMutation{
  7149. config: c,
  7150. op: op,
  7151. typ: TypeCategory,
  7152. clearedFields: make(map[string]struct{}),
  7153. }
  7154. for _, opt := range opts {
  7155. opt(m)
  7156. }
  7157. return m
  7158. }
  7159. // withCategoryID sets the ID field of the mutation.
  7160. func withCategoryID(id uint64) categoryOption {
  7161. return func(m *CategoryMutation) {
  7162. var (
  7163. err error
  7164. once sync.Once
  7165. value *Category
  7166. )
  7167. m.oldValue = func(ctx context.Context) (*Category, error) {
  7168. once.Do(func() {
  7169. if m.done {
  7170. err = errors.New("querying old values post mutation is not allowed")
  7171. } else {
  7172. value, err = m.Client().Category.Get(ctx, id)
  7173. }
  7174. })
  7175. return value, err
  7176. }
  7177. m.id = &id
  7178. }
  7179. }
  7180. // withCategory sets the old Category of the mutation.
  7181. func withCategory(node *Category) categoryOption {
  7182. return func(m *CategoryMutation) {
  7183. m.oldValue = func(context.Context) (*Category, error) {
  7184. return node, nil
  7185. }
  7186. m.id = &node.ID
  7187. }
  7188. }
  7189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7190. // executed in a transaction (ent.Tx), a transactional client is returned.
  7191. func (m CategoryMutation) Client() *Client {
  7192. client := &Client{config: m.config}
  7193. client.init()
  7194. return client
  7195. }
  7196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7197. // it returns an error otherwise.
  7198. func (m CategoryMutation) Tx() (*Tx, error) {
  7199. if _, ok := m.driver.(*txDriver); !ok {
  7200. return nil, errors.New("ent: mutation is not running in a transaction")
  7201. }
  7202. tx := &Tx{config: m.config}
  7203. tx.init()
  7204. return tx, nil
  7205. }
  7206. // SetID sets the value of the id field. Note that this
  7207. // operation is only accepted on creation of Category entities.
  7208. func (m *CategoryMutation) SetID(id uint64) {
  7209. m.id = &id
  7210. }
  7211. // ID returns the ID value in the mutation. Note that the ID is only available
  7212. // if it was provided to the builder or after it was returned from the database.
  7213. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7214. if m.id == nil {
  7215. return
  7216. }
  7217. return *m.id, true
  7218. }
  7219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7220. // That means, if the mutation is applied within a transaction with an isolation level such
  7221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7222. // or updated by the mutation.
  7223. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7224. switch {
  7225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7226. id, exists := m.ID()
  7227. if exists {
  7228. return []uint64{id}, nil
  7229. }
  7230. fallthrough
  7231. case m.op.Is(OpUpdate | OpDelete):
  7232. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7233. default:
  7234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7235. }
  7236. }
  7237. // SetCreatedAt sets the "created_at" field.
  7238. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7239. m.created_at = &t
  7240. }
  7241. // CreatedAt returns the value of the "created_at" field in the mutation.
  7242. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7243. v := m.created_at
  7244. if v == nil {
  7245. return
  7246. }
  7247. return *v, true
  7248. }
  7249. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7250. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7252. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7253. if !m.op.Is(OpUpdateOne) {
  7254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7255. }
  7256. if m.id == nil || m.oldValue == nil {
  7257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7258. }
  7259. oldValue, err := m.oldValue(ctx)
  7260. if err != nil {
  7261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7262. }
  7263. return oldValue.CreatedAt, nil
  7264. }
  7265. // ResetCreatedAt resets all changes to the "created_at" field.
  7266. func (m *CategoryMutation) ResetCreatedAt() {
  7267. m.created_at = nil
  7268. }
  7269. // SetUpdatedAt sets the "updated_at" field.
  7270. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7271. m.updated_at = &t
  7272. }
  7273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7274. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7275. v := m.updated_at
  7276. if v == nil {
  7277. return
  7278. }
  7279. return *v, true
  7280. }
  7281. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7282. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7284. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7285. if !m.op.Is(OpUpdateOne) {
  7286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7287. }
  7288. if m.id == nil || m.oldValue == nil {
  7289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7290. }
  7291. oldValue, err := m.oldValue(ctx)
  7292. if err != nil {
  7293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7294. }
  7295. return oldValue.UpdatedAt, nil
  7296. }
  7297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7298. func (m *CategoryMutation) ResetUpdatedAt() {
  7299. m.updated_at = nil
  7300. }
  7301. // SetDeletedAt sets the "deleted_at" field.
  7302. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7303. m.deleted_at = &t
  7304. }
  7305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7306. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7307. v := m.deleted_at
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7314. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7326. }
  7327. return oldValue.DeletedAt, nil
  7328. }
  7329. // ClearDeletedAt clears the value of the "deleted_at" field.
  7330. func (m *CategoryMutation) ClearDeletedAt() {
  7331. m.deleted_at = nil
  7332. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7333. }
  7334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7335. func (m *CategoryMutation) DeletedAtCleared() bool {
  7336. _, ok := m.clearedFields[category.FieldDeletedAt]
  7337. return ok
  7338. }
  7339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7340. func (m *CategoryMutation) ResetDeletedAt() {
  7341. m.deleted_at = nil
  7342. delete(m.clearedFields, category.FieldDeletedAt)
  7343. }
  7344. // SetName sets the "name" field.
  7345. func (m *CategoryMutation) SetName(s string) {
  7346. m.name = &s
  7347. }
  7348. // Name returns the value of the "name" field in the mutation.
  7349. func (m *CategoryMutation) Name() (r string, exists bool) {
  7350. v := m.name
  7351. if v == nil {
  7352. return
  7353. }
  7354. return *v, true
  7355. }
  7356. // OldName returns the old "name" field's value of the Category entity.
  7357. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7359. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7360. if !m.op.Is(OpUpdateOne) {
  7361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7362. }
  7363. if m.id == nil || m.oldValue == nil {
  7364. return v, errors.New("OldName requires an ID field in the mutation")
  7365. }
  7366. oldValue, err := m.oldValue(ctx)
  7367. if err != nil {
  7368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7369. }
  7370. return oldValue.Name, nil
  7371. }
  7372. // ResetName resets all changes to the "name" field.
  7373. func (m *CategoryMutation) ResetName() {
  7374. m.name = nil
  7375. }
  7376. // SetOrganizationID sets the "organization_id" field.
  7377. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7378. m.organization_id = &u
  7379. m.addorganization_id = nil
  7380. }
  7381. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7382. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7383. v := m.organization_id
  7384. if v == nil {
  7385. return
  7386. }
  7387. return *v, true
  7388. }
  7389. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7390. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7392. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7393. if !m.op.Is(OpUpdateOne) {
  7394. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7395. }
  7396. if m.id == nil || m.oldValue == nil {
  7397. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7398. }
  7399. oldValue, err := m.oldValue(ctx)
  7400. if err != nil {
  7401. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7402. }
  7403. return oldValue.OrganizationID, nil
  7404. }
  7405. // AddOrganizationID adds u to the "organization_id" field.
  7406. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7407. if m.addorganization_id != nil {
  7408. *m.addorganization_id += u
  7409. } else {
  7410. m.addorganization_id = &u
  7411. }
  7412. }
  7413. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7414. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7415. v := m.addorganization_id
  7416. if v == nil {
  7417. return
  7418. }
  7419. return *v, true
  7420. }
  7421. // ResetOrganizationID resets all changes to the "organization_id" field.
  7422. func (m *CategoryMutation) ResetOrganizationID() {
  7423. m.organization_id = nil
  7424. m.addorganization_id = nil
  7425. }
  7426. // Where appends a list predicates to the CategoryMutation builder.
  7427. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7428. m.predicates = append(m.predicates, ps...)
  7429. }
  7430. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7431. // users can use type-assertion to append predicates that do not depend on any generated package.
  7432. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7433. p := make([]predicate.Category, len(ps))
  7434. for i := range ps {
  7435. p[i] = ps[i]
  7436. }
  7437. m.Where(p...)
  7438. }
  7439. // Op returns the operation name.
  7440. func (m *CategoryMutation) Op() Op {
  7441. return m.op
  7442. }
  7443. // SetOp allows setting the mutation operation.
  7444. func (m *CategoryMutation) SetOp(op Op) {
  7445. m.op = op
  7446. }
  7447. // Type returns the node type of this mutation (Category).
  7448. func (m *CategoryMutation) Type() string {
  7449. return m.typ
  7450. }
  7451. // Fields returns all fields that were changed during this mutation. Note that in
  7452. // order to get all numeric fields that were incremented/decremented, call
  7453. // AddedFields().
  7454. func (m *CategoryMutation) Fields() []string {
  7455. fields := make([]string, 0, 5)
  7456. if m.created_at != nil {
  7457. fields = append(fields, category.FieldCreatedAt)
  7458. }
  7459. if m.updated_at != nil {
  7460. fields = append(fields, category.FieldUpdatedAt)
  7461. }
  7462. if m.deleted_at != nil {
  7463. fields = append(fields, category.FieldDeletedAt)
  7464. }
  7465. if m.name != nil {
  7466. fields = append(fields, category.FieldName)
  7467. }
  7468. if m.organization_id != nil {
  7469. fields = append(fields, category.FieldOrganizationID)
  7470. }
  7471. return fields
  7472. }
  7473. // Field returns the value of a field with the given name. The second boolean
  7474. // return value indicates that this field was not set, or was not defined in the
  7475. // schema.
  7476. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7477. switch name {
  7478. case category.FieldCreatedAt:
  7479. return m.CreatedAt()
  7480. case category.FieldUpdatedAt:
  7481. return m.UpdatedAt()
  7482. case category.FieldDeletedAt:
  7483. return m.DeletedAt()
  7484. case category.FieldName:
  7485. return m.Name()
  7486. case category.FieldOrganizationID:
  7487. return m.OrganizationID()
  7488. }
  7489. return nil, false
  7490. }
  7491. // OldField returns the old value of the field from the database. An error is
  7492. // returned if the mutation operation is not UpdateOne, or the query to the
  7493. // database failed.
  7494. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7495. switch name {
  7496. case category.FieldCreatedAt:
  7497. return m.OldCreatedAt(ctx)
  7498. case category.FieldUpdatedAt:
  7499. return m.OldUpdatedAt(ctx)
  7500. case category.FieldDeletedAt:
  7501. return m.OldDeletedAt(ctx)
  7502. case category.FieldName:
  7503. return m.OldName(ctx)
  7504. case category.FieldOrganizationID:
  7505. return m.OldOrganizationID(ctx)
  7506. }
  7507. return nil, fmt.Errorf("unknown Category field %s", name)
  7508. }
  7509. // SetField sets the value of a field with the given name. It returns an error if
  7510. // the field is not defined in the schema, or if the type mismatched the field
  7511. // type.
  7512. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7513. switch name {
  7514. case category.FieldCreatedAt:
  7515. v, ok := value.(time.Time)
  7516. if !ok {
  7517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7518. }
  7519. m.SetCreatedAt(v)
  7520. return nil
  7521. case category.FieldUpdatedAt:
  7522. v, ok := value.(time.Time)
  7523. if !ok {
  7524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7525. }
  7526. m.SetUpdatedAt(v)
  7527. return nil
  7528. case category.FieldDeletedAt:
  7529. v, ok := value.(time.Time)
  7530. if !ok {
  7531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7532. }
  7533. m.SetDeletedAt(v)
  7534. return nil
  7535. case category.FieldName:
  7536. v, ok := value.(string)
  7537. if !ok {
  7538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7539. }
  7540. m.SetName(v)
  7541. return nil
  7542. case category.FieldOrganizationID:
  7543. v, ok := value.(uint64)
  7544. if !ok {
  7545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7546. }
  7547. m.SetOrganizationID(v)
  7548. return nil
  7549. }
  7550. return fmt.Errorf("unknown Category field %s", name)
  7551. }
  7552. // AddedFields returns all numeric fields that were incremented/decremented during
  7553. // this mutation.
  7554. func (m *CategoryMutation) AddedFields() []string {
  7555. var fields []string
  7556. if m.addorganization_id != nil {
  7557. fields = append(fields, category.FieldOrganizationID)
  7558. }
  7559. return fields
  7560. }
  7561. // AddedField returns the numeric value that was incremented/decremented on a field
  7562. // with the given name. The second boolean return value indicates that this field
  7563. // was not set, or was not defined in the schema.
  7564. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7565. switch name {
  7566. case category.FieldOrganizationID:
  7567. return m.AddedOrganizationID()
  7568. }
  7569. return nil, false
  7570. }
  7571. // AddField adds the value to the field with the given name. It returns an error if
  7572. // the field is not defined in the schema, or if the type mismatched the field
  7573. // type.
  7574. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7575. switch name {
  7576. case category.FieldOrganizationID:
  7577. v, ok := value.(int64)
  7578. if !ok {
  7579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7580. }
  7581. m.AddOrganizationID(v)
  7582. return nil
  7583. }
  7584. return fmt.Errorf("unknown Category numeric field %s", name)
  7585. }
  7586. // ClearedFields returns all nullable fields that were cleared during this
  7587. // mutation.
  7588. func (m *CategoryMutation) ClearedFields() []string {
  7589. var fields []string
  7590. if m.FieldCleared(category.FieldDeletedAt) {
  7591. fields = append(fields, category.FieldDeletedAt)
  7592. }
  7593. return fields
  7594. }
  7595. // FieldCleared returns a boolean indicating if a field with the given name was
  7596. // cleared in this mutation.
  7597. func (m *CategoryMutation) FieldCleared(name string) bool {
  7598. _, ok := m.clearedFields[name]
  7599. return ok
  7600. }
  7601. // ClearField clears the value of the field with the given name. It returns an
  7602. // error if the field is not defined in the schema.
  7603. func (m *CategoryMutation) ClearField(name string) error {
  7604. switch name {
  7605. case category.FieldDeletedAt:
  7606. m.ClearDeletedAt()
  7607. return nil
  7608. }
  7609. return fmt.Errorf("unknown Category nullable field %s", name)
  7610. }
  7611. // ResetField resets all changes in the mutation for the field with the given name.
  7612. // It returns an error if the field is not defined in the schema.
  7613. func (m *CategoryMutation) ResetField(name string) error {
  7614. switch name {
  7615. case category.FieldCreatedAt:
  7616. m.ResetCreatedAt()
  7617. return nil
  7618. case category.FieldUpdatedAt:
  7619. m.ResetUpdatedAt()
  7620. return nil
  7621. case category.FieldDeletedAt:
  7622. m.ResetDeletedAt()
  7623. return nil
  7624. case category.FieldName:
  7625. m.ResetName()
  7626. return nil
  7627. case category.FieldOrganizationID:
  7628. m.ResetOrganizationID()
  7629. return nil
  7630. }
  7631. return fmt.Errorf("unknown Category field %s", name)
  7632. }
  7633. // AddedEdges returns all edge names that were set/added in this mutation.
  7634. func (m *CategoryMutation) AddedEdges() []string {
  7635. edges := make([]string, 0, 0)
  7636. return edges
  7637. }
  7638. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7639. // name in this mutation.
  7640. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7641. return nil
  7642. }
  7643. // RemovedEdges returns all edge names that were removed in this mutation.
  7644. func (m *CategoryMutation) RemovedEdges() []string {
  7645. edges := make([]string, 0, 0)
  7646. return edges
  7647. }
  7648. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7649. // the given name in this mutation.
  7650. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7651. return nil
  7652. }
  7653. // ClearedEdges returns all edge names that were cleared in this mutation.
  7654. func (m *CategoryMutation) ClearedEdges() []string {
  7655. edges := make([]string, 0, 0)
  7656. return edges
  7657. }
  7658. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7659. // was cleared in this mutation.
  7660. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7661. return false
  7662. }
  7663. // ClearEdge clears the value of the edge with the given name. It returns an error
  7664. // if that edge is not defined in the schema.
  7665. func (m *CategoryMutation) ClearEdge(name string) error {
  7666. return fmt.Errorf("unknown Category unique edge %s", name)
  7667. }
  7668. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7669. // It returns an error if the edge is not defined in the schema.
  7670. func (m *CategoryMutation) ResetEdge(name string) error {
  7671. return fmt.Errorf("unknown Category edge %s", name)
  7672. }
  7673. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7674. type ChatRecordsMutation struct {
  7675. config
  7676. op Op
  7677. typ string
  7678. id *uint64
  7679. created_at *time.Time
  7680. updated_at *time.Time
  7681. deleted_at *time.Time
  7682. content *string
  7683. content_type *uint8
  7684. addcontent_type *int8
  7685. session_id *uint64
  7686. addsession_id *int64
  7687. user_id *uint64
  7688. adduser_id *int64
  7689. bot_id *uint64
  7690. addbot_id *int64
  7691. bot_type *uint8
  7692. addbot_type *int8
  7693. clearedFields map[string]struct{}
  7694. done bool
  7695. oldValue func(context.Context) (*ChatRecords, error)
  7696. predicates []predicate.ChatRecords
  7697. }
  7698. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7699. // chatrecordsOption allows management of the mutation configuration using functional options.
  7700. type chatrecordsOption func(*ChatRecordsMutation)
  7701. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7702. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7703. m := &ChatRecordsMutation{
  7704. config: c,
  7705. op: op,
  7706. typ: TypeChatRecords,
  7707. clearedFields: make(map[string]struct{}),
  7708. }
  7709. for _, opt := range opts {
  7710. opt(m)
  7711. }
  7712. return m
  7713. }
  7714. // withChatRecordsID sets the ID field of the mutation.
  7715. func withChatRecordsID(id uint64) chatrecordsOption {
  7716. return func(m *ChatRecordsMutation) {
  7717. var (
  7718. err error
  7719. once sync.Once
  7720. value *ChatRecords
  7721. )
  7722. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7723. once.Do(func() {
  7724. if m.done {
  7725. err = errors.New("querying old values post mutation is not allowed")
  7726. } else {
  7727. value, err = m.Client().ChatRecords.Get(ctx, id)
  7728. }
  7729. })
  7730. return value, err
  7731. }
  7732. m.id = &id
  7733. }
  7734. }
  7735. // withChatRecords sets the old ChatRecords of the mutation.
  7736. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7737. return func(m *ChatRecordsMutation) {
  7738. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7739. return node, nil
  7740. }
  7741. m.id = &node.ID
  7742. }
  7743. }
  7744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7745. // executed in a transaction (ent.Tx), a transactional client is returned.
  7746. func (m ChatRecordsMutation) Client() *Client {
  7747. client := &Client{config: m.config}
  7748. client.init()
  7749. return client
  7750. }
  7751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7752. // it returns an error otherwise.
  7753. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7754. if _, ok := m.driver.(*txDriver); !ok {
  7755. return nil, errors.New("ent: mutation is not running in a transaction")
  7756. }
  7757. tx := &Tx{config: m.config}
  7758. tx.init()
  7759. return tx, nil
  7760. }
  7761. // SetID sets the value of the id field. Note that this
  7762. // operation is only accepted on creation of ChatRecords entities.
  7763. func (m *ChatRecordsMutation) SetID(id uint64) {
  7764. m.id = &id
  7765. }
  7766. // ID returns the ID value in the mutation. Note that the ID is only available
  7767. // if it was provided to the builder or after it was returned from the database.
  7768. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7769. if m.id == nil {
  7770. return
  7771. }
  7772. return *m.id, true
  7773. }
  7774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7775. // That means, if the mutation is applied within a transaction with an isolation level such
  7776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7777. // or updated by the mutation.
  7778. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7779. switch {
  7780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7781. id, exists := m.ID()
  7782. if exists {
  7783. return []uint64{id}, nil
  7784. }
  7785. fallthrough
  7786. case m.op.Is(OpUpdate | OpDelete):
  7787. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7788. default:
  7789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7790. }
  7791. }
  7792. // SetCreatedAt sets the "created_at" field.
  7793. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7794. m.created_at = &t
  7795. }
  7796. // CreatedAt returns the value of the "created_at" field in the mutation.
  7797. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7798. v := m.created_at
  7799. if v == nil {
  7800. return
  7801. }
  7802. return *v, true
  7803. }
  7804. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7805. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7807. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7808. if !m.op.Is(OpUpdateOne) {
  7809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7810. }
  7811. if m.id == nil || m.oldValue == nil {
  7812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7813. }
  7814. oldValue, err := m.oldValue(ctx)
  7815. if err != nil {
  7816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7817. }
  7818. return oldValue.CreatedAt, nil
  7819. }
  7820. // ResetCreatedAt resets all changes to the "created_at" field.
  7821. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7822. m.created_at = nil
  7823. }
  7824. // SetUpdatedAt sets the "updated_at" field.
  7825. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7826. m.updated_at = &t
  7827. }
  7828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7829. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7830. v := m.updated_at
  7831. if v == nil {
  7832. return
  7833. }
  7834. return *v, true
  7835. }
  7836. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7837. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7839. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7840. if !m.op.Is(OpUpdateOne) {
  7841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7842. }
  7843. if m.id == nil || m.oldValue == nil {
  7844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7845. }
  7846. oldValue, err := m.oldValue(ctx)
  7847. if err != nil {
  7848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7849. }
  7850. return oldValue.UpdatedAt, nil
  7851. }
  7852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7853. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7854. m.updated_at = nil
  7855. }
  7856. // SetDeletedAt sets the "deleted_at" field.
  7857. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7858. m.deleted_at = &t
  7859. }
  7860. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7861. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7862. v := m.deleted_at
  7863. if v == nil {
  7864. return
  7865. }
  7866. return *v, true
  7867. }
  7868. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7869. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7871. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7872. if !m.op.Is(OpUpdateOne) {
  7873. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7874. }
  7875. if m.id == nil || m.oldValue == nil {
  7876. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7877. }
  7878. oldValue, err := m.oldValue(ctx)
  7879. if err != nil {
  7880. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7881. }
  7882. return oldValue.DeletedAt, nil
  7883. }
  7884. // ClearDeletedAt clears the value of the "deleted_at" field.
  7885. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7886. m.deleted_at = nil
  7887. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7888. }
  7889. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7890. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7891. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7892. return ok
  7893. }
  7894. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7895. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7896. m.deleted_at = nil
  7897. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7898. }
  7899. // SetContent sets the "content" field.
  7900. func (m *ChatRecordsMutation) SetContent(s string) {
  7901. m.content = &s
  7902. }
  7903. // Content returns the value of the "content" field in the mutation.
  7904. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7905. v := m.content
  7906. if v == nil {
  7907. return
  7908. }
  7909. return *v, true
  7910. }
  7911. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7912. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7914. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7915. if !m.op.Is(OpUpdateOne) {
  7916. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7917. }
  7918. if m.id == nil || m.oldValue == nil {
  7919. return v, errors.New("OldContent requires an ID field in the mutation")
  7920. }
  7921. oldValue, err := m.oldValue(ctx)
  7922. if err != nil {
  7923. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7924. }
  7925. return oldValue.Content, nil
  7926. }
  7927. // ResetContent resets all changes to the "content" field.
  7928. func (m *ChatRecordsMutation) ResetContent() {
  7929. m.content = nil
  7930. }
  7931. // SetContentType sets the "content_type" field.
  7932. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7933. m.content_type = &u
  7934. m.addcontent_type = nil
  7935. }
  7936. // ContentType returns the value of the "content_type" field in the mutation.
  7937. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7938. v := m.content_type
  7939. if v == nil {
  7940. return
  7941. }
  7942. return *v, true
  7943. }
  7944. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7945. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7947. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7948. if !m.op.Is(OpUpdateOne) {
  7949. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7950. }
  7951. if m.id == nil || m.oldValue == nil {
  7952. return v, errors.New("OldContentType requires an ID field in the mutation")
  7953. }
  7954. oldValue, err := m.oldValue(ctx)
  7955. if err != nil {
  7956. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7957. }
  7958. return oldValue.ContentType, nil
  7959. }
  7960. // AddContentType adds u to the "content_type" field.
  7961. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7962. if m.addcontent_type != nil {
  7963. *m.addcontent_type += u
  7964. } else {
  7965. m.addcontent_type = &u
  7966. }
  7967. }
  7968. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7969. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7970. v := m.addcontent_type
  7971. if v == nil {
  7972. return
  7973. }
  7974. return *v, true
  7975. }
  7976. // ResetContentType resets all changes to the "content_type" field.
  7977. func (m *ChatRecordsMutation) ResetContentType() {
  7978. m.content_type = nil
  7979. m.addcontent_type = nil
  7980. }
  7981. // SetSessionID sets the "session_id" field.
  7982. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7983. m.session_id = &u
  7984. m.addsession_id = nil
  7985. }
  7986. // SessionID returns the value of the "session_id" field in the mutation.
  7987. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7988. v := m.session_id
  7989. if v == nil {
  7990. return
  7991. }
  7992. return *v, true
  7993. }
  7994. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7995. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7997. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7998. if !m.op.Is(OpUpdateOne) {
  7999. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8000. }
  8001. if m.id == nil || m.oldValue == nil {
  8002. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8003. }
  8004. oldValue, err := m.oldValue(ctx)
  8005. if err != nil {
  8006. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8007. }
  8008. return oldValue.SessionID, nil
  8009. }
  8010. // AddSessionID adds u to the "session_id" field.
  8011. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8012. if m.addsession_id != nil {
  8013. *m.addsession_id += u
  8014. } else {
  8015. m.addsession_id = &u
  8016. }
  8017. }
  8018. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8019. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8020. v := m.addsession_id
  8021. if v == nil {
  8022. return
  8023. }
  8024. return *v, true
  8025. }
  8026. // ResetSessionID resets all changes to the "session_id" field.
  8027. func (m *ChatRecordsMutation) ResetSessionID() {
  8028. m.session_id = nil
  8029. m.addsession_id = nil
  8030. }
  8031. // SetUserID sets the "user_id" field.
  8032. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8033. m.user_id = &u
  8034. m.adduser_id = nil
  8035. }
  8036. // UserID returns the value of the "user_id" field in the mutation.
  8037. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8038. v := m.user_id
  8039. if v == nil {
  8040. return
  8041. }
  8042. return *v, true
  8043. }
  8044. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8045. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8047. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8048. if !m.op.Is(OpUpdateOne) {
  8049. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8050. }
  8051. if m.id == nil || m.oldValue == nil {
  8052. return v, errors.New("OldUserID requires an ID field in the mutation")
  8053. }
  8054. oldValue, err := m.oldValue(ctx)
  8055. if err != nil {
  8056. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8057. }
  8058. return oldValue.UserID, nil
  8059. }
  8060. // AddUserID adds u to the "user_id" field.
  8061. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8062. if m.adduser_id != nil {
  8063. *m.adduser_id += u
  8064. } else {
  8065. m.adduser_id = &u
  8066. }
  8067. }
  8068. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8069. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8070. v := m.adduser_id
  8071. if v == nil {
  8072. return
  8073. }
  8074. return *v, true
  8075. }
  8076. // ResetUserID resets all changes to the "user_id" field.
  8077. func (m *ChatRecordsMutation) ResetUserID() {
  8078. m.user_id = nil
  8079. m.adduser_id = nil
  8080. }
  8081. // SetBotID sets the "bot_id" field.
  8082. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8083. m.bot_id = &u
  8084. m.addbot_id = nil
  8085. }
  8086. // BotID returns the value of the "bot_id" field in the mutation.
  8087. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8088. v := m.bot_id
  8089. if v == nil {
  8090. return
  8091. }
  8092. return *v, true
  8093. }
  8094. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8095. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8097. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8098. if !m.op.Is(OpUpdateOne) {
  8099. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8100. }
  8101. if m.id == nil || m.oldValue == nil {
  8102. return v, errors.New("OldBotID requires an ID field in the mutation")
  8103. }
  8104. oldValue, err := m.oldValue(ctx)
  8105. if err != nil {
  8106. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8107. }
  8108. return oldValue.BotID, nil
  8109. }
  8110. // AddBotID adds u to the "bot_id" field.
  8111. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8112. if m.addbot_id != nil {
  8113. *m.addbot_id += u
  8114. } else {
  8115. m.addbot_id = &u
  8116. }
  8117. }
  8118. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8119. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8120. v := m.addbot_id
  8121. if v == nil {
  8122. return
  8123. }
  8124. return *v, true
  8125. }
  8126. // ResetBotID resets all changes to the "bot_id" field.
  8127. func (m *ChatRecordsMutation) ResetBotID() {
  8128. m.bot_id = nil
  8129. m.addbot_id = nil
  8130. }
  8131. // SetBotType sets the "bot_type" field.
  8132. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8133. m.bot_type = &u
  8134. m.addbot_type = nil
  8135. }
  8136. // BotType returns the value of the "bot_type" field in the mutation.
  8137. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8138. v := m.bot_type
  8139. if v == nil {
  8140. return
  8141. }
  8142. return *v, true
  8143. }
  8144. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8145. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8147. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8148. if !m.op.Is(OpUpdateOne) {
  8149. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8150. }
  8151. if m.id == nil || m.oldValue == nil {
  8152. return v, errors.New("OldBotType requires an ID field in the mutation")
  8153. }
  8154. oldValue, err := m.oldValue(ctx)
  8155. if err != nil {
  8156. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8157. }
  8158. return oldValue.BotType, nil
  8159. }
  8160. // AddBotType adds u to the "bot_type" field.
  8161. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8162. if m.addbot_type != nil {
  8163. *m.addbot_type += u
  8164. } else {
  8165. m.addbot_type = &u
  8166. }
  8167. }
  8168. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8169. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8170. v := m.addbot_type
  8171. if v == nil {
  8172. return
  8173. }
  8174. return *v, true
  8175. }
  8176. // ResetBotType resets all changes to the "bot_type" field.
  8177. func (m *ChatRecordsMutation) ResetBotType() {
  8178. m.bot_type = nil
  8179. m.addbot_type = nil
  8180. }
  8181. // Where appends a list predicates to the ChatRecordsMutation builder.
  8182. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8183. m.predicates = append(m.predicates, ps...)
  8184. }
  8185. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8186. // users can use type-assertion to append predicates that do not depend on any generated package.
  8187. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8188. p := make([]predicate.ChatRecords, len(ps))
  8189. for i := range ps {
  8190. p[i] = ps[i]
  8191. }
  8192. m.Where(p...)
  8193. }
  8194. // Op returns the operation name.
  8195. func (m *ChatRecordsMutation) Op() Op {
  8196. return m.op
  8197. }
  8198. // SetOp allows setting the mutation operation.
  8199. func (m *ChatRecordsMutation) SetOp(op Op) {
  8200. m.op = op
  8201. }
  8202. // Type returns the node type of this mutation (ChatRecords).
  8203. func (m *ChatRecordsMutation) Type() string {
  8204. return m.typ
  8205. }
  8206. // Fields returns all fields that were changed during this mutation. Note that in
  8207. // order to get all numeric fields that were incremented/decremented, call
  8208. // AddedFields().
  8209. func (m *ChatRecordsMutation) Fields() []string {
  8210. fields := make([]string, 0, 9)
  8211. if m.created_at != nil {
  8212. fields = append(fields, chatrecords.FieldCreatedAt)
  8213. }
  8214. if m.updated_at != nil {
  8215. fields = append(fields, chatrecords.FieldUpdatedAt)
  8216. }
  8217. if m.deleted_at != nil {
  8218. fields = append(fields, chatrecords.FieldDeletedAt)
  8219. }
  8220. if m.content != nil {
  8221. fields = append(fields, chatrecords.FieldContent)
  8222. }
  8223. if m.content_type != nil {
  8224. fields = append(fields, chatrecords.FieldContentType)
  8225. }
  8226. if m.session_id != nil {
  8227. fields = append(fields, chatrecords.FieldSessionID)
  8228. }
  8229. if m.user_id != nil {
  8230. fields = append(fields, chatrecords.FieldUserID)
  8231. }
  8232. if m.bot_id != nil {
  8233. fields = append(fields, chatrecords.FieldBotID)
  8234. }
  8235. if m.bot_type != nil {
  8236. fields = append(fields, chatrecords.FieldBotType)
  8237. }
  8238. return fields
  8239. }
  8240. // Field returns the value of a field with the given name. The second boolean
  8241. // return value indicates that this field was not set, or was not defined in the
  8242. // schema.
  8243. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8244. switch name {
  8245. case chatrecords.FieldCreatedAt:
  8246. return m.CreatedAt()
  8247. case chatrecords.FieldUpdatedAt:
  8248. return m.UpdatedAt()
  8249. case chatrecords.FieldDeletedAt:
  8250. return m.DeletedAt()
  8251. case chatrecords.FieldContent:
  8252. return m.Content()
  8253. case chatrecords.FieldContentType:
  8254. return m.ContentType()
  8255. case chatrecords.FieldSessionID:
  8256. return m.SessionID()
  8257. case chatrecords.FieldUserID:
  8258. return m.UserID()
  8259. case chatrecords.FieldBotID:
  8260. return m.BotID()
  8261. case chatrecords.FieldBotType:
  8262. return m.BotType()
  8263. }
  8264. return nil, false
  8265. }
  8266. // OldField returns the old value of the field from the database. An error is
  8267. // returned if the mutation operation is not UpdateOne, or the query to the
  8268. // database failed.
  8269. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8270. switch name {
  8271. case chatrecords.FieldCreatedAt:
  8272. return m.OldCreatedAt(ctx)
  8273. case chatrecords.FieldUpdatedAt:
  8274. return m.OldUpdatedAt(ctx)
  8275. case chatrecords.FieldDeletedAt:
  8276. return m.OldDeletedAt(ctx)
  8277. case chatrecords.FieldContent:
  8278. return m.OldContent(ctx)
  8279. case chatrecords.FieldContentType:
  8280. return m.OldContentType(ctx)
  8281. case chatrecords.FieldSessionID:
  8282. return m.OldSessionID(ctx)
  8283. case chatrecords.FieldUserID:
  8284. return m.OldUserID(ctx)
  8285. case chatrecords.FieldBotID:
  8286. return m.OldBotID(ctx)
  8287. case chatrecords.FieldBotType:
  8288. return m.OldBotType(ctx)
  8289. }
  8290. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8291. }
  8292. // SetField sets the value of a field with the given name. It returns an error if
  8293. // the field is not defined in the schema, or if the type mismatched the field
  8294. // type.
  8295. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8296. switch name {
  8297. case chatrecords.FieldCreatedAt:
  8298. v, ok := value.(time.Time)
  8299. if !ok {
  8300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8301. }
  8302. m.SetCreatedAt(v)
  8303. return nil
  8304. case chatrecords.FieldUpdatedAt:
  8305. v, ok := value.(time.Time)
  8306. if !ok {
  8307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8308. }
  8309. m.SetUpdatedAt(v)
  8310. return nil
  8311. case chatrecords.FieldDeletedAt:
  8312. v, ok := value.(time.Time)
  8313. if !ok {
  8314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8315. }
  8316. m.SetDeletedAt(v)
  8317. return nil
  8318. case chatrecords.FieldContent:
  8319. v, ok := value.(string)
  8320. if !ok {
  8321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8322. }
  8323. m.SetContent(v)
  8324. return nil
  8325. case chatrecords.FieldContentType:
  8326. v, ok := value.(uint8)
  8327. if !ok {
  8328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8329. }
  8330. m.SetContentType(v)
  8331. return nil
  8332. case chatrecords.FieldSessionID:
  8333. v, ok := value.(uint64)
  8334. if !ok {
  8335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8336. }
  8337. m.SetSessionID(v)
  8338. return nil
  8339. case chatrecords.FieldUserID:
  8340. v, ok := value.(uint64)
  8341. if !ok {
  8342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8343. }
  8344. m.SetUserID(v)
  8345. return nil
  8346. case chatrecords.FieldBotID:
  8347. v, ok := value.(uint64)
  8348. if !ok {
  8349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8350. }
  8351. m.SetBotID(v)
  8352. return nil
  8353. case chatrecords.FieldBotType:
  8354. v, ok := value.(uint8)
  8355. if !ok {
  8356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8357. }
  8358. m.SetBotType(v)
  8359. return nil
  8360. }
  8361. return fmt.Errorf("unknown ChatRecords field %s", name)
  8362. }
  8363. // AddedFields returns all numeric fields that were incremented/decremented during
  8364. // this mutation.
  8365. func (m *ChatRecordsMutation) AddedFields() []string {
  8366. var fields []string
  8367. if m.addcontent_type != nil {
  8368. fields = append(fields, chatrecords.FieldContentType)
  8369. }
  8370. if m.addsession_id != nil {
  8371. fields = append(fields, chatrecords.FieldSessionID)
  8372. }
  8373. if m.adduser_id != nil {
  8374. fields = append(fields, chatrecords.FieldUserID)
  8375. }
  8376. if m.addbot_id != nil {
  8377. fields = append(fields, chatrecords.FieldBotID)
  8378. }
  8379. if m.addbot_type != nil {
  8380. fields = append(fields, chatrecords.FieldBotType)
  8381. }
  8382. return fields
  8383. }
  8384. // AddedField returns the numeric value that was incremented/decremented on a field
  8385. // with the given name. The second boolean return value indicates that this field
  8386. // was not set, or was not defined in the schema.
  8387. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8388. switch name {
  8389. case chatrecords.FieldContentType:
  8390. return m.AddedContentType()
  8391. case chatrecords.FieldSessionID:
  8392. return m.AddedSessionID()
  8393. case chatrecords.FieldUserID:
  8394. return m.AddedUserID()
  8395. case chatrecords.FieldBotID:
  8396. return m.AddedBotID()
  8397. case chatrecords.FieldBotType:
  8398. return m.AddedBotType()
  8399. }
  8400. return nil, false
  8401. }
  8402. // AddField adds the value to the field with the given name. It returns an error if
  8403. // the field is not defined in the schema, or if the type mismatched the field
  8404. // type.
  8405. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8406. switch name {
  8407. case chatrecords.FieldContentType:
  8408. v, ok := value.(int8)
  8409. if !ok {
  8410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8411. }
  8412. m.AddContentType(v)
  8413. return nil
  8414. case chatrecords.FieldSessionID:
  8415. v, ok := value.(int64)
  8416. if !ok {
  8417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8418. }
  8419. m.AddSessionID(v)
  8420. return nil
  8421. case chatrecords.FieldUserID:
  8422. v, ok := value.(int64)
  8423. if !ok {
  8424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8425. }
  8426. m.AddUserID(v)
  8427. return nil
  8428. case chatrecords.FieldBotID:
  8429. v, ok := value.(int64)
  8430. if !ok {
  8431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8432. }
  8433. m.AddBotID(v)
  8434. return nil
  8435. case chatrecords.FieldBotType:
  8436. v, ok := value.(int8)
  8437. if !ok {
  8438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8439. }
  8440. m.AddBotType(v)
  8441. return nil
  8442. }
  8443. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8444. }
  8445. // ClearedFields returns all nullable fields that were cleared during this
  8446. // mutation.
  8447. func (m *ChatRecordsMutation) ClearedFields() []string {
  8448. var fields []string
  8449. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8450. fields = append(fields, chatrecords.FieldDeletedAt)
  8451. }
  8452. return fields
  8453. }
  8454. // FieldCleared returns a boolean indicating if a field with the given name was
  8455. // cleared in this mutation.
  8456. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8457. _, ok := m.clearedFields[name]
  8458. return ok
  8459. }
  8460. // ClearField clears the value of the field with the given name. It returns an
  8461. // error if the field is not defined in the schema.
  8462. func (m *ChatRecordsMutation) ClearField(name string) error {
  8463. switch name {
  8464. case chatrecords.FieldDeletedAt:
  8465. m.ClearDeletedAt()
  8466. return nil
  8467. }
  8468. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8469. }
  8470. // ResetField resets all changes in the mutation for the field with the given name.
  8471. // It returns an error if the field is not defined in the schema.
  8472. func (m *ChatRecordsMutation) ResetField(name string) error {
  8473. switch name {
  8474. case chatrecords.FieldCreatedAt:
  8475. m.ResetCreatedAt()
  8476. return nil
  8477. case chatrecords.FieldUpdatedAt:
  8478. m.ResetUpdatedAt()
  8479. return nil
  8480. case chatrecords.FieldDeletedAt:
  8481. m.ResetDeletedAt()
  8482. return nil
  8483. case chatrecords.FieldContent:
  8484. m.ResetContent()
  8485. return nil
  8486. case chatrecords.FieldContentType:
  8487. m.ResetContentType()
  8488. return nil
  8489. case chatrecords.FieldSessionID:
  8490. m.ResetSessionID()
  8491. return nil
  8492. case chatrecords.FieldUserID:
  8493. m.ResetUserID()
  8494. return nil
  8495. case chatrecords.FieldBotID:
  8496. m.ResetBotID()
  8497. return nil
  8498. case chatrecords.FieldBotType:
  8499. m.ResetBotType()
  8500. return nil
  8501. }
  8502. return fmt.Errorf("unknown ChatRecords field %s", name)
  8503. }
  8504. // AddedEdges returns all edge names that were set/added in this mutation.
  8505. func (m *ChatRecordsMutation) AddedEdges() []string {
  8506. edges := make([]string, 0, 0)
  8507. return edges
  8508. }
  8509. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8510. // name in this mutation.
  8511. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8512. return nil
  8513. }
  8514. // RemovedEdges returns all edge names that were removed in this mutation.
  8515. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8516. edges := make([]string, 0, 0)
  8517. return edges
  8518. }
  8519. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8520. // the given name in this mutation.
  8521. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8522. return nil
  8523. }
  8524. // ClearedEdges returns all edge names that were cleared in this mutation.
  8525. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8526. edges := make([]string, 0, 0)
  8527. return edges
  8528. }
  8529. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8530. // was cleared in this mutation.
  8531. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8532. return false
  8533. }
  8534. // ClearEdge clears the value of the edge with the given name. It returns an error
  8535. // if that edge is not defined in the schema.
  8536. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8537. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8538. }
  8539. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8540. // It returns an error if the edge is not defined in the schema.
  8541. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8542. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8543. }
  8544. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8545. type ChatSessionMutation struct {
  8546. config
  8547. op Op
  8548. typ string
  8549. id *uint64
  8550. created_at *time.Time
  8551. updated_at *time.Time
  8552. deleted_at *time.Time
  8553. name *string
  8554. user_id *uint64
  8555. adduser_id *int64
  8556. bot_id *uint64
  8557. addbot_id *int64
  8558. bot_type *uint8
  8559. addbot_type *int8
  8560. clearedFields map[string]struct{}
  8561. done bool
  8562. oldValue func(context.Context) (*ChatSession, error)
  8563. predicates []predicate.ChatSession
  8564. }
  8565. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8566. // chatsessionOption allows management of the mutation configuration using functional options.
  8567. type chatsessionOption func(*ChatSessionMutation)
  8568. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8569. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8570. m := &ChatSessionMutation{
  8571. config: c,
  8572. op: op,
  8573. typ: TypeChatSession,
  8574. clearedFields: make(map[string]struct{}),
  8575. }
  8576. for _, opt := range opts {
  8577. opt(m)
  8578. }
  8579. return m
  8580. }
  8581. // withChatSessionID sets the ID field of the mutation.
  8582. func withChatSessionID(id uint64) chatsessionOption {
  8583. return func(m *ChatSessionMutation) {
  8584. var (
  8585. err error
  8586. once sync.Once
  8587. value *ChatSession
  8588. )
  8589. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8590. once.Do(func() {
  8591. if m.done {
  8592. err = errors.New("querying old values post mutation is not allowed")
  8593. } else {
  8594. value, err = m.Client().ChatSession.Get(ctx, id)
  8595. }
  8596. })
  8597. return value, err
  8598. }
  8599. m.id = &id
  8600. }
  8601. }
  8602. // withChatSession sets the old ChatSession of the mutation.
  8603. func withChatSession(node *ChatSession) chatsessionOption {
  8604. return func(m *ChatSessionMutation) {
  8605. m.oldValue = func(context.Context) (*ChatSession, error) {
  8606. return node, nil
  8607. }
  8608. m.id = &node.ID
  8609. }
  8610. }
  8611. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8612. // executed in a transaction (ent.Tx), a transactional client is returned.
  8613. func (m ChatSessionMutation) Client() *Client {
  8614. client := &Client{config: m.config}
  8615. client.init()
  8616. return client
  8617. }
  8618. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8619. // it returns an error otherwise.
  8620. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8621. if _, ok := m.driver.(*txDriver); !ok {
  8622. return nil, errors.New("ent: mutation is not running in a transaction")
  8623. }
  8624. tx := &Tx{config: m.config}
  8625. tx.init()
  8626. return tx, nil
  8627. }
  8628. // SetID sets the value of the id field. Note that this
  8629. // operation is only accepted on creation of ChatSession entities.
  8630. func (m *ChatSessionMutation) SetID(id uint64) {
  8631. m.id = &id
  8632. }
  8633. // ID returns the ID value in the mutation. Note that the ID is only available
  8634. // if it was provided to the builder or after it was returned from the database.
  8635. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8636. if m.id == nil {
  8637. return
  8638. }
  8639. return *m.id, true
  8640. }
  8641. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8642. // That means, if the mutation is applied within a transaction with an isolation level such
  8643. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8644. // or updated by the mutation.
  8645. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8646. switch {
  8647. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8648. id, exists := m.ID()
  8649. if exists {
  8650. return []uint64{id}, nil
  8651. }
  8652. fallthrough
  8653. case m.op.Is(OpUpdate | OpDelete):
  8654. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8655. default:
  8656. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8657. }
  8658. }
  8659. // SetCreatedAt sets the "created_at" field.
  8660. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8661. m.created_at = &t
  8662. }
  8663. // CreatedAt returns the value of the "created_at" field in the mutation.
  8664. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8665. v := m.created_at
  8666. if v == nil {
  8667. return
  8668. }
  8669. return *v, true
  8670. }
  8671. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8672. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8674. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8675. if !m.op.Is(OpUpdateOne) {
  8676. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8677. }
  8678. if m.id == nil || m.oldValue == nil {
  8679. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8680. }
  8681. oldValue, err := m.oldValue(ctx)
  8682. if err != nil {
  8683. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8684. }
  8685. return oldValue.CreatedAt, nil
  8686. }
  8687. // ResetCreatedAt resets all changes to the "created_at" field.
  8688. func (m *ChatSessionMutation) ResetCreatedAt() {
  8689. m.created_at = nil
  8690. }
  8691. // SetUpdatedAt sets the "updated_at" field.
  8692. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8693. m.updated_at = &t
  8694. }
  8695. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8696. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8697. v := m.updated_at
  8698. if v == nil {
  8699. return
  8700. }
  8701. return *v, true
  8702. }
  8703. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8704. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8706. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8707. if !m.op.Is(OpUpdateOne) {
  8708. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8709. }
  8710. if m.id == nil || m.oldValue == nil {
  8711. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8712. }
  8713. oldValue, err := m.oldValue(ctx)
  8714. if err != nil {
  8715. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8716. }
  8717. return oldValue.UpdatedAt, nil
  8718. }
  8719. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8720. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8721. m.updated_at = nil
  8722. }
  8723. // SetDeletedAt sets the "deleted_at" field.
  8724. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8725. m.deleted_at = &t
  8726. }
  8727. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8728. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8729. v := m.deleted_at
  8730. if v == nil {
  8731. return
  8732. }
  8733. return *v, true
  8734. }
  8735. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8736. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8738. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8739. if !m.op.Is(OpUpdateOne) {
  8740. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8741. }
  8742. if m.id == nil || m.oldValue == nil {
  8743. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8744. }
  8745. oldValue, err := m.oldValue(ctx)
  8746. if err != nil {
  8747. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8748. }
  8749. return oldValue.DeletedAt, nil
  8750. }
  8751. // ClearDeletedAt clears the value of the "deleted_at" field.
  8752. func (m *ChatSessionMutation) ClearDeletedAt() {
  8753. m.deleted_at = nil
  8754. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8755. }
  8756. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8757. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8758. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8759. return ok
  8760. }
  8761. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8762. func (m *ChatSessionMutation) ResetDeletedAt() {
  8763. m.deleted_at = nil
  8764. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8765. }
  8766. // SetName sets the "name" field.
  8767. func (m *ChatSessionMutation) SetName(s string) {
  8768. m.name = &s
  8769. }
  8770. // Name returns the value of the "name" field in the mutation.
  8771. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8772. v := m.name
  8773. if v == nil {
  8774. return
  8775. }
  8776. return *v, true
  8777. }
  8778. // OldName returns the old "name" field's value of the ChatSession entity.
  8779. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8781. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8782. if !m.op.Is(OpUpdateOne) {
  8783. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8784. }
  8785. if m.id == nil || m.oldValue == nil {
  8786. return v, errors.New("OldName requires an ID field in the mutation")
  8787. }
  8788. oldValue, err := m.oldValue(ctx)
  8789. if err != nil {
  8790. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8791. }
  8792. return oldValue.Name, nil
  8793. }
  8794. // ResetName resets all changes to the "name" field.
  8795. func (m *ChatSessionMutation) ResetName() {
  8796. m.name = nil
  8797. }
  8798. // SetUserID sets the "user_id" field.
  8799. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8800. m.user_id = &u
  8801. m.adduser_id = nil
  8802. }
  8803. // UserID returns the value of the "user_id" field in the mutation.
  8804. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8805. v := m.user_id
  8806. if v == nil {
  8807. return
  8808. }
  8809. return *v, true
  8810. }
  8811. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8812. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8814. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8815. if !m.op.Is(OpUpdateOne) {
  8816. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8817. }
  8818. if m.id == nil || m.oldValue == nil {
  8819. return v, errors.New("OldUserID requires an ID field in the mutation")
  8820. }
  8821. oldValue, err := m.oldValue(ctx)
  8822. if err != nil {
  8823. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8824. }
  8825. return oldValue.UserID, nil
  8826. }
  8827. // AddUserID adds u to the "user_id" field.
  8828. func (m *ChatSessionMutation) AddUserID(u int64) {
  8829. if m.adduser_id != nil {
  8830. *m.adduser_id += u
  8831. } else {
  8832. m.adduser_id = &u
  8833. }
  8834. }
  8835. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8836. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8837. v := m.adduser_id
  8838. if v == nil {
  8839. return
  8840. }
  8841. return *v, true
  8842. }
  8843. // ResetUserID resets all changes to the "user_id" field.
  8844. func (m *ChatSessionMutation) ResetUserID() {
  8845. m.user_id = nil
  8846. m.adduser_id = nil
  8847. }
  8848. // SetBotID sets the "bot_id" field.
  8849. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8850. m.bot_id = &u
  8851. m.addbot_id = nil
  8852. }
  8853. // BotID returns the value of the "bot_id" field in the mutation.
  8854. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8855. v := m.bot_id
  8856. if v == nil {
  8857. return
  8858. }
  8859. return *v, true
  8860. }
  8861. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8862. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8864. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8865. if !m.op.Is(OpUpdateOne) {
  8866. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8867. }
  8868. if m.id == nil || m.oldValue == nil {
  8869. return v, errors.New("OldBotID requires an ID field in the mutation")
  8870. }
  8871. oldValue, err := m.oldValue(ctx)
  8872. if err != nil {
  8873. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8874. }
  8875. return oldValue.BotID, nil
  8876. }
  8877. // AddBotID adds u to the "bot_id" field.
  8878. func (m *ChatSessionMutation) AddBotID(u int64) {
  8879. if m.addbot_id != nil {
  8880. *m.addbot_id += u
  8881. } else {
  8882. m.addbot_id = &u
  8883. }
  8884. }
  8885. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8886. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8887. v := m.addbot_id
  8888. if v == nil {
  8889. return
  8890. }
  8891. return *v, true
  8892. }
  8893. // ResetBotID resets all changes to the "bot_id" field.
  8894. func (m *ChatSessionMutation) ResetBotID() {
  8895. m.bot_id = nil
  8896. m.addbot_id = nil
  8897. }
  8898. // SetBotType sets the "bot_type" field.
  8899. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8900. m.bot_type = &u
  8901. m.addbot_type = nil
  8902. }
  8903. // BotType returns the value of the "bot_type" field in the mutation.
  8904. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8905. v := m.bot_type
  8906. if v == nil {
  8907. return
  8908. }
  8909. return *v, true
  8910. }
  8911. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8912. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8914. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8915. if !m.op.Is(OpUpdateOne) {
  8916. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8917. }
  8918. if m.id == nil || m.oldValue == nil {
  8919. return v, errors.New("OldBotType requires an ID field in the mutation")
  8920. }
  8921. oldValue, err := m.oldValue(ctx)
  8922. if err != nil {
  8923. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8924. }
  8925. return oldValue.BotType, nil
  8926. }
  8927. // AddBotType adds u to the "bot_type" field.
  8928. func (m *ChatSessionMutation) AddBotType(u int8) {
  8929. if m.addbot_type != nil {
  8930. *m.addbot_type += u
  8931. } else {
  8932. m.addbot_type = &u
  8933. }
  8934. }
  8935. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8936. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8937. v := m.addbot_type
  8938. if v == nil {
  8939. return
  8940. }
  8941. return *v, true
  8942. }
  8943. // ResetBotType resets all changes to the "bot_type" field.
  8944. func (m *ChatSessionMutation) ResetBotType() {
  8945. m.bot_type = nil
  8946. m.addbot_type = nil
  8947. }
  8948. // Where appends a list predicates to the ChatSessionMutation builder.
  8949. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8950. m.predicates = append(m.predicates, ps...)
  8951. }
  8952. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8953. // users can use type-assertion to append predicates that do not depend on any generated package.
  8954. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8955. p := make([]predicate.ChatSession, len(ps))
  8956. for i := range ps {
  8957. p[i] = ps[i]
  8958. }
  8959. m.Where(p...)
  8960. }
  8961. // Op returns the operation name.
  8962. func (m *ChatSessionMutation) Op() Op {
  8963. return m.op
  8964. }
  8965. // SetOp allows setting the mutation operation.
  8966. func (m *ChatSessionMutation) SetOp(op Op) {
  8967. m.op = op
  8968. }
  8969. // Type returns the node type of this mutation (ChatSession).
  8970. func (m *ChatSessionMutation) Type() string {
  8971. return m.typ
  8972. }
  8973. // Fields returns all fields that were changed during this mutation. Note that in
  8974. // order to get all numeric fields that were incremented/decremented, call
  8975. // AddedFields().
  8976. func (m *ChatSessionMutation) Fields() []string {
  8977. fields := make([]string, 0, 7)
  8978. if m.created_at != nil {
  8979. fields = append(fields, chatsession.FieldCreatedAt)
  8980. }
  8981. if m.updated_at != nil {
  8982. fields = append(fields, chatsession.FieldUpdatedAt)
  8983. }
  8984. if m.deleted_at != nil {
  8985. fields = append(fields, chatsession.FieldDeletedAt)
  8986. }
  8987. if m.name != nil {
  8988. fields = append(fields, chatsession.FieldName)
  8989. }
  8990. if m.user_id != nil {
  8991. fields = append(fields, chatsession.FieldUserID)
  8992. }
  8993. if m.bot_id != nil {
  8994. fields = append(fields, chatsession.FieldBotID)
  8995. }
  8996. if m.bot_type != nil {
  8997. fields = append(fields, chatsession.FieldBotType)
  8998. }
  8999. return fields
  9000. }
  9001. // Field returns the value of a field with the given name. The second boolean
  9002. // return value indicates that this field was not set, or was not defined in the
  9003. // schema.
  9004. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9005. switch name {
  9006. case chatsession.FieldCreatedAt:
  9007. return m.CreatedAt()
  9008. case chatsession.FieldUpdatedAt:
  9009. return m.UpdatedAt()
  9010. case chatsession.FieldDeletedAt:
  9011. return m.DeletedAt()
  9012. case chatsession.FieldName:
  9013. return m.Name()
  9014. case chatsession.FieldUserID:
  9015. return m.UserID()
  9016. case chatsession.FieldBotID:
  9017. return m.BotID()
  9018. case chatsession.FieldBotType:
  9019. return m.BotType()
  9020. }
  9021. return nil, false
  9022. }
  9023. // OldField returns the old value of the field from the database. An error is
  9024. // returned if the mutation operation is not UpdateOne, or the query to the
  9025. // database failed.
  9026. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9027. switch name {
  9028. case chatsession.FieldCreatedAt:
  9029. return m.OldCreatedAt(ctx)
  9030. case chatsession.FieldUpdatedAt:
  9031. return m.OldUpdatedAt(ctx)
  9032. case chatsession.FieldDeletedAt:
  9033. return m.OldDeletedAt(ctx)
  9034. case chatsession.FieldName:
  9035. return m.OldName(ctx)
  9036. case chatsession.FieldUserID:
  9037. return m.OldUserID(ctx)
  9038. case chatsession.FieldBotID:
  9039. return m.OldBotID(ctx)
  9040. case chatsession.FieldBotType:
  9041. return m.OldBotType(ctx)
  9042. }
  9043. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9044. }
  9045. // SetField sets the value of a field with the given name. It returns an error if
  9046. // the field is not defined in the schema, or if the type mismatched the field
  9047. // type.
  9048. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9049. switch name {
  9050. case chatsession.FieldCreatedAt:
  9051. v, ok := value.(time.Time)
  9052. if !ok {
  9053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9054. }
  9055. m.SetCreatedAt(v)
  9056. return nil
  9057. case chatsession.FieldUpdatedAt:
  9058. v, ok := value.(time.Time)
  9059. if !ok {
  9060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9061. }
  9062. m.SetUpdatedAt(v)
  9063. return nil
  9064. case chatsession.FieldDeletedAt:
  9065. v, ok := value.(time.Time)
  9066. if !ok {
  9067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9068. }
  9069. m.SetDeletedAt(v)
  9070. return nil
  9071. case chatsession.FieldName:
  9072. v, ok := value.(string)
  9073. if !ok {
  9074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9075. }
  9076. m.SetName(v)
  9077. return nil
  9078. case chatsession.FieldUserID:
  9079. v, ok := value.(uint64)
  9080. if !ok {
  9081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9082. }
  9083. m.SetUserID(v)
  9084. return nil
  9085. case chatsession.FieldBotID:
  9086. v, ok := value.(uint64)
  9087. if !ok {
  9088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9089. }
  9090. m.SetBotID(v)
  9091. return nil
  9092. case chatsession.FieldBotType:
  9093. v, ok := value.(uint8)
  9094. if !ok {
  9095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9096. }
  9097. m.SetBotType(v)
  9098. return nil
  9099. }
  9100. return fmt.Errorf("unknown ChatSession field %s", name)
  9101. }
  9102. // AddedFields returns all numeric fields that were incremented/decremented during
  9103. // this mutation.
  9104. func (m *ChatSessionMutation) AddedFields() []string {
  9105. var fields []string
  9106. if m.adduser_id != nil {
  9107. fields = append(fields, chatsession.FieldUserID)
  9108. }
  9109. if m.addbot_id != nil {
  9110. fields = append(fields, chatsession.FieldBotID)
  9111. }
  9112. if m.addbot_type != nil {
  9113. fields = append(fields, chatsession.FieldBotType)
  9114. }
  9115. return fields
  9116. }
  9117. // AddedField returns the numeric value that was incremented/decremented on a field
  9118. // with the given name. The second boolean return value indicates that this field
  9119. // was not set, or was not defined in the schema.
  9120. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9121. switch name {
  9122. case chatsession.FieldUserID:
  9123. return m.AddedUserID()
  9124. case chatsession.FieldBotID:
  9125. return m.AddedBotID()
  9126. case chatsession.FieldBotType:
  9127. return m.AddedBotType()
  9128. }
  9129. return nil, false
  9130. }
  9131. // AddField adds the value to the field with the given name. It returns an error if
  9132. // the field is not defined in the schema, or if the type mismatched the field
  9133. // type.
  9134. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9135. switch name {
  9136. case chatsession.FieldUserID:
  9137. v, ok := value.(int64)
  9138. if !ok {
  9139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9140. }
  9141. m.AddUserID(v)
  9142. return nil
  9143. case chatsession.FieldBotID:
  9144. v, ok := value.(int64)
  9145. if !ok {
  9146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9147. }
  9148. m.AddBotID(v)
  9149. return nil
  9150. case chatsession.FieldBotType:
  9151. v, ok := value.(int8)
  9152. if !ok {
  9153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9154. }
  9155. m.AddBotType(v)
  9156. return nil
  9157. }
  9158. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9159. }
  9160. // ClearedFields returns all nullable fields that were cleared during this
  9161. // mutation.
  9162. func (m *ChatSessionMutation) ClearedFields() []string {
  9163. var fields []string
  9164. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9165. fields = append(fields, chatsession.FieldDeletedAt)
  9166. }
  9167. return fields
  9168. }
  9169. // FieldCleared returns a boolean indicating if a field with the given name was
  9170. // cleared in this mutation.
  9171. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9172. _, ok := m.clearedFields[name]
  9173. return ok
  9174. }
  9175. // ClearField clears the value of the field with the given name. It returns an
  9176. // error if the field is not defined in the schema.
  9177. func (m *ChatSessionMutation) ClearField(name string) error {
  9178. switch name {
  9179. case chatsession.FieldDeletedAt:
  9180. m.ClearDeletedAt()
  9181. return nil
  9182. }
  9183. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9184. }
  9185. // ResetField resets all changes in the mutation for the field with the given name.
  9186. // It returns an error if the field is not defined in the schema.
  9187. func (m *ChatSessionMutation) ResetField(name string) error {
  9188. switch name {
  9189. case chatsession.FieldCreatedAt:
  9190. m.ResetCreatedAt()
  9191. return nil
  9192. case chatsession.FieldUpdatedAt:
  9193. m.ResetUpdatedAt()
  9194. return nil
  9195. case chatsession.FieldDeletedAt:
  9196. m.ResetDeletedAt()
  9197. return nil
  9198. case chatsession.FieldName:
  9199. m.ResetName()
  9200. return nil
  9201. case chatsession.FieldUserID:
  9202. m.ResetUserID()
  9203. return nil
  9204. case chatsession.FieldBotID:
  9205. m.ResetBotID()
  9206. return nil
  9207. case chatsession.FieldBotType:
  9208. m.ResetBotType()
  9209. return nil
  9210. }
  9211. return fmt.Errorf("unknown ChatSession field %s", name)
  9212. }
  9213. // AddedEdges returns all edge names that were set/added in this mutation.
  9214. func (m *ChatSessionMutation) AddedEdges() []string {
  9215. edges := make([]string, 0, 0)
  9216. return edges
  9217. }
  9218. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9219. // name in this mutation.
  9220. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9221. return nil
  9222. }
  9223. // RemovedEdges returns all edge names that were removed in this mutation.
  9224. func (m *ChatSessionMutation) RemovedEdges() []string {
  9225. edges := make([]string, 0, 0)
  9226. return edges
  9227. }
  9228. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9229. // the given name in this mutation.
  9230. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9231. return nil
  9232. }
  9233. // ClearedEdges returns all edge names that were cleared in this mutation.
  9234. func (m *ChatSessionMutation) ClearedEdges() []string {
  9235. edges := make([]string, 0, 0)
  9236. return edges
  9237. }
  9238. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9239. // was cleared in this mutation.
  9240. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9241. return false
  9242. }
  9243. // ClearEdge clears the value of the edge with the given name. It returns an error
  9244. // if that edge is not defined in the schema.
  9245. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9246. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9247. }
  9248. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9249. // It returns an error if the edge is not defined in the schema.
  9250. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9251. return fmt.Errorf("unknown ChatSession edge %s", name)
  9252. }
  9253. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9254. type ContactMutation struct {
  9255. config
  9256. op Op
  9257. typ string
  9258. id *uint64
  9259. created_at *time.Time
  9260. updated_at *time.Time
  9261. status *uint8
  9262. addstatus *int8
  9263. deleted_at *time.Time
  9264. wx_wxid *string
  9265. _type *int
  9266. add_type *int
  9267. wxid *string
  9268. account *string
  9269. nickname *string
  9270. markname *string
  9271. headimg *string
  9272. sex *int
  9273. addsex *int
  9274. starrole *string
  9275. dontseeit *int
  9276. adddontseeit *int
  9277. dontseeme *int
  9278. adddontseeme *int
  9279. lag *string
  9280. gid *string
  9281. gname *string
  9282. v3 *string
  9283. organization_id *uint64
  9284. addorganization_id *int64
  9285. ctype *uint64
  9286. addctype *int64
  9287. cage *int
  9288. addcage *int
  9289. cname *string
  9290. carea *string
  9291. cbirthday *string
  9292. cbirtharea *string
  9293. cidcard_no *string
  9294. ctitle *string
  9295. cc *string
  9296. phone *string
  9297. clearedFields map[string]struct{}
  9298. contact_relationships map[uint64]struct{}
  9299. removedcontact_relationships map[uint64]struct{}
  9300. clearedcontact_relationships bool
  9301. contact_messages map[uint64]struct{}
  9302. removedcontact_messages map[uint64]struct{}
  9303. clearedcontact_messages bool
  9304. done bool
  9305. oldValue func(context.Context) (*Contact, error)
  9306. predicates []predicate.Contact
  9307. }
  9308. var _ ent.Mutation = (*ContactMutation)(nil)
  9309. // contactOption allows management of the mutation configuration using functional options.
  9310. type contactOption func(*ContactMutation)
  9311. // newContactMutation creates new mutation for the Contact entity.
  9312. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9313. m := &ContactMutation{
  9314. config: c,
  9315. op: op,
  9316. typ: TypeContact,
  9317. clearedFields: make(map[string]struct{}),
  9318. }
  9319. for _, opt := range opts {
  9320. opt(m)
  9321. }
  9322. return m
  9323. }
  9324. // withContactID sets the ID field of the mutation.
  9325. func withContactID(id uint64) contactOption {
  9326. return func(m *ContactMutation) {
  9327. var (
  9328. err error
  9329. once sync.Once
  9330. value *Contact
  9331. )
  9332. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9333. once.Do(func() {
  9334. if m.done {
  9335. err = errors.New("querying old values post mutation is not allowed")
  9336. } else {
  9337. value, err = m.Client().Contact.Get(ctx, id)
  9338. }
  9339. })
  9340. return value, err
  9341. }
  9342. m.id = &id
  9343. }
  9344. }
  9345. // withContact sets the old Contact of the mutation.
  9346. func withContact(node *Contact) contactOption {
  9347. return func(m *ContactMutation) {
  9348. m.oldValue = func(context.Context) (*Contact, error) {
  9349. return node, nil
  9350. }
  9351. m.id = &node.ID
  9352. }
  9353. }
  9354. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9355. // executed in a transaction (ent.Tx), a transactional client is returned.
  9356. func (m ContactMutation) Client() *Client {
  9357. client := &Client{config: m.config}
  9358. client.init()
  9359. return client
  9360. }
  9361. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9362. // it returns an error otherwise.
  9363. func (m ContactMutation) Tx() (*Tx, error) {
  9364. if _, ok := m.driver.(*txDriver); !ok {
  9365. return nil, errors.New("ent: mutation is not running in a transaction")
  9366. }
  9367. tx := &Tx{config: m.config}
  9368. tx.init()
  9369. return tx, nil
  9370. }
  9371. // SetID sets the value of the id field. Note that this
  9372. // operation is only accepted on creation of Contact entities.
  9373. func (m *ContactMutation) SetID(id uint64) {
  9374. m.id = &id
  9375. }
  9376. // ID returns the ID value in the mutation. Note that the ID is only available
  9377. // if it was provided to the builder or after it was returned from the database.
  9378. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9379. if m.id == nil {
  9380. return
  9381. }
  9382. return *m.id, true
  9383. }
  9384. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9385. // That means, if the mutation is applied within a transaction with an isolation level such
  9386. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9387. // or updated by the mutation.
  9388. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9389. switch {
  9390. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9391. id, exists := m.ID()
  9392. if exists {
  9393. return []uint64{id}, nil
  9394. }
  9395. fallthrough
  9396. case m.op.Is(OpUpdate | OpDelete):
  9397. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9398. default:
  9399. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9400. }
  9401. }
  9402. // SetCreatedAt sets the "created_at" field.
  9403. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9404. m.created_at = &t
  9405. }
  9406. // CreatedAt returns the value of the "created_at" field in the mutation.
  9407. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9408. v := m.created_at
  9409. if v == nil {
  9410. return
  9411. }
  9412. return *v, true
  9413. }
  9414. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9415. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9417. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9418. if !m.op.Is(OpUpdateOne) {
  9419. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9420. }
  9421. if m.id == nil || m.oldValue == nil {
  9422. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9423. }
  9424. oldValue, err := m.oldValue(ctx)
  9425. if err != nil {
  9426. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9427. }
  9428. return oldValue.CreatedAt, nil
  9429. }
  9430. // ResetCreatedAt resets all changes to the "created_at" field.
  9431. func (m *ContactMutation) ResetCreatedAt() {
  9432. m.created_at = nil
  9433. }
  9434. // SetUpdatedAt sets the "updated_at" field.
  9435. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9436. m.updated_at = &t
  9437. }
  9438. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9439. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9440. v := m.updated_at
  9441. if v == nil {
  9442. return
  9443. }
  9444. return *v, true
  9445. }
  9446. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9447. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9449. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9450. if !m.op.Is(OpUpdateOne) {
  9451. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9452. }
  9453. if m.id == nil || m.oldValue == nil {
  9454. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9455. }
  9456. oldValue, err := m.oldValue(ctx)
  9457. if err != nil {
  9458. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9459. }
  9460. return oldValue.UpdatedAt, nil
  9461. }
  9462. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9463. func (m *ContactMutation) ResetUpdatedAt() {
  9464. m.updated_at = nil
  9465. }
  9466. // SetStatus sets the "status" field.
  9467. func (m *ContactMutation) SetStatus(u uint8) {
  9468. m.status = &u
  9469. m.addstatus = nil
  9470. }
  9471. // Status returns the value of the "status" field in the mutation.
  9472. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9473. v := m.status
  9474. if v == nil {
  9475. return
  9476. }
  9477. return *v, true
  9478. }
  9479. // OldStatus returns the old "status" field's value of the Contact entity.
  9480. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9482. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9483. if !m.op.Is(OpUpdateOne) {
  9484. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9485. }
  9486. if m.id == nil || m.oldValue == nil {
  9487. return v, errors.New("OldStatus requires an ID field in the mutation")
  9488. }
  9489. oldValue, err := m.oldValue(ctx)
  9490. if err != nil {
  9491. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9492. }
  9493. return oldValue.Status, nil
  9494. }
  9495. // AddStatus adds u to the "status" field.
  9496. func (m *ContactMutation) AddStatus(u int8) {
  9497. if m.addstatus != nil {
  9498. *m.addstatus += u
  9499. } else {
  9500. m.addstatus = &u
  9501. }
  9502. }
  9503. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9504. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9505. v := m.addstatus
  9506. if v == nil {
  9507. return
  9508. }
  9509. return *v, true
  9510. }
  9511. // ClearStatus clears the value of the "status" field.
  9512. func (m *ContactMutation) ClearStatus() {
  9513. m.status = nil
  9514. m.addstatus = nil
  9515. m.clearedFields[contact.FieldStatus] = struct{}{}
  9516. }
  9517. // StatusCleared returns if the "status" field was cleared in this mutation.
  9518. func (m *ContactMutation) StatusCleared() bool {
  9519. _, ok := m.clearedFields[contact.FieldStatus]
  9520. return ok
  9521. }
  9522. // ResetStatus resets all changes to the "status" field.
  9523. func (m *ContactMutation) ResetStatus() {
  9524. m.status = nil
  9525. m.addstatus = nil
  9526. delete(m.clearedFields, contact.FieldStatus)
  9527. }
  9528. // SetDeletedAt sets the "deleted_at" field.
  9529. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9530. m.deleted_at = &t
  9531. }
  9532. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9533. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9534. v := m.deleted_at
  9535. if v == nil {
  9536. return
  9537. }
  9538. return *v, true
  9539. }
  9540. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9541. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9543. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9544. if !m.op.Is(OpUpdateOne) {
  9545. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9546. }
  9547. if m.id == nil || m.oldValue == nil {
  9548. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9549. }
  9550. oldValue, err := m.oldValue(ctx)
  9551. if err != nil {
  9552. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9553. }
  9554. return oldValue.DeletedAt, nil
  9555. }
  9556. // ClearDeletedAt clears the value of the "deleted_at" field.
  9557. func (m *ContactMutation) ClearDeletedAt() {
  9558. m.deleted_at = nil
  9559. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9560. }
  9561. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9562. func (m *ContactMutation) DeletedAtCleared() bool {
  9563. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9564. return ok
  9565. }
  9566. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9567. func (m *ContactMutation) ResetDeletedAt() {
  9568. m.deleted_at = nil
  9569. delete(m.clearedFields, contact.FieldDeletedAt)
  9570. }
  9571. // SetWxWxid sets the "wx_wxid" field.
  9572. func (m *ContactMutation) SetWxWxid(s string) {
  9573. m.wx_wxid = &s
  9574. }
  9575. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9576. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9577. v := m.wx_wxid
  9578. if v == nil {
  9579. return
  9580. }
  9581. return *v, true
  9582. }
  9583. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9584. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9586. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9587. if !m.op.Is(OpUpdateOne) {
  9588. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9589. }
  9590. if m.id == nil || m.oldValue == nil {
  9591. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9592. }
  9593. oldValue, err := m.oldValue(ctx)
  9594. if err != nil {
  9595. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9596. }
  9597. return oldValue.WxWxid, nil
  9598. }
  9599. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9600. func (m *ContactMutation) ResetWxWxid() {
  9601. m.wx_wxid = nil
  9602. }
  9603. // SetType sets the "type" field.
  9604. func (m *ContactMutation) SetType(i int) {
  9605. m._type = &i
  9606. m.add_type = nil
  9607. }
  9608. // GetType returns the value of the "type" field in the mutation.
  9609. func (m *ContactMutation) GetType() (r int, exists bool) {
  9610. v := m._type
  9611. if v == nil {
  9612. return
  9613. }
  9614. return *v, true
  9615. }
  9616. // OldType returns the old "type" field's value of the Contact entity.
  9617. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9619. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9620. if !m.op.Is(OpUpdateOne) {
  9621. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9622. }
  9623. if m.id == nil || m.oldValue == nil {
  9624. return v, errors.New("OldType requires an ID field in the mutation")
  9625. }
  9626. oldValue, err := m.oldValue(ctx)
  9627. if err != nil {
  9628. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9629. }
  9630. return oldValue.Type, nil
  9631. }
  9632. // AddType adds i to the "type" field.
  9633. func (m *ContactMutation) AddType(i int) {
  9634. if m.add_type != nil {
  9635. *m.add_type += i
  9636. } else {
  9637. m.add_type = &i
  9638. }
  9639. }
  9640. // AddedType returns the value that was added to the "type" field in this mutation.
  9641. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9642. v := m.add_type
  9643. if v == nil {
  9644. return
  9645. }
  9646. return *v, true
  9647. }
  9648. // ClearType clears the value of the "type" field.
  9649. func (m *ContactMutation) ClearType() {
  9650. m._type = nil
  9651. m.add_type = nil
  9652. m.clearedFields[contact.FieldType] = struct{}{}
  9653. }
  9654. // TypeCleared returns if the "type" field was cleared in this mutation.
  9655. func (m *ContactMutation) TypeCleared() bool {
  9656. _, ok := m.clearedFields[contact.FieldType]
  9657. return ok
  9658. }
  9659. // ResetType resets all changes to the "type" field.
  9660. func (m *ContactMutation) ResetType() {
  9661. m._type = nil
  9662. m.add_type = nil
  9663. delete(m.clearedFields, contact.FieldType)
  9664. }
  9665. // SetWxid sets the "wxid" field.
  9666. func (m *ContactMutation) SetWxid(s string) {
  9667. m.wxid = &s
  9668. }
  9669. // Wxid returns the value of the "wxid" field in the mutation.
  9670. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9671. v := m.wxid
  9672. if v == nil {
  9673. return
  9674. }
  9675. return *v, true
  9676. }
  9677. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9678. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9680. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9681. if !m.op.Is(OpUpdateOne) {
  9682. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9683. }
  9684. if m.id == nil || m.oldValue == nil {
  9685. return v, errors.New("OldWxid requires an ID field in the mutation")
  9686. }
  9687. oldValue, err := m.oldValue(ctx)
  9688. if err != nil {
  9689. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9690. }
  9691. return oldValue.Wxid, nil
  9692. }
  9693. // ResetWxid resets all changes to the "wxid" field.
  9694. func (m *ContactMutation) ResetWxid() {
  9695. m.wxid = nil
  9696. }
  9697. // SetAccount sets the "account" field.
  9698. func (m *ContactMutation) SetAccount(s string) {
  9699. m.account = &s
  9700. }
  9701. // Account returns the value of the "account" field in the mutation.
  9702. func (m *ContactMutation) Account() (r string, exists bool) {
  9703. v := m.account
  9704. if v == nil {
  9705. return
  9706. }
  9707. return *v, true
  9708. }
  9709. // OldAccount returns the old "account" field's value of the Contact entity.
  9710. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9712. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9713. if !m.op.Is(OpUpdateOne) {
  9714. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9715. }
  9716. if m.id == nil || m.oldValue == nil {
  9717. return v, errors.New("OldAccount requires an ID field in the mutation")
  9718. }
  9719. oldValue, err := m.oldValue(ctx)
  9720. if err != nil {
  9721. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9722. }
  9723. return oldValue.Account, nil
  9724. }
  9725. // ResetAccount resets all changes to the "account" field.
  9726. func (m *ContactMutation) ResetAccount() {
  9727. m.account = nil
  9728. }
  9729. // SetNickname sets the "nickname" field.
  9730. func (m *ContactMutation) SetNickname(s string) {
  9731. m.nickname = &s
  9732. }
  9733. // Nickname returns the value of the "nickname" field in the mutation.
  9734. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9735. v := m.nickname
  9736. if v == nil {
  9737. return
  9738. }
  9739. return *v, true
  9740. }
  9741. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9742. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9744. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9745. if !m.op.Is(OpUpdateOne) {
  9746. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9747. }
  9748. if m.id == nil || m.oldValue == nil {
  9749. return v, errors.New("OldNickname requires an ID field in the mutation")
  9750. }
  9751. oldValue, err := m.oldValue(ctx)
  9752. if err != nil {
  9753. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9754. }
  9755. return oldValue.Nickname, nil
  9756. }
  9757. // ResetNickname resets all changes to the "nickname" field.
  9758. func (m *ContactMutation) ResetNickname() {
  9759. m.nickname = nil
  9760. }
  9761. // SetMarkname sets the "markname" field.
  9762. func (m *ContactMutation) SetMarkname(s string) {
  9763. m.markname = &s
  9764. }
  9765. // Markname returns the value of the "markname" field in the mutation.
  9766. func (m *ContactMutation) Markname() (r string, exists bool) {
  9767. v := m.markname
  9768. if v == nil {
  9769. return
  9770. }
  9771. return *v, true
  9772. }
  9773. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9774. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9776. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9777. if !m.op.Is(OpUpdateOne) {
  9778. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9779. }
  9780. if m.id == nil || m.oldValue == nil {
  9781. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9782. }
  9783. oldValue, err := m.oldValue(ctx)
  9784. if err != nil {
  9785. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9786. }
  9787. return oldValue.Markname, nil
  9788. }
  9789. // ResetMarkname resets all changes to the "markname" field.
  9790. func (m *ContactMutation) ResetMarkname() {
  9791. m.markname = nil
  9792. }
  9793. // SetHeadimg sets the "headimg" field.
  9794. func (m *ContactMutation) SetHeadimg(s string) {
  9795. m.headimg = &s
  9796. }
  9797. // Headimg returns the value of the "headimg" field in the mutation.
  9798. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9799. v := m.headimg
  9800. if v == nil {
  9801. return
  9802. }
  9803. return *v, true
  9804. }
  9805. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9806. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9808. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9809. if !m.op.Is(OpUpdateOne) {
  9810. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9811. }
  9812. if m.id == nil || m.oldValue == nil {
  9813. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9814. }
  9815. oldValue, err := m.oldValue(ctx)
  9816. if err != nil {
  9817. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9818. }
  9819. return oldValue.Headimg, nil
  9820. }
  9821. // ResetHeadimg resets all changes to the "headimg" field.
  9822. func (m *ContactMutation) ResetHeadimg() {
  9823. m.headimg = nil
  9824. }
  9825. // SetSex sets the "sex" field.
  9826. func (m *ContactMutation) SetSex(i int) {
  9827. m.sex = &i
  9828. m.addsex = nil
  9829. }
  9830. // Sex returns the value of the "sex" field in the mutation.
  9831. func (m *ContactMutation) Sex() (r int, exists bool) {
  9832. v := m.sex
  9833. if v == nil {
  9834. return
  9835. }
  9836. return *v, true
  9837. }
  9838. // OldSex returns the old "sex" field's value of the Contact entity.
  9839. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9841. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9842. if !m.op.Is(OpUpdateOne) {
  9843. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9844. }
  9845. if m.id == nil || m.oldValue == nil {
  9846. return v, errors.New("OldSex requires an ID field in the mutation")
  9847. }
  9848. oldValue, err := m.oldValue(ctx)
  9849. if err != nil {
  9850. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9851. }
  9852. return oldValue.Sex, nil
  9853. }
  9854. // AddSex adds i to the "sex" field.
  9855. func (m *ContactMutation) AddSex(i int) {
  9856. if m.addsex != nil {
  9857. *m.addsex += i
  9858. } else {
  9859. m.addsex = &i
  9860. }
  9861. }
  9862. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9863. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9864. v := m.addsex
  9865. if v == nil {
  9866. return
  9867. }
  9868. return *v, true
  9869. }
  9870. // ResetSex resets all changes to the "sex" field.
  9871. func (m *ContactMutation) ResetSex() {
  9872. m.sex = nil
  9873. m.addsex = nil
  9874. }
  9875. // SetStarrole sets the "starrole" field.
  9876. func (m *ContactMutation) SetStarrole(s string) {
  9877. m.starrole = &s
  9878. }
  9879. // Starrole returns the value of the "starrole" field in the mutation.
  9880. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9881. v := m.starrole
  9882. if v == nil {
  9883. return
  9884. }
  9885. return *v, true
  9886. }
  9887. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9888. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9890. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9891. if !m.op.Is(OpUpdateOne) {
  9892. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9893. }
  9894. if m.id == nil || m.oldValue == nil {
  9895. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9896. }
  9897. oldValue, err := m.oldValue(ctx)
  9898. if err != nil {
  9899. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9900. }
  9901. return oldValue.Starrole, nil
  9902. }
  9903. // ResetStarrole resets all changes to the "starrole" field.
  9904. func (m *ContactMutation) ResetStarrole() {
  9905. m.starrole = nil
  9906. }
  9907. // SetDontseeit sets the "dontseeit" field.
  9908. func (m *ContactMutation) SetDontseeit(i int) {
  9909. m.dontseeit = &i
  9910. m.adddontseeit = nil
  9911. }
  9912. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9913. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9914. v := m.dontseeit
  9915. if v == nil {
  9916. return
  9917. }
  9918. return *v, true
  9919. }
  9920. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9921. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9923. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9924. if !m.op.Is(OpUpdateOne) {
  9925. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9926. }
  9927. if m.id == nil || m.oldValue == nil {
  9928. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9929. }
  9930. oldValue, err := m.oldValue(ctx)
  9931. if err != nil {
  9932. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9933. }
  9934. return oldValue.Dontseeit, nil
  9935. }
  9936. // AddDontseeit adds i to the "dontseeit" field.
  9937. func (m *ContactMutation) AddDontseeit(i int) {
  9938. if m.adddontseeit != nil {
  9939. *m.adddontseeit += i
  9940. } else {
  9941. m.adddontseeit = &i
  9942. }
  9943. }
  9944. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9945. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9946. v := m.adddontseeit
  9947. if v == nil {
  9948. return
  9949. }
  9950. return *v, true
  9951. }
  9952. // ResetDontseeit resets all changes to the "dontseeit" field.
  9953. func (m *ContactMutation) ResetDontseeit() {
  9954. m.dontseeit = nil
  9955. m.adddontseeit = nil
  9956. }
  9957. // SetDontseeme sets the "dontseeme" field.
  9958. func (m *ContactMutation) SetDontseeme(i int) {
  9959. m.dontseeme = &i
  9960. m.adddontseeme = nil
  9961. }
  9962. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9963. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9964. v := m.dontseeme
  9965. if v == nil {
  9966. return
  9967. }
  9968. return *v, true
  9969. }
  9970. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9971. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9973. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9974. if !m.op.Is(OpUpdateOne) {
  9975. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9976. }
  9977. if m.id == nil || m.oldValue == nil {
  9978. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  9979. }
  9980. oldValue, err := m.oldValue(ctx)
  9981. if err != nil {
  9982. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  9983. }
  9984. return oldValue.Dontseeme, nil
  9985. }
  9986. // AddDontseeme adds i to the "dontseeme" field.
  9987. func (m *ContactMutation) AddDontseeme(i int) {
  9988. if m.adddontseeme != nil {
  9989. *m.adddontseeme += i
  9990. } else {
  9991. m.adddontseeme = &i
  9992. }
  9993. }
  9994. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  9995. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  9996. v := m.adddontseeme
  9997. if v == nil {
  9998. return
  9999. }
  10000. return *v, true
  10001. }
  10002. // ResetDontseeme resets all changes to the "dontseeme" field.
  10003. func (m *ContactMutation) ResetDontseeme() {
  10004. m.dontseeme = nil
  10005. m.adddontseeme = nil
  10006. }
  10007. // SetLag sets the "lag" field.
  10008. func (m *ContactMutation) SetLag(s string) {
  10009. m.lag = &s
  10010. }
  10011. // Lag returns the value of the "lag" field in the mutation.
  10012. func (m *ContactMutation) Lag() (r string, exists bool) {
  10013. v := m.lag
  10014. if v == nil {
  10015. return
  10016. }
  10017. return *v, true
  10018. }
  10019. // OldLag returns the old "lag" field's value of the Contact entity.
  10020. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10022. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10023. if !m.op.Is(OpUpdateOne) {
  10024. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10025. }
  10026. if m.id == nil || m.oldValue == nil {
  10027. return v, errors.New("OldLag requires an ID field in the mutation")
  10028. }
  10029. oldValue, err := m.oldValue(ctx)
  10030. if err != nil {
  10031. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10032. }
  10033. return oldValue.Lag, nil
  10034. }
  10035. // ResetLag resets all changes to the "lag" field.
  10036. func (m *ContactMutation) ResetLag() {
  10037. m.lag = nil
  10038. }
  10039. // SetGid sets the "gid" field.
  10040. func (m *ContactMutation) SetGid(s string) {
  10041. m.gid = &s
  10042. }
  10043. // Gid returns the value of the "gid" field in the mutation.
  10044. func (m *ContactMutation) Gid() (r string, exists bool) {
  10045. v := m.gid
  10046. if v == nil {
  10047. return
  10048. }
  10049. return *v, true
  10050. }
  10051. // OldGid returns the old "gid" field's value of the Contact entity.
  10052. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10054. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10055. if !m.op.Is(OpUpdateOne) {
  10056. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10057. }
  10058. if m.id == nil || m.oldValue == nil {
  10059. return v, errors.New("OldGid requires an ID field in the mutation")
  10060. }
  10061. oldValue, err := m.oldValue(ctx)
  10062. if err != nil {
  10063. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10064. }
  10065. return oldValue.Gid, nil
  10066. }
  10067. // ResetGid resets all changes to the "gid" field.
  10068. func (m *ContactMutation) ResetGid() {
  10069. m.gid = nil
  10070. }
  10071. // SetGname sets the "gname" field.
  10072. func (m *ContactMutation) SetGname(s string) {
  10073. m.gname = &s
  10074. }
  10075. // Gname returns the value of the "gname" field in the mutation.
  10076. func (m *ContactMutation) Gname() (r string, exists bool) {
  10077. v := m.gname
  10078. if v == nil {
  10079. return
  10080. }
  10081. return *v, true
  10082. }
  10083. // OldGname returns the old "gname" field's value of the Contact entity.
  10084. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10086. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10087. if !m.op.Is(OpUpdateOne) {
  10088. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10089. }
  10090. if m.id == nil || m.oldValue == nil {
  10091. return v, errors.New("OldGname requires an ID field in the mutation")
  10092. }
  10093. oldValue, err := m.oldValue(ctx)
  10094. if err != nil {
  10095. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10096. }
  10097. return oldValue.Gname, nil
  10098. }
  10099. // ResetGname resets all changes to the "gname" field.
  10100. func (m *ContactMutation) ResetGname() {
  10101. m.gname = nil
  10102. }
  10103. // SetV3 sets the "v3" field.
  10104. func (m *ContactMutation) SetV3(s string) {
  10105. m.v3 = &s
  10106. }
  10107. // V3 returns the value of the "v3" field in the mutation.
  10108. func (m *ContactMutation) V3() (r string, exists bool) {
  10109. v := m.v3
  10110. if v == nil {
  10111. return
  10112. }
  10113. return *v, true
  10114. }
  10115. // OldV3 returns the old "v3" field's value of the Contact entity.
  10116. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10118. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10119. if !m.op.Is(OpUpdateOne) {
  10120. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10121. }
  10122. if m.id == nil || m.oldValue == nil {
  10123. return v, errors.New("OldV3 requires an ID field in the mutation")
  10124. }
  10125. oldValue, err := m.oldValue(ctx)
  10126. if err != nil {
  10127. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10128. }
  10129. return oldValue.V3, nil
  10130. }
  10131. // ResetV3 resets all changes to the "v3" field.
  10132. func (m *ContactMutation) ResetV3() {
  10133. m.v3 = nil
  10134. }
  10135. // SetOrganizationID sets the "organization_id" field.
  10136. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10137. m.organization_id = &u
  10138. m.addorganization_id = nil
  10139. }
  10140. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10141. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10142. v := m.organization_id
  10143. if v == nil {
  10144. return
  10145. }
  10146. return *v, true
  10147. }
  10148. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10149. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10151. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10152. if !m.op.Is(OpUpdateOne) {
  10153. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10154. }
  10155. if m.id == nil || m.oldValue == nil {
  10156. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10157. }
  10158. oldValue, err := m.oldValue(ctx)
  10159. if err != nil {
  10160. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10161. }
  10162. return oldValue.OrganizationID, nil
  10163. }
  10164. // AddOrganizationID adds u to the "organization_id" field.
  10165. func (m *ContactMutation) AddOrganizationID(u int64) {
  10166. if m.addorganization_id != nil {
  10167. *m.addorganization_id += u
  10168. } else {
  10169. m.addorganization_id = &u
  10170. }
  10171. }
  10172. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10173. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10174. v := m.addorganization_id
  10175. if v == nil {
  10176. return
  10177. }
  10178. return *v, true
  10179. }
  10180. // ClearOrganizationID clears the value of the "organization_id" field.
  10181. func (m *ContactMutation) ClearOrganizationID() {
  10182. m.organization_id = nil
  10183. m.addorganization_id = nil
  10184. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10185. }
  10186. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10187. func (m *ContactMutation) OrganizationIDCleared() bool {
  10188. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10189. return ok
  10190. }
  10191. // ResetOrganizationID resets all changes to the "organization_id" field.
  10192. func (m *ContactMutation) ResetOrganizationID() {
  10193. m.organization_id = nil
  10194. m.addorganization_id = nil
  10195. delete(m.clearedFields, contact.FieldOrganizationID)
  10196. }
  10197. // SetCtype sets the "ctype" field.
  10198. func (m *ContactMutation) SetCtype(u uint64) {
  10199. m.ctype = &u
  10200. m.addctype = nil
  10201. }
  10202. // Ctype returns the value of the "ctype" field in the mutation.
  10203. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10204. v := m.ctype
  10205. if v == nil {
  10206. return
  10207. }
  10208. return *v, true
  10209. }
  10210. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10211. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10213. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10214. if !m.op.Is(OpUpdateOne) {
  10215. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10216. }
  10217. if m.id == nil || m.oldValue == nil {
  10218. return v, errors.New("OldCtype requires an ID field in the mutation")
  10219. }
  10220. oldValue, err := m.oldValue(ctx)
  10221. if err != nil {
  10222. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10223. }
  10224. return oldValue.Ctype, nil
  10225. }
  10226. // AddCtype adds u to the "ctype" field.
  10227. func (m *ContactMutation) AddCtype(u int64) {
  10228. if m.addctype != nil {
  10229. *m.addctype += u
  10230. } else {
  10231. m.addctype = &u
  10232. }
  10233. }
  10234. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10235. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10236. v := m.addctype
  10237. if v == nil {
  10238. return
  10239. }
  10240. return *v, true
  10241. }
  10242. // ResetCtype resets all changes to the "ctype" field.
  10243. func (m *ContactMutation) ResetCtype() {
  10244. m.ctype = nil
  10245. m.addctype = nil
  10246. }
  10247. // SetCage sets the "cage" field.
  10248. func (m *ContactMutation) SetCage(i int) {
  10249. m.cage = &i
  10250. m.addcage = nil
  10251. }
  10252. // Cage returns the value of the "cage" field in the mutation.
  10253. func (m *ContactMutation) Cage() (r int, exists bool) {
  10254. v := m.cage
  10255. if v == nil {
  10256. return
  10257. }
  10258. return *v, true
  10259. }
  10260. // OldCage returns the old "cage" field's value of the Contact entity.
  10261. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10263. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10264. if !m.op.Is(OpUpdateOne) {
  10265. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10266. }
  10267. if m.id == nil || m.oldValue == nil {
  10268. return v, errors.New("OldCage requires an ID field in the mutation")
  10269. }
  10270. oldValue, err := m.oldValue(ctx)
  10271. if err != nil {
  10272. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10273. }
  10274. return oldValue.Cage, nil
  10275. }
  10276. // AddCage adds i to the "cage" field.
  10277. func (m *ContactMutation) AddCage(i int) {
  10278. if m.addcage != nil {
  10279. *m.addcage += i
  10280. } else {
  10281. m.addcage = &i
  10282. }
  10283. }
  10284. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10285. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10286. v := m.addcage
  10287. if v == nil {
  10288. return
  10289. }
  10290. return *v, true
  10291. }
  10292. // ResetCage resets all changes to the "cage" field.
  10293. func (m *ContactMutation) ResetCage() {
  10294. m.cage = nil
  10295. m.addcage = nil
  10296. }
  10297. // SetCname sets the "cname" field.
  10298. func (m *ContactMutation) SetCname(s string) {
  10299. m.cname = &s
  10300. }
  10301. // Cname returns the value of the "cname" field in the mutation.
  10302. func (m *ContactMutation) Cname() (r string, exists bool) {
  10303. v := m.cname
  10304. if v == nil {
  10305. return
  10306. }
  10307. return *v, true
  10308. }
  10309. // OldCname returns the old "cname" field's value of the Contact entity.
  10310. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10312. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10313. if !m.op.Is(OpUpdateOne) {
  10314. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10315. }
  10316. if m.id == nil || m.oldValue == nil {
  10317. return v, errors.New("OldCname requires an ID field in the mutation")
  10318. }
  10319. oldValue, err := m.oldValue(ctx)
  10320. if err != nil {
  10321. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10322. }
  10323. return oldValue.Cname, nil
  10324. }
  10325. // ResetCname resets all changes to the "cname" field.
  10326. func (m *ContactMutation) ResetCname() {
  10327. m.cname = nil
  10328. }
  10329. // SetCarea sets the "carea" field.
  10330. func (m *ContactMutation) SetCarea(s string) {
  10331. m.carea = &s
  10332. }
  10333. // Carea returns the value of the "carea" field in the mutation.
  10334. func (m *ContactMutation) Carea() (r string, exists bool) {
  10335. v := m.carea
  10336. if v == nil {
  10337. return
  10338. }
  10339. return *v, true
  10340. }
  10341. // OldCarea returns the old "carea" field's value of the Contact entity.
  10342. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10344. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10345. if !m.op.Is(OpUpdateOne) {
  10346. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10347. }
  10348. if m.id == nil || m.oldValue == nil {
  10349. return v, errors.New("OldCarea requires an ID field in the mutation")
  10350. }
  10351. oldValue, err := m.oldValue(ctx)
  10352. if err != nil {
  10353. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10354. }
  10355. return oldValue.Carea, nil
  10356. }
  10357. // ResetCarea resets all changes to the "carea" field.
  10358. func (m *ContactMutation) ResetCarea() {
  10359. m.carea = nil
  10360. }
  10361. // SetCbirthday sets the "cbirthday" field.
  10362. func (m *ContactMutation) SetCbirthday(s string) {
  10363. m.cbirthday = &s
  10364. }
  10365. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10366. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10367. v := m.cbirthday
  10368. if v == nil {
  10369. return
  10370. }
  10371. return *v, true
  10372. }
  10373. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10374. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10376. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10377. if !m.op.Is(OpUpdateOne) {
  10378. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10379. }
  10380. if m.id == nil || m.oldValue == nil {
  10381. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10382. }
  10383. oldValue, err := m.oldValue(ctx)
  10384. if err != nil {
  10385. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10386. }
  10387. return oldValue.Cbirthday, nil
  10388. }
  10389. // ResetCbirthday resets all changes to the "cbirthday" field.
  10390. func (m *ContactMutation) ResetCbirthday() {
  10391. m.cbirthday = nil
  10392. }
  10393. // SetCbirtharea sets the "cbirtharea" field.
  10394. func (m *ContactMutation) SetCbirtharea(s string) {
  10395. m.cbirtharea = &s
  10396. }
  10397. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10398. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10399. v := m.cbirtharea
  10400. if v == nil {
  10401. return
  10402. }
  10403. return *v, true
  10404. }
  10405. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10406. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10408. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10409. if !m.op.Is(OpUpdateOne) {
  10410. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10411. }
  10412. if m.id == nil || m.oldValue == nil {
  10413. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10414. }
  10415. oldValue, err := m.oldValue(ctx)
  10416. if err != nil {
  10417. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10418. }
  10419. return oldValue.Cbirtharea, nil
  10420. }
  10421. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10422. func (m *ContactMutation) ResetCbirtharea() {
  10423. m.cbirtharea = nil
  10424. }
  10425. // SetCidcardNo sets the "cidcard_no" field.
  10426. func (m *ContactMutation) SetCidcardNo(s string) {
  10427. m.cidcard_no = &s
  10428. }
  10429. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10430. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10431. v := m.cidcard_no
  10432. if v == nil {
  10433. return
  10434. }
  10435. return *v, true
  10436. }
  10437. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10438. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10440. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10441. if !m.op.Is(OpUpdateOne) {
  10442. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10443. }
  10444. if m.id == nil || m.oldValue == nil {
  10445. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10446. }
  10447. oldValue, err := m.oldValue(ctx)
  10448. if err != nil {
  10449. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10450. }
  10451. return oldValue.CidcardNo, nil
  10452. }
  10453. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10454. func (m *ContactMutation) ResetCidcardNo() {
  10455. m.cidcard_no = nil
  10456. }
  10457. // SetCtitle sets the "ctitle" field.
  10458. func (m *ContactMutation) SetCtitle(s string) {
  10459. m.ctitle = &s
  10460. }
  10461. // Ctitle returns the value of the "ctitle" field in the mutation.
  10462. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10463. v := m.ctitle
  10464. if v == nil {
  10465. return
  10466. }
  10467. return *v, true
  10468. }
  10469. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10470. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10472. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10473. if !m.op.Is(OpUpdateOne) {
  10474. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10475. }
  10476. if m.id == nil || m.oldValue == nil {
  10477. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10478. }
  10479. oldValue, err := m.oldValue(ctx)
  10480. if err != nil {
  10481. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10482. }
  10483. return oldValue.Ctitle, nil
  10484. }
  10485. // ResetCtitle resets all changes to the "ctitle" field.
  10486. func (m *ContactMutation) ResetCtitle() {
  10487. m.ctitle = nil
  10488. }
  10489. // SetCc sets the "cc" field.
  10490. func (m *ContactMutation) SetCc(s string) {
  10491. m.cc = &s
  10492. }
  10493. // Cc returns the value of the "cc" field in the mutation.
  10494. func (m *ContactMutation) Cc() (r string, exists bool) {
  10495. v := m.cc
  10496. if v == nil {
  10497. return
  10498. }
  10499. return *v, true
  10500. }
  10501. // OldCc returns the old "cc" field's value of the Contact entity.
  10502. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10504. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10505. if !m.op.Is(OpUpdateOne) {
  10506. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10507. }
  10508. if m.id == nil || m.oldValue == nil {
  10509. return v, errors.New("OldCc requires an ID field in the mutation")
  10510. }
  10511. oldValue, err := m.oldValue(ctx)
  10512. if err != nil {
  10513. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10514. }
  10515. return oldValue.Cc, nil
  10516. }
  10517. // ResetCc resets all changes to the "cc" field.
  10518. func (m *ContactMutation) ResetCc() {
  10519. m.cc = nil
  10520. }
  10521. // SetPhone sets the "phone" field.
  10522. func (m *ContactMutation) SetPhone(s string) {
  10523. m.phone = &s
  10524. }
  10525. // Phone returns the value of the "phone" field in the mutation.
  10526. func (m *ContactMutation) Phone() (r string, exists bool) {
  10527. v := m.phone
  10528. if v == nil {
  10529. return
  10530. }
  10531. return *v, true
  10532. }
  10533. // OldPhone returns the old "phone" field's value of the Contact entity.
  10534. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10536. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10537. if !m.op.Is(OpUpdateOne) {
  10538. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10539. }
  10540. if m.id == nil || m.oldValue == nil {
  10541. return v, errors.New("OldPhone requires an ID field in the mutation")
  10542. }
  10543. oldValue, err := m.oldValue(ctx)
  10544. if err != nil {
  10545. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10546. }
  10547. return oldValue.Phone, nil
  10548. }
  10549. // ResetPhone resets all changes to the "phone" field.
  10550. func (m *ContactMutation) ResetPhone() {
  10551. m.phone = nil
  10552. }
  10553. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10554. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10555. if m.contact_relationships == nil {
  10556. m.contact_relationships = make(map[uint64]struct{})
  10557. }
  10558. for i := range ids {
  10559. m.contact_relationships[ids[i]] = struct{}{}
  10560. }
  10561. }
  10562. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10563. func (m *ContactMutation) ClearContactRelationships() {
  10564. m.clearedcontact_relationships = true
  10565. }
  10566. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10567. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10568. return m.clearedcontact_relationships
  10569. }
  10570. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10571. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10572. if m.removedcontact_relationships == nil {
  10573. m.removedcontact_relationships = make(map[uint64]struct{})
  10574. }
  10575. for i := range ids {
  10576. delete(m.contact_relationships, ids[i])
  10577. m.removedcontact_relationships[ids[i]] = struct{}{}
  10578. }
  10579. }
  10580. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10581. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10582. for id := range m.removedcontact_relationships {
  10583. ids = append(ids, id)
  10584. }
  10585. return
  10586. }
  10587. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10588. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10589. for id := range m.contact_relationships {
  10590. ids = append(ids, id)
  10591. }
  10592. return
  10593. }
  10594. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10595. func (m *ContactMutation) ResetContactRelationships() {
  10596. m.contact_relationships = nil
  10597. m.clearedcontact_relationships = false
  10598. m.removedcontact_relationships = nil
  10599. }
  10600. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10601. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10602. if m.contact_messages == nil {
  10603. m.contact_messages = make(map[uint64]struct{})
  10604. }
  10605. for i := range ids {
  10606. m.contact_messages[ids[i]] = struct{}{}
  10607. }
  10608. }
  10609. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10610. func (m *ContactMutation) ClearContactMessages() {
  10611. m.clearedcontact_messages = true
  10612. }
  10613. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10614. func (m *ContactMutation) ContactMessagesCleared() bool {
  10615. return m.clearedcontact_messages
  10616. }
  10617. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10618. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10619. if m.removedcontact_messages == nil {
  10620. m.removedcontact_messages = make(map[uint64]struct{})
  10621. }
  10622. for i := range ids {
  10623. delete(m.contact_messages, ids[i])
  10624. m.removedcontact_messages[ids[i]] = struct{}{}
  10625. }
  10626. }
  10627. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10628. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10629. for id := range m.removedcontact_messages {
  10630. ids = append(ids, id)
  10631. }
  10632. return
  10633. }
  10634. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10635. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10636. for id := range m.contact_messages {
  10637. ids = append(ids, id)
  10638. }
  10639. return
  10640. }
  10641. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10642. func (m *ContactMutation) ResetContactMessages() {
  10643. m.contact_messages = nil
  10644. m.clearedcontact_messages = false
  10645. m.removedcontact_messages = nil
  10646. }
  10647. // Where appends a list predicates to the ContactMutation builder.
  10648. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10649. m.predicates = append(m.predicates, ps...)
  10650. }
  10651. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10652. // users can use type-assertion to append predicates that do not depend on any generated package.
  10653. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10654. p := make([]predicate.Contact, len(ps))
  10655. for i := range ps {
  10656. p[i] = ps[i]
  10657. }
  10658. m.Where(p...)
  10659. }
  10660. // Op returns the operation name.
  10661. func (m *ContactMutation) Op() Op {
  10662. return m.op
  10663. }
  10664. // SetOp allows setting the mutation operation.
  10665. func (m *ContactMutation) SetOp(op Op) {
  10666. m.op = op
  10667. }
  10668. // Type returns the node type of this mutation (Contact).
  10669. func (m *ContactMutation) Type() string {
  10670. return m.typ
  10671. }
  10672. // Fields returns all fields that were changed during this mutation. Note that in
  10673. // order to get all numeric fields that were incremented/decremented, call
  10674. // AddedFields().
  10675. func (m *ContactMutation) Fields() []string {
  10676. fields := make([]string, 0, 30)
  10677. if m.created_at != nil {
  10678. fields = append(fields, contact.FieldCreatedAt)
  10679. }
  10680. if m.updated_at != nil {
  10681. fields = append(fields, contact.FieldUpdatedAt)
  10682. }
  10683. if m.status != nil {
  10684. fields = append(fields, contact.FieldStatus)
  10685. }
  10686. if m.deleted_at != nil {
  10687. fields = append(fields, contact.FieldDeletedAt)
  10688. }
  10689. if m.wx_wxid != nil {
  10690. fields = append(fields, contact.FieldWxWxid)
  10691. }
  10692. if m._type != nil {
  10693. fields = append(fields, contact.FieldType)
  10694. }
  10695. if m.wxid != nil {
  10696. fields = append(fields, contact.FieldWxid)
  10697. }
  10698. if m.account != nil {
  10699. fields = append(fields, contact.FieldAccount)
  10700. }
  10701. if m.nickname != nil {
  10702. fields = append(fields, contact.FieldNickname)
  10703. }
  10704. if m.markname != nil {
  10705. fields = append(fields, contact.FieldMarkname)
  10706. }
  10707. if m.headimg != nil {
  10708. fields = append(fields, contact.FieldHeadimg)
  10709. }
  10710. if m.sex != nil {
  10711. fields = append(fields, contact.FieldSex)
  10712. }
  10713. if m.starrole != nil {
  10714. fields = append(fields, contact.FieldStarrole)
  10715. }
  10716. if m.dontseeit != nil {
  10717. fields = append(fields, contact.FieldDontseeit)
  10718. }
  10719. if m.dontseeme != nil {
  10720. fields = append(fields, contact.FieldDontseeme)
  10721. }
  10722. if m.lag != nil {
  10723. fields = append(fields, contact.FieldLag)
  10724. }
  10725. if m.gid != nil {
  10726. fields = append(fields, contact.FieldGid)
  10727. }
  10728. if m.gname != nil {
  10729. fields = append(fields, contact.FieldGname)
  10730. }
  10731. if m.v3 != nil {
  10732. fields = append(fields, contact.FieldV3)
  10733. }
  10734. if m.organization_id != nil {
  10735. fields = append(fields, contact.FieldOrganizationID)
  10736. }
  10737. if m.ctype != nil {
  10738. fields = append(fields, contact.FieldCtype)
  10739. }
  10740. if m.cage != nil {
  10741. fields = append(fields, contact.FieldCage)
  10742. }
  10743. if m.cname != nil {
  10744. fields = append(fields, contact.FieldCname)
  10745. }
  10746. if m.carea != nil {
  10747. fields = append(fields, contact.FieldCarea)
  10748. }
  10749. if m.cbirthday != nil {
  10750. fields = append(fields, contact.FieldCbirthday)
  10751. }
  10752. if m.cbirtharea != nil {
  10753. fields = append(fields, contact.FieldCbirtharea)
  10754. }
  10755. if m.cidcard_no != nil {
  10756. fields = append(fields, contact.FieldCidcardNo)
  10757. }
  10758. if m.ctitle != nil {
  10759. fields = append(fields, contact.FieldCtitle)
  10760. }
  10761. if m.cc != nil {
  10762. fields = append(fields, contact.FieldCc)
  10763. }
  10764. if m.phone != nil {
  10765. fields = append(fields, contact.FieldPhone)
  10766. }
  10767. return fields
  10768. }
  10769. // Field returns the value of a field with the given name. The second boolean
  10770. // return value indicates that this field was not set, or was not defined in the
  10771. // schema.
  10772. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10773. switch name {
  10774. case contact.FieldCreatedAt:
  10775. return m.CreatedAt()
  10776. case contact.FieldUpdatedAt:
  10777. return m.UpdatedAt()
  10778. case contact.FieldStatus:
  10779. return m.Status()
  10780. case contact.FieldDeletedAt:
  10781. return m.DeletedAt()
  10782. case contact.FieldWxWxid:
  10783. return m.WxWxid()
  10784. case contact.FieldType:
  10785. return m.GetType()
  10786. case contact.FieldWxid:
  10787. return m.Wxid()
  10788. case contact.FieldAccount:
  10789. return m.Account()
  10790. case contact.FieldNickname:
  10791. return m.Nickname()
  10792. case contact.FieldMarkname:
  10793. return m.Markname()
  10794. case contact.FieldHeadimg:
  10795. return m.Headimg()
  10796. case contact.FieldSex:
  10797. return m.Sex()
  10798. case contact.FieldStarrole:
  10799. return m.Starrole()
  10800. case contact.FieldDontseeit:
  10801. return m.Dontseeit()
  10802. case contact.FieldDontseeme:
  10803. return m.Dontseeme()
  10804. case contact.FieldLag:
  10805. return m.Lag()
  10806. case contact.FieldGid:
  10807. return m.Gid()
  10808. case contact.FieldGname:
  10809. return m.Gname()
  10810. case contact.FieldV3:
  10811. return m.V3()
  10812. case contact.FieldOrganizationID:
  10813. return m.OrganizationID()
  10814. case contact.FieldCtype:
  10815. return m.Ctype()
  10816. case contact.FieldCage:
  10817. return m.Cage()
  10818. case contact.FieldCname:
  10819. return m.Cname()
  10820. case contact.FieldCarea:
  10821. return m.Carea()
  10822. case contact.FieldCbirthday:
  10823. return m.Cbirthday()
  10824. case contact.FieldCbirtharea:
  10825. return m.Cbirtharea()
  10826. case contact.FieldCidcardNo:
  10827. return m.CidcardNo()
  10828. case contact.FieldCtitle:
  10829. return m.Ctitle()
  10830. case contact.FieldCc:
  10831. return m.Cc()
  10832. case contact.FieldPhone:
  10833. return m.Phone()
  10834. }
  10835. return nil, false
  10836. }
  10837. // OldField returns the old value of the field from the database. An error is
  10838. // returned if the mutation operation is not UpdateOne, or the query to the
  10839. // database failed.
  10840. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10841. switch name {
  10842. case contact.FieldCreatedAt:
  10843. return m.OldCreatedAt(ctx)
  10844. case contact.FieldUpdatedAt:
  10845. return m.OldUpdatedAt(ctx)
  10846. case contact.FieldStatus:
  10847. return m.OldStatus(ctx)
  10848. case contact.FieldDeletedAt:
  10849. return m.OldDeletedAt(ctx)
  10850. case contact.FieldWxWxid:
  10851. return m.OldWxWxid(ctx)
  10852. case contact.FieldType:
  10853. return m.OldType(ctx)
  10854. case contact.FieldWxid:
  10855. return m.OldWxid(ctx)
  10856. case contact.FieldAccount:
  10857. return m.OldAccount(ctx)
  10858. case contact.FieldNickname:
  10859. return m.OldNickname(ctx)
  10860. case contact.FieldMarkname:
  10861. return m.OldMarkname(ctx)
  10862. case contact.FieldHeadimg:
  10863. return m.OldHeadimg(ctx)
  10864. case contact.FieldSex:
  10865. return m.OldSex(ctx)
  10866. case contact.FieldStarrole:
  10867. return m.OldStarrole(ctx)
  10868. case contact.FieldDontseeit:
  10869. return m.OldDontseeit(ctx)
  10870. case contact.FieldDontseeme:
  10871. return m.OldDontseeme(ctx)
  10872. case contact.FieldLag:
  10873. return m.OldLag(ctx)
  10874. case contact.FieldGid:
  10875. return m.OldGid(ctx)
  10876. case contact.FieldGname:
  10877. return m.OldGname(ctx)
  10878. case contact.FieldV3:
  10879. return m.OldV3(ctx)
  10880. case contact.FieldOrganizationID:
  10881. return m.OldOrganizationID(ctx)
  10882. case contact.FieldCtype:
  10883. return m.OldCtype(ctx)
  10884. case contact.FieldCage:
  10885. return m.OldCage(ctx)
  10886. case contact.FieldCname:
  10887. return m.OldCname(ctx)
  10888. case contact.FieldCarea:
  10889. return m.OldCarea(ctx)
  10890. case contact.FieldCbirthday:
  10891. return m.OldCbirthday(ctx)
  10892. case contact.FieldCbirtharea:
  10893. return m.OldCbirtharea(ctx)
  10894. case contact.FieldCidcardNo:
  10895. return m.OldCidcardNo(ctx)
  10896. case contact.FieldCtitle:
  10897. return m.OldCtitle(ctx)
  10898. case contact.FieldCc:
  10899. return m.OldCc(ctx)
  10900. case contact.FieldPhone:
  10901. return m.OldPhone(ctx)
  10902. }
  10903. return nil, fmt.Errorf("unknown Contact field %s", name)
  10904. }
  10905. // SetField sets the value of a field with the given name. It returns an error if
  10906. // the field is not defined in the schema, or if the type mismatched the field
  10907. // type.
  10908. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10909. switch name {
  10910. case contact.FieldCreatedAt:
  10911. v, ok := value.(time.Time)
  10912. if !ok {
  10913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10914. }
  10915. m.SetCreatedAt(v)
  10916. return nil
  10917. case contact.FieldUpdatedAt:
  10918. v, ok := value.(time.Time)
  10919. if !ok {
  10920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10921. }
  10922. m.SetUpdatedAt(v)
  10923. return nil
  10924. case contact.FieldStatus:
  10925. v, ok := value.(uint8)
  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 contact.FieldDeletedAt:
  10932. v, ok := value.(time.Time)
  10933. if !ok {
  10934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10935. }
  10936. m.SetDeletedAt(v)
  10937. return nil
  10938. case contact.FieldWxWxid:
  10939. v, ok := value.(string)
  10940. if !ok {
  10941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10942. }
  10943. m.SetWxWxid(v)
  10944. return nil
  10945. case contact.FieldType:
  10946. v, ok := value.(int)
  10947. if !ok {
  10948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10949. }
  10950. m.SetType(v)
  10951. return nil
  10952. case contact.FieldWxid:
  10953. v, ok := value.(string)
  10954. if !ok {
  10955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10956. }
  10957. m.SetWxid(v)
  10958. return nil
  10959. case contact.FieldAccount:
  10960. v, ok := value.(string)
  10961. if !ok {
  10962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10963. }
  10964. m.SetAccount(v)
  10965. return nil
  10966. case contact.FieldNickname:
  10967. v, ok := value.(string)
  10968. if !ok {
  10969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10970. }
  10971. m.SetNickname(v)
  10972. return nil
  10973. case contact.FieldMarkname:
  10974. v, ok := value.(string)
  10975. if !ok {
  10976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10977. }
  10978. m.SetMarkname(v)
  10979. return nil
  10980. case contact.FieldHeadimg:
  10981. v, ok := value.(string)
  10982. if !ok {
  10983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10984. }
  10985. m.SetHeadimg(v)
  10986. return nil
  10987. case contact.FieldSex:
  10988. v, ok := value.(int)
  10989. if !ok {
  10990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10991. }
  10992. m.SetSex(v)
  10993. return nil
  10994. case contact.FieldStarrole:
  10995. v, ok := value.(string)
  10996. if !ok {
  10997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10998. }
  10999. m.SetStarrole(v)
  11000. return nil
  11001. case contact.FieldDontseeit:
  11002. v, ok := value.(int)
  11003. if !ok {
  11004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11005. }
  11006. m.SetDontseeit(v)
  11007. return nil
  11008. case contact.FieldDontseeme:
  11009. v, ok := value.(int)
  11010. if !ok {
  11011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11012. }
  11013. m.SetDontseeme(v)
  11014. return nil
  11015. case contact.FieldLag:
  11016. v, ok := value.(string)
  11017. if !ok {
  11018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11019. }
  11020. m.SetLag(v)
  11021. return nil
  11022. case contact.FieldGid:
  11023. v, ok := value.(string)
  11024. if !ok {
  11025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11026. }
  11027. m.SetGid(v)
  11028. return nil
  11029. case contact.FieldGname:
  11030. v, ok := value.(string)
  11031. if !ok {
  11032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11033. }
  11034. m.SetGname(v)
  11035. return nil
  11036. case contact.FieldV3:
  11037. v, ok := value.(string)
  11038. if !ok {
  11039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11040. }
  11041. m.SetV3(v)
  11042. return nil
  11043. case contact.FieldOrganizationID:
  11044. v, ok := value.(uint64)
  11045. if !ok {
  11046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11047. }
  11048. m.SetOrganizationID(v)
  11049. return nil
  11050. case contact.FieldCtype:
  11051. v, ok := value.(uint64)
  11052. if !ok {
  11053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11054. }
  11055. m.SetCtype(v)
  11056. return nil
  11057. case contact.FieldCage:
  11058. v, ok := value.(int)
  11059. if !ok {
  11060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11061. }
  11062. m.SetCage(v)
  11063. return nil
  11064. case contact.FieldCname:
  11065. v, ok := value.(string)
  11066. if !ok {
  11067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11068. }
  11069. m.SetCname(v)
  11070. return nil
  11071. case contact.FieldCarea:
  11072. v, ok := value.(string)
  11073. if !ok {
  11074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11075. }
  11076. m.SetCarea(v)
  11077. return nil
  11078. case contact.FieldCbirthday:
  11079. v, ok := value.(string)
  11080. if !ok {
  11081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11082. }
  11083. m.SetCbirthday(v)
  11084. return nil
  11085. case contact.FieldCbirtharea:
  11086. v, ok := value.(string)
  11087. if !ok {
  11088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11089. }
  11090. m.SetCbirtharea(v)
  11091. return nil
  11092. case contact.FieldCidcardNo:
  11093. v, ok := value.(string)
  11094. if !ok {
  11095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11096. }
  11097. m.SetCidcardNo(v)
  11098. return nil
  11099. case contact.FieldCtitle:
  11100. v, ok := value.(string)
  11101. if !ok {
  11102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11103. }
  11104. m.SetCtitle(v)
  11105. return nil
  11106. case contact.FieldCc:
  11107. v, ok := value.(string)
  11108. if !ok {
  11109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11110. }
  11111. m.SetCc(v)
  11112. return nil
  11113. case contact.FieldPhone:
  11114. v, ok := value.(string)
  11115. if !ok {
  11116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11117. }
  11118. m.SetPhone(v)
  11119. return nil
  11120. }
  11121. return fmt.Errorf("unknown Contact field %s", name)
  11122. }
  11123. // AddedFields returns all numeric fields that were incremented/decremented during
  11124. // this mutation.
  11125. func (m *ContactMutation) AddedFields() []string {
  11126. var fields []string
  11127. if m.addstatus != nil {
  11128. fields = append(fields, contact.FieldStatus)
  11129. }
  11130. if m.add_type != nil {
  11131. fields = append(fields, contact.FieldType)
  11132. }
  11133. if m.addsex != nil {
  11134. fields = append(fields, contact.FieldSex)
  11135. }
  11136. if m.adddontseeit != nil {
  11137. fields = append(fields, contact.FieldDontseeit)
  11138. }
  11139. if m.adddontseeme != nil {
  11140. fields = append(fields, contact.FieldDontseeme)
  11141. }
  11142. if m.addorganization_id != nil {
  11143. fields = append(fields, contact.FieldOrganizationID)
  11144. }
  11145. if m.addctype != nil {
  11146. fields = append(fields, contact.FieldCtype)
  11147. }
  11148. if m.addcage != nil {
  11149. fields = append(fields, contact.FieldCage)
  11150. }
  11151. return fields
  11152. }
  11153. // AddedField returns the numeric value that was incremented/decremented on a field
  11154. // with the given name. The second boolean return value indicates that this field
  11155. // was not set, or was not defined in the schema.
  11156. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11157. switch name {
  11158. case contact.FieldStatus:
  11159. return m.AddedStatus()
  11160. case contact.FieldType:
  11161. return m.AddedType()
  11162. case contact.FieldSex:
  11163. return m.AddedSex()
  11164. case contact.FieldDontseeit:
  11165. return m.AddedDontseeit()
  11166. case contact.FieldDontseeme:
  11167. return m.AddedDontseeme()
  11168. case contact.FieldOrganizationID:
  11169. return m.AddedOrganizationID()
  11170. case contact.FieldCtype:
  11171. return m.AddedCtype()
  11172. case contact.FieldCage:
  11173. return m.AddedCage()
  11174. }
  11175. return nil, false
  11176. }
  11177. // AddField adds the value to the field with the given name. It returns an error if
  11178. // the field is not defined in the schema, or if the type mismatched the field
  11179. // type.
  11180. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11181. switch name {
  11182. case contact.FieldStatus:
  11183. v, ok := value.(int8)
  11184. if !ok {
  11185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11186. }
  11187. m.AddStatus(v)
  11188. return nil
  11189. case contact.FieldType:
  11190. v, ok := value.(int)
  11191. if !ok {
  11192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11193. }
  11194. m.AddType(v)
  11195. return nil
  11196. case contact.FieldSex:
  11197. v, ok := value.(int)
  11198. if !ok {
  11199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11200. }
  11201. m.AddSex(v)
  11202. return nil
  11203. case contact.FieldDontseeit:
  11204. v, ok := value.(int)
  11205. if !ok {
  11206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11207. }
  11208. m.AddDontseeit(v)
  11209. return nil
  11210. case contact.FieldDontseeme:
  11211. v, ok := value.(int)
  11212. if !ok {
  11213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11214. }
  11215. m.AddDontseeme(v)
  11216. return nil
  11217. case contact.FieldOrganizationID:
  11218. v, ok := value.(int64)
  11219. if !ok {
  11220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11221. }
  11222. m.AddOrganizationID(v)
  11223. return nil
  11224. case contact.FieldCtype:
  11225. v, ok := value.(int64)
  11226. if !ok {
  11227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11228. }
  11229. m.AddCtype(v)
  11230. return nil
  11231. case contact.FieldCage:
  11232. v, ok := value.(int)
  11233. if !ok {
  11234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11235. }
  11236. m.AddCage(v)
  11237. return nil
  11238. }
  11239. return fmt.Errorf("unknown Contact numeric field %s", name)
  11240. }
  11241. // ClearedFields returns all nullable fields that were cleared during this
  11242. // mutation.
  11243. func (m *ContactMutation) ClearedFields() []string {
  11244. var fields []string
  11245. if m.FieldCleared(contact.FieldStatus) {
  11246. fields = append(fields, contact.FieldStatus)
  11247. }
  11248. if m.FieldCleared(contact.FieldDeletedAt) {
  11249. fields = append(fields, contact.FieldDeletedAt)
  11250. }
  11251. if m.FieldCleared(contact.FieldType) {
  11252. fields = append(fields, contact.FieldType)
  11253. }
  11254. if m.FieldCleared(contact.FieldOrganizationID) {
  11255. fields = append(fields, contact.FieldOrganizationID)
  11256. }
  11257. return fields
  11258. }
  11259. // FieldCleared returns a boolean indicating if a field with the given name was
  11260. // cleared in this mutation.
  11261. func (m *ContactMutation) FieldCleared(name string) bool {
  11262. _, ok := m.clearedFields[name]
  11263. return ok
  11264. }
  11265. // ClearField clears the value of the field with the given name. It returns an
  11266. // error if the field is not defined in the schema.
  11267. func (m *ContactMutation) ClearField(name string) error {
  11268. switch name {
  11269. case contact.FieldStatus:
  11270. m.ClearStatus()
  11271. return nil
  11272. case contact.FieldDeletedAt:
  11273. m.ClearDeletedAt()
  11274. return nil
  11275. case contact.FieldType:
  11276. m.ClearType()
  11277. return nil
  11278. case contact.FieldOrganizationID:
  11279. m.ClearOrganizationID()
  11280. return nil
  11281. }
  11282. return fmt.Errorf("unknown Contact nullable field %s", name)
  11283. }
  11284. // ResetField resets all changes in the mutation for the field with the given name.
  11285. // It returns an error if the field is not defined in the schema.
  11286. func (m *ContactMutation) ResetField(name string) error {
  11287. switch name {
  11288. case contact.FieldCreatedAt:
  11289. m.ResetCreatedAt()
  11290. return nil
  11291. case contact.FieldUpdatedAt:
  11292. m.ResetUpdatedAt()
  11293. return nil
  11294. case contact.FieldStatus:
  11295. m.ResetStatus()
  11296. return nil
  11297. case contact.FieldDeletedAt:
  11298. m.ResetDeletedAt()
  11299. return nil
  11300. case contact.FieldWxWxid:
  11301. m.ResetWxWxid()
  11302. return nil
  11303. case contact.FieldType:
  11304. m.ResetType()
  11305. return nil
  11306. case contact.FieldWxid:
  11307. m.ResetWxid()
  11308. return nil
  11309. case contact.FieldAccount:
  11310. m.ResetAccount()
  11311. return nil
  11312. case contact.FieldNickname:
  11313. m.ResetNickname()
  11314. return nil
  11315. case contact.FieldMarkname:
  11316. m.ResetMarkname()
  11317. return nil
  11318. case contact.FieldHeadimg:
  11319. m.ResetHeadimg()
  11320. return nil
  11321. case contact.FieldSex:
  11322. m.ResetSex()
  11323. return nil
  11324. case contact.FieldStarrole:
  11325. m.ResetStarrole()
  11326. return nil
  11327. case contact.FieldDontseeit:
  11328. m.ResetDontseeit()
  11329. return nil
  11330. case contact.FieldDontseeme:
  11331. m.ResetDontseeme()
  11332. return nil
  11333. case contact.FieldLag:
  11334. m.ResetLag()
  11335. return nil
  11336. case contact.FieldGid:
  11337. m.ResetGid()
  11338. return nil
  11339. case contact.FieldGname:
  11340. m.ResetGname()
  11341. return nil
  11342. case contact.FieldV3:
  11343. m.ResetV3()
  11344. return nil
  11345. case contact.FieldOrganizationID:
  11346. m.ResetOrganizationID()
  11347. return nil
  11348. case contact.FieldCtype:
  11349. m.ResetCtype()
  11350. return nil
  11351. case contact.FieldCage:
  11352. m.ResetCage()
  11353. return nil
  11354. case contact.FieldCname:
  11355. m.ResetCname()
  11356. return nil
  11357. case contact.FieldCarea:
  11358. m.ResetCarea()
  11359. return nil
  11360. case contact.FieldCbirthday:
  11361. m.ResetCbirthday()
  11362. return nil
  11363. case contact.FieldCbirtharea:
  11364. m.ResetCbirtharea()
  11365. return nil
  11366. case contact.FieldCidcardNo:
  11367. m.ResetCidcardNo()
  11368. return nil
  11369. case contact.FieldCtitle:
  11370. m.ResetCtitle()
  11371. return nil
  11372. case contact.FieldCc:
  11373. m.ResetCc()
  11374. return nil
  11375. case contact.FieldPhone:
  11376. m.ResetPhone()
  11377. return nil
  11378. }
  11379. return fmt.Errorf("unknown Contact field %s", name)
  11380. }
  11381. // AddedEdges returns all edge names that were set/added in this mutation.
  11382. func (m *ContactMutation) AddedEdges() []string {
  11383. edges := make([]string, 0, 2)
  11384. if m.contact_relationships != nil {
  11385. edges = append(edges, contact.EdgeContactRelationships)
  11386. }
  11387. if m.contact_messages != nil {
  11388. edges = append(edges, contact.EdgeContactMessages)
  11389. }
  11390. return edges
  11391. }
  11392. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11393. // name in this mutation.
  11394. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11395. switch name {
  11396. case contact.EdgeContactRelationships:
  11397. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11398. for id := range m.contact_relationships {
  11399. ids = append(ids, id)
  11400. }
  11401. return ids
  11402. case contact.EdgeContactMessages:
  11403. ids := make([]ent.Value, 0, len(m.contact_messages))
  11404. for id := range m.contact_messages {
  11405. ids = append(ids, id)
  11406. }
  11407. return ids
  11408. }
  11409. return nil
  11410. }
  11411. // RemovedEdges returns all edge names that were removed in this mutation.
  11412. func (m *ContactMutation) RemovedEdges() []string {
  11413. edges := make([]string, 0, 2)
  11414. if m.removedcontact_relationships != nil {
  11415. edges = append(edges, contact.EdgeContactRelationships)
  11416. }
  11417. if m.removedcontact_messages != nil {
  11418. edges = append(edges, contact.EdgeContactMessages)
  11419. }
  11420. return edges
  11421. }
  11422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11423. // the given name in this mutation.
  11424. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11425. switch name {
  11426. case contact.EdgeContactRelationships:
  11427. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11428. for id := range m.removedcontact_relationships {
  11429. ids = append(ids, id)
  11430. }
  11431. return ids
  11432. case contact.EdgeContactMessages:
  11433. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11434. for id := range m.removedcontact_messages {
  11435. ids = append(ids, id)
  11436. }
  11437. return ids
  11438. }
  11439. return nil
  11440. }
  11441. // ClearedEdges returns all edge names that were cleared in this mutation.
  11442. func (m *ContactMutation) ClearedEdges() []string {
  11443. edges := make([]string, 0, 2)
  11444. if m.clearedcontact_relationships {
  11445. edges = append(edges, contact.EdgeContactRelationships)
  11446. }
  11447. if m.clearedcontact_messages {
  11448. edges = append(edges, contact.EdgeContactMessages)
  11449. }
  11450. return edges
  11451. }
  11452. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11453. // was cleared in this mutation.
  11454. func (m *ContactMutation) EdgeCleared(name string) bool {
  11455. switch name {
  11456. case contact.EdgeContactRelationships:
  11457. return m.clearedcontact_relationships
  11458. case contact.EdgeContactMessages:
  11459. return m.clearedcontact_messages
  11460. }
  11461. return false
  11462. }
  11463. // ClearEdge clears the value of the edge with the given name. It returns an error
  11464. // if that edge is not defined in the schema.
  11465. func (m *ContactMutation) ClearEdge(name string) error {
  11466. switch name {
  11467. }
  11468. return fmt.Errorf("unknown Contact unique edge %s", name)
  11469. }
  11470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11471. // It returns an error if the edge is not defined in the schema.
  11472. func (m *ContactMutation) ResetEdge(name string) error {
  11473. switch name {
  11474. case contact.EdgeContactRelationships:
  11475. m.ResetContactRelationships()
  11476. return nil
  11477. case contact.EdgeContactMessages:
  11478. m.ResetContactMessages()
  11479. return nil
  11480. }
  11481. return fmt.Errorf("unknown Contact edge %s", name)
  11482. }
  11483. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11484. type CreditBalanceMutation struct {
  11485. config
  11486. op Op
  11487. typ string
  11488. id *uint64
  11489. created_at *time.Time
  11490. updated_at *time.Time
  11491. deleted_at *time.Time
  11492. user_id *string
  11493. balance *float32
  11494. addbalance *float32
  11495. status *int
  11496. addstatus *int
  11497. organization_id *uint64
  11498. addorganization_id *int64
  11499. clearedFields map[string]struct{}
  11500. done bool
  11501. oldValue func(context.Context) (*CreditBalance, error)
  11502. predicates []predicate.CreditBalance
  11503. }
  11504. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11505. // creditbalanceOption allows management of the mutation configuration using functional options.
  11506. type creditbalanceOption func(*CreditBalanceMutation)
  11507. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11508. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11509. m := &CreditBalanceMutation{
  11510. config: c,
  11511. op: op,
  11512. typ: TypeCreditBalance,
  11513. clearedFields: make(map[string]struct{}),
  11514. }
  11515. for _, opt := range opts {
  11516. opt(m)
  11517. }
  11518. return m
  11519. }
  11520. // withCreditBalanceID sets the ID field of the mutation.
  11521. func withCreditBalanceID(id uint64) creditbalanceOption {
  11522. return func(m *CreditBalanceMutation) {
  11523. var (
  11524. err error
  11525. once sync.Once
  11526. value *CreditBalance
  11527. )
  11528. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11529. once.Do(func() {
  11530. if m.done {
  11531. err = errors.New("querying old values post mutation is not allowed")
  11532. } else {
  11533. value, err = m.Client().CreditBalance.Get(ctx, id)
  11534. }
  11535. })
  11536. return value, err
  11537. }
  11538. m.id = &id
  11539. }
  11540. }
  11541. // withCreditBalance sets the old CreditBalance of the mutation.
  11542. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11543. return func(m *CreditBalanceMutation) {
  11544. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11545. return node, nil
  11546. }
  11547. m.id = &node.ID
  11548. }
  11549. }
  11550. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11551. // executed in a transaction (ent.Tx), a transactional client is returned.
  11552. func (m CreditBalanceMutation) Client() *Client {
  11553. client := &Client{config: m.config}
  11554. client.init()
  11555. return client
  11556. }
  11557. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11558. // it returns an error otherwise.
  11559. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11560. if _, ok := m.driver.(*txDriver); !ok {
  11561. return nil, errors.New("ent: mutation is not running in a transaction")
  11562. }
  11563. tx := &Tx{config: m.config}
  11564. tx.init()
  11565. return tx, nil
  11566. }
  11567. // SetID sets the value of the id field. Note that this
  11568. // operation is only accepted on creation of CreditBalance entities.
  11569. func (m *CreditBalanceMutation) SetID(id uint64) {
  11570. m.id = &id
  11571. }
  11572. // ID returns the ID value in the mutation. Note that the ID is only available
  11573. // if it was provided to the builder or after it was returned from the database.
  11574. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11575. if m.id == nil {
  11576. return
  11577. }
  11578. return *m.id, true
  11579. }
  11580. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11581. // That means, if the mutation is applied within a transaction with an isolation level such
  11582. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11583. // or updated by the mutation.
  11584. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11585. switch {
  11586. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11587. id, exists := m.ID()
  11588. if exists {
  11589. return []uint64{id}, nil
  11590. }
  11591. fallthrough
  11592. case m.op.Is(OpUpdate | OpDelete):
  11593. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11594. default:
  11595. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11596. }
  11597. }
  11598. // SetCreatedAt sets the "created_at" field.
  11599. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11600. m.created_at = &t
  11601. }
  11602. // CreatedAt returns the value of the "created_at" field in the mutation.
  11603. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11604. v := m.created_at
  11605. if v == nil {
  11606. return
  11607. }
  11608. return *v, true
  11609. }
  11610. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11611. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11613. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11614. if !m.op.Is(OpUpdateOne) {
  11615. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11616. }
  11617. if m.id == nil || m.oldValue == nil {
  11618. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11619. }
  11620. oldValue, err := m.oldValue(ctx)
  11621. if err != nil {
  11622. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11623. }
  11624. return oldValue.CreatedAt, nil
  11625. }
  11626. // ResetCreatedAt resets all changes to the "created_at" field.
  11627. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11628. m.created_at = nil
  11629. }
  11630. // SetUpdatedAt sets the "updated_at" field.
  11631. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11632. m.updated_at = &t
  11633. }
  11634. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11635. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11636. v := m.updated_at
  11637. if v == nil {
  11638. return
  11639. }
  11640. return *v, true
  11641. }
  11642. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11643. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11645. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11646. if !m.op.Is(OpUpdateOne) {
  11647. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11648. }
  11649. if m.id == nil || m.oldValue == nil {
  11650. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11651. }
  11652. oldValue, err := m.oldValue(ctx)
  11653. if err != nil {
  11654. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11655. }
  11656. return oldValue.UpdatedAt, nil
  11657. }
  11658. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11659. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11660. m.updated_at = nil
  11661. }
  11662. // SetDeletedAt sets the "deleted_at" field.
  11663. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11664. m.deleted_at = &t
  11665. }
  11666. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11667. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11668. v := m.deleted_at
  11669. if v == nil {
  11670. return
  11671. }
  11672. return *v, true
  11673. }
  11674. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11675. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11677. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11678. if !m.op.Is(OpUpdateOne) {
  11679. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11680. }
  11681. if m.id == nil || m.oldValue == nil {
  11682. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11683. }
  11684. oldValue, err := m.oldValue(ctx)
  11685. if err != nil {
  11686. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11687. }
  11688. return oldValue.DeletedAt, nil
  11689. }
  11690. // ClearDeletedAt clears the value of the "deleted_at" field.
  11691. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11692. m.deleted_at = nil
  11693. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11694. }
  11695. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11696. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11697. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11698. return ok
  11699. }
  11700. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11701. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11702. m.deleted_at = nil
  11703. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11704. }
  11705. // SetUserID sets the "user_id" field.
  11706. func (m *CreditBalanceMutation) SetUserID(s string) {
  11707. m.user_id = &s
  11708. }
  11709. // UserID returns the value of the "user_id" field in the mutation.
  11710. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11711. v := m.user_id
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11718. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11720. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldUserID requires an ID field in the mutation")
  11726. }
  11727. oldValue, err := m.oldValue(ctx)
  11728. if err != nil {
  11729. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11730. }
  11731. return oldValue.UserID, nil
  11732. }
  11733. // ClearUserID clears the value of the "user_id" field.
  11734. func (m *CreditBalanceMutation) ClearUserID() {
  11735. m.user_id = nil
  11736. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11737. }
  11738. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11739. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11740. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11741. return ok
  11742. }
  11743. // ResetUserID resets all changes to the "user_id" field.
  11744. func (m *CreditBalanceMutation) ResetUserID() {
  11745. m.user_id = nil
  11746. delete(m.clearedFields, creditbalance.FieldUserID)
  11747. }
  11748. // SetBalance sets the "balance" field.
  11749. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11750. m.balance = &f
  11751. m.addbalance = nil
  11752. }
  11753. // Balance returns the value of the "balance" field in the mutation.
  11754. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11755. v := m.balance
  11756. if v == nil {
  11757. return
  11758. }
  11759. return *v, true
  11760. }
  11761. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11762. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11764. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  11765. if !m.op.Is(OpUpdateOne) {
  11766. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  11767. }
  11768. if m.id == nil || m.oldValue == nil {
  11769. return v, errors.New("OldBalance requires an ID field in the mutation")
  11770. }
  11771. oldValue, err := m.oldValue(ctx)
  11772. if err != nil {
  11773. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  11774. }
  11775. return oldValue.Balance, nil
  11776. }
  11777. // AddBalance adds f to the "balance" field.
  11778. func (m *CreditBalanceMutation) AddBalance(f float32) {
  11779. if m.addbalance != nil {
  11780. *m.addbalance += f
  11781. } else {
  11782. m.addbalance = &f
  11783. }
  11784. }
  11785. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  11786. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  11787. v := m.addbalance
  11788. if v == nil {
  11789. return
  11790. }
  11791. return *v, true
  11792. }
  11793. // ResetBalance resets all changes to the "balance" field.
  11794. func (m *CreditBalanceMutation) ResetBalance() {
  11795. m.balance = nil
  11796. m.addbalance = nil
  11797. }
  11798. // SetStatus sets the "status" field.
  11799. func (m *CreditBalanceMutation) SetStatus(i int) {
  11800. m.status = &i
  11801. m.addstatus = nil
  11802. }
  11803. // Status returns the value of the "status" field in the mutation.
  11804. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  11805. v := m.status
  11806. if v == nil {
  11807. return
  11808. }
  11809. return *v, true
  11810. }
  11811. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  11812. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11814. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  11815. if !m.op.Is(OpUpdateOne) {
  11816. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11817. }
  11818. if m.id == nil || m.oldValue == nil {
  11819. return v, errors.New("OldStatus requires an ID field in the mutation")
  11820. }
  11821. oldValue, err := m.oldValue(ctx)
  11822. if err != nil {
  11823. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11824. }
  11825. return oldValue.Status, nil
  11826. }
  11827. // AddStatus adds i to the "status" field.
  11828. func (m *CreditBalanceMutation) AddStatus(i int) {
  11829. if m.addstatus != nil {
  11830. *m.addstatus += i
  11831. } else {
  11832. m.addstatus = &i
  11833. }
  11834. }
  11835. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11836. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  11837. v := m.addstatus
  11838. if v == nil {
  11839. return
  11840. }
  11841. return *v, true
  11842. }
  11843. // ClearStatus clears the value of the "status" field.
  11844. func (m *CreditBalanceMutation) ClearStatus() {
  11845. m.status = nil
  11846. m.addstatus = nil
  11847. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  11848. }
  11849. // StatusCleared returns if the "status" field was cleared in this mutation.
  11850. func (m *CreditBalanceMutation) StatusCleared() bool {
  11851. _, ok := m.clearedFields[creditbalance.FieldStatus]
  11852. return ok
  11853. }
  11854. // ResetStatus resets all changes to the "status" field.
  11855. func (m *CreditBalanceMutation) ResetStatus() {
  11856. m.status = nil
  11857. m.addstatus = nil
  11858. delete(m.clearedFields, creditbalance.FieldStatus)
  11859. }
  11860. // SetOrganizationID sets the "organization_id" field.
  11861. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  11862. m.organization_id = &u
  11863. m.addorganization_id = nil
  11864. }
  11865. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11866. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  11867. v := m.organization_id
  11868. if v == nil {
  11869. return
  11870. }
  11871. return *v, true
  11872. }
  11873. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  11874. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11876. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11877. if !m.op.Is(OpUpdateOne) {
  11878. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11879. }
  11880. if m.id == nil || m.oldValue == nil {
  11881. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11882. }
  11883. oldValue, err := m.oldValue(ctx)
  11884. if err != nil {
  11885. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11886. }
  11887. return oldValue.OrganizationID, nil
  11888. }
  11889. // AddOrganizationID adds u to the "organization_id" field.
  11890. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  11891. if m.addorganization_id != nil {
  11892. *m.addorganization_id += u
  11893. } else {
  11894. m.addorganization_id = &u
  11895. }
  11896. }
  11897. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11898. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  11899. v := m.addorganization_id
  11900. if v == nil {
  11901. return
  11902. }
  11903. return *v, true
  11904. }
  11905. // ClearOrganizationID clears the value of the "organization_id" field.
  11906. func (m *CreditBalanceMutation) ClearOrganizationID() {
  11907. m.organization_id = nil
  11908. m.addorganization_id = nil
  11909. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  11910. }
  11911. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11912. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  11913. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  11914. return ok
  11915. }
  11916. // ResetOrganizationID resets all changes to the "organization_id" field.
  11917. func (m *CreditBalanceMutation) ResetOrganizationID() {
  11918. m.organization_id = nil
  11919. m.addorganization_id = nil
  11920. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  11921. }
  11922. // Where appends a list predicates to the CreditBalanceMutation builder.
  11923. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  11924. m.predicates = append(m.predicates, ps...)
  11925. }
  11926. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  11927. // users can use type-assertion to append predicates that do not depend on any generated package.
  11928. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  11929. p := make([]predicate.CreditBalance, len(ps))
  11930. for i := range ps {
  11931. p[i] = ps[i]
  11932. }
  11933. m.Where(p...)
  11934. }
  11935. // Op returns the operation name.
  11936. func (m *CreditBalanceMutation) Op() Op {
  11937. return m.op
  11938. }
  11939. // SetOp allows setting the mutation operation.
  11940. func (m *CreditBalanceMutation) SetOp(op Op) {
  11941. m.op = op
  11942. }
  11943. // Type returns the node type of this mutation (CreditBalance).
  11944. func (m *CreditBalanceMutation) Type() string {
  11945. return m.typ
  11946. }
  11947. // Fields returns all fields that were changed during this mutation. Note that in
  11948. // order to get all numeric fields that were incremented/decremented, call
  11949. // AddedFields().
  11950. func (m *CreditBalanceMutation) Fields() []string {
  11951. fields := make([]string, 0, 7)
  11952. if m.created_at != nil {
  11953. fields = append(fields, creditbalance.FieldCreatedAt)
  11954. }
  11955. if m.updated_at != nil {
  11956. fields = append(fields, creditbalance.FieldUpdatedAt)
  11957. }
  11958. if m.deleted_at != nil {
  11959. fields = append(fields, creditbalance.FieldDeletedAt)
  11960. }
  11961. if m.user_id != nil {
  11962. fields = append(fields, creditbalance.FieldUserID)
  11963. }
  11964. if m.balance != nil {
  11965. fields = append(fields, creditbalance.FieldBalance)
  11966. }
  11967. if m.status != nil {
  11968. fields = append(fields, creditbalance.FieldStatus)
  11969. }
  11970. if m.organization_id != nil {
  11971. fields = append(fields, creditbalance.FieldOrganizationID)
  11972. }
  11973. return fields
  11974. }
  11975. // Field returns the value of a field with the given name. The second boolean
  11976. // return value indicates that this field was not set, or was not defined in the
  11977. // schema.
  11978. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  11979. switch name {
  11980. case creditbalance.FieldCreatedAt:
  11981. return m.CreatedAt()
  11982. case creditbalance.FieldUpdatedAt:
  11983. return m.UpdatedAt()
  11984. case creditbalance.FieldDeletedAt:
  11985. return m.DeletedAt()
  11986. case creditbalance.FieldUserID:
  11987. return m.UserID()
  11988. case creditbalance.FieldBalance:
  11989. return m.Balance()
  11990. case creditbalance.FieldStatus:
  11991. return m.Status()
  11992. case creditbalance.FieldOrganizationID:
  11993. return m.OrganizationID()
  11994. }
  11995. return nil, false
  11996. }
  11997. // OldField returns the old value of the field from the database. An error is
  11998. // returned if the mutation operation is not UpdateOne, or the query to the
  11999. // database failed.
  12000. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12001. switch name {
  12002. case creditbalance.FieldCreatedAt:
  12003. return m.OldCreatedAt(ctx)
  12004. case creditbalance.FieldUpdatedAt:
  12005. return m.OldUpdatedAt(ctx)
  12006. case creditbalance.FieldDeletedAt:
  12007. return m.OldDeletedAt(ctx)
  12008. case creditbalance.FieldUserID:
  12009. return m.OldUserID(ctx)
  12010. case creditbalance.FieldBalance:
  12011. return m.OldBalance(ctx)
  12012. case creditbalance.FieldStatus:
  12013. return m.OldStatus(ctx)
  12014. case creditbalance.FieldOrganizationID:
  12015. return m.OldOrganizationID(ctx)
  12016. }
  12017. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  12018. }
  12019. // SetField sets the value of a field with the given name. It returns an error if
  12020. // the field is not defined in the schema, or if the type mismatched the field
  12021. // type.
  12022. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  12023. switch name {
  12024. case creditbalance.FieldCreatedAt:
  12025. v, ok := value.(time.Time)
  12026. if !ok {
  12027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12028. }
  12029. m.SetCreatedAt(v)
  12030. return nil
  12031. case creditbalance.FieldUpdatedAt:
  12032. v, ok := value.(time.Time)
  12033. if !ok {
  12034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12035. }
  12036. m.SetUpdatedAt(v)
  12037. return nil
  12038. case creditbalance.FieldDeletedAt:
  12039. v, ok := value.(time.Time)
  12040. if !ok {
  12041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12042. }
  12043. m.SetDeletedAt(v)
  12044. return nil
  12045. case creditbalance.FieldUserID:
  12046. v, ok := value.(string)
  12047. if !ok {
  12048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12049. }
  12050. m.SetUserID(v)
  12051. return nil
  12052. case creditbalance.FieldBalance:
  12053. v, ok := value.(float32)
  12054. if !ok {
  12055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12056. }
  12057. m.SetBalance(v)
  12058. return nil
  12059. case creditbalance.FieldStatus:
  12060. v, ok := value.(int)
  12061. if !ok {
  12062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12063. }
  12064. m.SetStatus(v)
  12065. return nil
  12066. case creditbalance.FieldOrganizationID:
  12067. v, ok := value.(uint64)
  12068. if !ok {
  12069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12070. }
  12071. m.SetOrganizationID(v)
  12072. return nil
  12073. }
  12074. return fmt.Errorf("unknown CreditBalance field %s", name)
  12075. }
  12076. // AddedFields returns all numeric fields that were incremented/decremented during
  12077. // this mutation.
  12078. func (m *CreditBalanceMutation) AddedFields() []string {
  12079. var fields []string
  12080. if m.addbalance != nil {
  12081. fields = append(fields, creditbalance.FieldBalance)
  12082. }
  12083. if m.addstatus != nil {
  12084. fields = append(fields, creditbalance.FieldStatus)
  12085. }
  12086. if m.addorganization_id != nil {
  12087. fields = append(fields, creditbalance.FieldOrganizationID)
  12088. }
  12089. return fields
  12090. }
  12091. // AddedField returns the numeric value that was incremented/decremented on a field
  12092. // with the given name. The second boolean return value indicates that this field
  12093. // was not set, or was not defined in the schema.
  12094. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12095. switch name {
  12096. case creditbalance.FieldBalance:
  12097. return m.AddedBalance()
  12098. case creditbalance.FieldStatus:
  12099. return m.AddedStatus()
  12100. case creditbalance.FieldOrganizationID:
  12101. return m.AddedOrganizationID()
  12102. }
  12103. return nil, false
  12104. }
  12105. // AddField adds the value to the field with the given name. It returns an error if
  12106. // the field is not defined in the schema, or if the type mismatched the field
  12107. // type.
  12108. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12109. switch name {
  12110. case creditbalance.FieldBalance:
  12111. v, ok := value.(float32)
  12112. if !ok {
  12113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12114. }
  12115. m.AddBalance(v)
  12116. return nil
  12117. case creditbalance.FieldStatus:
  12118. v, ok := value.(int)
  12119. if !ok {
  12120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12121. }
  12122. m.AddStatus(v)
  12123. return nil
  12124. case creditbalance.FieldOrganizationID:
  12125. v, ok := value.(int64)
  12126. if !ok {
  12127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12128. }
  12129. m.AddOrganizationID(v)
  12130. return nil
  12131. }
  12132. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12133. }
  12134. // ClearedFields returns all nullable fields that were cleared during this
  12135. // mutation.
  12136. func (m *CreditBalanceMutation) ClearedFields() []string {
  12137. var fields []string
  12138. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12139. fields = append(fields, creditbalance.FieldDeletedAt)
  12140. }
  12141. if m.FieldCleared(creditbalance.FieldUserID) {
  12142. fields = append(fields, creditbalance.FieldUserID)
  12143. }
  12144. if m.FieldCleared(creditbalance.FieldStatus) {
  12145. fields = append(fields, creditbalance.FieldStatus)
  12146. }
  12147. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12148. fields = append(fields, creditbalance.FieldOrganizationID)
  12149. }
  12150. return fields
  12151. }
  12152. // FieldCleared returns a boolean indicating if a field with the given name was
  12153. // cleared in this mutation.
  12154. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12155. _, ok := m.clearedFields[name]
  12156. return ok
  12157. }
  12158. // ClearField clears the value of the field with the given name. It returns an
  12159. // error if the field is not defined in the schema.
  12160. func (m *CreditBalanceMutation) ClearField(name string) error {
  12161. switch name {
  12162. case creditbalance.FieldDeletedAt:
  12163. m.ClearDeletedAt()
  12164. return nil
  12165. case creditbalance.FieldUserID:
  12166. m.ClearUserID()
  12167. return nil
  12168. case creditbalance.FieldStatus:
  12169. m.ClearStatus()
  12170. return nil
  12171. case creditbalance.FieldOrganizationID:
  12172. m.ClearOrganizationID()
  12173. return nil
  12174. }
  12175. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12176. }
  12177. // ResetField resets all changes in the mutation for the field with the given name.
  12178. // It returns an error if the field is not defined in the schema.
  12179. func (m *CreditBalanceMutation) ResetField(name string) error {
  12180. switch name {
  12181. case creditbalance.FieldCreatedAt:
  12182. m.ResetCreatedAt()
  12183. return nil
  12184. case creditbalance.FieldUpdatedAt:
  12185. m.ResetUpdatedAt()
  12186. return nil
  12187. case creditbalance.FieldDeletedAt:
  12188. m.ResetDeletedAt()
  12189. return nil
  12190. case creditbalance.FieldUserID:
  12191. m.ResetUserID()
  12192. return nil
  12193. case creditbalance.FieldBalance:
  12194. m.ResetBalance()
  12195. return nil
  12196. case creditbalance.FieldStatus:
  12197. m.ResetStatus()
  12198. return nil
  12199. case creditbalance.FieldOrganizationID:
  12200. m.ResetOrganizationID()
  12201. return nil
  12202. }
  12203. return fmt.Errorf("unknown CreditBalance field %s", name)
  12204. }
  12205. // AddedEdges returns all edge names that were set/added in this mutation.
  12206. func (m *CreditBalanceMutation) AddedEdges() []string {
  12207. edges := make([]string, 0, 0)
  12208. return edges
  12209. }
  12210. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12211. // name in this mutation.
  12212. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12213. return nil
  12214. }
  12215. // RemovedEdges returns all edge names that were removed in this mutation.
  12216. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12217. edges := make([]string, 0, 0)
  12218. return edges
  12219. }
  12220. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12221. // the given name in this mutation.
  12222. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12223. return nil
  12224. }
  12225. // ClearedEdges returns all edge names that were cleared in this mutation.
  12226. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12227. edges := make([]string, 0, 0)
  12228. return edges
  12229. }
  12230. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12231. // was cleared in this mutation.
  12232. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12233. return false
  12234. }
  12235. // ClearEdge clears the value of the edge with the given name. It returns an error
  12236. // if that edge is not defined in the schema.
  12237. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12238. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12239. }
  12240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12241. // It returns an error if the edge is not defined in the schema.
  12242. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12243. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12244. }
  12245. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12246. type CreditUsageMutation struct {
  12247. config
  12248. op Op
  12249. typ string
  12250. id *uint64
  12251. created_at *time.Time
  12252. updated_at *time.Time
  12253. deleted_at *time.Time
  12254. user_id *string
  12255. number *float32
  12256. addnumber *float32
  12257. status *int
  12258. addstatus *int
  12259. ntype *int
  12260. addntype *int
  12261. table *string
  12262. organization_id *uint64
  12263. addorganization_id *int64
  12264. nid *uint64
  12265. addnid *int64
  12266. reason *string
  12267. operator *string
  12268. clearedFields map[string]struct{}
  12269. done bool
  12270. oldValue func(context.Context) (*CreditUsage, error)
  12271. predicates []predicate.CreditUsage
  12272. }
  12273. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12274. // creditusageOption allows management of the mutation configuration using functional options.
  12275. type creditusageOption func(*CreditUsageMutation)
  12276. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12277. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12278. m := &CreditUsageMutation{
  12279. config: c,
  12280. op: op,
  12281. typ: TypeCreditUsage,
  12282. clearedFields: make(map[string]struct{}),
  12283. }
  12284. for _, opt := range opts {
  12285. opt(m)
  12286. }
  12287. return m
  12288. }
  12289. // withCreditUsageID sets the ID field of the mutation.
  12290. func withCreditUsageID(id uint64) creditusageOption {
  12291. return func(m *CreditUsageMutation) {
  12292. var (
  12293. err error
  12294. once sync.Once
  12295. value *CreditUsage
  12296. )
  12297. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12298. once.Do(func() {
  12299. if m.done {
  12300. err = errors.New("querying old values post mutation is not allowed")
  12301. } else {
  12302. value, err = m.Client().CreditUsage.Get(ctx, id)
  12303. }
  12304. })
  12305. return value, err
  12306. }
  12307. m.id = &id
  12308. }
  12309. }
  12310. // withCreditUsage sets the old CreditUsage of the mutation.
  12311. func withCreditUsage(node *CreditUsage) creditusageOption {
  12312. return func(m *CreditUsageMutation) {
  12313. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12314. return node, nil
  12315. }
  12316. m.id = &node.ID
  12317. }
  12318. }
  12319. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12320. // executed in a transaction (ent.Tx), a transactional client is returned.
  12321. func (m CreditUsageMutation) Client() *Client {
  12322. client := &Client{config: m.config}
  12323. client.init()
  12324. return client
  12325. }
  12326. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12327. // it returns an error otherwise.
  12328. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12329. if _, ok := m.driver.(*txDriver); !ok {
  12330. return nil, errors.New("ent: mutation is not running in a transaction")
  12331. }
  12332. tx := &Tx{config: m.config}
  12333. tx.init()
  12334. return tx, nil
  12335. }
  12336. // SetID sets the value of the id field. Note that this
  12337. // operation is only accepted on creation of CreditUsage entities.
  12338. func (m *CreditUsageMutation) SetID(id uint64) {
  12339. m.id = &id
  12340. }
  12341. // ID returns the ID value in the mutation. Note that the ID is only available
  12342. // if it was provided to the builder or after it was returned from the database.
  12343. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12344. if m.id == nil {
  12345. return
  12346. }
  12347. return *m.id, true
  12348. }
  12349. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12350. // That means, if the mutation is applied within a transaction with an isolation level such
  12351. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12352. // or updated by the mutation.
  12353. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12354. switch {
  12355. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12356. id, exists := m.ID()
  12357. if exists {
  12358. return []uint64{id}, nil
  12359. }
  12360. fallthrough
  12361. case m.op.Is(OpUpdate | OpDelete):
  12362. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12363. default:
  12364. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12365. }
  12366. }
  12367. // SetCreatedAt sets the "created_at" field.
  12368. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12369. m.created_at = &t
  12370. }
  12371. // CreatedAt returns the value of the "created_at" field in the mutation.
  12372. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12373. v := m.created_at
  12374. if v == nil {
  12375. return
  12376. }
  12377. return *v, true
  12378. }
  12379. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12380. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12382. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12383. if !m.op.Is(OpUpdateOne) {
  12384. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12385. }
  12386. if m.id == nil || m.oldValue == nil {
  12387. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12388. }
  12389. oldValue, err := m.oldValue(ctx)
  12390. if err != nil {
  12391. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12392. }
  12393. return oldValue.CreatedAt, nil
  12394. }
  12395. // ResetCreatedAt resets all changes to the "created_at" field.
  12396. func (m *CreditUsageMutation) ResetCreatedAt() {
  12397. m.created_at = nil
  12398. }
  12399. // SetUpdatedAt sets the "updated_at" field.
  12400. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12401. m.updated_at = &t
  12402. }
  12403. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12404. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12405. v := m.updated_at
  12406. if v == nil {
  12407. return
  12408. }
  12409. return *v, true
  12410. }
  12411. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12412. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12414. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12415. if !m.op.Is(OpUpdateOne) {
  12416. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12417. }
  12418. if m.id == nil || m.oldValue == nil {
  12419. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12420. }
  12421. oldValue, err := m.oldValue(ctx)
  12422. if err != nil {
  12423. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12424. }
  12425. return oldValue.UpdatedAt, nil
  12426. }
  12427. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12428. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12429. m.updated_at = nil
  12430. }
  12431. // SetDeletedAt sets the "deleted_at" field.
  12432. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12433. m.deleted_at = &t
  12434. }
  12435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12436. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12437. v := m.deleted_at
  12438. if v == nil {
  12439. return
  12440. }
  12441. return *v, true
  12442. }
  12443. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12444. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12446. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12447. if !m.op.Is(OpUpdateOne) {
  12448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12449. }
  12450. if m.id == nil || m.oldValue == nil {
  12451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12452. }
  12453. oldValue, err := m.oldValue(ctx)
  12454. if err != nil {
  12455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12456. }
  12457. return oldValue.DeletedAt, nil
  12458. }
  12459. // ClearDeletedAt clears the value of the "deleted_at" field.
  12460. func (m *CreditUsageMutation) ClearDeletedAt() {
  12461. m.deleted_at = nil
  12462. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12463. }
  12464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12465. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12466. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12467. return ok
  12468. }
  12469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12470. func (m *CreditUsageMutation) ResetDeletedAt() {
  12471. m.deleted_at = nil
  12472. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12473. }
  12474. // SetUserID sets the "user_id" field.
  12475. func (m *CreditUsageMutation) SetUserID(s string) {
  12476. m.user_id = &s
  12477. }
  12478. // UserID returns the value of the "user_id" field in the mutation.
  12479. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12480. v := m.user_id
  12481. if v == nil {
  12482. return
  12483. }
  12484. return *v, true
  12485. }
  12486. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12487. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12489. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12490. if !m.op.Is(OpUpdateOne) {
  12491. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12492. }
  12493. if m.id == nil || m.oldValue == nil {
  12494. return v, errors.New("OldUserID requires an ID field in the mutation")
  12495. }
  12496. oldValue, err := m.oldValue(ctx)
  12497. if err != nil {
  12498. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12499. }
  12500. return oldValue.UserID, nil
  12501. }
  12502. // ClearUserID clears the value of the "user_id" field.
  12503. func (m *CreditUsageMutation) ClearUserID() {
  12504. m.user_id = nil
  12505. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12506. }
  12507. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12508. func (m *CreditUsageMutation) UserIDCleared() bool {
  12509. _, ok := m.clearedFields[creditusage.FieldUserID]
  12510. return ok
  12511. }
  12512. // ResetUserID resets all changes to the "user_id" field.
  12513. func (m *CreditUsageMutation) ResetUserID() {
  12514. m.user_id = nil
  12515. delete(m.clearedFields, creditusage.FieldUserID)
  12516. }
  12517. // SetNumber sets the "number" field.
  12518. func (m *CreditUsageMutation) SetNumber(f float32) {
  12519. m.number = &f
  12520. m.addnumber = nil
  12521. }
  12522. // Number returns the value of the "number" field in the mutation.
  12523. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12524. v := m.number
  12525. if v == nil {
  12526. return
  12527. }
  12528. return *v, true
  12529. }
  12530. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12531. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12533. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12534. if !m.op.Is(OpUpdateOne) {
  12535. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12536. }
  12537. if m.id == nil || m.oldValue == nil {
  12538. return v, errors.New("OldNumber requires an ID field in the mutation")
  12539. }
  12540. oldValue, err := m.oldValue(ctx)
  12541. if err != nil {
  12542. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12543. }
  12544. return oldValue.Number, nil
  12545. }
  12546. // AddNumber adds f to the "number" field.
  12547. func (m *CreditUsageMutation) AddNumber(f float32) {
  12548. if m.addnumber != nil {
  12549. *m.addnumber += f
  12550. } else {
  12551. m.addnumber = &f
  12552. }
  12553. }
  12554. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12555. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12556. v := m.addnumber
  12557. if v == nil {
  12558. return
  12559. }
  12560. return *v, true
  12561. }
  12562. // ResetNumber resets all changes to the "number" field.
  12563. func (m *CreditUsageMutation) ResetNumber() {
  12564. m.number = nil
  12565. m.addnumber = nil
  12566. }
  12567. // SetStatus sets the "status" field.
  12568. func (m *CreditUsageMutation) SetStatus(i int) {
  12569. m.status = &i
  12570. m.addstatus = nil
  12571. }
  12572. // Status returns the value of the "status" field in the mutation.
  12573. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12574. v := m.status
  12575. if v == nil {
  12576. return
  12577. }
  12578. return *v, true
  12579. }
  12580. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12581. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12583. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12584. if !m.op.Is(OpUpdateOne) {
  12585. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12586. }
  12587. if m.id == nil || m.oldValue == nil {
  12588. return v, errors.New("OldStatus requires an ID field in the mutation")
  12589. }
  12590. oldValue, err := m.oldValue(ctx)
  12591. if err != nil {
  12592. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12593. }
  12594. return oldValue.Status, nil
  12595. }
  12596. // AddStatus adds i to the "status" field.
  12597. func (m *CreditUsageMutation) AddStatus(i int) {
  12598. if m.addstatus != nil {
  12599. *m.addstatus += i
  12600. } else {
  12601. m.addstatus = &i
  12602. }
  12603. }
  12604. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12605. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12606. v := m.addstatus
  12607. if v == nil {
  12608. return
  12609. }
  12610. return *v, true
  12611. }
  12612. // ClearStatus clears the value of the "status" field.
  12613. func (m *CreditUsageMutation) ClearStatus() {
  12614. m.status = nil
  12615. m.addstatus = nil
  12616. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12617. }
  12618. // StatusCleared returns if the "status" field was cleared in this mutation.
  12619. func (m *CreditUsageMutation) StatusCleared() bool {
  12620. _, ok := m.clearedFields[creditusage.FieldStatus]
  12621. return ok
  12622. }
  12623. // ResetStatus resets all changes to the "status" field.
  12624. func (m *CreditUsageMutation) ResetStatus() {
  12625. m.status = nil
  12626. m.addstatus = nil
  12627. delete(m.clearedFields, creditusage.FieldStatus)
  12628. }
  12629. // SetNtype sets the "ntype" field.
  12630. func (m *CreditUsageMutation) SetNtype(i int) {
  12631. m.ntype = &i
  12632. m.addntype = nil
  12633. }
  12634. // Ntype returns the value of the "ntype" field in the mutation.
  12635. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12636. v := m.ntype
  12637. if v == nil {
  12638. return
  12639. }
  12640. return *v, true
  12641. }
  12642. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  12643. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12645. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  12646. if !m.op.Is(OpUpdateOne) {
  12647. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12648. }
  12649. if m.id == nil || m.oldValue == nil {
  12650. return v, errors.New("OldNtype requires an ID field in the mutation")
  12651. }
  12652. oldValue, err := m.oldValue(ctx)
  12653. if err != nil {
  12654. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  12655. }
  12656. return oldValue.Ntype, nil
  12657. }
  12658. // AddNtype adds i to the "ntype" field.
  12659. func (m *CreditUsageMutation) AddNtype(i int) {
  12660. if m.addntype != nil {
  12661. *m.addntype += i
  12662. } else {
  12663. m.addntype = &i
  12664. }
  12665. }
  12666. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12667. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12668. v := m.addntype
  12669. if v == nil {
  12670. return
  12671. }
  12672. return *v, true
  12673. }
  12674. // ResetNtype resets all changes to the "ntype" field.
  12675. func (m *CreditUsageMutation) ResetNtype() {
  12676. m.ntype = nil
  12677. m.addntype = nil
  12678. }
  12679. // SetTable sets the "table" field.
  12680. func (m *CreditUsageMutation) SetTable(s string) {
  12681. m.table = &s
  12682. }
  12683. // Table returns the value of the "table" field in the mutation.
  12684. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12685. v := m.table
  12686. if v == nil {
  12687. return
  12688. }
  12689. return *v, true
  12690. }
  12691. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12692. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12694. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12695. if !m.op.Is(OpUpdateOne) {
  12696. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12697. }
  12698. if m.id == nil || m.oldValue == nil {
  12699. return v, errors.New("OldTable requires an ID field in the mutation")
  12700. }
  12701. oldValue, err := m.oldValue(ctx)
  12702. if err != nil {
  12703. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12704. }
  12705. return oldValue.Table, nil
  12706. }
  12707. // ResetTable resets all changes to the "table" field.
  12708. func (m *CreditUsageMutation) ResetTable() {
  12709. m.table = nil
  12710. }
  12711. // SetOrganizationID sets the "organization_id" field.
  12712. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12713. m.organization_id = &u
  12714. m.addorganization_id = nil
  12715. }
  12716. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12717. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12718. v := m.organization_id
  12719. if v == nil {
  12720. return
  12721. }
  12722. return *v, true
  12723. }
  12724. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12725. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12727. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12728. if !m.op.Is(OpUpdateOne) {
  12729. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12730. }
  12731. if m.id == nil || m.oldValue == nil {
  12732. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12733. }
  12734. oldValue, err := m.oldValue(ctx)
  12735. if err != nil {
  12736. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12737. }
  12738. return oldValue.OrganizationID, nil
  12739. }
  12740. // AddOrganizationID adds u to the "organization_id" field.
  12741. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12742. if m.addorganization_id != nil {
  12743. *m.addorganization_id += u
  12744. } else {
  12745. m.addorganization_id = &u
  12746. }
  12747. }
  12748. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12749. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12750. v := m.addorganization_id
  12751. if v == nil {
  12752. return
  12753. }
  12754. return *v, true
  12755. }
  12756. // ClearOrganizationID clears the value of the "organization_id" field.
  12757. func (m *CreditUsageMutation) ClearOrganizationID() {
  12758. m.organization_id = nil
  12759. m.addorganization_id = nil
  12760. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12761. }
  12762. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12763. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  12764. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  12765. return ok
  12766. }
  12767. // ResetOrganizationID resets all changes to the "organization_id" field.
  12768. func (m *CreditUsageMutation) ResetOrganizationID() {
  12769. m.organization_id = nil
  12770. m.addorganization_id = nil
  12771. delete(m.clearedFields, creditusage.FieldOrganizationID)
  12772. }
  12773. // SetNid sets the "nid" field.
  12774. func (m *CreditUsageMutation) SetNid(u uint64) {
  12775. m.nid = &u
  12776. m.addnid = nil
  12777. }
  12778. // Nid returns the value of the "nid" field in the mutation.
  12779. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  12780. v := m.nid
  12781. if v == nil {
  12782. return
  12783. }
  12784. return *v, true
  12785. }
  12786. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  12787. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12789. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  12790. if !m.op.Is(OpUpdateOne) {
  12791. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  12792. }
  12793. if m.id == nil || m.oldValue == nil {
  12794. return v, errors.New("OldNid requires an ID field in the mutation")
  12795. }
  12796. oldValue, err := m.oldValue(ctx)
  12797. if err != nil {
  12798. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  12799. }
  12800. return oldValue.Nid, nil
  12801. }
  12802. // AddNid adds u to the "nid" field.
  12803. func (m *CreditUsageMutation) AddNid(u int64) {
  12804. if m.addnid != nil {
  12805. *m.addnid += u
  12806. } else {
  12807. m.addnid = &u
  12808. }
  12809. }
  12810. // AddedNid returns the value that was added to the "nid" field in this mutation.
  12811. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  12812. v := m.addnid
  12813. if v == nil {
  12814. return
  12815. }
  12816. return *v, true
  12817. }
  12818. // ResetNid resets all changes to the "nid" field.
  12819. func (m *CreditUsageMutation) ResetNid() {
  12820. m.nid = nil
  12821. m.addnid = nil
  12822. }
  12823. // SetReason sets the "reason" field.
  12824. func (m *CreditUsageMutation) SetReason(s string) {
  12825. m.reason = &s
  12826. }
  12827. // Reason returns the value of the "reason" field in the mutation.
  12828. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  12829. v := m.reason
  12830. if v == nil {
  12831. return
  12832. }
  12833. return *v, true
  12834. }
  12835. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  12836. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12838. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  12839. if !m.op.Is(OpUpdateOne) {
  12840. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  12841. }
  12842. if m.id == nil || m.oldValue == nil {
  12843. return v, errors.New("OldReason requires an ID field in the mutation")
  12844. }
  12845. oldValue, err := m.oldValue(ctx)
  12846. if err != nil {
  12847. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  12848. }
  12849. return oldValue.Reason, nil
  12850. }
  12851. // ResetReason resets all changes to the "reason" field.
  12852. func (m *CreditUsageMutation) ResetReason() {
  12853. m.reason = nil
  12854. }
  12855. // SetOperator sets the "operator" field.
  12856. func (m *CreditUsageMutation) SetOperator(s string) {
  12857. m.operator = &s
  12858. }
  12859. // Operator returns the value of the "operator" field in the mutation.
  12860. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  12861. v := m.operator
  12862. if v == nil {
  12863. return
  12864. }
  12865. return *v, true
  12866. }
  12867. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  12868. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12870. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  12871. if !m.op.Is(OpUpdateOne) {
  12872. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  12873. }
  12874. if m.id == nil || m.oldValue == nil {
  12875. return v, errors.New("OldOperator requires an ID field in the mutation")
  12876. }
  12877. oldValue, err := m.oldValue(ctx)
  12878. if err != nil {
  12879. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  12880. }
  12881. return oldValue.Operator, nil
  12882. }
  12883. // ResetOperator resets all changes to the "operator" field.
  12884. func (m *CreditUsageMutation) ResetOperator() {
  12885. m.operator = nil
  12886. }
  12887. // Where appends a list predicates to the CreditUsageMutation builder.
  12888. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  12889. m.predicates = append(m.predicates, ps...)
  12890. }
  12891. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  12892. // users can use type-assertion to append predicates that do not depend on any generated package.
  12893. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  12894. p := make([]predicate.CreditUsage, len(ps))
  12895. for i := range ps {
  12896. p[i] = ps[i]
  12897. }
  12898. m.Where(p...)
  12899. }
  12900. // Op returns the operation name.
  12901. func (m *CreditUsageMutation) Op() Op {
  12902. return m.op
  12903. }
  12904. // SetOp allows setting the mutation operation.
  12905. func (m *CreditUsageMutation) SetOp(op Op) {
  12906. m.op = op
  12907. }
  12908. // Type returns the node type of this mutation (CreditUsage).
  12909. func (m *CreditUsageMutation) Type() string {
  12910. return m.typ
  12911. }
  12912. // Fields returns all fields that were changed during this mutation. Note that in
  12913. // order to get all numeric fields that were incremented/decremented, call
  12914. // AddedFields().
  12915. func (m *CreditUsageMutation) Fields() []string {
  12916. fields := make([]string, 0, 12)
  12917. if m.created_at != nil {
  12918. fields = append(fields, creditusage.FieldCreatedAt)
  12919. }
  12920. if m.updated_at != nil {
  12921. fields = append(fields, creditusage.FieldUpdatedAt)
  12922. }
  12923. if m.deleted_at != nil {
  12924. fields = append(fields, creditusage.FieldDeletedAt)
  12925. }
  12926. if m.user_id != nil {
  12927. fields = append(fields, creditusage.FieldUserID)
  12928. }
  12929. if m.number != nil {
  12930. fields = append(fields, creditusage.FieldNumber)
  12931. }
  12932. if m.status != nil {
  12933. fields = append(fields, creditusage.FieldStatus)
  12934. }
  12935. if m.ntype != nil {
  12936. fields = append(fields, creditusage.FieldNtype)
  12937. }
  12938. if m.table != nil {
  12939. fields = append(fields, creditusage.FieldTable)
  12940. }
  12941. if m.organization_id != nil {
  12942. fields = append(fields, creditusage.FieldOrganizationID)
  12943. }
  12944. if m.nid != nil {
  12945. fields = append(fields, creditusage.FieldNid)
  12946. }
  12947. if m.reason != nil {
  12948. fields = append(fields, creditusage.FieldReason)
  12949. }
  12950. if m.operator != nil {
  12951. fields = append(fields, creditusage.FieldOperator)
  12952. }
  12953. return fields
  12954. }
  12955. // Field returns the value of a field with the given name. The second boolean
  12956. // return value indicates that this field was not set, or was not defined in the
  12957. // schema.
  12958. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  12959. switch name {
  12960. case creditusage.FieldCreatedAt:
  12961. return m.CreatedAt()
  12962. case creditusage.FieldUpdatedAt:
  12963. return m.UpdatedAt()
  12964. case creditusage.FieldDeletedAt:
  12965. return m.DeletedAt()
  12966. case creditusage.FieldUserID:
  12967. return m.UserID()
  12968. case creditusage.FieldNumber:
  12969. return m.Number()
  12970. case creditusage.FieldStatus:
  12971. return m.Status()
  12972. case creditusage.FieldNtype:
  12973. return m.Ntype()
  12974. case creditusage.FieldTable:
  12975. return m.Table()
  12976. case creditusage.FieldOrganizationID:
  12977. return m.OrganizationID()
  12978. case creditusage.FieldNid:
  12979. return m.Nid()
  12980. case creditusage.FieldReason:
  12981. return m.Reason()
  12982. case creditusage.FieldOperator:
  12983. return m.Operator()
  12984. }
  12985. return nil, false
  12986. }
  12987. // OldField returns the old value of the field from the database. An error is
  12988. // returned if the mutation operation is not UpdateOne, or the query to the
  12989. // database failed.
  12990. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12991. switch name {
  12992. case creditusage.FieldCreatedAt:
  12993. return m.OldCreatedAt(ctx)
  12994. case creditusage.FieldUpdatedAt:
  12995. return m.OldUpdatedAt(ctx)
  12996. case creditusage.FieldDeletedAt:
  12997. return m.OldDeletedAt(ctx)
  12998. case creditusage.FieldUserID:
  12999. return m.OldUserID(ctx)
  13000. case creditusage.FieldNumber:
  13001. return m.OldNumber(ctx)
  13002. case creditusage.FieldStatus:
  13003. return m.OldStatus(ctx)
  13004. case creditusage.FieldNtype:
  13005. return m.OldNtype(ctx)
  13006. case creditusage.FieldTable:
  13007. return m.OldTable(ctx)
  13008. case creditusage.FieldOrganizationID:
  13009. return m.OldOrganizationID(ctx)
  13010. case creditusage.FieldNid:
  13011. return m.OldNid(ctx)
  13012. case creditusage.FieldReason:
  13013. return m.OldReason(ctx)
  13014. case creditusage.FieldOperator:
  13015. return m.OldOperator(ctx)
  13016. }
  13017. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  13018. }
  13019. // SetField sets the value of a field with the given name. It returns an error if
  13020. // the field is not defined in the schema, or if the type mismatched the field
  13021. // type.
  13022. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  13023. switch name {
  13024. case creditusage.FieldCreatedAt:
  13025. v, ok := value.(time.Time)
  13026. if !ok {
  13027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13028. }
  13029. m.SetCreatedAt(v)
  13030. return nil
  13031. case creditusage.FieldUpdatedAt:
  13032. v, ok := value.(time.Time)
  13033. if !ok {
  13034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13035. }
  13036. m.SetUpdatedAt(v)
  13037. return nil
  13038. case creditusage.FieldDeletedAt:
  13039. v, ok := value.(time.Time)
  13040. if !ok {
  13041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13042. }
  13043. m.SetDeletedAt(v)
  13044. return nil
  13045. case creditusage.FieldUserID:
  13046. v, ok := value.(string)
  13047. if !ok {
  13048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13049. }
  13050. m.SetUserID(v)
  13051. return nil
  13052. case creditusage.FieldNumber:
  13053. v, ok := value.(float32)
  13054. if !ok {
  13055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13056. }
  13057. m.SetNumber(v)
  13058. return nil
  13059. case creditusage.FieldStatus:
  13060. v, ok := value.(int)
  13061. if !ok {
  13062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13063. }
  13064. m.SetStatus(v)
  13065. return nil
  13066. case creditusage.FieldNtype:
  13067. v, ok := value.(int)
  13068. if !ok {
  13069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13070. }
  13071. m.SetNtype(v)
  13072. return nil
  13073. case creditusage.FieldTable:
  13074. v, ok := value.(string)
  13075. if !ok {
  13076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13077. }
  13078. m.SetTable(v)
  13079. return nil
  13080. case creditusage.FieldOrganizationID:
  13081. v, ok := value.(uint64)
  13082. if !ok {
  13083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13084. }
  13085. m.SetOrganizationID(v)
  13086. return nil
  13087. case creditusage.FieldNid:
  13088. v, ok := value.(uint64)
  13089. if !ok {
  13090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13091. }
  13092. m.SetNid(v)
  13093. return nil
  13094. case creditusage.FieldReason:
  13095. v, ok := value.(string)
  13096. if !ok {
  13097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13098. }
  13099. m.SetReason(v)
  13100. return nil
  13101. case creditusage.FieldOperator:
  13102. v, ok := value.(string)
  13103. if !ok {
  13104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13105. }
  13106. m.SetOperator(v)
  13107. return nil
  13108. }
  13109. return fmt.Errorf("unknown CreditUsage field %s", name)
  13110. }
  13111. // AddedFields returns all numeric fields that were incremented/decremented during
  13112. // this mutation.
  13113. func (m *CreditUsageMutation) AddedFields() []string {
  13114. var fields []string
  13115. if m.addnumber != nil {
  13116. fields = append(fields, creditusage.FieldNumber)
  13117. }
  13118. if m.addstatus != nil {
  13119. fields = append(fields, creditusage.FieldStatus)
  13120. }
  13121. if m.addntype != nil {
  13122. fields = append(fields, creditusage.FieldNtype)
  13123. }
  13124. if m.addorganization_id != nil {
  13125. fields = append(fields, creditusage.FieldOrganizationID)
  13126. }
  13127. if m.addnid != nil {
  13128. fields = append(fields, creditusage.FieldNid)
  13129. }
  13130. return fields
  13131. }
  13132. // AddedField returns the numeric value that was incremented/decremented on a field
  13133. // with the given name. The second boolean return value indicates that this field
  13134. // was not set, or was not defined in the schema.
  13135. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13136. switch name {
  13137. case creditusage.FieldNumber:
  13138. return m.AddedNumber()
  13139. case creditusage.FieldStatus:
  13140. return m.AddedStatus()
  13141. case creditusage.FieldNtype:
  13142. return m.AddedNtype()
  13143. case creditusage.FieldOrganizationID:
  13144. return m.AddedOrganizationID()
  13145. case creditusage.FieldNid:
  13146. return m.AddedNid()
  13147. }
  13148. return nil, false
  13149. }
  13150. // AddField adds the value to the field with the given name. It returns an error if
  13151. // the field is not defined in the schema, or if the type mismatched the field
  13152. // type.
  13153. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13154. switch name {
  13155. case creditusage.FieldNumber:
  13156. v, ok := value.(float32)
  13157. if !ok {
  13158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13159. }
  13160. m.AddNumber(v)
  13161. return nil
  13162. case creditusage.FieldStatus:
  13163. v, ok := value.(int)
  13164. if !ok {
  13165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13166. }
  13167. m.AddStatus(v)
  13168. return nil
  13169. case creditusage.FieldNtype:
  13170. v, ok := value.(int)
  13171. if !ok {
  13172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13173. }
  13174. m.AddNtype(v)
  13175. return nil
  13176. case creditusage.FieldOrganizationID:
  13177. v, ok := value.(int64)
  13178. if !ok {
  13179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13180. }
  13181. m.AddOrganizationID(v)
  13182. return nil
  13183. case creditusage.FieldNid:
  13184. v, ok := value.(int64)
  13185. if !ok {
  13186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13187. }
  13188. m.AddNid(v)
  13189. return nil
  13190. }
  13191. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13192. }
  13193. // ClearedFields returns all nullable fields that were cleared during this
  13194. // mutation.
  13195. func (m *CreditUsageMutation) ClearedFields() []string {
  13196. var fields []string
  13197. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13198. fields = append(fields, creditusage.FieldDeletedAt)
  13199. }
  13200. if m.FieldCleared(creditusage.FieldUserID) {
  13201. fields = append(fields, creditusage.FieldUserID)
  13202. }
  13203. if m.FieldCleared(creditusage.FieldStatus) {
  13204. fields = append(fields, creditusage.FieldStatus)
  13205. }
  13206. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13207. fields = append(fields, creditusage.FieldOrganizationID)
  13208. }
  13209. return fields
  13210. }
  13211. // FieldCleared returns a boolean indicating if a field with the given name was
  13212. // cleared in this mutation.
  13213. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13214. _, ok := m.clearedFields[name]
  13215. return ok
  13216. }
  13217. // ClearField clears the value of the field with the given name. It returns an
  13218. // error if the field is not defined in the schema.
  13219. func (m *CreditUsageMutation) ClearField(name string) error {
  13220. switch name {
  13221. case creditusage.FieldDeletedAt:
  13222. m.ClearDeletedAt()
  13223. return nil
  13224. case creditusage.FieldUserID:
  13225. m.ClearUserID()
  13226. return nil
  13227. case creditusage.FieldStatus:
  13228. m.ClearStatus()
  13229. return nil
  13230. case creditusage.FieldOrganizationID:
  13231. m.ClearOrganizationID()
  13232. return nil
  13233. }
  13234. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13235. }
  13236. // ResetField resets all changes in the mutation for the field with the given name.
  13237. // It returns an error if the field is not defined in the schema.
  13238. func (m *CreditUsageMutation) ResetField(name string) error {
  13239. switch name {
  13240. case creditusage.FieldCreatedAt:
  13241. m.ResetCreatedAt()
  13242. return nil
  13243. case creditusage.FieldUpdatedAt:
  13244. m.ResetUpdatedAt()
  13245. return nil
  13246. case creditusage.FieldDeletedAt:
  13247. m.ResetDeletedAt()
  13248. return nil
  13249. case creditusage.FieldUserID:
  13250. m.ResetUserID()
  13251. return nil
  13252. case creditusage.FieldNumber:
  13253. m.ResetNumber()
  13254. return nil
  13255. case creditusage.FieldStatus:
  13256. m.ResetStatus()
  13257. return nil
  13258. case creditusage.FieldNtype:
  13259. m.ResetNtype()
  13260. return nil
  13261. case creditusage.FieldTable:
  13262. m.ResetTable()
  13263. return nil
  13264. case creditusage.FieldOrganizationID:
  13265. m.ResetOrganizationID()
  13266. return nil
  13267. case creditusage.FieldNid:
  13268. m.ResetNid()
  13269. return nil
  13270. case creditusage.FieldReason:
  13271. m.ResetReason()
  13272. return nil
  13273. case creditusage.FieldOperator:
  13274. m.ResetOperator()
  13275. return nil
  13276. }
  13277. return fmt.Errorf("unknown CreditUsage field %s", name)
  13278. }
  13279. // AddedEdges returns all edge names that were set/added in this mutation.
  13280. func (m *CreditUsageMutation) AddedEdges() []string {
  13281. edges := make([]string, 0, 0)
  13282. return edges
  13283. }
  13284. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13285. // name in this mutation.
  13286. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13287. return nil
  13288. }
  13289. // RemovedEdges returns all edge names that were removed in this mutation.
  13290. func (m *CreditUsageMutation) RemovedEdges() []string {
  13291. edges := make([]string, 0, 0)
  13292. return edges
  13293. }
  13294. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13295. // the given name in this mutation.
  13296. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13297. return nil
  13298. }
  13299. // ClearedEdges returns all edge names that were cleared in this mutation.
  13300. func (m *CreditUsageMutation) ClearedEdges() []string {
  13301. edges := make([]string, 0, 0)
  13302. return edges
  13303. }
  13304. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13305. // was cleared in this mutation.
  13306. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13307. return false
  13308. }
  13309. // ClearEdge clears the value of the edge with the given name. It returns an error
  13310. // if that edge is not defined in the schema.
  13311. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13312. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13313. }
  13314. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13315. // It returns an error if the edge is not defined in the schema.
  13316. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13317. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13318. }
  13319. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13320. type EmployeeMutation struct {
  13321. config
  13322. op Op
  13323. typ string
  13324. id *uint64
  13325. created_at *time.Time
  13326. updated_at *time.Time
  13327. deleted_at *time.Time
  13328. title *string
  13329. avatar *string
  13330. tags *string
  13331. hire_count *int
  13332. addhire_count *int
  13333. service_count *int
  13334. addservice_count *int
  13335. achievement_count *int
  13336. addachievement_count *int
  13337. intro *string
  13338. estimate *string
  13339. skill *string
  13340. ability_type *string
  13341. scene *string
  13342. switch_in *string
  13343. video_url *string
  13344. organization_id *uint64
  13345. addorganization_id *int64
  13346. category_id *uint64
  13347. addcategory_id *int64
  13348. api_base *string
  13349. api_key *string
  13350. ai_info *string
  13351. is_vip *int
  13352. addis_vip *int
  13353. chat_url *string
  13354. clearedFields map[string]struct{}
  13355. em_work_experiences map[uint64]struct{}
  13356. removedem_work_experiences map[uint64]struct{}
  13357. clearedem_work_experiences bool
  13358. em_tutorial map[uint64]struct{}
  13359. removedem_tutorial map[uint64]struct{}
  13360. clearedem_tutorial bool
  13361. done bool
  13362. oldValue func(context.Context) (*Employee, error)
  13363. predicates []predicate.Employee
  13364. }
  13365. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13366. // employeeOption allows management of the mutation configuration using functional options.
  13367. type employeeOption func(*EmployeeMutation)
  13368. // newEmployeeMutation creates new mutation for the Employee entity.
  13369. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13370. m := &EmployeeMutation{
  13371. config: c,
  13372. op: op,
  13373. typ: TypeEmployee,
  13374. clearedFields: make(map[string]struct{}),
  13375. }
  13376. for _, opt := range opts {
  13377. opt(m)
  13378. }
  13379. return m
  13380. }
  13381. // withEmployeeID sets the ID field of the mutation.
  13382. func withEmployeeID(id uint64) employeeOption {
  13383. return func(m *EmployeeMutation) {
  13384. var (
  13385. err error
  13386. once sync.Once
  13387. value *Employee
  13388. )
  13389. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13390. once.Do(func() {
  13391. if m.done {
  13392. err = errors.New("querying old values post mutation is not allowed")
  13393. } else {
  13394. value, err = m.Client().Employee.Get(ctx, id)
  13395. }
  13396. })
  13397. return value, err
  13398. }
  13399. m.id = &id
  13400. }
  13401. }
  13402. // withEmployee sets the old Employee of the mutation.
  13403. func withEmployee(node *Employee) employeeOption {
  13404. return func(m *EmployeeMutation) {
  13405. m.oldValue = func(context.Context) (*Employee, error) {
  13406. return node, nil
  13407. }
  13408. m.id = &node.ID
  13409. }
  13410. }
  13411. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13412. // executed in a transaction (ent.Tx), a transactional client is returned.
  13413. func (m EmployeeMutation) Client() *Client {
  13414. client := &Client{config: m.config}
  13415. client.init()
  13416. return client
  13417. }
  13418. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13419. // it returns an error otherwise.
  13420. func (m EmployeeMutation) Tx() (*Tx, error) {
  13421. if _, ok := m.driver.(*txDriver); !ok {
  13422. return nil, errors.New("ent: mutation is not running in a transaction")
  13423. }
  13424. tx := &Tx{config: m.config}
  13425. tx.init()
  13426. return tx, nil
  13427. }
  13428. // SetID sets the value of the id field. Note that this
  13429. // operation is only accepted on creation of Employee entities.
  13430. func (m *EmployeeMutation) SetID(id uint64) {
  13431. m.id = &id
  13432. }
  13433. // ID returns the ID value in the mutation. Note that the ID is only available
  13434. // if it was provided to the builder or after it was returned from the database.
  13435. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13436. if m.id == nil {
  13437. return
  13438. }
  13439. return *m.id, true
  13440. }
  13441. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13442. // That means, if the mutation is applied within a transaction with an isolation level such
  13443. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13444. // or updated by the mutation.
  13445. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13446. switch {
  13447. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13448. id, exists := m.ID()
  13449. if exists {
  13450. return []uint64{id}, nil
  13451. }
  13452. fallthrough
  13453. case m.op.Is(OpUpdate | OpDelete):
  13454. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13455. default:
  13456. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13457. }
  13458. }
  13459. // SetCreatedAt sets the "created_at" field.
  13460. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13461. m.created_at = &t
  13462. }
  13463. // CreatedAt returns the value of the "created_at" field in the mutation.
  13464. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13465. v := m.created_at
  13466. if v == nil {
  13467. return
  13468. }
  13469. return *v, true
  13470. }
  13471. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13472. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13474. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13475. if !m.op.Is(OpUpdateOne) {
  13476. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13477. }
  13478. if m.id == nil || m.oldValue == nil {
  13479. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13480. }
  13481. oldValue, err := m.oldValue(ctx)
  13482. if err != nil {
  13483. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13484. }
  13485. return oldValue.CreatedAt, nil
  13486. }
  13487. // ResetCreatedAt resets all changes to the "created_at" field.
  13488. func (m *EmployeeMutation) ResetCreatedAt() {
  13489. m.created_at = nil
  13490. }
  13491. // SetUpdatedAt sets the "updated_at" field.
  13492. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13493. m.updated_at = &t
  13494. }
  13495. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13496. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13497. v := m.updated_at
  13498. if v == nil {
  13499. return
  13500. }
  13501. return *v, true
  13502. }
  13503. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13504. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13506. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13507. if !m.op.Is(OpUpdateOne) {
  13508. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13509. }
  13510. if m.id == nil || m.oldValue == nil {
  13511. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13512. }
  13513. oldValue, err := m.oldValue(ctx)
  13514. if err != nil {
  13515. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13516. }
  13517. return oldValue.UpdatedAt, nil
  13518. }
  13519. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13520. func (m *EmployeeMutation) ResetUpdatedAt() {
  13521. m.updated_at = nil
  13522. }
  13523. // SetDeletedAt sets the "deleted_at" field.
  13524. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13525. m.deleted_at = &t
  13526. }
  13527. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13528. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13529. v := m.deleted_at
  13530. if v == nil {
  13531. return
  13532. }
  13533. return *v, true
  13534. }
  13535. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13536. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13538. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13539. if !m.op.Is(OpUpdateOne) {
  13540. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13541. }
  13542. if m.id == nil || m.oldValue == nil {
  13543. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13544. }
  13545. oldValue, err := m.oldValue(ctx)
  13546. if err != nil {
  13547. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13548. }
  13549. return oldValue.DeletedAt, nil
  13550. }
  13551. // ClearDeletedAt clears the value of the "deleted_at" field.
  13552. func (m *EmployeeMutation) ClearDeletedAt() {
  13553. m.deleted_at = nil
  13554. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13555. }
  13556. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13557. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13558. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13559. return ok
  13560. }
  13561. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13562. func (m *EmployeeMutation) ResetDeletedAt() {
  13563. m.deleted_at = nil
  13564. delete(m.clearedFields, employee.FieldDeletedAt)
  13565. }
  13566. // SetTitle sets the "title" field.
  13567. func (m *EmployeeMutation) SetTitle(s string) {
  13568. m.title = &s
  13569. }
  13570. // Title returns the value of the "title" field in the mutation.
  13571. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13572. v := m.title
  13573. if v == nil {
  13574. return
  13575. }
  13576. return *v, true
  13577. }
  13578. // OldTitle returns the old "title" field's value of the Employee entity.
  13579. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13581. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13582. if !m.op.Is(OpUpdateOne) {
  13583. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13584. }
  13585. if m.id == nil || m.oldValue == nil {
  13586. return v, errors.New("OldTitle requires an ID field in the mutation")
  13587. }
  13588. oldValue, err := m.oldValue(ctx)
  13589. if err != nil {
  13590. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13591. }
  13592. return oldValue.Title, nil
  13593. }
  13594. // ResetTitle resets all changes to the "title" field.
  13595. func (m *EmployeeMutation) ResetTitle() {
  13596. m.title = nil
  13597. }
  13598. // SetAvatar sets the "avatar" field.
  13599. func (m *EmployeeMutation) SetAvatar(s string) {
  13600. m.avatar = &s
  13601. }
  13602. // Avatar returns the value of the "avatar" field in the mutation.
  13603. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13604. v := m.avatar
  13605. if v == nil {
  13606. return
  13607. }
  13608. return *v, true
  13609. }
  13610. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13611. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13613. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13614. if !m.op.Is(OpUpdateOne) {
  13615. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13616. }
  13617. if m.id == nil || m.oldValue == nil {
  13618. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13619. }
  13620. oldValue, err := m.oldValue(ctx)
  13621. if err != nil {
  13622. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13623. }
  13624. return oldValue.Avatar, nil
  13625. }
  13626. // ResetAvatar resets all changes to the "avatar" field.
  13627. func (m *EmployeeMutation) ResetAvatar() {
  13628. m.avatar = nil
  13629. }
  13630. // SetTags sets the "tags" field.
  13631. func (m *EmployeeMutation) SetTags(s string) {
  13632. m.tags = &s
  13633. }
  13634. // Tags returns the value of the "tags" field in the mutation.
  13635. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  13636. v := m.tags
  13637. if v == nil {
  13638. return
  13639. }
  13640. return *v, true
  13641. }
  13642. // OldTags returns the old "tags" field's value of the Employee entity.
  13643. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13645. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  13646. if !m.op.Is(OpUpdateOne) {
  13647. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  13648. }
  13649. if m.id == nil || m.oldValue == nil {
  13650. return v, errors.New("OldTags requires an ID field in the mutation")
  13651. }
  13652. oldValue, err := m.oldValue(ctx)
  13653. if err != nil {
  13654. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  13655. }
  13656. return oldValue.Tags, nil
  13657. }
  13658. // ResetTags resets all changes to the "tags" field.
  13659. func (m *EmployeeMutation) ResetTags() {
  13660. m.tags = nil
  13661. }
  13662. // SetHireCount sets the "hire_count" field.
  13663. func (m *EmployeeMutation) SetHireCount(i int) {
  13664. m.hire_count = &i
  13665. m.addhire_count = nil
  13666. }
  13667. // HireCount returns the value of the "hire_count" field in the mutation.
  13668. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  13669. v := m.hire_count
  13670. if v == nil {
  13671. return
  13672. }
  13673. return *v, true
  13674. }
  13675. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  13676. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13678. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  13679. if !m.op.Is(OpUpdateOne) {
  13680. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  13681. }
  13682. if m.id == nil || m.oldValue == nil {
  13683. return v, errors.New("OldHireCount requires an ID field in the mutation")
  13684. }
  13685. oldValue, err := m.oldValue(ctx)
  13686. if err != nil {
  13687. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  13688. }
  13689. return oldValue.HireCount, nil
  13690. }
  13691. // AddHireCount adds i to the "hire_count" field.
  13692. func (m *EmployeeMutation) AddHireCount(i int) {
  13693. if m.addhire_count != nil {
  13694. *m.addhire_count += i
  13695. } else {
  13696. m.addhire_count = &i
  13697. }
  13698. }
  13699. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  13700. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  13701. v := m.addhire_count
  13702. if v == nil {
  13703. return
  13704. }
  13705. return *v, true
  13706. }
  13707. // ResetHireCount resets all changes to the "hire_count" field.
  13708. func (m *EmployeeMutation) ResetHireCount() {
  13709. m.hire_count = nil
  13710. m.addhire_count = nil
  13711. }
  13712. // SetServiceCount sets the "service_count" field.
  13713. func (m *EmployeeMutation) SetServiceCount(i int) {
  13714. m.service_count = &i
  13715. m.addservice_count = nil
  13716. }
  13717. // ServiceCount returns the value of the "service_count" field in the mutation.
  13718. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  13719. v := m.service_count
  13720. if v == nil {
  13721. return
  13722. }
  13723. return *v, true
  13724. }
  13725. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  13726. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13728. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  13729. if !m.op.Is(OpUpdateOne) {
  13730. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  13731. }
  13732. if m.id == nil || m.oldValue == nil {
  13733. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  13734. }
  13735. oldValue, err := m.oldValue(ctx)
  13736. if err != nil {
  13737. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  13738. }
  13739. return oldValue.ServiceCount, nil
  13740. }
  13741. // AddServiceCount adds i to the "service_count" field.
  13742. func (m *EmployeeMutation) AddServiceCount(i int) {
  13743. if m.addservice_count != nil {
  13744. *m.addservice_count += i
  13745. } else {
  13746. m.addservice_count = &i
  13747. }
  13748. }
  13749. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  13750. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  13751. v := m.addservice_count
  13752. if v == nil {
  13753. return
  13754. }
  13755. return *v, true
  13756. }
  13757. // ResetServiceCount resets all changes to the "service_count" field.
  13758. func (m *EmployeeMutation) ResetServiceCount() {
  13759. m.service_count = nil
  13760. m.addservice_count = nil
  13761. }
  13762. // SetAchievementCount sets the "achievement_count" field.
  13763. func (m *EmployeeMutation) SetAchievementCount(i int) {
  13764. m.achievement_count = &i
  13765. m.addachievement_count = nil
  13766. }
  13767. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  13768. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  13769. v := m.achievement_count
  13770. if v == nil {
  13771. return
  13772. }
  13773. return *v, true
  13774. }
  13775. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  13776. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13778. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  13779. if !m.op.Is(OpUpdateOne) {
  13780. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  13781. }
  13782. if m.id == nil || m.oldValue == nil {
  13783. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  13784. }
  13785. oldValue, err := m.oldValue(ctx)
  13786. if err != nil {
  13787. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  13788. }
  13789. return oldValue.AchievementCount, nil
  13790. }
  13791. // AddAchievementCount adds i to the "achievement_count" field.
  13792. func (m *EmployeeMutation) AddAchievementCount(i int) {
  13793. if m.addachievement_count != nil {
  13794. *m.addachievement_count += i
  13795. } else {
  13796. m.addachievement_count = &i
  13797. }
  13798. }
  13799. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  13800. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  13801. v := m.addachievement_count
  13802. if v == nil {
  13803. return
  13804. }
  13805. return *v, true
  13806. }
  13807. // ResetAchievementCount resets all changes to the "achievement_count" field.
  13808. func (m *EmployeeMutation) ResetAchievementCount() {
  13809. m.achievement_count = nil
  13810. m.addachievement_count = nil
  13811. }
  13812. // SetIntro sets the "intro" field.
  13813. func (m *EmployeeMutation) SetIntro(s string) {
  13814. m.intro = &s
  13815. }
  13816. // Intro returns the value of the "intro" field in the mutation.
  13817. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  13818. v := m.intro
  13819. if v == nil {
  13820. return
  13821. }
  13822. return *v, true
  13823. }
  13824. // OldIntro returns the old "intro" field's value of the Employee entity.
  13825. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13827. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  13828. if !m.op.Is(OpUpdateOne) {
  13829. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  13830. }
  13831. if m.id == nil || m.oldValue == nil {
  13832. return v, errors.New("OldIntro requires an ID field in the mutation")
  13833. }
  13834. oldValue, err := m.oldValue(ctx)
  13835. if err != nil {
  13836. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  13837. }
  13838. return oldValue.Intro, nil
  13839. }
  13840. // ResetIntro resets all changes to the "intro" field.
  13841. func (m *EmployeeMutation) ResetIntro() {
  13842. m.intro = nil
  13843. }
  13844. // SetEstimate sets the "estimate" field.
  13845. func (m *EmployeeMutation) SetEstimate(s string) {
  13846. m.estimate = &s
  13847. }
  13848. // Estimate returns the value of the "estimate" field in the mutation.
  13849. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  13850. v := m.estimate
  13851. if v == nil {
  13852. return
  13853. }
  13854. return *v, true
  13855. }
  13856. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  13857. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13859. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  13860. if !m.op.Is(OpUpdateOne) {
  13861. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  13862. }
  13863. if m.id == nil || m.oldValue == nil {
  13864. return v, errors.New("OldEstimate requires an ID field in the mutation")
  13865. }
  13866. oldValue, err := m.oldValue(ctx)
  13867. if err != nil {
  13868. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  13869. }
  13870. return oldValue.Estimate, nil
  13871. }
  13872. // ResetEstimate resets all changes to the "estimate" field.
  13873. func (m *EmployeeMutation) ResetEstimate() {
  13874. m.estimate = nil
  13875. }
  13876. // SetSkill sets the "skill" field.
  13877. func (m *EmployeeMutation) SetSkill(s string) {
  13878. m.skill = &s
  13879. }
  13880. // Skill returns the value of the "skill" field in the mutation.
  13881. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  13882. v := m.skill
  13883. if v == nil {
  13884. return
  13885. }
  13886. return *v, true
  13887. }
  13888. // OldSkill returns the old "skill" field's value of the Employee entity.
  13889. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13891. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  13892. if !m.op.Is(OpUpdateOne) {
  13893. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  13894. }
  13895. if m.id == nil || m.oldValue == nil {
  13896. return v, errors.New("OldSkill requires an ID field in the mutation")
  13897. }
  13898. oldValue, err := m.oldValue(ctx)
  13899. if err != nil {
  13900. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  13901. }
  13902. return oldValue.Skill, nil
  13903. }
  13904. // ResetSkill resets all changes to the "skill" field.
  13905. func (m *EmployeeMutation) ResetSkill() {
  13906. m.skill = nil
  13907. }
  13908. // SetAbilityType sets the "ability_type" field.
  13909. func (m *EmployeeMutation) SetAbilityType(s string) {
  13910. m.ability_type = &s
  13911. }
  13912. // AbilityType returns the value of the "ability_type" field in the mutation.
  13913. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  13914. v := m.ability_type
  13915. if v == nil {
  13916. return
  13917. }
  13918. return *v, true
  13919. }
  13920. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  13921. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13923. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  13924. if !m.op.Is(OpUpdateOne) {
  13925. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  13926. }
  13927. if m.id == nil || m.oldValue == nil {
  13928. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  13929. }
  13930. oldValue, err := m.oldValue(ctx)
  13931. if err != nil {
  13932. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  13933. }
  13934. return oldValue.AbilityType, nil
  13935. }
  13936. // ResetAbilityType resets all changes to the "ability_type" field.
  13937. func (m *EmployeeMutation) ResetAbilityType() {
  13938. m.ability_type = nil
  13939. }
  13940. // SetScene sets the "scene" field.
  13941. func (m *EmployeeMutation) SetScene(s string) {
  13942. m.scene = &s
  13943. }
  13944. // Scene returns the value of the "scene" field in the mutation.
  13945. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  13946. v := m.scene
  13947. if v == nil {
  13948. return
  13949. }
  13950. return *v, true
  13951. }
  13952. // OldScene returns the old "scene" field's value of the Employee entity.
  13953. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13955. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  13956. if !m.op.Is(OpUpdateOne) {
  13957. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  13958. }
  13959. if m.id == nil || m.oldValue == nil {
  13960. return v, errors.New("OldScene requires an ID field in the mutation")
  13961. }
  13962. oldValue, err := m.oldValue(ctx)
  13963. if err != nil {
  13964. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  13965. }
  13966. return oldValue.Scene, nil
  13967. }
  13968. // ResetScene resets all changes to the "scene" field.
  13969. func (m *EmployeeMutation) ResetScene() {
  13970. m.scene = nil
  13971. }
  13972. // SetSwitchIn sets the "switch_in" field.
  13973. func (m *EmployeeMutation) SetSwitchIn(s string) {
  13974. m.switch_in = &s
  13975. }
  13976. // SwitchIn returns the value of the "switch_in" field in the mutation.
  13977. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  13978. v := m.switch_in
  13979. if v == nil {
  13980. return
  13981. }
  13982. return *v, true
  13983. }
  13984. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  13985. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13987. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  13988. if !m.op.Is(OpUpdateOne) {
  13989. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  13990. }
  13991. if m.id == nil || m.oldValue == nil {
  13992. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  13993. }
  13994. oldValue, err := m.oldValue(ctx)
  13995. if err != nil {
  13996. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  13997. }
  13998. return oldValue.SwitchIn, nil
  13999. }
  14000. // ResetSwitchIn resets all changes to the "switch_in" field.
  14001. func (m *EmployeeMutation) ResetSwitchIn() {
  14002. m.switch_in = nil
  14003. }
  14004. // SetVideoURL sets the "video_url" field.
  14005. func (m *EmployeeMutation) SetVideoURL(s string) {
  14006. m.video_url = &s
  14007. }
  14008. // VideoURL returns the value of the "video_url" field in the mutation.
  14009. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  14010. v := m.video_url
  14011. if v == nil {
  14012. return
  14013. }
  14014. return *v, true
  14015. }
  14016. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  14017. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14019. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  14020. if !m.op.Is(OpUpdateOne) {
  14021. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  14022. }
  14023. if m.id == nil || m.oldValue == nil {
  14024. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  14025. }
  14026. oldValue, err := m.oldValue(ctx)
  14027. if err != nil {
  14028. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  14029. }
  14030. return oldValue.VideoURL, nil
  14031. }
  14032. // ResetVideoURL resets all changes to the "video_url" field.
  14033. func (m *EmployeeMutation) ResetVideoURL() {
  14034. m.video_url = nil
  14035. }
  14036. // SetOrganizationID sets the "organization_id" field.
  14037. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  14038. m.organization_id = &u
  14039. m.addorganization_id = nil
  14040. }
  14041. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14042. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  14043. v := m.organization_id
  14044. if v == nil {
  14045. return
  14046. }
  14047. return *v, true
  14048. }
  14049. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  14050. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14052. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14053. if !m.op.Is(OpUpdateOne) {
  14054. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14055. }
  14056. if m.id == nil || m.oldValue == nil {
  14057. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14058. }
  14059. oldValue, err := m.oldValue(ctx)
  14060. if err != nil {
  14061. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14062. }
  14063. return oldValue.OrganizationID, nil
  14064. }
  14065. // AddOrganizationID adds u to the "organization_id" field.
  14066. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  14067. if m.addorganization_id != nil {
  14068. *m.addorganization_id += u
  14069. } else {
  14070. m.addorganization_id = &u
  14071. }
  14072. }
  14073. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14074. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  14075. v := m.addorganization_id
  14076. if v == nil {
  14077. return
  14078. }
  14079. return *v, true
  14080. }
  14081. // ResetOrganizationID resets all changes to the "organization_id" field.
  14082. func (m *EmployeeMutation) ResetOrganizationID() {
  14083. m.organization_id = nil
  14084. m.addorganization_id = nil
  14085. }
  14086. // SetCategoryID sets the "category_id" field.
  14087. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14088. m.category_id = &u
  14089. m.addcategory_id = nil
  14090. }
  14091. // CategoryID returns the value of the "category_id" field in the mutation.
  14092. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14093. v := m.category_id
  14094. if v == nil {
  14095. return
  14096. }
  14097. return *v, true
  14098. }
  14099. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14100. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14102. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14103. if !m.op.Is(OpUpdateOne) {
  14104. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14105. }
  14106. if m.id == nil || m.oldValue == nil {
  14107. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14108. }
  14109. oldValue, err := m.oldValue(ctx)
  14110. if err != nil {
  14111. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14112. }
  14113. return oldValue.CategoryID, nil
  14114. }
  14115. // AddCategoryID adds u to the "category_id" field.
  14116. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14117. if m.addcategory_id != nil {
  14118. *m.addcategory_id += u
  14119. } else {
  14120. m.addcategory_id = &u
  14121. }
  14122. }
  14123. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14124. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14125. v := m.addcategory_id
  14126. if v == nil {
  14127. return
  14128. }
  14129. return *v, true
  14130. }
  14131. // ResetCategoryID resets all changes to the "category_id" field.
  14132. func (m *EmployeeMutation) ResetCategoryID() {
  14133. m.category_id = nil
  14134. m.addcategory_id = nil
  14135. }
  14136. // SetAPIBase sets the "api_base" field.
  14137. func (m *EmployeeMutation) SetAPIBase(s string) {
  14138. m.api_base = &s
  14139. }
  14140. // APIBase returns the value of the "api_base" field in the mutation.
  14141. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14142. v := m.api_base
  14143. if v == nil {
  14144. return
  14145. }
  14146. return *v, true
  14147. }
  14148. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14149. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14151. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14152. if !m.op.Is(OpUpdateOne) {
  14153. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14154. }
  14155. if m.id == nil || m.oldValue == nil {
  14156. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14157. }
  14158. oldValue, err := m.oldValue(ctx)
  14159. if err != nil {
  14160. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14161. }
  14162. return oldValue.APIBase, nil
  14163. }
  14164. // ResetAPIBase resets all changes to the "api_base" field.
  14165. func (m *EmployeeMutation) ResetAPIBase() {
  14166. m.api_base = nil
  14167. }
  14168. // SetAPIKey sets the "api_key" field.
  14169. func (m *EmployeeMutation) SetAPIKey(s string) {
  14170. m.api_key = &s
  14171. }
  14172. // APIKey returns the value of the "api_key" field in the mutation.
  14173. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14174. v := m.api_key
  14175. if v == nil {
  14176. return
  14177. }
  14178. return *v, true
  14179. }
  14180. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14181. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14183. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14184. if !m.op.Is(OpUpdateOne) {
  14185. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14186. }
  14187. if m.id == nil || m.oldValue == nil {
  14188. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14189. }
  14190. oldValue, err := m.oldValue(ctx)
  14191. if err != nil {
  14192. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14193. }
  14194. return oldValue.APIKey, nil
  14195. }
  14196. // ResetAPIKey resets all changes to the "api_key" field.
  14197. func (m *EmployeeMutation) ResetAPIKey() {
  14198. m.api_key = nil
  14199. }
  14200. // SetAiInfo sets the "ai_info" field.
  14201. func (m *EmployeeMutation) SetAiInfo(s string) {
  14202. m.ai_info = &s
  14203. }
  14204. // AiInfo returns the value of the "ai_info" field in the mutation.
  14205. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14206. v := m.ai_info
  14207. if v == nil {
  14208. return
  14209. }
  14210. return *v, true
  14211. }
  14212. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14213. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14215. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14216. if !m.op.Is(OpUpdateOne) {
  14217. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14218. }
  14219. if m.id == nil || m.oldValue == nil {
  14220. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14221. }
  14222. oldValue, err := m.oldValue(ctx)
  14223. if err != nil {
  14224. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14225. }
  14226. return oldValue.AiInfo, nil
  14227. }
  14228. // ClearAiInfo clears the value of the "ai_info" field.
  14229. func (m *EmployeeMutation) ClearAiInfo() {
  14230. m.ai_info = nil
  14231. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14232. }
  14233. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14234. func (m *EmployeeMutation) AiInfoCleared() bool {
  14235. _, ok := m.clearedFields[employee.FieldAiInfo]
  14236. return ok
  14237. }
  14238. // ResetAiInfo resets all changes to the "ai_info" field.
  14239. func (m *EmployeeMutation) ResetAiInfo() {
  14240. m.ai_info = nil
  14241. delete(m.clearedFields, employee.FieldAiInfo)
  14242. }
  14243. // SetIsVip sets the "is_vip" field.
  14244. func (m *EmployeeMutation) SetIsVip(i int) {
  14245. m.is_vip = &i
  14246. m.addis_vip = nil
  14247. }
  14248. // IsVip returns the value of the "is_vip" field in the mutation.
  14249. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14250. v := m.is_vip
  14251. if v == nil {
  14252. return
  14253. }
  14254. return *v, true
  14255. }
  14256. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14257. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14259. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14260. if !m.op.Is(OpUpdateOne) {
  14261. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14262. }
  14263. if m.id == nil || m.oldValue == nil {
  14264. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14265. }
  14266. oldValue, err := m.oldValue(ctx)
  14267. if err != nil {
  14268. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14269. }
  14270. return oldValue.IsVip, nil
  14271. }
  14272. // AddIsVip adds i to the "is_vip" field.
  14273. func (m *EmployeeMutation) AddIsVip(i int) {
  14274. if m.addis_vip != nil {
  14275. *m.addis_vip += i
  14276. } else {
  14277. m.addis_vip = &i
  14278. }
  14279. }
  14280. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14281. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14282. v := m.addis_vip
  14283. if v == nil {
  14284. return
  14285. }
  14286. return *v, true
  14287. }
  14288. // ResetIsVip resets all changes to the "is_vip" field.
  14289. func (m *EmployeeMutation) ResetIsVip() {
  14290. m.is_vip = nil
  14291. m.addis_vip = nil
  14292. }
  14293. // SetChatURL sets the "chat_url" field.
  14294. func (m *EmployeeMutation) SetChatURL(s string) {
  14295. m.chat_url = &s
  14296. }
  14297. // ChatURL returns the value of the "chat_url" field in the mutation.
  14298. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14299. v := m.chat_url
  14300. if v == nil {
  14301. return
  14302. }
  14303. return *v, true
  14304. }
  14305. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14306. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14308. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14309. if !m.op.Is(OpUpdateOne) {
  14310. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14311. }
  14312. if m.id == nil || m.oldValue == nil {
  14313. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14314. }
  14315. oldValue, err := m.oldValue(ctx)
  14316. if err != nil {
  14317. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14318. }
  14319. return oldValue.ChatURL, nil
  14320. }
  14321. // ResetChatURL resets all changes to the "chat_url" field.
  14322. func (m *EmployeeMutation) ResetChatURL() {
  14323. m.chat_url = nil
  14324. }
  14325. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14326. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14327. if m.em_work_experiences == nil {
  14328. m.em_work_experiences = make(map[uint64]struct{})
  14329. }
  14330. for i := range ids {
  14331. m.em_work_experiences[ids[i]] = struct{}{}
  14332. }
  14333. }
  14334. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14335. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14336. m.clearedem_work_experiences = true
  14337. }
  14338. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14339. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14340. return m.clearedem_work_experiences
  14341. }
  14342. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14343. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14344. if m.removedem_work_experiences == nil {
  14345. m.removedem_work_experiences = make(map[uint64]struct{})
  14346. }
  14347. for i := range ids {
  14348. delete(m.em_work_experiences, ids[i])
  14349. m.removedem_work_experiences[ids[i]] = struct{}{}
  14350. }
  14351. }
  14352. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14353. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14354. for id := range m.removedem_work_experiences {
  14355. ids = append(ids, id)
  14356. }
  14357. return
  14358. }
  14359. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14360. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14361. for id := range m.em_work_experiences {
  14362. ids = append(ids, id)
  14363. }
  14364. return
  14365. }
  14366. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14367. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14368. m.em_work_experiences = nil
  14369. m.clearedem_work_experiences = false
  14370. m.removedem_work_experiences = nil
  14371. }
  14372. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14373. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14374. if m.em_tutorial == nil {
  14375. m.em_tutorial = make(map[uint64]struct{})
  14376. }
  14377. for i := range ids {
  14378. m.em_tutorial[ids[i]] = struct{}{}
  14379. }
  14380. }
  14381. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14382. func (m *EmployeeMutation) ClearEmTutorial() {
  14383. m.clearedem_tutorial = true
  14384. }
  14385. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14386. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14387. return m.clearedem_tutorial
  14388. }
  14389. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14390. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14391. if m.removedem_tutorial == nil {
  14392. m.removedem_tutorial = make(map[uint64]struct{})
  14393. }
  14394. for i := range ids {
  14395. delete(m.em_tutorial, ids[i])
  14396. m.removedem_tutorial[ids[i]] = struct{}{}
  14397. }
  14398. }
  14399. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14400. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14401. for id := range m.removedem_tutorial {
  14402. ids = append(ids, id)
  14403. }
  14404. return
  14405. }
  14406. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14407. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14408. for id := range m.em_tutorial {
  14409. ids = append(ids, id)
  14410. }
  14411. return
  14412. }
  14413. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14414. func (m *EmployeeMutation) ResetEmTutorial() {
  14415. m.em_tutorial = nil
  14416. m.clearedem_tutorial = false
  14417. m.removedem_tutorial = nil
  14418. }
  14419. // Where appends a list predicates to the EmployeeMutation builder.
  14420. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14421. m.predicates = append(m.predicates, ps...)
  14422. }
  14423. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14424. // users can use type-assertion to append predicates that do not depend on any generated package.
  14425. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14426. p := make([]predicate.Employee, len(ps))
  14427. for i := range ps {
  14428. p[i] = ps[i]
  14429. }
  14430. m.Where(p...)
  14431. }
  14432. // Op returns the operation name.
  14433. func (m *EmployeeMutation) Op() Op {
  14434. return m.op
  14435. }
  14436. // SetOp allows setting the mutation operation.
  14437. func (m *EmployeeMutation) SetOp(op Op) {
  14438. m.op = op
  14439. }
  14440. // Type returns the node type of this mutation (Employee).
  14441. func (m *EmployeeMutation) Type() string {
  14442. return m.typ
  14443. }
  14444. // Fields returns all fields that were changed during this mutation. Note that in
  14445. // order to get all numeric fields that were incremented/decremented, call
  14446. // AddedFields().
  14447. func (m *EmployeeMutation) Fields() []string {
  14448. fields := make([]string, 0, 23)
  14449. if m.created_at != nil {
  14450. fields = append(fields, employee.FieldCreatedAt)
  14451. }
  14452. if m.updated_at != nil {
  14453. fields = append(fields, employee.FieldUpdatedAt)
  14454. }
  14455. if m.deleted_at != nil {
  14456. fields = append(fields, employee.FieldDeletedAt)
  14457. }
  14458. if m.title != nil {
  14459. fields = append(fields, employee.FieldTitle)
  14460. }
  14461. if m.avatar != nil {
  14462. fields = append(fields, employee.FieldAvatar)
  14463. }
  14464. if m.tags != nil {
  14465. fields = append(fields, employee.FieldTags)
  14466. }
  14467. if m.hire_count != nil {
  14468. fields = append(fields, employee.FieldHireCount)
  14469. }
  14470. if m.service_count != nil {
  14471. fields = append(fields, employee.FieldServiceCount)
  14472. }
  14473. if m.achievement_count != nil {
  14474. fields = append(fields, employee.FieldAchievementCount)
  14475. }
  14476. if m.intro != nil {
  14477. fields = append(fields, employee.FieldIntro)
  14478. }
  14479. if m.estimate != nil {
  14480. fields = append(fields, employee.FieldEstimate)
  14481. }
  14482. if m.skill != nil {
  14483. fields = append(fields, employee.FieldSkill)
  14484. }
  14485. if m.ability_type != nil {
  14486. fields = append(fields, employee.FieldAbilityType)
  14487. }
  14488. if m.scene != nil {
  14489. fields = append(fields, employee.FieldScene)
  14490. }
  14491. if m.switch_in != nil {
  14492. fields = append(fields, employee.FieldSwitchIn)
  14493. }
  14494. if m.video_url != nil {
  14495. fields = append(fields, employee.FieldVideoURL)
  14496. }
  14497. if m.organization_id != nil {
  14498. fields = append(fields, employee.FieldOrganizationID)
  14499. }
  14500. if m.category_id != nil {
  14501. fields = append(fields, employee.FieldCategoryID)
  14502. }
  14503. if m.api_base != nil {
  14504. fields = append(fields, employee.FieldAPIBase)
  14505. }
  14506. if m.api_key != nil {
  14507. fields = append(fields, employee.FieldAPIKey)
  14508. }
  14509. if m.ai_info != nil {
  14510. fields = append(fields, employee.FieldAiInfo)
  14511. }
  14512. if m.is_vip != nil {
  14513. fields = append(fields, employee.FieldIsVip)
  14514. }
  14515. if m.chat_url != nil {
  14516. fields = append(fields, employee.FieldChatURL)
  14517. }
  14518. return fields
  14519. }
  14520. // Field returns the value of a field with the given name. The second boolean
  14521. // return value indicates that this field was not set, or was not defined in the
  14522. // schema.
  14523. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14524. switch name {
  14525. case employee.FieldCreatedAt:
  14526. return m.CreatedAt()
  14527. case employee.FieldUpdatedAt:
  14528. return m.UpdatedAt()
  14529. case employee.FieldDeletedAt:
  14530. return m.DeletedAt()
  14531. case employee.FieldTitle:
  14532. return m.Title()
  14533. case employee.FieldAvatar:
  14534. return m.Avatar()
  14535. case employee.FieldTags:
  14536. return m.Tags()
  14537. case employee.FieldHireCount:
  14538. return m.HireCount()
  14539. case employee.FieldServiceCount:
  14540. return m.ServiceCount()
  14541. case employee.FieldAchievementCount:
  14542. return m.AchievementCount()
  14543. case employee.FieldIntro:
  14544. return m.Intro()
  14545. case employee.FieldEstimate:
  14546. return m.Estimate()
  14547. case employee.FieldSkill:
  14548. return m.Skill()
  14549. case employee.FieldAbilityType:
  14550. return m.AbilityType()
  14551. case employee.FieldScene:
  14552. return m.Scene()
  14553. case employee.FieldSwitchIn:
  14554. return m.SwitchIn()
  14555. case employee.FieldVideoURL:
  14556. return m.VideoURL()
  14557. case employee.FieldOrganizationID:
  14558. return m.OrganizationID()
  14559. case employee.FieldCategoryID:
  14560. return m.CategoryID()
  14561. case employee.FieldAPIBase:
  14562. return m.APIBase()
  14563. case employee.FieldAPIKey:
  14564. return m.APIKey()
  14565. case employee.FieldAiInfo:
  14566. return m.AiInfo()
  14567. case employee.FieldIsVip:
  14568. return m.IsVip()
  14569. case employee.FieldChatURL:
  14570. return m.ChatURL()
  14571. }
  14572. return nil, false
  14573. }
  14574. // OldField returns the old value of the field from the database. An error is
  14575. // returned if the mutation operation is not UpdateOne, or the query to the
  14576. // database failed.
  14577. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14578. switch name {
  14579. case employee.FieldCreatedAt:
  14580. return m.OldCreatedAt(ctx)
  14581. case employee.FieldUpdatedAt:
  14582. return m.OldUpdatedAt(ctx)
  14583. case employee.FieldDeletedAt:
  14584. return m.OldDeletedAt(ctx)
  14585. case employee.FieldTitle:
  14586. return m.OldTitle(ctx)
  14587. case employee.FieldAvatar:
  14588. return m.OldAvatar(ctx)
  14589. case employee.FieldTags:
  14590. return m.OldTags(ctx)
  14591. case employee.FieldHireCount:
  14592. return m.OldHireCount(ctx)
  14593. case employee.FieldServiceCount:
  14594. return m.OldServiceCount(ctx)
  14595. case employee.FieldAchievementCount:
  14596. return m.OldAchievementCount(ctx)
  14597. case employee.FieldIntro:
  14598. return m.OldIntro(ctx)
  14599. case employee.FieldEstimate:
  14600. return m.OldEstimate(ctx)
  14601. case employee.FieldSkill:
  14602. return m.OldSkill(ctx)
  14603. case employee.FieldAbilityType:
  14604. return m.OldAbilityType(ctx)
  14605. case employee.FieldScene:
  14606. return m.OldScene(ctx)
  14607. case employee.FieldSwitchIn:
  14608. return m.OldSwitchIn(ctx)
  14609. case employee.FieldVideoURL:
  14610. return m.OldVideoURL(ctx)
  14611. case employee.FieldOrganizationID:
  14612. return m.OldOrganizationID(ctx)
  14613. case employee.FieldCategoryID:
  14614. return m.OldCategoryID(ctx)
  14615. case employee.FieldAPIBase:
  14616. return m.OldAPIBase(ctx)
  14617. case employee.FieldAPIKey:
  14618. return m.OldAPIKey(ctx)
  14619. case employee.FieldAiInfo:
  14620. return m.OldAiInfo(ctx)
  14621. case employee.FieldIsVip:
  14622. return m.OldIsVip(ctx)
  14623. case employee.FieldChatURL:
  14624. return m.OldChatURL(ctx)
  14625. }
  14626. return nil, fmt.Errorf("unknown Employee field %s", name)
  14627. }
  14628. // SetField sets the value of a field with the given name. It returns an error if
  14629. // the field is not defined in the schema, or if the type mismatched the field
  14630. // type.
  14631. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14632. switch name {
  14633. case employee.FieldCreatedAt:
  14634. v, ok := value.(time.Time)
  14635. if !ok {
  14636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14637. }
  14638. m.SetCreatedAt(v)
  14639. return nil
  14640. case employee.FieldUpdatedAt:
  14641. v, ok := value.(time.Time)
  14642. if !ok {
  14643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14644. }
  14645. m.SetUpdatedAt(v)
  14646. return nil
  14647. case employee.FieldDeletedAt:
  14648. v, ok := value.(time.Time)
  14649. if !ok {
  14650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14651. }
  14652. m.SetDeletedAt(v)
  14653. return nil
  14654. case employee.FieldTitle:
  14655. v, ok := value.(string)
  14656. if !ok {
  14657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14658. }
  14659. m.SetTitle(v)
  14660. return nil
  14661. case employee.FieldAvatar:
  14662. v, ok := value.(string)
  14663. if !ok {
  14664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14665. }
  14666. m.SetAvatar(v)
  14667. return nil
  14668. case employee.FieldTags:
  14669. v, ok := value.(string)
  14670. if !ok {
  14671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14672. }
  14673. m.SetTags(v)
  14674. return nil
  14675. case employee.FieldHireCount:
  14676. v, ok := value.(int)
  14677. if !ok {
  14678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14679. }
  14680. m.SetHireCount(v)
  14681. return nil
  14682. case employee.FieldServiceCount:
  14683. v, ok := value.(int)
  14684. if !ok {
  14685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14686. }
  14687. m.SetServiceCount(v)
  14688. return nil
  14689. case employee.FieldAchievementCount:
  14690. v, ok := value.(int)
  14691. if !ok {
  14692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14693. }
  14694. m.SetAchievementCount(v)
  14695. return nil
  14696. case employee.FieldIntro:
  14697. v, ok := value.(string)
  14698. if !ok {
  14699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14700. }
  14701. m.SetIntro(v)
  14702. return nil
  14703. case employee.FieldEstimate:
  14704. v, ok := value.(string)
  14705. if !ok {
  14706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14707. }
  14708. m.SetEstimate(v)
  14709. return nil
  14710. case employee.FieldSkill:
  14711. v, ok := value.(string)
  14712. if !ok {
  14713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14714. }
  14715. m.SetSkill(v)
  14716. return nil
  14717. case employee.FieldAbilityType:
  14718. v, ok := value.(string)
  14719. if !ok {
  14720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14721. }
  14722. m.SetAbilityType(v)
  14723. return nil
  14724. case employee.FieldScene:
  14725. v, ok := value.(string)
  14726. if !ok {
  14727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14728. }
  14729. m.SetScene(v)
  14730. return nil
  14731. case employee.FieldSwitchIn:
  14732. v, ok := value.(string)
  14733. if !ok {
  14734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14735. }
  14736. m.SetSwitchIn(v)
  14737. return nil
  14738. case employee.FieldVideoURL:
  14739. v, ok := value.(string)
  14740. if !ok {
  14741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14742. }
  14743. m.SetVideoURL(v)
  14744. return nil
  14745. case employee.FieldOrganizationID:
  14746. v, ok := value.(uint64)
  14747. if !ok {
  14748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14749. }
  14750. m.SetOrganizationID(v)
  14751. return nil
  14752. case employee.FieldCategoryID:
  14753. v, ok := value.(uint64)
  14754. if !ok {
  14755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14756. }
  14757. m.SetCategoryID(v)
  14758. return nil
  14759. case employee.FieldAPIBase:
  14760. v, ok := value.(string)
  14761. if !ok {
  14762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14763. }
  14764. m.SetAPIBase(v)
  14765. return nil
  14766. case employee.FieldAPIKey:
  14767. v, ok := value.(string)
  14768. if !ok {
  14769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14770. }
  14771. m.SetAPIKey(v)
  14772. return nil
  14773. case employee.FieldAiInfo:
  14774. v, ok := value.(string)
  14775. if !ok {
  14776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14777. }
  14778. m.SetAiInfo(v)
  14779. return nil
  14780. case employee.FieldIsVip:
  14781. v, ok := value.(int)
  14782. if !ok {
  14783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14784. }
  14785. m.SetIsVip(v)
  14786. return nil
  14787. case employee.FieldChatURL:
  14788. v, ok := value.(string)
  14789. if !ok {
  14790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14791. }
  14792. m.SetChatURL(v)
  14793. return nil
  14794. }
  14795. return fmt.Errorf("unknown Employee field %s", name)
  14796. }
  14797. // AddedFields returns all numeric fields that were incremented/decremented during
  14798. // this mutation.
  14799. func (m *EmployeeMutation) AddedFields() []string {
  14800. var fields []string
  14801. if m.addhire_count != nil {
  14802. fields = append(fields, employee.FieldHireCount)
  14803. }
  14804. if m.addservice_count != nil {
  14805. fields = append(fields, employee.FieldServiceCount)
  14806. }
  14807. if m.addachievement_count != nil {
  14808. fields = append(fields, employee.FieldAchievementCount)
  14809. }
  14810. if m.addorganization_id != nil {
  14811. fields = append(fields, employee.FieldOrganizationID)
  14812. }
  14813. if m.addcategory_id != nil {
  14814. fields = append(fields, employee.FieldCategoryID)
  14815. }
  14816. if m.addis_vip != nil {
  14817. fields = append(fields, employee.FieldIsVip)
  14818. }
  14819. return fields
  14820. }
  14821. // AddedField returns the numeric value that was incremented/decremented on a field
  14822. // with the given name. The second boolean return value indicates that this field
  14823. // was not set, or was not defined in the schema.
  14824. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  14825. switch name {
  14826. case employee.FieldHireCount:
  14827. return m.AddedHireCount()
  14828. case employee.FieldServiceCount:
  14829. return m.AddedServiceCount()
  14830. case employee.FieldAchievementCount:
  14831. return m.AddedAchievementCount()
  14832. case employee.FieldOrganizationID:
  14833. return m.AddedOrganizationID()
  14834. case employee.FieldCategoryID:
  14835. return m.AddedCategoryID()
  14836. case employee.FieldIsVip:
  14837. return m.AddedIsVip()
  14838. }
  14839. return nil, false
  14840. }
  14841. // AddField adds the value to the field with the given name. It returns an error if
  14842. // the field is not defined in the schema, or if the type mismatched the field
  14843. // type.
  14844. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  14845. switch name {
  14846. case employee.FieldHireCount:
  14847. v, ok := value.(int)
  14848. if !ok {
  14849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14850. }
  14851. m.AddHireCount(v)
  14852. return nil
  14853. case employee.FieldServiceCount:
  14854. v, ok := value.(int)
  14855. if !ok {
  14856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14857. }
  14858. m.AddServiceCount(v)
  14859. return nil
  14860. case employee.FieldAchievementCount:
  14861. v, ok := value.(int)
  14862. if !ok {
  14863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14864. }
  14865. m.AddAchievementCount(v)
  14866. return nil
  14867. case employee.FieldOrganizationID:
  14868. v, ok := value.(int64)
  14869. if !ok {
  14870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14871. }
  14872. m.AddOrganizationID(v)
  14873. return nil
  14874. case employee.FieldCategoryID:
  14875. v, ok := value.(int64)
  14876. if !ok {
  14877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14878. }
  14879. m.AddCategoryID(v)
  14880. return nil
  14881. case employee.FieldIsVip:
  14882. v, ok := value.(int)
  14883. if !ok {
  14884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14885. }
  14886. m.AddIsVip(v)
  14887. return nil
  14888. }
  14889. return fmt.Errorf("unknown Employee numeric field %s", name)
  14890. }
  14891. // ClearedFields returns all nullable fields that were cleared during this
  14892. // mutation.
  14893. func (m *EmployeeMutation) ClearedFields() []string {
  14894. var fields []string
  14895. if m.FieldCleared(employee.FieldDeletedAt) {
  14896. fields = append(fields, employee.FieldDeletedAt)
  14897. }
  14898. if m.FieldCleared(employee.FieldAiInfo) {
  14899. fields = append(fields, employee.FieldAiInfo)
  14900. }
  14901. return fields
  14902. }
  14903. // FieldCleared returns a boolean indicating if a field with the given name was
  14904. // cleared in this mutation.
  14905. func (m *EmployeeMutation) FieldCleared(name string) bool {
  14906. _, ok := m.clearedFields[name]
  14907. return ok
  14908. }
  14909. // ClearField clears the value of the field with the given name. It returns an
  14910. // error if the field is not defined in the schema.
  14911. func (m *EmployeeMutation) ClearField(name string) error {
  14912. switch name {
  14913. case employee.FieldDeletedAt:
  14914. m.ClearDeletedAt()
  14915. return nil
  14916. case employee.FieldAiInfo:
  14917. m.ClearAiInfo()
  14918. return nil
  14919. }
  14920. return fmt.Errorf("unknown Employee nullable field %s", name)
  14921. }
  14922. // ResetField resets all changes in the mutation for the field with the given name.
  14923. // It returns an error if the field is not defined in the schema.
  14924. func (m *EmployeeMutation) ResetField(name string) error {
  14925. switch name {
  14926. case employee.FieldCreatedAt:
  14927. m.ResetCreatedAt()
  14928. return nil
  14929. case employee.FieldUpdatedAt:
  14930. m.ResetUpdatedAt()
  14931. return nil
  14932. case employee.FieldDeletedAt:
  14933. m.ResetDeletedAt()
  14934. return nil
  14935. case employee.FieldTitle:
  14936. m.ResetTitle()
  14937. return nil
  14938. case employee.FieldAvatar:
  14939. m.ResetAvatar()
  14940. return nil
  14941. case employee.FieldTags:
  14942. m.ResetTags()
  14943. return nil
  14944. case employee.FieldHireCount:
  14945. m.ResetHireCount()
  14946. return nil
  14947. case employee.FieldServiceCount:
  14948. m.ResetServiceCount()
  14949. return nil
  14950. case employee.FieldAchievementCount:
  14951. m.ResetAchievementCount()
  14952. return nil
  14953. case employee.FieldIntro:
  14954. m.ResetIntro()
  14955. return nil
  14956. case employee.FieldEstimate:
  14957. m.ResetEstimate()
  14958. return nil
  14959. case employee.FieldSkill:
  14960. m.ResetSkill()
  14961. return nil
  14962. case employee.FieldAbilityType:
  14963. m.ResetAbilityType()
  14964. return nil
  14965. case employee.FieldScene:
  14966. m.ResetScene()
  14967. return nil
  14968. case employee.FieldSwitchIn:
  14969. m.ResetSwitchIn()
  14970. return nil
  14971. case employee.FieldVideoURL:
  14972. m.ResetVideoURL()
  14973. return nil
  14974. case employee.FieldOrganizationID:
  14975. m.ResetOrganizationID()
  14976. return nil
  14977. case employee.FieldCategoryID:
  14978. m.ResetCategoryID()
  14979. return nil
  14980. case employee.FieldAPIBase:
  14981. m.ResetAPIBase()
  14982. return nil
  14983. case employee.FieldAPIKey:
  14984. m.ResetAPIKey()
  14985. return nil
  14986. case employee.FieldAiInfo:
  14987. m.ResetAiInfo()
  14988. return nil
  14989. case employee.FieldIsVip:
  14990. m.ResetIsVip()
  14991. return nil
  14992. case employee.FieldChatURL:
  14993. m.ResetChatURL()
  14994. return nil
  14995. }
  14996. return fmt.Errorf("unknown Employee field %s", name)
  14997. }
  14998. // AddedEdges returns all edge names that were set/added in this mutation.
  14999. func (m *EmployeeMutation) AddedEdges() []string {
  15000. edges := make([]string, 0, 2)
  15001. if m.em_work_experiences != nil {
  15002. edges = append(edges, employee.EdgeEmWorkExperiences)
  15003. }
  15004. if m.em_tutorial != nil {
  15005. edges = append(edges, employee.EdgeEmTutorial)
  15006. }
  15007. return edges
  15008. }
  15009. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15010. // name in this mutation.
  15011. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  15012. switch name {
  15013. case employee.EdgeEmWorkExperiences:
  15014. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  15015. for id := range m.em_work_experiences {
  15016. ids = append(ids, id)
  15017. }
  15018. return ids
  15019. case employee.EdgeEmTutorial:
  15020. ids := make([]ent.Value, 0, len(m.em_tutorial))
  15021. for id := range m.em_tutorial {
  15022. ids = append(ids, id)
  15023. }
  15024. return ids
  15025. }
  15026. return nil
  15027. }
  15028. // RemovedEdges returns all edge names that were removed in this mutation.
  15029. func (m *EmployeeMutation) RemovedEdges() []string {
  15030. edges := make([]string, 0, 2)
  15031. if m.removedem_work_experiences != nil {
  15032. edges = append(edges, employee.EdgeEmWorkExperiences)
  15033. }
  15034. if m.removedem_tutorial != nil {
  15035. edges = append(edges, employee.EdgeEmTutorial)
  15036. }
  15037. return edges
  15038. }
  15039. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15040. // the given name in this mutation.
  15041. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  15042. switch name {
  15043. case employee.EdgeEmWorkExperiences:
  15044. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  15045. for id := range m.removedem_work_experiences {
  15046. ids = append(ids, id)
  15047. }
  15048. return ids
  15049. case employee.EdgeEmTutorial:
  15050. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  15051. for id := range m.removedem_tutorial {
  15052. ids = append(ids, id)
  15053. }
  15054. return ids
  15055. }
  15056. return nil
  15057. }
  15058. // ClearedEdges returns all edge names that were cleared in this mutation.
  15059. func (m *EmployeeMutation) ClearedEdges() []string {
  15060. edges := make([]string, 0, 2)
  15061. if m.clearedem_work_experiences {
  15062. edges = append(edges, employee.EdgeEmWorkExperiences)
  15063. }
  15064. if m.clearedem_tutorial {
  15065. edges = append(edges, employee.EdgeEmTutorial)
  15066. }
  15067. return edges
  15068. }
  15069. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15070. // was cleared in this mutation.
  15071. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  15072. switch name {
  15073. case employee.EdgeEmWorkExperiences:
  15074. return m.clearedem_work_experiences
  15075. case employee.EdgeEmTutorial:
  15076. return m.clearedem_tutorial
  15077. }
  15078. return false
  15079. }
  15080. // ClearEdge clears the value of the edge with the given name. It returns an error
  15081. // if that edge is not defined in the schema.
  15082. func (m *EmployeeMutation) ClearEdge(name string) error {
  15083. switch name {
  15084. }
  15085. return fmt.Errorf("unknown Employee unique edge %s", name)
  15086. }
  15087. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15088. // It returns an error if the edge is not defined in the schema.
  15089. func (m *EmployeeMutation) ResetEdge(name string) error {
  15090. switch name {
  15091. case employee.EdgeEmWorkExperiences:
  15092. m.ResetEmWorkExperiences()
  15093. return nil
  15094. case employee.EdgeEmTutorial:
  15095. m.ResetEmTutorial()
  15096. return nil
  15097. }
  15098. return fmt.Errorf("unknown Employee edge %s", name)
  15099. }
  15100. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15101. type EmployeeConfigMutation struct {
  15102. config
  15103. op Op
  15104. typ string
  15105. id *uint64
  15106. created_at *time.Time
  15107. updated_at *time.Time
  15108. deleted_at *time.Time
  15109. stype *string
  15110. title *string
  15111. photo *string
  15112. organization_id *uint64
  15113. addorganization_id *int64
  15114. clearedFields map[string]struct{}
  15115. done bool
  15116. oldValue func(context.Context) (*EmployeeConfig, error)
  15117. predicates []predicate.EmployeeConfig
  15118. }
  15119. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15120. // employeeconfigOption allows management of the mutation configuration using functional options.
  15121. type employeeconfigOption func(*EmployeeConfigMutation)
  15122. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15123. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15124. m := &EmployeeConfigMutation{
  15125. config: c,
  15126. op: op,
  15127. typ: TypeEmployeeConfig,
  15128. clearedFields: make(map[string]struct{}),
  15129. }
  15130. for _, opt := range opts {
  15131. opt(m)
  15132. }
  15133. return m
  15134. }
  15135. // withEmployeeConfigID sets the ID field of the mutation.
  15136. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15137. return func(m *EmployeeConfigMutation) {
  15138. var (
  15139. err error
  15140. once sync.Once
  15141. value *EmployeeConfig
  15142. )
  15143. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15144. once.Do(func() {
  15145. if m.done {
  15146. err = errors.New("querying old values post mutation is not allowed")
  15147. } else {
  15148. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15149. }
  15150. })
  15151. return value, err
  15152. }
  15153. m.id = &id
  15154. }
  15155. }
  15156. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15157. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15158. return func(m *EmployeeConfigMutation) {
  15159. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15160. return node, nil
  15161. }
  15162. m.id = &node.ID
  15163. }
  15164. }
  15165. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15166. // executed in a transaction (ent.Tx), a transactional client is returned.
  15167. func (m EmployeeConfigMutation) Client() *Client {
  15168. client := &Client{config: m.config}
  15169. client.init()
  15170. return client
  15171. }
  15172. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15173. // it returns an error otherwise.
  15174. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15175. if _, ok := m.driver.(*txDriver); !ok {
  15176. return nil, errors.New("ent: mutation is not running in a transaction")
  15177. }
  15178. tx := &Tx{config: m.config}
  15179. tx.init()
  15180. return tx, nil
  15181. }
  15182. // SetID sets the value of the id field. Note that this
  15183. // operation is only accepted on creation of EmployeeConfig entities.
  15184. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15185. m.id = &id
  15186. }
  15187. // ID returns the ID value in the mutation. Note that the ID is only available
  15188. // if it was provided to the builder or after it was returned from the database.
  15189. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15190. if m.id == nil {
  15191. return
  15192. }
  15193. return *m.id, true
  15194. }
  15195. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15196. // That means, if the mutation is applied within a transaction with an isolation level such
  15197. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15198. // or updated by the mutation.
  15199. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15200. switch {
  15201. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15202. id, exists := m.ID()
  15203. if exists {
  15204. return []uint64{id}, nil
  15205. }
  15206. fallthrough
  15207. case m.op.Is(OpUpdate | OpDelete):
  15208. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15209. default:
  15210. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15211. }
  15212. }
  15213. // SetCreatedAt sets the "created_at" field.
  15214. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15215. m.created_at = &t
  15216. }
  15217. // CreatedAt returns the value of the "created_at" field in the mutation.
  15218. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15219. v := m.created_at
  15220. if v == nil {
  15221. return
  15222. }
  15223. return *v, true
  15224. }
  15225. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15226. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15228. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15229. if !m.op.Is(OpUpdateOne) {
  15230. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15231. }
  15232. if m.id == nil || m.oldValue == nil {
  15233. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15234. }
  15235. oldValue, err := m.oldValue(ctx)
  15236. if err != nil {
  15237. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15238. }
  15239. return oldValue.CreatedAt, nil
  15240. }
  15241. // ResetCreatedAt resets all changes to the "created_at" field.
  15242. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15243. m.created_at = nil
  15244. }
  15245. // SetUpdatedAt sets the "updated_at" field.
  15246. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15247. m.updated_at = &t
  15248. }
  15249. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15250. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15251. v := m.updated_at
  15252. if v == nil {
  15253. return
  15254. }
  15255. return *v, true
  15256. }
  15257. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15258. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15260. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15261. if !m.op.Is(OpUpdateOne) {
  15262. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15263. }
  15264. if m.id == nil || m.oldValue == nil {
  15265. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15266. }
  15267. oldValue, err := m.oldValue(ctx)
  15268. if err != nil {
  15269. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15270. }
  15271. return oldValue.UpdatedAt, nil
  15272. }
  15273. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15274. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15275. m.updated_at = nil
  15276. }
  15277. // SetDeletedAt sets the "deleted_at" field.
  15278. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15279. m.deleted_at = &t
  15280. }
  15281. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15282. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15283. v := m.deleted_at
  15284. if v == nil {
  15285. return
  15286. }
  15287. return *v, true
  15288. }
  15289. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15290. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15292. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15293. if !m.op.Is(OpUpdateOne) {
  15294. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15295. }
  15296. if m.id == nil || m.oldValue == nil {
  15297. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15298. }
  15299. oldValue, err := m.oldValue(ctx)
  15300. if err != nil {
  15301. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15302. }
  15303. return oldValue.DeletedAt, nil
  15304. }
  15305. // ClearDeletedAt clears the value of the "deleted_at" field.
  15306. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15307. m.deleted_at = nil
  15308. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15309. }
  15310. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15311. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15312. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15313. return ok
  15314. }
  15315. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15316. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15317. m.deleted_at = nil
  15318. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15319. }
  15320. // SetStype sets the "stype" field.
  15321. func (m *EmployeeConfigMutation) SetStype(s string) {
  15322. m.stype = &s
  15323. }
  15324. // Stype returns the value of the "stype" field in the mutation.
  15325. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15326. v := m.stype
  15327. if v == nil {
  15328. return
  15329. }
  15330. return *v, true
  15331. }
  15332. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15333. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15335. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15336. if !m.op.Is(OpUpdateOne) {
  15337. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15338. }
  15339. if m.id == nil || m.oldValue == nil {
  15340. return v, errors.New("OldStype requires an ID field in the mutation")
  15341. }
  15342. oldValue, err := m.oldValue(ctx)
  15343. if err != nil {
  15344. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15345. }
  15346. return oldValue.Stype, nil
  15347. }
  15348. // ResetStype resets all changes to the "stype" field.
  15349. func (m *EmployeeConfigMutation) ResetStype() {
  15350. m.stype = nil
  15351. }
  15352. // SetTitle sets the "title" field.
  15353. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15354. m.title = &s
  15355. }
  15356. // Title returns the value of the "title" field in the mutation.
  15357. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15358. v := m.title
  15359. if v == nil {
  15360. return
  15361. }
  15362. return *v, true
  15363. }
  15364. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15365. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15367. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15368. if !m.op.Is(OpUpdateOne) {
  15369. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15370. }
  15371. if m.id == nil || m.oldValue == nil {
  15372. return v, errors.New("OldTitle requires an ID field in the mutation")
  15373. }
  15374. oldValue, err := m.oldValue(ctx)
  15375. if err != nil {
  15376. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15377. }
  15378. return oldValue.Title, nil
  15379. }
  15380. // ResetTitle resets all changes to the "title" field.
  15381. func (m *EmployeeConfigMutation) ResetTitle() {
  15382. m.title = nil
  15383. }
  15384. // SetPhoto sets the "photo" field.
  15385. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15386. m.photo = &s
  15387. }
  15388. // Photo returns the value of the "photo" field in the mutation.
  15389. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15390. v := m.photo
  15391. if v == nil {
  15392. return
  15393. }
  15394. return *v, true
  15395. }
  15396. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15397. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15399. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15400. if !m.op.Is(OpUpdateOne) {
  15401. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15402. }
  15403. if m.id == nil || m.oldValue == nil {
  15404. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15405. }
  15406. oldValue, err := m.oldValue(ctx)
  15407. if err != nil {
  15408. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15409. }
  15410. return oldValue.Photo, nil
  15411. }
  15412. // ResetPhoto resets all changes to the "photo" field.
  15413. func (m *EmployeeConfigMutation) ResetPhoto() {
  15414. m.photo = nil
  15415. }
  15416. // SetOrganizationID sets the "organization_id" field.
  15417. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15418. m.organization_id = &u
  15419. m.addorganization_id = nil
  15420. }
  15421. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15422. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15423. v := m.organization_id
  15424. if v == nil {
  15425. return
  15426. }
  15427. return *v, true
  15428. }
  15429. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15430. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15432. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15433. if !m.op.Is(OpUpdateOne) {
  15434. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15435. }
  15436. if m.id == nil || m.oldValue == nil {
  15437. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15438. }
  15439. oldValue, err := m.oldValue(ctx)
  15440. if err != nil {
  15441. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15442. }
  15443. return oldValue.OrganizationID, nil
  15444. }
  15445. // AddOrganizationID adds u to the "organization_id" field.
  15446. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15447. if m.addorganization_id != nil {
  15448. *m.addorganization_id += u
  15449. } else {
  15450. m.addorganization_id = &u
  15451. }
  15452. }
  15453. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15454. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15455. v := m.addorganization_id
  15456. if v == nil {
  15457. return
  15458. }
  15459. return *v, true
  15460. }
  15461. // ClearOrganizationID clears the value of the "organization_id" field.
  15462. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15463. m.organization_id = nil
  15464. m.addorganization_id = nil
  15465. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15466. }
  15467. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15468. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15469. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15470. return ok
  15471. }
  15472. // ResetOrganizationID resets all changes to the "organization_id" field.
  15473. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15474. m.organization_id = nil
  15475. m.addorganization_id = nil
  15476. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15477. }
  15478. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15479. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15480. m.predicates = append(m.predicates, ps...)
  15481. }
  15482. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15483. // users can use type-assertion to append predicates that do not depend on any generated package.
  15484. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15485. p := make([]predicate.EmployeeConfig, len(ps))
  15486. for i := range ps {
  15487. p[i] = ps[i]
  15488. }
  15489. m.Where(p...)
  15490. }
  15491. // Op returns the operation name.
  15492. func (m *EmployeeConfigMutation) Op() Op {
  15493. return m.op
  15494. }
  15495. // SetOp allows setting the mutation operation.
  15496. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15497. m.op = op
  15498. }
  15499. // Type returns the node type of this mutation (EmployeeConfig).
  15500. func (m *EmployeeConfigMutation) Type() string {
  15501. return m.typ
  15502. }
  15503. // Fields returns all fields that were changed during this mutation. Note that in
  15504. // order to get all numeric fields that were incremented/decremented, call
  15505. // AddedFields().
  15506. func (m *EmployeeConfigMutation) Fields() []string {
  15507. fields := make([]string, 0, 7)
  15508. if m.created_at != nil {
  15509. fields = append(fields, employeeconfig.FieldCreatedAt)
  15510. }
  15511. if m.updated_at != nil {
  15512. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15513. }
  15514. if m.deleted_at != nil {
  15515. fields = append(fields, employeeconfig.FieldDeletedAt)
  15516. }
  15517. if m.stype != nil {
  15518. fields = append(fields, employeeconfig.FieldStype)
  15519. }
  15520. if m.title != nil {
  15521. fields = append(fields, employeeconfig.FieldTitle)
  15522. }
  15523. if m.photo != nil {
  15524. fields = append(fields, employeeconfig.FieldPhoto)
  15525. }
  15526. if m.organization_id != nil {
  15527. fields = append(fields, employeeconfig.FieldOrganizationID)
  15528. }
  15529. return fields
  15530. }
  15531. // Field returns the value of a field with the given name. The second boolean
  15532. // return value indicates that this field was not set, or was not defined in the
  15533. // schema.
  15534. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15535. switch name {
  15536. case employeeconfig.FieldCreatedAt:
  15537. return m.CreatedAt()
  15538. case employeeconfig.FieldUpdatedAt:
  15539. return m.UpdatedAt()
  15540. case employeeconfig.FieldDeletedAt:
  15541. return m.DeletedAt()
  15542. case employeeconfig.FieldStype:
  15543. return m.Stype()
  15544. case employeeconfig.FieldTitle:
  15545. return m.Title()
  15546. case employeeconfig.FieldPhoto:
  15547. return m.Photo()
  15548. case employeeconfig.FieldOrganizationID:
  15549. return m.OrganizationID()
  15550. }
  15551. return nil, false
  15552. }
  15553. // OldField returns the old value of the field from the database. An error is
  15554. // returned if the mutation operation is not UpdateOne, or the query to the
  15555. // database failed.
  15556. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15557. switch name {
  15558. case employeeconfig.FieldCreatedAt:
  15559. return m.OldCreatedAt(ctx)
  15560. case employeeconfig.FieldUpdatedAt:
  15561. return m.OldUpdatedAt(ctx)
  15562. case employeeconfig.FieldDeletedAt:
  15563. return m.OldDeletedAt(ctx)
  15564. case employeeconfig.FieldStype:
  15565. return m.OldStype(ctx)
  15566. case employeeconfig.FieldTitle:
  15567. return m.OldTitle(ctx)
  15568. case employeeconfig.FieldPhoto:
  15569. return m.OldPhoto(ctx)
  15570. case employeeconfig.FieldOrganizationID:
  15571. return m.OldOrganizationID(ctx)
  15572. }
  15573. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15574. }
  15575. // SetField sets the value of a field with the given name. It returns an error if
  15576. // the field is not defined in the schema, or if the type mismatched the field
  15577. // type.
  15578. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15579. switch name {
  15580. case employeeconfig.FieldCreatedAt:
  15581. v, ok := value.(time.Time)
  15582. if !ok {
  15583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15584. }
  15585. m.SetCreatedAt(v)
  15586. return nil
  15587. case employeeconfig.FieldUpdatedAt:
  15588. v, ok := value.(time.Time)
  15589. if !ok {
  15590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15591. }
  15592. m.SetUpdatedAt(v)
  15593. return nil
  15594. case employeeconfig.FieldDeletedAt:
  15595. v, ok := value.(time.Time)
  15596. if !ok {
  15597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15598. }
  15599. m.SetDeletedAt(v)
  15600. return nil
  15601. case employeeconfig.FieldStype:
  15602. v, ok := value.(string)
  15603. if !ok {
  15604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15605. }
  15606. m.SetStype(v)
  15607. return nil
  15608. case employeeconfig.FieldTitle:
  15609. v, ok := value.(string)
  15610. if !ok {
  15611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15612. }
  15613. m.SetTitle(v)
  15614. return nil
  15615. case employeeconfig.FieldPhoto:
  15616. v, ok := value.(string)
  15617. if !ok {
  15618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15619. }
  15620. m.SetPhoto(v)
  15621. return nil
  15622. case employeeconfig.FieldOrganizationID:
  15623. v, ok := value.(uint64)
  15624. if !ok {
  15625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15626. }
  15627. m.SetOrganizationID(v)
  15628. return nil
  15629. }
  15630. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15631. }
  15632. // AddedFields returns all numeric fields that were incremented/decremented during
  15633. // this mutation.
  15634. func (m *EmployeeConfigMutation) AddedFields() []string {
  15635. var fields []string
  15636. if m.addorganization_id != nil {
  15637. fields = append(fields, employeeconfig.FieldOrganizationID)
  15638. }
  15639. return fields
  15640. }
  15641. // AddedField returns the numeric value that was incremented/decremented on a field
  15642. // with the given name. The second boolean return value indicates that this field
  15643. // was not set, or was not defined in the schema.
  15644. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  15645. switch name {
  15646. case employeeconfig.FieldOrganizationID:
  15647. return m.AddedOrganizationID()
  15648. }
  15649. return nil, false
  15650. }
  15651. // AddField adds the value to the field with the given name. It returns an error if
  15652. // the field is not defined in the schema, or if the type mismatched the field
  15653. // type.
  15654. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  15655. switch name {
  15656. case employeeconfig.FieldOrganizationID:
  15657. v, ok := value.(int64)
  15658. if !ok {
  15659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15660. }
  15661. m.AddOrganizationID(v)
  15662. return nil
  15663. }
  15664. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  15665. }
  15666. // ClearedFields returns all nullable fields that were cleared during this
  15667. // mutation.
  15668. func (m *EmployeeConfigMutation) ClearedFields() []string {
  15669. var fields []string
  15670. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  15671. fields = append(fields, employeeconfig.FieldDeletedAt)
  15672. }
  15673. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  15674. fields = append(fields, employeeconfig.FieldOrganizationID)
  15675. }
  15676. return fields
  15677. }
  15678. // FieldCleared returns a boolean indicating if a field with the given name was
  15679. // cleared in this mutation.
  15680. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  15681. _, ok := m.clearedFields[name]
  15682. return ok
  15683. }
  15684. // ClearField clears the value of the field with the given name. It returns an
  15685. // error if the field is not defined in the schema.
  15686. func (m *EmployeeConfigMutation) ClearField(name string) error {
  15687. switch name {
  15688. case employeeconfig.FieldDeletedAt:
  15689. m.ClearDeletedAt()
  15690. return nil
  15691. case employeeconfig.FieldOrganizationID:
  15692. m.ClearOrganizationID()
  15693. return nil
  15694. }
  15695. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  15696. }
  15697. // ResetField resets all changes in the mutation for the field with the given name.
  15698. // It returns an error if the field is not defined in the schema.
  15699. func (m *EmployeeConfigMutation) ResetField(name string) error {
  15700. switch name {
  15701. case employeeconfig.FieldCreatedAt:
  15702. m.ResetCreatedAt()
  15703. return nil
  15704. case employeeconfig.FieldUpdatedAt:
  15705. m.ResetUpdatedAt()
  15706. return nil
  15707. case employeeconfig.FieldDeletedAt:
  15708. m.ResetDeletedAt()
  15709. return nil
  15710. case employeeconfig.FieldStype:
  15711. m.ResetStype()
  15712. return nil
  15713. case employeeconfig.FieldTitle:
  15714. m.ResetTitle()
  15715. return nil
  15716. case employeeconfig.FieldPhoto:
  15717. m.ResetPhoto()
  15718. return nil
  15719. case employeeconfig.FieldOrganizationID:
  15720. m.ResetOrganizationID()
  15721. return nil
  15722. }
  15723. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15724. }
  15725. // AddedEdges returns all edge names that were set/added in this mutation.
  15726. func (m *EmployeeConfigMutation) AddedEdges() []string {
  15727. edges := make([]string, 0, 0)
  15728. return edges
  15729. }
  15730. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15731. // name in this mutation.
  15732. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  15733. return nil
  15734. }
  15735. // RemovedEdges returns all edge names that were removed in this mutation.
  15736. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  15737. edges := make([]string, 0, 0)
  15738. return edges
  15739. }
  15740. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15741. // the given name in this mutation.
  15742. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  15743. return nil
  15744. }
  15745. // ClearedEdges returns all edge names that were cleared in this mutation.
  15746. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  15747. edges := make([]string, 0, 0)
  15748. return edges
  15749. }
  15750. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15751. // was cleared in this mutation.
  15752. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  15753. return false
  15754. }
  15755. // ClearEdge clears the value of the edge with the given name. It returns an error
  15756. // if that edge is not defined in the schema.
  15757. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  15758. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  15759. }
  15760. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15761. // It returns an error if the edge is not defined in the schema.
  15762. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  15763. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  15764. }
  15765. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  15766. type LabelMutation struct {
  15767. config
  15768. op Op
  15769. typ string
  15770. id *uint64
  15771. created_at *time.Time
  15772. updated_at *time.Time
  15773. status *uint8
  15774. addstatus *int8
  15775. _type *int
  15776. add_type *int
  15777. name *string
  15778. from *int
  15779. addfrom *int
  15780. mode *int
  15781. addmode *int
  15782. conditions *string
  15783. organization_id *uint64
  15784. addorganization_id *int64
  15785. clearedFields map[string]struct{}
  15786. label_relationships map[uint64]struct{}
  15787. removedlabel_relationships map[uint64]struct{}
  15788. clearedlabel_relationships bool
  15789. done bool
  15790. oldValue func(context.Context) (*Label, error)
  15791. predicates []predicate.Label
  15792. }
  15793. var _ ent.Mutation = (*LabelMutation)(nil)
  15794. // labelOption allows management of the mutation configuration using functional options.
  15795. type labelOption func(*LabelMutation)
  15796. // newLabelMutation creates new mutation for the Label entity.
  15797. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  15798. m := &LabelMutation{
  15799. config: c,
  15800. op: op,
  15801. typ: TypeLabel,
  15802. clearedFields: make(map[string]struct{}),
  15803. }
  15804. for _, opt := range opts {
  15805. opt(m)
  15806. }
  15807. return m
  15808. }
  15809. // withLabelID sets the ID field of the mutation.
  15810. func withLabelID(id uint64) labelOption {
  15811. return func(m *LabelMutation) {
  15812. var (
  15813. err error
  15814. once sync.Once
  15815. value *Label
  15816. )
  15817. m.oldValue = func(ctx context.Context) (*Label, error) {
  15818. once.Do(func() {
  15819. if m.done {
  15820. err = errors.New("querying old values post mutation is not allowed")
  15821. } else {
  15822. value, err = m.Client().Label.Get(ctx, id)
  15823. }
  15824. })
  15825. return value, err
  15826. }
  15827. m.id = &id
  15828. }
  15829. }
  15830. // withLabel sets the old Label of the mutation.
  15831. func withLabel(node *Label) labelOption {
  15832. return func(m *LabelMutation) {
  15833. m.oldValue = func(context.Context) (*Label, error) {
  15834. return node, nil
  15835. }
  15836. m.id = &node.ID
  15837. }
  15838. }
  15839. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15840. // executed in a transaction (ent.Tx), a transactional client is returned.
  15841. func (m LabelMutation) Client() *Client {
  15842. client := &Client{config: m.config}
  15843. client.init()
  15844. return client
  15845. }
  15846. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15847. // it returns an error otherwise.
  15848. func (m LabelMutation) Tx() (*Tx, error) {
  15849. if _, ok := m.driver.(*txDriver); !ok {
  15850. return nil, errors.New("ent: mutation is not running in a transaction")
  15851. }
  15852. tx := &Tx{config: m.config}
  15853. tx.init()
  15854. return tx, nil
  15855. }
  15856. // SetID sets the value of the id field. Note that this
  15857. // operation is only accepted on creation of Label entities.
  15858. func (m *LabelMutation) SetID(id uint64) {
  15859. m.id = &id
  15860. }
  15861. // ID returns the ID value in the mutation. Note that the ID is only available
  15862. // if it was provided to the builder or after it was returned from the database.
  15863. func (m *LabelMutation) ID() (id uint64, exists bool) {
  15864. if m.id == nil {
  15865. return
  15866. }
  15867. return *m.id, true
  15868. }
  15869. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15870. // That means, if the mutation is applied within a transaction with an isolation level such
  15871. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15872. // or updated by the mutation.
  15873. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  15874. switch {
  15875. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15876. id, exists := m.ID()
  15877. if exists {
  15878. return []uint64{id}, nil
  15879. }
  15880. fallthrough
  15881. case m.op.Is(OpUpdate | OpDelete):
  15882. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  15883. default:
  15884. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15885. }
  15886. }
  15887. // SetCreatedAt sets the "created_at" field.
  15888. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  15889. m.created_at = &t
  15890. }
  15891. // CreatedAt returns the value of the "created_at" field in the mutation.
  15892. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  15893. v := m.created_at
  15894. if v == nil {
  15895. return
  15896. }
  15897. return *v, true
  15898. }
  15899. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  15900. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15902. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15903. if !m.op.Is(OpUpdateOne) {
  15904. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15905. }
  15906. if m.id == nil || m.oldValue == nil {
  15907. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15908. }
  15909. oldValue, err := m.oldValue(ctx)
  15910. if err != nil {
  15911. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15912. }
  15913. return oldValue.CreatedAt, nil
  15914. }
  15915. // ResetCreatedAt resets all changes to the "created_at" field.
  15916. func (m *LabelMutation) ResetCreatedAt() {
  15917. m.created_at = nil
  15918. }
  15919. // SetUpdatedAt sets the "updated_at" field.
  15920. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  15921. m.updated_at = &t
  15922. }
  15923. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15924. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  15925. v := m.updated_at
  15926. if v == nil {
  15927. return
  15928. }
  15929. return *v, true
  15930. }
  15931. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  15932. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15934. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15935. if !m.op.Is(OpUpdateOne) {
  15936. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15937. }
  15938. if m.id == nil || m.oldValue == nil {
  15939. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15940. }
  15941. oldValue, err := m.oldValue(ctx)
  15942. if err != nil {
  15943. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15944. }
  15945. return oldValue.UpdatedAt, nil
  15946. }
  15947. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15948. func (m *LabelMutation) ResetUpdatedAt() {
  15949. m.updated_at = nil
  15950. }
  15951. // SetStatus sets the "status" field.
  15952. func (m *LabelMutation) SetStatus(u uint8) {
  15953. m.status = &u
  15954. m.addstatus = nil
  15955. }
  15956. // Status returns the value of the "status" field in the mutation.
  15957. func (m *LabelMutation) Status() (r uint8, exists bool) {
  15958. v := m.status
  15959. if v == nil {
  15960. return
  15961. }
  15962. return *v, true
  15963. }
  15964. // OldStatus returns the old "status" field's value of the Label entity.
  15965. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15967. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15968. if !m.op.Is(OpUpdateOne) {
  15969. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15970. }
  15971. if m.id == nil || m.oldValue == nil {
  15972. return v, errors.New("OldStatus requires an ID field in the mutation")
  15973. }
  15974. oldValue, err := m.oldValue(ctx)
  15975. if err != nil {
  15976. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15977. }
  15978. return oldValue.Status, nil
  15979. }
  15980. // AddStatus adds u to the "status" field.
  15981. func (m *LabelMutation) AddStatus(u int8) {
  15982. if m.addstatus != nil {
  15983. *m.addstatus += u
  15984. } else {
  15985. m.addstatus = &u
  15986. }
  15987. }
  15988. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15989. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  15990. v := m.addstatus
  15991. if v == nil {
  15992. return
  15993. }
  15994. return *v, true
  15995. }
  15996. // ClearStatus clears the value of the "status" field.
  15997. func (m *LabelMutation) ClearStatus() {
  15998. m.status = nil
  15999. m.addstatus = nil
  16000. m.clearedFields[label.FieldStatus] = struct{}{}
  16001. }
  16002. // StatusCleared returns if the "status" field was cleared in this mutation.
  16003. func (m *LabelMutation) StatusCleared() bool {
  16004. _, ok := m.clearedFields[label.FieldStatus]
  16005. return ok
  16006. }
  16007. // ResetStatus resets all changes to the "status" field.
  16008. func (m *LabelMutation) ResetStatus() {
  16009. m.status = nil
  16010. m.addstatus = nil
  16011. delete(m.clearedFields, label.FieldStatus)
  16012. }
  16013. // SetType sets the "type" field.
  16014. func (m *LabelMutation) SetType(i int) {
  16015. m._type = &i
  16016. m.add_type = nil
  16017. }
  16018. // GetType returns the value of the "type" field in the mutation.
  16019. func (m *LabelMutation) GetType() (r int, exists bool) {
  16020. v := m._type
  16021. if v == nil {
  16022. return
  16023. }
  16024. return *v, true
  16025. }
  16026. // OldType returns the old "type" field's value of the Label entity.
  16027. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16029. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  16030. if !m.op.Is(OpUpdateOne) {
  16031. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16032. }
  16033. if m.id == nil || m.oldValue == nil {
  16034. return v, errors.New("OldType requires an ID field in the mutation")
  16035. }
  16036. oldValue, err := m.oldValue(ctx)
  16037. if err != nil {
  16038. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16039. }
  16040. return oldValue.Type, nil
  16041. }
  16042. // AddType adds i to the "type" field.
  16043. func (m *LabelMutation) AddType(i int) {
  16044. if m.add_type != nil {
  16045. *m.add_type += i
  16046. } else {
  16047. m.add_type = &i
  16048. }
  16049. }
  16050. // AddedType returns the value that was added to the "type" field in this mutation.
  16051. func (m *LabelMutation) AddedType() (r int, exists bool) {
  16052. v := m.add_type
  16053. if v == nil {
  16054. return
  16055. }
  16056. return *v, true
  16057. }
  16058. // ResetType resets all changes to the "type" field.
  16059. func (m *LabelMutation) ResetType() {
  16060. m._type = nil
  16061. m.add_type = nil
  16062. }
  16063. // SetName sets the "name" field.
  16064. func (m *LabelMutation) SetName(s string) {
  16065. m.name = &s
  16066. }
  16067. // Name returns the value of the "name" field in the mutation.
  16068. func (m *LabelMutation) Name() (r string, exists bool) {
  16069. v := m.name
  16070. if v == nil {
  16071. return
  16072. }
  16073. return *v, true
  16074. }
  16075. // OldName returns the old "name" field's value of the Label entity.
  16076. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16078. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  16079. if !m.op.Is(OpUpdateOne) {
  16080. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16081. }
  16082. if m.id == nil || m.oldValue == nil {
  16083. return v, errors.New("OldName requires an ID field in the mutation")
  16084. }
  16085. oldValue, err := m.oldValue(ctx)
  16086. if err != nil {
  16087. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16088. }
  16089. return oldValue.Name, nil
  16090. }
  16091. // ResetName resets all changes to the "name" field.
  16092. func (m *LabelMutation) ResetName() {
  16093. m.name = nil
  16094. }
  16095. // SetFrom sets the "from" field.
  16096. func (m *LabelMutation) SetFrom(i int) {
  16097. m.from = &i
  16098. m.addfrom = nil
  16099. }
  16100. // From returns the value of the "from" field in the mutation.
  16101. func (m *LabelMutation) From() (r int, exists bool) {
  16102. v := m.from
  16103. if v == nil {
  16104. return
  16105. }
  16106. return *v, true
  16107. }
  16108. // OldFrom returns the old "from" field's value of the Label entity.
  16109. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16111. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16112. if !m.op.Is(OpUpdateOne) {
  16113. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16114. }
  16115. if m.id == nil || m.oldValue == nil {
  16116. return v, errors.New("OldFrom requires an ID field in the mutation")
  16117. }
  16118. oldValue, err := m.oldValue(ctx)
  16119. if err != nil {
  16120. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16121. }
  16122. return oldValue.From, nil
  16123. }
  16124. // AddFrom adds i to the "from" field.
  16125. func (m *LabelMutation) AddFrom(i int) {
  16126. if m.addfrom != nil {
  16127. *m.addfrom += i
  16128. } else {
  16129. m.addfrom = &i
  16130. }
  16131. }
  16132. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16133. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16134. v := m.addfrom
  16135. if v == nil {
  16136. return
  16137. }
  16138. return *v, true
  16139. }
  16140. // ResetFrom resets all changes to the "from" field.
  16141. func (m *LabelMutation) ResetFrom() {
  16142. m.from = nil
  16143. m.addfrom = nil
  16144. }
  16145. // SetMode sets the "mode" field.
  16146. func (m *LabelMutation) SetMode(i int) {
  16147. m.mode = &i
  16148. m.addmode = nil
  16149. }
  16150. // Mode returns the value of the "mode" field in the mutation.
  16151. func (m *LabelMutation) Mode() (r int, exists bool) {
  16152. v := m.mode
  16153. if v == nil {
  16154. return
  16155. }
  16156. return *v, true
  16157. }
  16158. // OldMode returns the old "mode" field's value of the Label entity.
  16159. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16161. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16162. if !m.op.Is(OpUpdateOne) {
  16163. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16164. }
  16165. if m.id == nil || m.oldValue == nil {
  16166. return v, errors.New("OldMode requires an ID field in the mutation")
  16167. }
  16168. oldValue, err := m.oldValue(ctx)
  16169. if err != nil {
  16170. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16171. }
  16172. return oldValue.Mode, nil
  16173. }
  16174. // AddMode adds i to the "mode" field.
  16175. func (m *LabelMutation) AddMode(i int) {
  16176. if m.addmode != nil {
  16177. *m.addmode += i
  16178. } else {
  16179. m.addmode = &i
  16180. }
  16181. }
  16182. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16183. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16184. v := m.addmode
  16185. if v == nil {
  16186. return
  16187. }
  16188. return *v, true
  16189. }
  16190. // ResetMode resets all changes to the "mode" field.
  16191. func (m *LabelMutation) ResetMode() {
  16192. m.mode = nil
  16193. m.addmode = nil
  16194. }
  16195. // SetConditions sets the "conditions" field.
  16196. func (m *LabelMutation) SetConditions(s string) {
  16197. m.conditions = &s
  16198. }
  16199. // Conditions returns the value of the "conditions" field in the mutation.
  16200. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16201. v := m.conditions
  16202. if v == nil {
  16203. return
  16204. }
  16205. return *v, true
  16206. }
  16207. // OldConditions returns the old "conditions" field's value of the Label entity.
  16208. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16210. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16211. if !m.op.Is(OpUpdateOne) {
  16212. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16213. }
  16214. if m.id == nil || m.oldValue == nil {
  16215. return v, errors.New("OldConditions requires an ID field in the mutation")
  16216. }
  16217. oldValue, err := m.oldValue(ctx)
  16218. if err != nil {
  16219. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16220. }
  16221. return oldValue.Conditions, nil
  16222. }
  16223. // ClearConditions clears the value of the "conditions" field.
  16224. func (m *LabelMutation) ClearConditions() {
  16225. m.conditions = nil
  16226. m.clearedFields[label.FieldConditions] = struct{}{}
  16227. }
  16228. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16229. func (m *LabelMutation) ConditionsCleared() bool {
  16230. _, ok := m.clearedFields[label.FieldConditions]
  16231. return ok
  16232. }
  16233. // ResetConditions resets all changes to the "conditions" field.
  16234. func (m *LabelMutation) ResetConditions() {
  16235. m.conditions = nil
  16236. delete(m.clearedFields, label.FieldConditions)
  16237. }
  16238. // SetOrganizationID sets the "organization_id" field.
  16239. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16240. m.organization_id = &u
  16241. m.addorganization_id = nil
  16242. }
  16243. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16244. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16245. v := m.organization_id
  16246. if v == nil {
  16247. return
  16248. }
  16249. return *v, true
  16250. }
  16251. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16252. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16254. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16255. if !m.op.Is(OpUpdateOne) {
  16256. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16257. }
  16258. if m.id == nil || m.oldValue == nil {
  16259. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16260. }
  16261. oldValue, err := m.oldValue(ctx)
  16262. if err != nil {
  16263. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16264. }
  16265. return oldValue.OrganizationID, nil
  16266. }
  16267. // AddOrganizationID adds u to the "organization_id" field.
  16268. func (m *LabelMutation) AddOrganizationID(u int64) {
  16269. if m.addorganization_id != nil {
  16270. *m.addorganization_id += u
  16271. } else {
  16272. m.addorganization_id = &u
  16273. }
  16274. }
  16275. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16276. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16277. v := m.addorganization_id
  16278. if v == nil {
  16279. return
  16280. }
  16281. return *v, true
  16282. }
  16283. // ClearOrganizationID clears the value of the "organization_id" field.
  16284. func (m *LabelMutation) ClearOrganizationID() {
  16285. m.organization_id = nil
  16286. m.addorganization_id = nil
  16287. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16288. }
  16289. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16290. func (m *LabelMutation) OrganizationIDCleared() bool {
  16291. _, ok := m.clearedFields[label.FieldOrganizationID]
  16292. return ok
  16293. }
  16294. // ResetOrganizationID resets all changes to the "organization_id" field.
  16295. func (m *LabelMutation) ResetOrganizationID() {
  16296. m.organization_id = nil
  16297. m.addorganization_id = nil
  16298. delete(m.clearedFields, label.FieldOrganizationID)
  16299. }
  16300. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16301. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16302. if m.label_relationships == nil {
  16303. m.label_relationships = make(map[uint64]struct{})
  16304. }
  16305. for i := range ids {
  16306. m.label_relationships[ids[i]] = struct{}{}
  16307. }
  16308. }
  16309. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16310. func (m *LabelMutation) ClearLabelRelationships() {
  16311. m.clearedlabel_relationships = true
  16312. }
  16313. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16314. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16315. return m.clearedlabel_relationships
  16316. }
  16317. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16318. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16319. if m.removedlabel_relationships == nil {
  16320. m.removedlabel_relationships = make(map[uint64]struct{})
  16321. }
  16322. for i := range ids {
  16323. delete(m.label_relationships, ids[i])
  16324. m.removedlabel_relationships[ids[i]] = struct{}{}
  16325. }
  16326. }
  16327. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16328. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16329. for id := range m.removedlabel_relationships {
  16330. ids = append(ids, id)
  16331. }
  16332. return
  16333. }
  16334. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16335. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16336. for id := range m.label_relationships {
  16337. ids = append(ids, id)
  16338. }
  16339. return
  16340. }
  16341. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16342. func (m *LabelMutation) ResetLabelRelationships() {
  16343. m.label_relationships = nil
  16344. m.clearedlabel_relationships = false
  16345. m.removedlabel_relationships = nil
  16346. }
  16347. // Where appends a list predicates to the LabelMutation builder.
  16348. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16349. m.predicates = append(m.predicates, ps...)
  16350. }
  16351. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16352. // users can use type-assertion to append predicates that do not depend on any generated package.
  16353. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16354. p := make([]predicate.Label, len(ps))
  16355. for i := range ps {
  16356. p[i] = ps[i]
  16357. }
  16358. m.Where(p...)
  16359. }
  16360. // Op returns the operation name.
  16361. func (m *LabelMutation) Op() Op {
  16362. return m.op
  16363. }
  16364. // SetOp allows setting the mutation operation.
  16365. func (m *LabelMutation) SetOp(op Op) {
  16366. m.op = op
  16367. }
  16368. // Type returns the node type of this mutation (Label).
  16369. func (m *LabelMutation) Type() string {
  16370. return m.typ
  16371. }
  16372. // Fields returns all fields that were changed during this mutation. Note that in
  16373. // order to get all numeric fields that were incremented/decremented, call
  16374. // AddedFields().
  16375. func (m *LabelMutation) Fields() []string {
  16376. fields := make([]string, 0, 9)
  16377. if m.created_at != nil {
  16378. fields = append(fields, label.FieldCreatedAt)
  16379. }
  16380. if m.updated_at != nil {
  16381. fields = append(fields, label.FieldUpdatedAt)
  16382. }
  16383. if m.status != nil {
  16384. fields = append(fields, label.FieldStatus)
  16385. }
  16386. if m._type != nil {
  16387. fields = append(fields, label.FieldType)
  16388. }
  16389. if m.name != nil {
  16390. fields = append(fields, label.FieldName)
  16391. }
  16392. if m.from != nil {
  16393. fields = append(fields, label.FieldFrom)
  16394. }
  16395. if m.mode != nil {
  16396. fields = append(fields, label.FieldMode)
  16397. }
  16398. if m.conditions != nil {
  16399. fields = append(fields, label.FieldConditions)
  16400. }
  16401. if m.organization_id != nil {
  16402. fields = append(fields, label.FieldOrganizationID)
  16403. }
  16404. return fields
  16405. }
  16406. // Field returns the value of a field with the given name. The second boolean
  16407. // return value indicates that this field was not set, or was not defined in the
  16408. // schema.
  16409. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16410. switch name {
  16411. case label.FieldCreatedAt:
  16412. return m.CreatedAt()
  16413. case label.FieldUpdatedAt:
  16414. return m.UpdatedAt()
  16415. case label.FieldStatus:
  16416. return m.Status()
  16417. case label.FieldType:
  16418. return m.GetType()
  16419. case label.FieldName:
  16420. return m.Name()
  16421. case label.FieldFrom:
  16422. return m.From()
  16423. case label.FieldMode:
  16424. return m.Mode()
  16425. case label.FieldConditions:
  16426. return m.Conditions()
  16427. case label.FieldOrganizationID:
  16428. return m.OrganizationID()
  16429. }
  16430. return nil, false
  16431. }
  16432. // OldField returns the old value of the field from the database. An error is
  16433. // returned if the mutation operation is not UpdateOne, or the query to the
  16434. // database failed.
  16435. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16436. switch name {
  16437. case label.FieldCreatedAt:
  16438. return m.OldCreatedAt(ctx)
  16439. case label.FieldUpdatedAt:
  16440. return m.OldUpdatedAt(ctx)
  16441. case label.FieldStatus:
  16442. return m.OldStatus(ctx)
  16443. case label.FieldType:
  16444. return m.OldType(ctx)
  16445. case label.FieldName:
  16446. return m.OldName(ctx)
  16447. case label.FieldFrom:
  16448. return m.OldFrom(ctx)
  16449. case label.FieldMode:
  16450. return m.OldMode(ctx)
  16451. case label.FieldConditions:
  16452. return m.OldConditions(ctx)
  16453. case label.FieldOrganizationID:
  16454. return m.OldOrganizationID(ctx)
  16455. }
  16456. return nil, fmt.Errorf("unknown Label field %s", name)
  16457. }
  16458. // SetField sets the value of a field with the given name. It returns an error if
  16459. // the field is not defined in the schema, or if the type mismatched the field
  16460. // type.
  16461. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16462. switch name {
  16463. case label.FieldCreatedAt:
  16464. v, ok := value.(time.Time)
  16465. if !ok {
  16466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16467. }
  16468. m.SetCreatedAt(v)
  16469. return nil
  16470. case label.FieldUpdatedAt:
  16471. v, ok := value.(time.Time)
  16472. if !ok {
  16473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16474. }
  16475. m.SetUpdatedAt(v)
  16476. return nil
  16477. case label.FieldStatus:
  16478. v, ok := value.(uint8)
  16479. if !ok {
  16480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16481. }
  16482. m.SetStatus(v)
  16483. return nil
  16484. case label.FieldType:
  16485. v, ok := value.(int)
  16486. if !ok {
  16487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16488. }
  16489. m.SetType(v)
  16490. return nil
  16491. case label.FieldName:
  16492. v, ok := value.(string)
  16493. if !ok {
  16494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16495. }
  16496. m.SetName(v)
  16497. return nil
  16498. case label.FieldFrom:
  16499. v, ok := value.(int)
  16500. if !ok {
  16501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16502. }
  16503. m.SetFrom(v)
  16504. return nil
  16505. case label.FieldMode:
  16506. v, ok := value.(int)
  16507. if !ok {
  16508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16509. }
  16510. m.SetMode(v)
  16511. return nil
  16512. case label.FieldConditions:
  16513. v, ok := value.(string)
  16514. if !ok {
  16515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16516. }
  16517. m.SetConditions(v)
  16518. return nil
  16519. case label.FieldOrganizationID:
  16520. v, ok := value.(uint64)
  16521. if !ok {
  16522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16523. }
  16524. m.SetOrganizationID(v)
  16525. return nil
  16526. }
  16527. return fmt.Errorf("unknown Label field %s", name)
  16528. }
  16529. // AddedFields returns all numeric fields that were incremented/decremented during
  16530. // this mutation.
  16531. func (m *LabelMutation) AddedFields() []string {
  16532. var fields []string
  16533. if m.addstatus != nil {
  16534. fields = append(fields, label.FieldStatus)
  16535. }
  16536. if m.add_type != nil {
  16537. fields = append(fields, label.FieldType)
  16538. }
  16539. if m.addfrom != nil {
  16540. fields = append(fields, label.FieldFrom)
  16541. }
  16542. if m.addmode != nil {
  16543. fields = append(fields, label.FieldMode)
  16544. }
  16545. if m.addorganization_id != nil {
  16546. fields = append(fields, label.FieldOrganizationID)
  16547. }
  16548. return fields
  16549. }
  16550. // AddedField returns the numeric value that was incremented/decremented on a field
  16551. // with the given name. The second boolean return value indicates that this field
  16552. // was not set, or was not defined in the schema.
  16553. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16554. switch name {
  16555. case label.FieldStatus:
  16556. return m.AddedStatus()
  16557. case label.FieldType:
  16558. return m.AddedType()
  16559. case label.FieldFrom:
  16560. return m.AddedFrom()
  16561. case label.FieldMode:
  16562. return m.AddedMode()
  16563. case label.FieldOrganizationID:
  16564. return m.AddedOrganizationID()
  16565. }
  16566. return nil, false
  16567. }
  16568. // AddField adds the value to the field with the given name. It returns an error if
  16569. // the field is not defined in the schema, or if the type mismatched the field
  16570. // type.
  16571. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16572. switch name {
  16573. case label.FieldStatus:
  16574. v, ok := value.(int8)
  16575. if !ok {
  16576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16577. }
  16578. m.AddStatus(v)
  16579. return nil
  16580. case label.FieldType:
  16581. v, ok := value.(int)
  16582. if !ok {
  16583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16584. }
  16585. m.AddType(v)
  16586. return nil
  16587. case label.FieldFrom:
  16588. v, ok := value.(int)
  16589. if !ok {
  16590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16591. }
  16592. m.AddFrom(v)
  16593. return nil
  16594. case label.FieldMode:
  16595. v, ok := value.(int)
  16596. if !ok {
  16597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16598. }
  16599. m.AddMode(v)
  16600. return nil
  16601. case label.FieldOrganizationID:
  16602. v, ok := value.(int64)
  16603. if !ok {
  16604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16605. }
  16606. m.AddOrganizationID(v)
  16607. return nil
  16608. }
  16609. return fmt.Errorf("unknown Label numeric field %s", name)
  16610. }
  16611. // ClearedFields returns all nullable fields that were cleared during this
  16612. // mutation.
  16613. func (m *LabelMutation) ClearedFields() []string {
  16614. var fields []string
  16615. if m.FieldCleared(label.FieldStatus) {
  16616. fields = append(fields, label.FieldStatus)
  16617. }
  16618. if m.FieldCleared(label.FieldConditions) {
  16619. fields = append(fields, label.FieldConditions)
  16620. }
  16621. if m.FieldCleared(label.FieldOrganizationID) {
  16622. fields = append(fields, label.FieldOrganizationID)
  16623. }
  16624. return fields
  16625. }
  16626. // FieldCleared returns a boolean indicating if a field with the given name was
  16627. // cleared in this mutation.
  16628. func (m *LabelMutation) FieldCleared(name string) bool {
  16629. _, ok := m.clearedFields[name]
  16630. return ok
  16631. }
  16632. // ClearField clears the value of the field with the given name. It returns an
  16633. // error if the field is not defined in the schema.
  16634. func (m *LabelMutation) ClearField(name string) error {
  16635. switch name {
  16636. case label.FieldStatus:
  16637. m.ClearStatus()
  16638. return nil
  16639. case label.FieldConditions:
  16640. m.ClearConditions()
  16641. return nil
  16642. case label.FieldOrganizationID:
  16643. m.ClearOrganizationID()
  16644. return nil
  16645. }
  16646. return fmt.Errorf("unknown Label nullable field %s", name)
  16647. }
  16648. // ResetField resets all changes in the mutation for the field with the given name.
  16649. // It returns an error if the field is not defined in the schema.
  16650. func (m *LabelMutation) ResetField(name string) error {
  16651. switch name {
  16652. case label.FieldCreatedAt:
  16653. m.ResetCreatedAt()
  16654. return nil
  16655. case label.FieldUpdatedAt:
  16656. m.ResetUpdatedAt()
  16657. return nil
  16658. case label.FieldStatus:
  16659. m.ResetStatus()
  16660. return nil
  16661. case label.FieldType:
  16662. m.ResetType()
  16663. return nil
  16664. case label.FieldName:
  16665. m.ResetName()
  16666. return nil
  16667. case label.FieldFrom:
  16668. m.ResetFrom()
  16669. return nil
  16670. case label.FieldMode:
  16671. m.ResetMode()
  16672. return nil
  16673. case label.FieldConditions:
  16674. m.ResetConditions()
  16675. return nil
  16676. case label.FieldOrganizationID:
  16677. m.ResetOrganizationID()
  16678. return nil
  16679. }
  16680. return fmt.Errorf("unknown Label field %s", name)
  16681. }
  16682. // AddedEdges returns all edge names that were set/added in this mutation.
  16683. func (m *LabelMutation) AddedEdges() []string {
  16684. edges := make([]string, 0, 1)
  16685. if m.label_relationships != nil {
  16686. edges = append(edges, label.EdgeLabelRelationships)
  16687. }
  16688. return edges
  16689. }
  16690. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16691. // name in this mutation.
  16692. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  16693. switch name {
  16694. case label.EdgeLabelRelationships:
  16695. ids := make([]ent.Value, 0, len(m.label_relationships))
  16696. for id := range m.label_relationships {
  16697. ids = append(ids, id)
  16698. }
  16699. return ids
  16700. }
  16701. return nil
  16702. }
  16703. // RemovedEdges returns all edge names that were removed in this mutation.
  16704. func (m *LabelMutation) RemovedEdges() []string {
  16705. edges := make([]string, 0, 1)
  16706. if m.removedlabel_relationships != nil {
  16707. edges = append(edges, label.EdgeLabelRelationships)
  16708. }
  16709. return edges
  16710. }
  16711. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16712. // the given name in this mutation.
  16713. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  16714. switch name {
  16715. case label.EdgeLabelRelationships:
  16716. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  16717. for id := range m.removedlabel_relationships {
  16718. ids = append(ids, id)
  16719. }
  16720. return ids
  16721. }
  16722. return nil
  16723. }
  16724. // ClearedEdges returns all edge names that were cleared in this mutation.
  16725. func (m *LabelMutation) ClearedEdges() []string {
  16726. edges := make([]string, 0, 1)
  16727. if m.clearedlabel_relationships {
  16728. edges = append(edges, label.EdgeLabelRelationships)
  16729. }
  16730. return edges
  16731. }
  16732. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16733. // was cleared in this mutation.
  16734. func (m *LabelMutation) EdgeCleared(name string) bool {
  16735. switch name {
  16736. case label.EdgeLabelRelationships:
  16737. return m.clearedlabel_relationships
  16738. }
  16739. return false
  16740. }
  16741. // ClearEdge clears the value of the edge with the given name. It returns an error
  16742. // if that edge is not defined in the schema.
  16743. func (m *LabelMutation) ClearEdge(name string) error {
  16744. switch name {
  16745. }
  16746. return fmt.Errorf("unknown Label unique edge %s", name)
  16747. }
  16748. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16749. // It returns an error if the edge is not defined in the schema.
  16750. func (m *LabelMutation) ResetEdge(name string) error {
  16751. switch name {
  16752. case label.EdgeLabelRelationships:
  16753. m.ResetLabelRelationships()
  16754. return nil
  16755. }
  16756. return fmt.Errorf("unknown Label edge %s", name)
  16757. }
  16758. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  16759. type LabelRelationshipMutation struct {
  16760. config
  16761. op Op
  16762. typ string
  16763. id *uint64
  16764. created_at *time.Time
  16765. updated_at *time.Time
  16766. status *uint8
  16767. addstatus *int8
  16768. organization_id *uint64
  16769. addorganization_id *int64
  16770. clearedFields map[string]struct{}
  16771. contacts *uint64
  16772. clearedcontacts bool
  16773. labels *uint64
  16774. clearedlabels bool
  16775. done bool
  16776. oldValue func(context.Context) (*LabelRelationship, error)
  16777. predicates []predicate.LabelRelationship
  16778. }
  16779. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  16780. // labelrelationshipOption allows management of the mutation configuration using functional options.
  16781. type labelrelationshipOption func(*LabelRelationshipMutation)
  16782. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  16783. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  16784. m := &LabelRelationshipMutation{
  16785. config: c,
  16786. op: op,
  16787. typ: TypeLabelRelationship,
  16788. clearedFields: make(map[string]struct{}),
  16789. }
  16790. for _, opt := range opts {
  16791. opt(m)
  16792. }
  16793. return m
  16794. }
  16795. // withLabelRelationshipID sets the ID field of the mutation.
  16796. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  16797. return func(m *LabelRelationshipMutation) {
  16798. var (
  16799. err error
  16800. once sync.Once
  16801. value *LabelRelationship
  16802. )
  16803. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  16804. once.Do(func() {
  16805. if m.done {
  16806. err = errors.New("querying old values post mutation is not allowed")
  16807. } else {
  16808. value, err = m.Client().LabelRelationship.Get(ctx, id)
  16809. }
  16810. })
  16811. return value, err
  16812. }
  16813. m.id = &id
  16814. }
  16815. }
  16816. // withLabelRelationship sets the old LabelRelationship of the mutation.
  16817. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  16818. return func(m *LabelRelationshipMutation) {
  16819. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  16820. return node, nil
  16821. }
  16822. m.id = &node.ID
  16823. }
  16824. }
  16825. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16826. // executed in a transaction (ent.Tx), a transactional client is returned.
  16827. func (m LabelRelationshipMutation) Client() *Client {
  16828. client := &Client{config: m.config}
  16829. client.init()
  16830. return client
  16831. }
  16832. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16833. // it returns an error otherwise.
  16834. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  16835. if _, ok := m.driver.(*txDriver); !ok {
  16836. return nil, errors.New("ent: mutation is not running in a transaction")
  16837. }
  16838. tx := &Tx{config: m.config}
  16839. tx.init()
  16840. return tx, nil
  16841. }
  16842. // SetID sets the value of the id field. Note that this
  16843. // operation is only accepted on creation of LabelRelationship entities.
  16844. func (m *LabelRelationshipMutation) SetID(id uint64) {
  16845. m.id = &id
  16846. }
  16847. // ID returns the ID value in the mutation. Note that the ID is only available
  16848. // if it was provided to the builder or after it was returned from the database.
  16849. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  16850. if m.id == nil {
  16851. return
  16852. }
  16853. return *m.id, true
  16854. }
  16855. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16856. // That means, if the mutation is applied within a transaction with an isolation level such
  16857. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16858. // or updated by the mutation.
  16859. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  16860. switch {
  16861. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16862. id, exists := m.ID()
  16863. if exists {
  16864. return []uint64{id}, nil
  16865. }
  16866. fallthrough
  16867. case m.op.Is(OpUpdate | OpDelete):
  16868. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  16869. default:
  16870. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16871. }
  16872. }
  16873. // SetCreatedAt sets the "created_at" field.
  16874. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  16875. m.created_at = &t
  16876. }
  16877. // CreatedAt returns the value of the "created_at" field in the mutation.
  16878. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  16879. v := m.created_at
  16880. if v == nil {
  16881. return
  16882. }
  16883. return *v, true
  16884. }
  16885. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  16886. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16888. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16889. if !m.op.Is(OpUpdateOne) {
  16890. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16891. }
  16892. if m.id == nil || m.oldValue == nil {
  16893. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16894. }
  16895. oldValue, err := m.oldValue(ctx)
  16896. if err != nil {
  16897. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16898. }
  16899. return oldValue.CreatedAt, nil
  16900. }
  16901. // ResetCreatedAt resets all changes to the "created_at" field.
  16902. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  16903. m.created_at = nil
  16904. }
  16905. // SetUpdatedAt sets the "updated_at" field.
  16906. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  16907. m.updated_at = &t
  16908. }
  16909. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16910. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  16911. v := m.updated_at
  16912. if v == nil {
  16913. return
  16914. }
  16915. return *v, true
  16916. }
  16917. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  16918. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16920. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16921. if !m.op.Is(OpUpdateOne) {
  16922. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16923. }
  16924. if m.id == nil || m.oldValue == nil {
  16925. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16926. }
  16927. oldValue, err := m.oldValue(ctx)
  16928. if err != nil {
  16929. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16930. }
  16931. return oldValue.UpdatedAt, nil
  16932. }
  16933. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16934. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  16935. m.updated_at = nil
  16936. }
  16937. // SetStatus sets the "status" field.
  16938. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  16939. m.status = &u
  16940. m.addstatus = nil
  16941. }
  16942. // Status returns the value of the "status" field in the mutation.
  16943. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  16944. v := m.status
  16945. if v == nil {
  16946. return
  16947. }
  16948. return *v, true
  16949. }
  16950. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  16951. // If the LabelRelationship 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 *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16954. if !m.op.Is(OpUpdateOne) {
  16955. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16956. }
  16957. if m.id == nil || m.oldValue == nil {
  16958. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  16963. }
  16964. return oldValue.Status, nil
  16965. }
  16966. // AddStatus adds u to the "status" field.
  16967. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  16968. if m.addstatus != nil {
  16969. *m.addstatus += u
  16970. } else {
  16971. m.addstatus = &u
  16972. }
  16973. }
  16974. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16975. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  16976. v := m.addstatus
  16977. if v == nil {
  16978. return
  16979. }
  16980. return *v, true
  16981. }
  16982. // ClearStatus clears the value of the "status" field.
  16983. func (m *LabelRelationshipMutation) ClearStatus() {
  16984. m.status = nil
  16985. m.addstatus = nil
  16986. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  16987. }
  16988. // StatusCleared returns if the "status" field was cleared in this mutation.
  16989. func (m *LabelRelationshipMutation) StatusCleared() bool {
  16990. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  16991. return ok
  16992. }
  16993. // ResetStatus resets all changes to the "status" field.
  16994. func (m *LabelRelationshipMutation) ResetStatus() {
  16995. m.status = nil
  16996. m.addstatus = nil
  16997. delete(m.clearedFields, labelrelationship.FieldStatus)
  16998. }
  16999. // SetLabelID sets the "label_id" field.
  17000. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  17001. m.labels = &u
  17002. }
  17003. // LabelID returns the value of the "label_id" field in the mutation.
  17004. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  17005. v := m.labels
  17006. if v == nil {
  17007. return
  17008. }
  17009. return *v, true
  17010. }
  17011. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  17012. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17014. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  17015. if !m.op.Is(OpUpdateOne) {
  17016. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  17017. }
  17018. if m.id == nil || m.oldValue == nil {
  17019. return v, errors.New("OldLabelID requires an ID field in the mutation")
  17020. }
  17021. oldValue, err := m.oldValue(ctx)
  17022. if err != nil {
  17023. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  17024. }
  17025. return oldValue.LabelID, nil
  17026. }
  17027. // ResetLabelID resets all changes to the "label_id" field.
  17028. func (m *LabelRelationshipMutation) ResetLabelID() {
  17029. m.labels = nil
  17030. }
  17031. // SetContactID sets the "contact_id" field.
  17032. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  17033. m.contacts = &u
  17034. }
  17035. // ContactID returns the value of the "contact_id" field in the mutation.
  17036. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  17037. v := m.contacts
  17038. if v == nil {
  17039. return
  17040. }
  17041. return *v, true
  17042. }
  17043. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  17044. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17046. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17047. if !m.op.Is(OpUpdateOne) {
  17048. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17049. }
  17050. if m.id == nil || m.oldValue == nil {
  17051. return v, errors.New("OldContactID requires an ID field in the mutation")
  17052. }
  17053. oldValue, err := m.oldValue(ctx)
  17054. if err != nil {
  17055. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17056. }
  17057. return oldValue.ContactID, nil
  17058. }
  17059. // ResetContactID resets all changes to the "contact_id" field.
  17060. func (m *LabelRelationshipMutation) ResetContactID() {
  17061. m.contacts = nil
  17062. }
  17063. // SetOrganizationID sets the "organization_id" field.
  17064. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  17065. m.organization_id = &u
  17066. m.addorganization_id = nil
  17067. }
  17068. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17069. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  17070. v := m.organization_id
  17071. if v == nil {
  17072. return
  17073. }
  17074. return *v, true
  17075. }
  17076. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  17077. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17079. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17080. if !m.op.Is(OpUpdateOne) {
  17081. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17082. }
  17083. if m.id == nil || m.oldValue == nil {
  17084. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17085. }
  17086. oldValue, err := m.oldValue(ctx)
  17087. if err != nil {
  17088. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17089. }
  17090. return oldValue.OrganizationID, nil
  17091. }
  17092. // AddOrganizationID adds u to the "organization_id" field.
  17093. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17094. if m.addorganization_id != nil {
  17095. *m.addorganization_id += u
  17096. } else {
  17097. m.addorganization_id = &u
  17098. }
  17099. }
  17100. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17101. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17102. v := m.addorganization_id
  17103. if v == nil {
  17104. return
  17105. }
  17106. return *v, true
  17107. }
  17108. // ClearOrganizationID clears the value of the "organization_id" field.
  17109. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17110. m.organization_id = nil
  17111. m.addorganization_id = nil
  17112. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17113. }
  17114. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17115. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17116. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17117. return ok
  17118. }
  17119. // ResetOrganizationID resets all changes to the "organization_id" field.
  17120. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17121. m.organization_id = nil
  17122. m.addorganization_id = nil
  17123. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17124. }
  17125. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17126. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17127. m.contacts = &id
  17128. }
  17129. // ClearContacts clears the "contacts" edge to the Contact entity.
  17130. func (m *LabelRelationshipMutation) ClearContacts() {
  17131. m.clearedcontacts = true
  17132. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17133. }
  17134. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17135. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17136. return m.clearedcontacts
  17137. }
  17138. // ContactsID returns the "contacts" edge ID in the mutation.
  17139. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17140. if m.contacts != nil {
  17141. return *m.contacts, true
  17142. }
  17143. return
  17144. }
  17145. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17146. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17147. // ContactsID instead. It exists only for internal usage by the builders.
  17148. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17149. if id := m.contacts; id != nil {
  17150. ids = append(ids, *id)
  17151. }
  17152. return
  17153. }
  17154. // ResetContacts resets all changes to the "contacts" edge.
  17155. func (m *LabelRelationshipMutation) ResetContacts() {
  17156. m.contacts = nil
  17157. m.clearedcontacts = false
  17158. }
  17159. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17160. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17161. m.labels = &id
  17162. }
  17163. // ClearLabels clears the "labels" edge to the Label entity.
  17164. func (m *LabelRelationshipMutation) ClearLabels() {
  17165. m.clearedlabels = true
  17166. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17167. }
  17168. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17169. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17170. return m.clearedlabels
  17171. }
  17172. // LabelsID returns the "labels" edge ID in the mutation.
  17173. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17174. if m.labels != nil {
  17175. return *m.labels, true
  17176. }
  17177. return
  17178. }
  17179. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17180. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17181. // LabelsID instead. It exists only for internal usage by the builders.
  17182. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17183. if id := m.labels; id != nil {
  17184. ids = append(ids, *id)
  17185. }
  17186. return
  17187. }
  17188. // ResetLabels resets all changes to the "labels" edge.
  17189. func (m *LabelRelationshipMutation) ResetLabels() {
  17190. m.labels = nil
  17191. m.clearedlabels = false
  17192. }
  17193. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17194. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17195. m.predicates = append(m.predicates, ps...)
  17196. }
  17197. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17198. // users can use type-assertion to append predicates that do not depend on any generated package.
  17199. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17200. p := make([]predicate.LabelRelationship, len(ps))
  17201. for i := range ps {
  17202. p[i] = ps[i]
  17203. }
  17204. m.Where(p...)
  17205. }
  17206. // Op returns the operation name.
  17207. func (m *LabelRelationshipMutation) Op() Op {
  17208. return m.op
  17209. }
  17210. // SetOp allows setting the mutation operation.
  17211. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17212. m.op = op
  17213. }
  17214. // Type returns the node type of this mutation (LabelRelationship).
  17215. func (m *LabelRelationshipMutation) Type() string {
  17216. return m.typ
  17217. }
  17218. // Fields returns all fields that were changed during this mutation. Note that in
  17219. // order to get all numeric fields that were incremented/decremented, call
  17220. // AddedFields().
  17221. func (m *LabelRelationshipMutation) Fields() []string {
  17222. fields := make([]string, 0, 6)
  17223. if m.created_at != nil {
  17224. fields = append(fields, labelrelationship.FieldCreatedAt)
  17225. }
  17226. if m.updated_at != nil {
  17227. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17228. }
  17229. if m.status != nil {
  17230. fields = append(fields, labelrelationship.FieldStatus)
  17231. }
  17232. if m.labels != nil {
  17233. fields = append(fields, labelrelationship.FieldLabelID)
  17234. }
  17235. if m.contacts != nil {
  17236. fields = append(fields, labelrelationship.FieldContactID)
  17237. }
  17238. if m.organization_id != nil {
  17239. fields = append(fields, labelrelationship.FieldOrganizationID)
  17240. }
  17241. return fields
  17242. }
  17243. // Field returns the value of a field with the given name. The second boolean
  17244. // return value indicates that this field was not set, or was not defined in the
  17245. // schema.
  17246. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17247. switch name {
  17248. case labelrelationship.FieldCreatedAt:
  17249. return m.CreatedAt()
  17250. case labelrelationship.FieldUpdatedAt:
  17251. return m.UpdatedAt()
  17252. case labelrelationship.FieldStatus:
  17253. return m.Status()
  17254. case labelrelationship.FieldLabelID:
  17255. return m.LabelID()
  17256. case labelrelationship.FieldContactID:
  17257. return m.ContactID()
  17258. case labelrelationship.FieldOrganizationID:
  17259. return m.OrganizationID()
  17260. }
  17261. return nil, false
  17262. }
  17263. // OldField returns the old value of the field from the database. An error is
  17264. // returned if the mutation operation is not UpdateOne, or the query to the
  17265. // database failed.
  17266. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17267. switch name {
  17268. case labelrelationship.FieldCreatedAt:
  17269. return m.OldCreatedAt(ctx)
  17270. case labelrelationship.FieldUpdatedAt:
  17271. return m.OldUpdatedAt(ctx)
  17272. case labelrelationship.FieldStatus:
  17273. return m.OldStatus(ctx)
  17274. case labelrelationship.FieldLabelID:
  17275. return m.OldLabelID(ctx)
  17276. case labelrelationship.FieldContactID:
  17277. return m.OldContactID(ctx)
  17278. case labelrelationship.FieldOrganizationID:
  17279. return m.OldOrganizationID(ctx)
  17280. }
  17281. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17282. }
  17283. // SetField sets the value of a field with the given name. It returns an error if
  17284. // the field is not defined in the schema, or if the type mismatched the field
  17285. // type.
  17286. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17287. switch name {
  17288. case labelrelationship.FieldCreatedAt:
  17289. v, ok := value.(time.Time)
  17290. if !ok {
  17291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17292. }
  17293. m.SetCreatedAt(v)
  17294. return nil
  17295. case labelrelationship.FieldUpdatedAt:
  17296. v, ok := value.(time.Time)
  17297. if !ok {
  17298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17299. }
  17300. m.SetUpdatedAt(v)
  17301. return nil
  17302. case labelrelationship.FieldStatus:
  17303. v, ok := value.(uint8)
  17304. if !ok {
  17305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17306. }
  17307. m.SetStatus(v)
  17308. return nil
  17309. case labelrelationship.FieldLabelID:
  17310. v, ok := value.(uint64)
  17311. if !ok {
  17312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17313. }
  17314. m.SetLabelID(v)
  17315. return nil
  17316. case labelrelationship.FieldContactID:
  17317. v, ok := value.(uint64)
  17318. if !ok {
  17319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17320. }
  17321. m.SetContactID(v)
  17322. return nil
  17323. case labelrelationship.FieldOrganizationID:
  17324. v, ok := value.(uint64)
  17325. if !ok {
  17326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17327. }
  17328. m.SetOrganizationID(v)
  17329. return nil
  17330. }
  17331. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17332. }
  17333. // AddedFields returns all numeric fields that were incremented/decremented during
  17334. // this mutation.
  17335. func (m *LabelRelationshipMutation) AddedFields() []string {
  17336. var fields []string
  17337. if m.addstatus != nil {
  17338. fields = append(fields, labelrelationship.FieldStatus)
  17339. }
  17340. if m.addorganization_id != nil {
  17341. fields = append(fields, labelrelationship.FieldOrganizationID)
  17342. }
  17343. return fields
  17344. }
  17345. // AddedField returns the numeric value that was incremented/decremented on a field
  17346. // with the given name. The second boolean return value indicates that this field
  17347. // was not set, or was not defined in the schema.
  17348. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17349. switch name {
  17350. case labelrelationship.FieldStatus:
  17351. return m.AddedStatus()
  17352. case labelrelationship.FieldOrganizationID:
  17353. return m.AddedOrganizationID()
  17354. }
  17355. return nil, false
  17356. }
  17357. // AddField adds the value to the field with the given name. It returns an error if
  17358. // the field is not defined in the schema, or if the type mismatched the field
  17359. // type.
  17360. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17361. switch name {
  17362. case labelrelationship.FieldStatus:
  17363. v, ok := value.(int8)
  17364. if !ok {
  17365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17366. }
  17367. m.AddStatus(v)
  17368. return nil
  17369. case labelrelationship.FieldOrganizationID:
  17370. v, ok := value.(int64)
  17371. if !ok {
  17372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17373. }
  17374. m.AddOrganizationID(v)
  17375. return nil
  17376. }
  17377. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17378. }
  17379. // ClearedFields returns all nullable fields that were cleared during this
  17380. // mutation.
  17381. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17382. var fields []string
  17383. if m.FieldCleared(labelrelationship.FieldStatus) {
  17384. fields = append(fields, labelrelationship.FieldStatus)
  17385. }
  17386. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17387. fields = append(fields, labelrelationship.FieldOrganizationID)
  17388. }
  17389. return fields
  17390. }
  17391. // FieldCleared returns a boolean indicating if a field with the given name was
  17392. // cleared in this mutation.
  17393. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17394. _, ok := m.clearedFields[name]
  17395. return ok
  17396. }
  17397. // ClearField clears the value of the field with the given name. It returns an
  17398. // error if the field is not defined in the schema.
  17399. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17400. switch name {
  17401. case labelrelationship.FieldStatus:
  17402. m.ClearStatus()
  17403. return nil
  17404. case labelrelationship.FieldOrganizationID:
  17405. m.ClearOrganizationID()
  17406. return nil
  17407. }
  17408. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17409. }
  17410. // ResetField resets all changes in the mutation for the field with the given name.
  17411. // It returns an error if the field is not defined in the schema.
  17412. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17413. switch name {
  17414. case labelrelationship.FieldCreatedAt:
  17415. m.ResetCreatedAt()
  17416. return nil
  17417. case labelrelationship.FieldUpdatedAt:
  17418. m.ResetUpdatedAt()
  17419. return nil
  17420. case labelrelationship.FieldStatus:
  17421. m.ResetStatus()
  17422. return nil
  17423. case labelrelationship.FieldLabelID:
  17424. m.ResetLabelID()
  17425. return nil
  17426. case labelrelationship.FieldContactID:
  17427. m.ResetContactID()
  17428. return nil
  17429. case labelrelationship.FieldOrganizationID:
  17430. m.ResetOrganizationID()
  17431. return nil
  17432. }
  17433. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17434. }
  17435. // AddedEdges returns all edge names that were set/added in this mutation.
  17436. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17437. edges := make([]string, 0, 2)
  17438. if m.contacts != nil {
  17439. edges = append(edges, labelrelationship.EdgeContacts)
  17440. }
  17441. if m.labels != nil {
  17442. edges = append(edges, labelrelationship.EdgeLabels)
  17443. }
  17444. return edges
  17445. }
  17446. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17447. // name in this mutation.
  17448. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17449. switch name {
  17450. case labelrelationship.EdgeContacts:
  17451. if id := m.contacts; id != nil {
  17452. return []ent.Value{*id}
  17453. }
  17454. case labelrelationship.EdgeLabels:
  17455. if id := m.labels; id != nil {
  17456. return []ent.Value{*id}
  17457. }
  17458. }
  17459. return nil
  17460. }
  17461. // RemovedEdges returns all edge names that were removed in this mutation.
  17462. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17463. edges := make([]string, 0, 2)
  17464. return edges
  17465. }
  17466. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17467. // the given name in this mutation.
  17468. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17469. return nil
  17470. }
  17471. // ClearedEdges returns all edge names that were cleared in this mutation.
  17472. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17473. edges := make([]string, 0, 2)
  17474. if m.clearedcontacts {
  17475. edges = append(edges, labelrelationship.EdgeContacts)
  17476. }
  17477. if m.clearedlabels {
  17478. edges = append(edges, labelrelationship.EdgeLabels)
  17479. }
  17480. return edges
  17481. }
  17482. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17483. // was cleared in this mutation.
  17484. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17485. switch name {
  17486. case labelrelationship.EdgeContacts:
  17487. return m.clearedcontacts
  17488. case labelrelationship.EdgeLabels:
  17489. return m.clearedlabels
  17490. }
  17491. return false
  17492. }
  17493. // ClearEdge clears the value of the edge with the given name. It returns an error
  17494. // if that edge is not defined in the schema.
  17495. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17496. switch name {
  17497. case labelrelationship.EdgeContacts:
  17498. m.ClearContacts()
  17499. return nil
  17500. case labelrelationship.EdgeLabels:
  17501. m.ClearLabels()
  17502. return nil
  17503. }
  17504. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17505. }
  17506. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17507. // It returns an error if the edge is not defined in the schema.
  17508. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17509. switch name {
  17510. case labelrelationship.EdgeContacts:
  17511. m.ResetContacts()
  17512. return nil
  17513. case labelrelationship.EdgeLabels:
  17514. m.ResetLabels()
  17515. return nil
  17516. }
  17517. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17518. }
  17519. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17520. type LabelTaggingMutation struct {
  17521. config
  17522. op Op
  17523. typ string
  17524. id *uint64
  17525. created_at *time.Time
  17526. updated_at *time.Time
  17527. status *uint8
  17528. addstatus *int8
  17529. deleted_at *time.Time
  17530. organization_id *uint64
  17531. addorganization_id *int64
  17532. _type *int
  17533. add_type *int
  17534. conditions *string
  17535. action_label_add *[]uint64
  17536. appendaction_label_add []uint64
  17537. action_label_del *[]uint64
  17538. appendaction_label_del []uint64
  17539. clearedFields map[string]struct{}
  17540. done bool
  17541. oldValue func(context.Context) (*LabelTagging, error)
  17542. predicates []predicate.LabelTagging
  17543. }
  17544. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17545. // labeltaggingOption allows management of the mutation configuration using functional options.
  17546. type labeltaggingOption func(*LabelTaggingMutation)
  17547. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17548. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17549. m := &LabelTaggingMutation{
  17550. config: c,
  17551. op: op,
  17552. typ: TypeLabelTagging,
  17553. clearedFields: make(map[string]struct{}),
  17554. }
  17555. for _, opt := range opts {
  17556. opt(m)
  17557. }
  17558. return m
  17559. }
  17560. // withLabelTaggingID sets the ID field of the mutation.
  17561. func withLabelTaggingID(id uint64) labeltaggingOption {
  17562. return func(m *LabelTaggingMutation) {
  17563. var (
  17564. err error
  17565. once sync.Once
  17566. value *LabelTagging
  17567. )
  17568. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17569. once.Do(func() {
  17570. if m.done {
  17571. err = errors.New("querying old values post mutation is not allowed")
  17572. } else {
  17573. value, err = m.Client().LabelTagging.Get(ctx, id)
  17574. }
  17575. })
  17576. return value, err
  17577. }
  17578. m.id = &id
  17579. }
  17580. }
  17581. // withLabelTagging sets the old LabelTagging of the mutation.
  17582. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17583. return func(m *LabelTaggingMutation) {
  17584. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17585. return node, nil
  17586. }
  17587. m.id = &node.ID
  17588. }
  17589. }
  17590. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17591. // executed in a transaction (ent.Tx), a transactional client is returned.
  17592. func (m LabelTaggingMutation) Client() *Client {
  17593. client := &Client{config: m.config}
  17594. client.init()
  17595. return client
  17596. }
  17597. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17598. // it returns an error otherwise.
  17599. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17600. if _, ok := m.driver.(*txDriver); !ok {
  17601. return nil, errors.New("ent: mutation is not running in a transaction")
  17602. }
  17603. tx := &Tx{config: m.config}
  17604. tx.init()
  17605. return tx, nil
  17606. }
  17607. // SetID sets the value of the id field. Note that this
  17608. // operation is only accepted on creation of LabelTagging entities.
  17609. func (m *LabelTaggingMutation) SetID(id uint64) {
  17610. m.id = &id
  17611. }
  17612. // ID returns the ID value in the mutation. Note that the ID is only available
  17613. // if it was provided to the builder or after it was returned from the database.
  17614. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17615. if m.id == nil {
  17616. return
  17617. }
  17618. return *m.id, true
  17619. }
  17620. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17621. // That means, if the mutation is applied within a transaction with an isolation level such
  17622. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17623. // or updated by the mutation.
  17624. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17625. switch {
  17626. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17627. id, exists := m.ID()
  17628. if exists {
  17629. return []uint64{id}, nil
  17630. }
  17631. fallthrough
  17632. case m.op.Is(OpUpdate | OpDelete):
  17633. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17634. default:
  17635. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17636. }
  17637. }
  17638. // SetCreatedAt sets the "created_at" field.
  17639. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  17640. m.created_at = &t
  17641. }
  17642. // CreatedAt returns the value of the "created_at" field in the mutation.
  17643. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  17644. v := m.created_at
  17645. if v == nil {
  17646. return
  17647. }
  17648. return *v, true
  17649. }
  17650. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  17651. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17653. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17654. if !m.op.Is(OpUpdateOne) {
  17655. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17656. }
  17657. if m.id == nil || m.oldValue == nil {
  17658. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17659. }
  17660. oldValue, err := m.oldValue(ctx)
  17661. if err != nil {
  17662. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17663. }
  17664. return oldValue.CreatedAt, nil
  17665. }
  17666. // ResetCreatedAt resets all changes to the "created_at" field.
  17667. func (m *LabelTaggingMutation) ResetCreatedAt() {
  17668. m.created_at = nil
  17669. }
  17670. // SetUpdatedAt sets the "updated_at" field.
  17671. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  17672. m.updated_at = &t
  17673. }
  17674. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17675. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  17676. v := m.updated_at
  17677. if v == nil {
  17678. return
  17679. }
  17680. return *v, true
  17681. }
  17682. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  17683. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17685. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17686. if !m.op.Is(OpUpdateOne) {
  17687. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17688. }
  17689. if m.id == nil || m.oldValue == nil {
  17690. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17691. }
  17692. oldValue, err := m.oldValue(ctx)
  17693. if err != nil {
  17694. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17695. }
  17696. return oldValue.UpdatedAt, nil
  17697. }
  17698. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17699. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  17700. m.updated_at = nil
  17701. }
  17702. // SetStatus sets the "status" field.
  17703. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  17704. m.status = &u
  17705. m.addstatus = nil
  17706. }
  17707. // Status returns the value of the "status" field in the mutation.
  17708. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  17709. v := m.status
  17710. if v == nil {
  17711. return
  17712. }
  17713. return *v, true
  17714. }
  17715. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  17716. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17718. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17719. if !m.op.Is(OpUpdateOne) {
  17720. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17721. }
  17722. if m.id == nil || m.oldValue == nil {
  17723. return v, errors.New("OldStatus requires an ID field in the mutation")
  17724. }
  17725. oldValue, err := m.oldValue(ctx)
  17726. if err != nil {
  17727. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17728. }
  17729. return oldValue.Status, nil
  17730. }
  17731. // AddStatus adds u to the "status" field.
  17732. func (m *LabelTaggingMutation) AddStatus(u int8) {
  17733. if m.addstatus != nil {
  17734. *m.addstatus += u
  17735. } else {
  17736. m.addstatus = &u
  17737. }
  17738. }
  17739. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17740. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  17741. v := m.addstatus
  17742. if v == nil {
  17743. return
  17744. }
  17745. return *v, true
  17746. }
  17747. // ClearStatus clears the value of the "status" field.
  17748. func (m *LabelTaggingMutation) ClearStatus() {
  17749. m.status = nil
  17750. m.addstatus = nil
  17751. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  17752. }
  17753. // StatusCleared returns if the "status" field was cleared in this mutation.
  17754. func (m *LabelTaggingMutation) StatusCleared() bool {
  17755. _, ok := m.clearedFields[labeltagging.FieldStatus]
  17756. return ok
  17757. }
  17758. // ResetStatus resets all changes to the "status" field.
  17759. func (m *LabelTaggingMutation) ResetStatus() {
  17760. m.status = nil
  17761. m.addstatus = nil
  17762. delete(m.clearedFields, labeltagging.FieldStatus)
  17763. }
  17764. // SetDeletedAt sets the "deleted_at" field.
  17765. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  17766. m.deleted_at = &t
  17767. }
  17768. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17769. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  17770. v := m.deleted_at
  17771. if v == nil {
  17772. return
  17773. }
  17774. return *v, true
  17775. }
  17776. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  17777. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17779. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17780. if !m.op.Is(OpUpdateOne) {
  17781. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17782. }
  17783. if m.id == nil || m.oldValue == nil {
  17784. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17785. }
  17786. oldValue, err := m.oldValue(ctx)
  17787. if err != nil {
  17788. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17789. }
  17790. return oldValue.DeletedAt, nil
  17791. }
  17792. // ClearDeletedAt clears the value of the "deleted_at" field.
  17793. func (m *LabelTaggingMutation) ClearDeletedAt() {
  17794. m.deleted_at = nil
  17795. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  17796. }
  17797. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17798. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  17799. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  17800. return ok
  17801. }
  17802. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17803. func (m *LabelTaggingMutation) ResetDeletedAt() {
  17804. m.deleted_at = nil
  17805. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  17806. }
  17807. // SetOrganizationID sets the "organization_id" field.
  17808. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  17809. m.organization_id = &u
  17810. m.addorganization_id = nil
  17811. }
  17812. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17813. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  17814. v := m.organization_id
  17815. if v == nil {
  17816. return
  17817. }
  17818. return *v, true
  17819. }
  17820. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  17821. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17823. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17824. if !m.op.Is(OpUpdateOne) {
  17825. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17826. }
  17827. if m.id == nil || m.oldValue == nil {
  17828. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17829. }
  17830. oldValue, err := m.oldValue(ctx)
  17831. if err != nil {
  17832. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17833. }
  17834. return oldValue.OrganizationID, nil
  17835. }
  17836. // AddOrganizationID adds u to the "organization_id" field.
  17837. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  17838. if m.addorganization_id != nil {
  17839. *m.addorganization_id += u
  17840. } else {
  17841. m.addorganization_id = &u
  17842. }
  17843. }
  17844. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17845. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  17846. v := m.addorganization_id
  17847. if v == nil {
  17848. return
  17849. }
  17850. return *v, true
  17851. }
  17852. // ResetOrganizationID resets all changes to the "organization_id" field.
  17853. func (m *LabelTaggingMutation) ResetOrganizationID() {
  17854. m.organization_id = nil
  17855. m.addorganization_id = nil
  17856. }
  17857. // SetType sets the "type" field.
  17858. func (m *LabelTaggingMutation) SetType(i int) {
  17859. m._type = &i
  17860. m.add_type = nil
  17861. }
  17862. // GetType returns the value of the "type" field in the mutation.
  17863. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  17864. v := m._type
  17865. if v == nil {
  17866. return
  17867. }
  17868. return *v, true
  17869. }
  17870. // OldType returns the old "type" field's value of the LabelTagging entity.
  17871. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17873. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  17874. if !m.op.Is(OpUpdateOne) {
  17875. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17876. }
  17877. if m.id == nil || m.oldValue == nil {
  17878. return v, errors.New("OldType requires an ID field in the mutation")
  17879. }
  17880. oldValue, err := m.oldValue(ctx)
  17881. if err != nil {
  17882. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17883. }
  17884. return oldValue.Type, nil
  17885. }
  17886. // AddType adds i to the "type" field.
  17887. func (m *LabelTaggingMutation) AddType(i int) {
  17888. if m.add_type != nil {
  17889. *m.add_type += i
  17890. } else {
  17891. m.add_type = &i
  17892. }
  17893. }
  17894. // AddedType returns the value that was added to the "type" field in this mutation.
  17895. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  17896. v := m.add_type
  17897. if v == nil {
  17898. return
  17899. }
  17900. return *v, true
  17901. }
  17902. // ResetType resets all changes to the "type" field.
  17903. func (m *LabelTaggingMutation) ResetType() {
  17904. m._type = nil
  17905. m.add_type = nil
  17906. }
  17907. // SetConditions sets the "conditions" field.
  17908. func (m *LabelTaggingMutation) SetConditions(s string) {
  17909. m.conditions = &s
  17910. }
  17911. // Conditions returns the value of the "conditions" field in the mutation.
  17912. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  17913. v := m.conditions
  17914. if v == nil {
  17915. return
  17916. }
  17917. return *v, true
  17918. }
  17919. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  17920. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17922. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  17923. if !m.op.Is(OpUpdateOne) {
  17924. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17925. }
  17926. if m.id == nil || m.oldValue == nil {
  17927. return v, errors.New("OldConditions requires an ID field in the mutation")
  17928. }
  17929. oldValue, err := m.oldValue(ctx)
  17930. if err != nil {
  17931. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17932. }
  17933. return oldValue.Conditions, nil
  17934. }
  17935. // ResetConditions resets all changes to the "conditions" field.
  17936. func (m *LabelTaggingMutation) ResetConditions() {
  17937. m.conditions = nil
  17938. }
  17939. // SetActionLabelAdd sets the "action_label_add" field.
  17940. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  17941. m.action_label_add = &u
  17942. m.appendaction_label_add = nil
  17943. }
  17944. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17945. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17946. v := m.action_label_add
  17947. if v == nil {
  17948. return
  17949. }
  17950. return *v, true
  17951. }
  17952. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  17953. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17955. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17956. if !m.op.Is(OpUpdateOne) {
  17957. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17958. }
  17959. if m.id == nil || m.oldValue == nil {
  17960. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17961. }
  17962. oldValue, err := m.oldValue(ctx)
  17963. if err != nil {
  17964. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17965. }
  17966. return oldValue.ActionLabelAdd, nil
  17967. }
  17968. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17969. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  17970. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17971. }
  17972. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17973. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17974. if len(m.appendaction_label_add) == 0 {
  17975. return nil, false
  17976. }
  17977. return m.appendaction_label_add, true
  17978. }
  17979. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17980. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  17981. m.action_label_add = nil
  17982. m.appendaction_label_add = nil
  17983. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  17984. }
  17985. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17986. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  17987. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  17988. return ok
  17989. }
  17990. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17991. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  17992. m.action_label_add = nil
  17993. m.appendaction_label_add = nil
  17994. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  17995. }
  17996. // SetActionLabelDel sets the "action_label_del" field.
  17997. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  17998. m.action_label_del = &u
  17999. m.appendaction_label_del = nil
  18000. }
  18001. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18002. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  18003. v := m.action_label_del
  18004. if v == nil {
  18005. return
  18006. }
  18007. return *v, true
  18008. }
  18009. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  18010. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18012. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18013. if !m.op.Is(OpUpdateOne) {
  18014. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18015. }
  18016. if m.id == nil || m.oldValue == nil {
  18017. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18018. }
  18019. oldValue, err := m.oldValue(ctx)
  18020. if err != nil {
  18021. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18022. }
  18023. return oldValue.ActionLabelDel, nil
  18024. }
  18025. // AppendActionLabelDel adds u to the "action_label_del" field.
  18026. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  18027. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18028. }
  18029. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18030. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18031. if len(m.appendaction_label_del) == 0 {
  18032. return nil, false
  18033. }
  18034. return m.appendaction_label_del, true
  18035. }
  18036. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18037. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  18038. m.action_label_del = nil
  18039. m.appendaction_label_del = nil
  18040. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  18041. }
  18042. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18043. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  18044. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  18045. return ok
  18046. }
  18047. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18048. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  18049. m.action_label_del = nil
  18050. m.appendaction_label_del = nil
  18051. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  18052. }
  18053. // Where appends a list predicates to the LabelTaggingMutation builder.
  18054. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  18055. m.predicates = append(m.predicates, ps...)
  18056. }
  18057. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  18058. // users can use type-assertion to append predicates that do not depend on any generated package.
  18059. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  18060. p := make([]predicate.LabelTagging, len(ps))
  18061. for i := range ps {
  18062. p[i] = ps[i]
  18063. }
  18064. m.Where(p...)
  18065. }
  18066. // Op returns the operation name.
  18067. func (m *LabelTaggingMutation) Op() Op {
  18068. return m.op
  18069. }
  18070. // SetOp allows setting the mutation operation.
  18071. func (m *LabelTaggingMutation) SetOp(op Op) {
  18072. m.op = op
  18073. }
  18074. // Type returns the node type of this mutation (LabelTagging).
  18075. func (m *LabelTaggingMutation) Type() string {
  18076. return m.typ
  18077. }
  18078. // Fields returns all fields that were changed during this mutation. Note that in
  18079. // order to get all numeric fields that were incremented/decremented, call
  18080. // AddedFields().
  18081. func (m *LabelTaggingMutation) Fields() []string {
  18082. fields := make([]string, 0, 9)
  18083. if m.created_at != nil {
  18084. fields = append(fields, labeltagging.FieldCreatedAt)
  18085. }
  18086. if m.updated_at != nil {
  18087. fields = append(fields, labeltagging.FieldUpdatedAt)
  18088. }
  18089. if m.status != nil {
  18090. fields = append(fields, labeltagging.FieldStatus)
  18091. }
  18092. if m.deleted_at != nil {
  18093. fields = append(fields, labeltagging.FieldDeletedAt)
  18094. }
  18095. if m.organization_id != nil {
  18096. fields = append(fields, labeltagging.FieldOrganizationID)
  18097. }
  18098. if m._type != nil {
  18099. fields = append(fields, labeltagging.FieldType)
  18100. }
  18101. if m.conditions != nil {
  18102. fields = append(fields, labeltagging.FieldConditions)
  18103. }
  18104. if m.action_label_add != nil {
  18105. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18106. }
  18107. if m.action_label_del != nil {
  18108. fields = append(fields, labeltagging.FieldActionLabelDel)
  18109. }
  18110. return fields
  18111. }
  18112. // Field returns the value of a field with the given name. The second boolean
  18113. // return value indicates that this field was not set, or was not defined in the
  18114. // schema.
  18115. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18116. switch name {
  18117. case labeltagging.FieldCreatedAt:
  18118. return m.CreatedAt()
  18119. case labeltagging.FieldUpdatedAt:
  18120. return m.UpdatedAt()
  18121. case labeltagging.FieldStatus:
  18122. return m.Status()
  18123. case labeltagging.FieldDeletedAt:
  18124. return m.DeletedAt()
  18125. case labeltagging.FieldOrganizationID:
  18126. return m.OrganizationID()
  18127. case labeltagging.FieldType:
  18128. return m.GetType()
  18129. case labeltagging.FieldConditions:
  18130. return m.Conditions()
  18131. case labeltagging.FieldActionLabelAdd:
  18132. return m.ActionLabelAdd()
  18133. case labeltagging.FieldActionLabelDel:
  18134. return m.ActionLabelDel()
  18135. }
  18136. return nil, false
  18137. }
  18138. // OldField returns the old value of the field from the database. An error is
  18139. // returned if the mutation operation is not UpdateOne, or the query to the
  18140. // database failed.
  18141. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18142. switch name {
  18143. case labeltagging.FieldCreatedAt:
  18144. return m.OldCreatedAt(ctx)
  18145. case labeltagging.FieldUpdatedAt:
  18146. return m.OldUpdatedAt(ctx)
  18147. case labeltagging.FieldStatus:
  18148. return m.OldStatus(ctx)
  18149. case labeltagging.FieldDeletedAt:
  18150. return m.OldDeletedAt(ctx)
  18151. case labeltagging.FieldOrganizationID:
  18152. return m.OldOrganizationID(ctx)
  18153. case labeltagging.FieldType:
  18154. return m.OldType(ctx)
  18155. case labeltagging.FieldConditions:
  18156. return m.OldConditions(ctx)
  18157. case labeltagging.FieldActionLabelAdd:
  18158. return m.OldActionLabelAdd(ctx)
  18159. case labeltagging.FieldActionLabelDel:
  18160. return m.OldActionLabelDel(ctx)
  18161. }
  18162. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18163. }
  18164. // SetField sets the value of a field with the given name. It returns an error if
  18165. // the field is not defined in the schema, or if the type mismatched the field
  18166. // type.
  18167. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18168. switch name {
  18169. case labeltagging.FieldCreatedAt:
  18170. v, ok := value.(time.Time)
  18171. if !ok {
  18172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18173. }
  18174. m.SetCreatedAt(v)
  18175. return nil
  18176. case labeltagging.FieldUpdatedAt:
  18177. v, ok := value.(time.Time)
  18178. if !ok {
  18179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18180. }
  18181. m.SetUpdatedAt(v)
  18182. return nil
  18183. case labeltagging.FieldStatus:
  18184. v, ok := value.(uint8)
  18185. if !ok {
  18186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18187. }
  18188. m.SetStatus(v)
  18189. return nil
  18190. case labeltagging.FieldDeletedAt:
  18191. v, ok := value.(time.Time)
  18192. if !ok {
  18193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18194. }
  18195. m.SetDeletedAt(v)
  18196. return nil
  18197. case labeltagging.FieldOrganizationID:
  18198. v, ok := value.(uint64)
  18199. if !ok {
  18200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18201. }
  18202. m.SetOrganizationID(v)
  18203. return nil
  18204. case labeltagging.FieldType:
  18205. v, ok := value.(int)
  18206. if !ok {
  18207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18208. }
  18209. m.SetType(v)
  18210. return nil
  18211. case labeltagging.FieldConditions:
  18212. v, ok := value.(string)
  18213. if !ok {
  18214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18215. }
  18216. m.SetConditions(v)
  18217. return nil
  18218. case labeltagging.FieldActionLabelAdd:
  18219. v, ok := value.([]uint64)
  18220. if !ok {
  18221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18222. }
  18223. m.SetActionLabelAdd(v)
  18224. return nil
  18225. case labeltagging.FieldActionLabelDel:
  18226. v, ok := value.([]uint64)
  18227. if !ok {
  18228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18229. }
  18230. m.SetActionLabelDel(v)
  18231. return nil
  18232. }
  18233. return fmt.Errorf("unknown LabelTagging field %s", name)
  18234. }
  18235. // AddedFields returns all numeric fields that were incremented/decremented during
  18236. // this mutation.
  18237. func (m *LabelTaggingMutation) AddedFields() []string {
  18238. var fields []string
  18239. if m.addstatus != nil {
  18240. fields = append(fields, labeltagging.FieldStatus)
  18241. }
  18242. if m.addorganization_id != nil {
  18243. fields = append(fields, labeltagging.FieldOrganizationID)
  18244. }
  18245. if m.add_type != nil {
  18246. fields = append(fields, labeltagging.FieldType)
  18247. }
  18248. return fields
  18249. }
  18250. // AddedField returns the numeric value that was incremented/decremented on a field
  18251. // with the given name. The second boolean return value indicates that this field
  18252. // was not set, or was not defined in the schema.
  18253. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18254. switch name {
  18255. case labeltagging.FieldStatus:
  18256. return m.AddedStatus()
  18257. case labeltagging.FieldOrganizationID:
  18258. return m.AddedOrganizationID()
  18259. case labeltagging.FieldType:
  18260. return m.AddedType()
  18261. }
  18262. return nil, false
  18263. }
  18264. // AddField adds the value to the field with the given name. It returns an error if
  18265. // the field is not defined in the schema, or if the type mismatched the field
  18266. // type.
  18267. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18268. switch name {
  18269. case labeltagging.FieldStatus:
  18270. v, ok := value.(int8)
  18271. if !ok {
  18272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18273. }
  18274. m.AddStatus(v)
  18275. return nil
  18276. case labeltagging.FieldOrganizationID:
  18277. v, ok := value.(int64)
  18278. if !ok {
  18279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18280. }
  18281. m.AddOrganizationID(v)
  18282. return nil
  18283. case labeltagging.FieldType:
  18284. v, ok := value.(int)
  18285. if !ok {
  18286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18287. }
  18288. m.AddType(v)
  18289. return nil
  18290. }
  18291. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18292. }
  18293. // ClearedFields returns all nullable fields that were cleared during this
  18294. // mutation.
  18295. func (m *LabelTaggingMutation) ClearedFields() []string {
  18296. var fields []string
  18297. if m.FieldCleared(labeltagging.FieldStatus) {
  18298. fields = append(fields, labeltagging.FieldStatus)
  18299. }
  18300. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18301. fields = append(fields, labeltagging.FieldDeletedAt)
  18302. }
  18303. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18304. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18305. }
  18306. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18307. fields = append(fields, labeltagging.FieldActionLabelDel)
  18308. }
  18309. return fields
  18310. }
  18311. // FieldCleared returns a boolean indicating if a field with the given name was
  18312. // cleared in this mutation.
  18313. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18314. _, ok := m.clearedFields[name]
  18315. return ok
  18316. }
  18317. // ClearField clears the value of the field with the given name. It returns an
  18318. // error if the field is not defined in the schema.
  18319. func (m *LabelTaggingMutation) ClearField(name string) error {
  18320. switch name {
  18321. case labeltagging.FieldStatus:
  18322. m.ClearStatus()
  18323. return nil
  18324. case labeltagging.FieldDeletedAt:
  18325. m.ClearDeletedAt()
  18326. return nil
  18327. case labeltagging.FieldActionLabelAdd:
  18328. m.ClearActionLabelAdd()
  18329. return nil
  18330. case labeltagging.FieldActionLabelDel:
  18331. m.ClearActionLabelDel()
  18332. return nil
  18333. }
  18334. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18335. }
  18336. // ResetField resets all changes in the mutation for the field with the given name.
  18337. // It returns an error if the field is not defined in the schema.
  18338. func (m *LabelTaggingMutation) ResetField(name string) error {
  18339. switch name {
  18340. case labeltagging.FieldCreatedAt:
  18341. m.ResetCreatedAt()
  18342. return nil
  18343. case labeltagging.FieldUpdatedAt:
  18344. m.ResetUpdatedAt()
  18345. return nil
  18346. case labeltagging.FieldStatus:
  18347. m.ResetStatus()
  18348. return nil
  18349. case labeltagging.FieldDeletedAt:
  18350. m.ResetDeletedAt()
  18351. return nil
  18352. case labeltagging.FieldOrganizationID:
  18353. m.ResetOrganizationID()
  18354. return nil
  18355. case labeltagging.FieldType:
  18356. m.ResetType()
  18357. return nil
  18358. case labeltagging.FieldConditions:
  18359. m.ResetConditions()
  18360. return nil
  18361. case labeltagging.FieldActionLabelAdd:
  18362. m.ResetActionLabelAdd()
  18363. return nil
  18364. case labeltagging.FieldActionLabelDel:
  18365. m.ResetActionLabelDel()
  18366. return nil
  18367. }
  18368. return fmt.Errorf("unknown LabelTagging field %s", name)
  18369. }
  18370. // AddedEdges returns all edge names that were set/added in this mutation.
  18371. func (m *LabelTaggingMutation) AddedEdges() []string {
  18372. edges := make([]string, 0, 0)
  18373. return edges
  18374. }
  18375. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18376. // name in this mutation.
  18377. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18378. return nil
  18379. }
  18380. // RemovedEdges returns all edge names that were removed in this mutation.
  18381. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18382. edges := make([]string, 0, 0)
  18383. return edges
  18384. }
  18385. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18386. // the given name in this mutation.
  18387. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18388. return nil
  18389. }
  18390. // ClearedEdges returns all edge names that were cleared in this mutation.
  18391. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18392. edges := make([]string, 0, 0)
  18393. return edges
  18394. }
  18395. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18396. // was cleared in this mutation.
  18397. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18398. return false
  18399. }
  18400. // ClearEdge clears the value of the edge with the given name. It returns an error
  18401. // if that edge is not defined in the schema.
  18402. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18403. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18404. }
  18405. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18406. // It returns an error if the edge is not defined in the schema.
  18407. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18408. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18409. }
  18410. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18411. type MessageMutation struct {
  18412. config
  18413. op Op
  18414. typ string
  18415. id *int
  18416. wx_wxid *string
  18417. wxid *string
  18418. content *string
  18419. clearedFields map[string]struct{}
  18420. done bool
  18421. oldValue func(context.Context) (*Message, error)
  18422. predicates []predicate.Message
  18423. }
  18424. var _ ent.Mutation = (*MessageMutation)(nil)
  18425. // messageOption allows management of the mutation configuration using functional options.
  18426. type messageOption func(*MessageMutation)
  18427. // newMessageMutation creates new mutation for the Message entity.
  18428. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18429. m := &MessageMutation{
  18430. config: c,
  18431. op: op,
  18432. typ: TypeMessage,
  18433. clearedFields: make(map[string]struct{}),
  18434. }
  18435. for _, opt := range opts {
  18436. opt(m)
  18437. }
  18438. return m
  18439. }
  18440. // withMessageID sets the ID field of the mutation.
  18441. func withMessageID(id int) messageOption {
  18442. return func(m *MessageMutation) {
  18443. var (
  18444. err error
  18445. once sync.Once
  18446. value *Message
  18447. )
  18448. m.oldValue = func(ctx context.Context) (*Message, error) {
  18449. once.Do(func() {
  18450. if m.done {
  18451. err = errors.New("querying old values post mutation is not allowed")
  18452. } else {
  18453. value, err = m.Client().Message.Get(ctx, id)
  18454. }
  18455. })
  18456. return value, err
  18457. }
  18458. m.id = &id
  18459. }
  18460. }
  18461. // withMessage sets the old Message of the mutation.
  18462. func withMessage(node *Message) messageOption {
  18463. return func(m *MessageMutation) {
  18464. m.oldValue = func(context.Context) (*Message, error) {
  18465. return node, nil
  18466. }
  18467. m.id = &node.ID
  18468. }
  18469. }
  18470. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18471. // executed in a transaction (ent.Tx), a transactional client is returned.
  18472. func (m MessageMutation) Client() *Client {
  18473. client := &Client{config: m.config}
  18474. client.init()
  18475. return client
  18476. }
  18477. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18478. // it returns an error otherwise.
  18479. func (m MessageMutation) Tx() (*Tx, error) {
  18480. if _, ok := m.driver.(*txDriver); !ok {
  18481. return nil, errors.New("ent: mutation is not running in a transaction")
  18482. }
  18483. tx := &Tx{config: m.config}
  18484. tx.init()
  18485. return tx, nil
  18486. }
  18487. // ID returns the ID value in the mutation. Note that the ID is only available
  18488. // if it was provided to the builder or after it was returned from the database.
  18489. func (m *MessageMutation) ID() (id int, exists bool) {
  18490. if m.id == nil {
  18491. return
  18492. }
  18493. return *m.id, true
  18494. }
  18495. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18496. // That means, if the mutation is applied within a transaction with an isolation level such
  18497. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18498. // or updated by the mutation.
  18499. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18500. switch {
  18501. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18502. id, exists := m.ID()
  18503. if exists {
  18504. return []int{id}, nil
  18505. }
  18506. fallthrough
  18507. case m.op.Is(OpUpdate | OpDelete):
  18508. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18509. default:
  18510. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18511. }
  18512. }
  18513. // SetWxWxid sets the "wx_wxid" field.
  18514. func (m *MessageMutation) SetWxWxid(s string) {
  18515. m.wx_wxid = &s
  18516. }
  18517. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18518. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18519. v := m.wx_wxid
  18520. if v == nil {
  18521. return
  18522. }
  18523. return *v, true
  18524. }
  18525. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18526. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18528. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18529. if !m.op.Is(OpUpdateOne) {
  18530. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18531. }
  18532. if m.id == nil || m.oldValue == nil {
  18533. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18534. }
  18535. oldValue, err := m.oldValue(ctx)
  18536. if err != nil {
  18537. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18538. }
  18539. return oldValue.WxWxid, nil
  18540. }
  18541. // ClearWxWxid clears the value of the "wx_wxid" field.
  18542. func (m *MessageMutation) ClearWxWxid() {
  18543. m.wx_wxid = nil
  18544. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18545. }
  18546. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18547. func (m *MessageMutation) WxWxidCleared() bool {
  18548. _, ok := m.clearedFields[message.FieldWxWxid]
  18549. return ok
  18550. }
  18551. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18552. func (m *MessageMutation) ResetWxWxid() {
  18553. m.wx_wxid = nil
  18554. delete(m.clearedFields, message.FieldWxWxid)
  18555. }
  18556. // SetWxid sets the "wxid" field.
  18557. func (m *MessageMutation) SetWxid(s string) {
  18558. m.wxid = &s
  18559. }
  18560. // Wxid returns the value of the "wxid" field in the mutation.
  18561. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18562. v := m.wxid
  18563. if v == nil {
  18564. return
  18565. }
  18566. return *v, true
  18567. }
  18568. // OldWxid returns the old "wxid" field's value of the Message entity.
  18569. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18571. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18572. if !m.op.Is(OpUpdateOne) {
  18573. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18574. }
  18575. if m.id == nil || m.oldValue == nil {
  18576. return v, errors.New("OldWxid requires an ID field in the mutation")
  18577. }
  18578. oldValue, err := m.oldValue(ctx)
  18579. if err != nil {
  18580. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18581. }
  18582. return oldValue.Wxid, nil
  18583. }
  18584. // ResetWxid resets all changes to the "wxid" field.
  18585. func (m *MessageMutation) ResetWxid() {
  18586. m.wxid = nil
  18587. }
  18588. // SetContent sets the "content" field.
  18589. func (m *MessageMutation) SetContent(s string) {
  18590. m.content = &s
  18591. }
  18592. // Content returns the value of the "content" field in the mutation.
  18593. func (m *MessageMutation) Content() (r string, exists bool) {
  18594. v := m.content
  18595. if v == nil {
  18596. return
  18597. }
  18598. return *v, true
  18599. }
  18600. // OldContent returns the old "content" field's value of the Message entity.
  18601. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18603. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18604. if !m.op.Is(OpUpdateOne) {
  18605. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18606. }
  18607. if m.id == nil || m.oldValue == nil {
  18608. return v, errors.New("OldContent requires an ID field in the mutation")
  18609. }
  18610. oldValue, err := m.oldValue(ctx)
  18611. if err != nil {
  18612. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18613. }
  18614. return oldValue.Content, nil
  18615. }
  18616. // ResetContent resets all changes to the "content" field.
  18617. func (m *MessageMutation) ResetContent() {
  18618. m.content = nil
  18619. }
  18620. // Where appends a list predicates to the MessageMutation builder.
  18621. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18622. m.predicates = append(m.predicates, ps...)
  18623. }
  18624. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18625. // users can use type-assertion to append predicates that do not depend on any generated package.
  18626. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18627. p := make([]predicate.Message, len(ps))
  18628. for i := range ps {
  18629. p[i] = ps[i]
  18630. }
  18631. m.Where(p...)
  18632. }
  18633. // Op returns the operation name.
  18634. func (m *MessageMutation) Op() Op {
  18635. return m.op
  18636. }
  18637. // SetOp allows setting the mutation operation.
  18638. func (m *MessageMutation) SetOp(op Op) {
  18639. m.op = op
  18640. }
  18641. // Type returns the node type of this mutation (Message).
  18642. func (m *MessageMutation) Type() string {
  18643. return m.typ
  18644. }
  18645. // Fields returns all fields that were changed during this mutation. Note that in
  18646. // order to get all numeric fields that were incremented/decremented, call
  18647. // AddedFields().
  18648. func (m *MessageMutation) Fields() []string {
  18649. fields := make([]string, 0, 3)
  18650. if m.wx_wxid != nil {
  18651. fields = append(fields, message.FieldWxWxid)
  18652. }
  18653. if m.wxid != nil {
  18654. fields = append(fields, message.FieldWxid)
  18655. }
  18656. if m.content != nil {
  18657. fields = append(fields, message.FieldContent)
  18658. }
  18659. return fields
  18660. }
  18661. // Field returns the value of a field with the given name. The second boolean
  18662. // return value indicates that this field was not set, or was not defined in the
  18663. // schema.
  18664. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  18665. switch name {
  18666. case message.FieldWxWxid:
  18667. return m.WxWxid()
  18668. case message.FieldWxid:
  18669. return m.Wxid()
  18670. case message.FieldContent:
  18671. return m.Content()
  18672. }
  18673. return nil, false
  18674. }
  18675. // OldField returns the old value of the field from the database. An error is
  18676. // returned if the mutation operation is not UpdateOne, or the query to the
  18677. // database failed.
  18678. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18679. switch name {
  18680. case message.FieldWxWxid:
  18681. return m.OldWxWxid(ctx)
  18682. case message.FieldWxid:
  18683. return m.OldWxid(ctx)
  18684. case message.FieldContent:
  18685. return m.OldContent(ctx)
  18686. }
  18687. return nil, fmt.Errorf("unknown Message field %s", name)
  18688. }
  18689. // SetField sets the value of a field with the given name. It returns an error if
  18690. // the field is not defined in the schema, or if the type mismatched the field
  18691. // type.
  18692. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  18693. switch name {
  18694. case message.FieldWxWxid:
  18695. v, ok := value.(string)
  18696. if !ok {
  18697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18698. }
  18699. m.SetWxWxid(v)
  18700. return nil
  18701. case message.FieldWxid:
  18702. v, ok := value.(string)
  18703. if !ok {
  18704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18705. }
  18706. m.SetWxid(v)
  18707. return nil
  18708. case message.FieldContent:
  18709. v, ok := value.(string)
  18710. if !ok {
  18711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18712. }
  18713. m.SetContent(v)
  18714. return nil
  18715. }
  18716. return fmt.Errorf("unknown Message field %s", name)
  18717. }
  18718. // AddedFields returns all numeric fields that were incremented/decremented during
  18719. // this mutation.
  18720. func (m *MessageMutation) AddedFields() []string {
  18721. return nil
  18722. }
  18723. // AddedField returns the numeric value that was incremented/decremented on a field
  18724. // with the given name. The second boolean return value indicates that this field
  18725. // was not set, or was not defined in the schema.
  18726. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  18727. return nil, false
  18728. }
  18729. // AddField adds the value to the field with the given name. It returns an error if
  18730. // the field is not defined in the schema, or if the type mismatched the field
  18731. // type.
  18732. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  18733. switch name {
  18734. }
  18735. return fmt.Errorf("unknown Message numeric field %s", name)
  18736. }
  18737. // ClearedFields returns all nullable fields that were cleared during this
  18738. // mutation.
  18739. func (m *MessageMutation) ClearedFields() []string {
  18740. var fields []string
  18741. if m.FieldCleared(message.FieldWxWxid) {
  18742. fields = append(fields, message.FieldWxWxid)
  18743. }
  18744. return fields
  18745. }
  18746. // FieldCleared returns a boolean indicating if a field with the given name was
  18747. // cleared in this mutation.
  18748. func (m *MessageMutation) FieldCleared(name string) bool {
  18749. _, ok := m.clearedFields[name]
  18750. return ok
  18751. }
  18752. // ClearField clears the value of the field with the given name. It returns an
  18753. // error if the field is not defined in the schema.
  18754. func (m *MessageMutation) ClearField(name string) error {
  18755. switch name {
  18756. case message.FieldWxWxid:
  18757. m.ClearWxWxid()
  18758. return nil
  18759. }
  18760. return fmt.Errorf("unknown Message nullable field %s", name)
  18761. }
  18762. // ResetField resets all changes in the mutation for the field with the given name.
  18763. // It returns an error if the field is not defined in the schema.
  18764. func (m *MessageMutation) ResetField(name string) error {
  18765. switch name {
  18766. case message.FieldWxWxid:
  18767. m.ResetWxWxid()
  18768. return nil
  18769. case message.FieldWxid:
  18770. m.ResetWxid()
  18771. return nil
  18772. case message.FieldContent:
  18773. m.ResetContent()
  18774. return nil
  18775. }
  18776. return fmt.Errorf("unknown Message field %s", name)
  18777. }
  18778. // AddedEdges returns all edge names that were set/added in this mutation.
  18779. func (m *MessageMutation) AddedEdges() []string {
  18780. edges := make([]string, 0, 0)
  18781. return edges
  18782. }
  18783. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18784. // name in this mutation.
  18785. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  18786. return nil
  18787. }
  18788. // RemovedEdges returns all edge names that were removed in this mutation.
  18789. func (m *MessageMutation) RemovedEdges() []string {
  18790. edges := make([]string, 0, 0)
  18791. return edges
  18792. }
  18793. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18794. // the given name in this mutation.
  18795. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  18796. return nil
  18797. }
  18798. // ClearedEdges returns all edge names that were cleared in this mutation.
  18799. func (m *MessageMutation) ClearedEdges() []string {
  18800. edges := make([]string, 0, 0)
  18801. return edges
  18802. }
  18803. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18804. // was cleared in this mutation.
  18805. func (m *MessageMutation) EdgeCleared(name string) bool {
  18806. return false
  18807. }
  18808. // ClearEdge clears the value of the edge with the given name. It returns an error
  18809. // if that edge is not defined in the schema.
  18810. func (m *MessageMutation) ClearEdge(name string) error {
  18811. return fmt.Errorf("unknown Message unique edge %s", name)
  18812. }
  18813. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18814. // It returns an error if the edge is not defined in the schema.
  18815. func (m *MessageMutation) ResetEdge(name string) error {
  18816. return fmt.Errorf("unknown Message edge %s", name)
  18817. }
  18818. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  18819. type MessageRecordsMutation struct {
  18820. config
  18821. op Op
  18822. typ string
  18823. id *uint64
  18824. created_at *time.Time
  18825. updated_at *time.Time
  18826. status *uint8
  18827. addstatus *int8
  18828. bot_wxid *string
  18829. contact_type *int
  18830. addcontact_type *int
  18831. contact_wxid *string
  18832. content_type *int
  18833. addcontent_type *int
  18834. content *string
  18835. meta *custom_types.Meta
  18836. error_detail *string
  18837. send_time *time.Time
  18838. source_type *int
  18839. addsource_type *int
  18840. organization_id *uint64
  18841. addorganization_id *int64
  18842. clearedFields map[string]struct{}
  18843. sop_stage *uint64
  18844. clearedsop_stage bool
  18845. sop_node *uint64
  18846. clearedsop_node bool
  18847. message_contact *uint64
  18848. clearedmessage_contact bool
  18849. done bool
  18850. oldValue func(context.Context) (*MessageRecords, error)
  18851. predicates []predicate.MessageRecords
  18852. }
  18853. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  18854. // messagerecordsOption allows management of the mutation configuration using functional options.
  18855. type messagerecordsOption func(*MessageRecordsMutation)
  18856. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  18857. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  18858. m := &MessageRecordsMutation{
  18859. config: c,
  18860. op: op,
  18861. typ: TypeMessageRecords,
  18862. clearedFields: make(map[string]struct{}),
  18863. }
  18864. for _, opt := range opts {
  18865. opt(m)
  18866. }
  18867. return m
  18868. }
  18869. // withMessageRecordsID sets the ID field of the mutation.
  18870. func withMessageRecordsID(id uint64) messagerecordsOption {
  18871. return func(m *MessageRecordsMutation) {
  18872. var (
  18873. err error
  18874. once sync.Once
  18875. value *MessageRecords
  18876. )
  18877. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  18878. once.Do(func() {
  18879. if m.done {
  18880. err = errors.New("querying old values post mutation is not allowed")
  18881. } else {
  18882. value, err = m.Client().MessageRecords.Get(ctx, id)
  18883. }
  18884. })
  18885. return value, err
  18886. }
  18887. m.id = &id
  18888. }
  18889. }
  18890. // withMessageRecords sets the old MessageRecords of the mutation.
  18891. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  18892. return func(m *MessageRecordsMutation) {
  18893. m.oldValue = func(context.Context) (*MessageRecords, error) {
  18894. return node, nil
  18895. }
  18896. m.id = &node.ID
  18897. }
  18898. }
  18899. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18900. // executed in a transaction (ent.Tx), a transactional client is returned.
  18901. func (m MessageRecordsMutation) Client() *Client {
  18902. client := &Client{config: m.config}
  18903. client.init()
  18904. return client
  18905. }
  18906. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18907. // it returns an error otherwise.
  18908. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  18909. if _, ok := m.driver.(*txDriver); !ok {
  18910. return nil, errors.New("ent: mutation is not running in a transaction")
  18911. }
  18912. tx := &Tx{config: m.config}
  18913. tx.init()
  18914. return tx, nil
  18915. }
  18916. // SetID sets the value of the id field. Note that this
  18917. // operation is only accepted on creation of MessageRecords entities.
  18918. func (m *MessageRecordsMutation) SetID(id uint64) {
  18919. m.id = &id
  18920. }
  18921. // ID returns the ID value in the mutation. Note that the ID is only available
  18922. // if it was provided to the builder or after it was returned from the database.
  18923. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  18924. if m.id == nil {
  18925. return
  18926. }
  18927. return *m.id, true
  18928. }
  18929. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18930. // That means, if the mutation is applied within a transaction with an isolation level such
  18931. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18932. // or updated by the mutation.
  18933. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  18934. switch {
  18935. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18936. id, exists := m.ID()
  18937. if exists {
  18938. return []uint64{id}, nil
  18939. }
  18940. fallthrough
  18941. case m.op.Is(OpUpdate | OpDelete):
  18942. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  18943. default:
  18944. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18945. }
  18946. }
  18947. // SetCreatedAt sets the "created_at" field.
  18948. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  18949. m.created_at = &t
  18950. }
  18951. // CreatedAt returns the value of the "created_at" field in the mutation.
  18952. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  18953. v := m.created_at
  18954. if v == nil {
  18955. return
  18956. }
  18957. return *v, true
  18958. }
  18959. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  18960. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18962. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18963. if !m.op.Is(OpUpdateOne) {
  18964. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18965. }
  18966. if m.id == nil || m.oldValue == nil {
  18967. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18968. }
  18969. oldValue, err := m.oldValue(ctx)
  18970. if err != nil {
  18971. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18972. }
  18973. return oldValue.CreatedAt, nil
  18974. }
  18975. // ResetCreatedAt resets all changes to the "created_at" field.
  18976. func (m *MessageRecordsMutation) ResetCreatedAt() {
  18977. m.created_at = nil
  18978. }
  18979. // SetUpdatedAt sets the "updated_at" field.
  18980. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  18981. m.updated_at = &t
  18982. }
  18983. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18984. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  18985. v := m.updated_at
  18986. if v == nil {
  18987. return
  18988. }
  18989. return *v, true
  18990. }
  18991. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  18992. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18994. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18995. if !m.op.Is(OpUpdateOne) {
  18996. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18997. }
  18998. if m.id == nil || m.oldValue == nil {
  18999. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19000. }
  19001. oldValue, err := m.oldValue(ctx)
  19002. if err != nil {
  19003. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19004. }
  19005. return oldValue.UpdatedAt, nil
  19006. }
  19007. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19008. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  19009. m.updated_at = nil
  19010. }
  19011. // SetStatus sets the "status" field.
  19012. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  19013. m.status = &u
  19014. m.addstatus = nil
  19015. }
  19016. // Status returns the value of the "status" field in the mutation.
  19017. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  19018. v := m.status
  19019. if v == nil {
  19020. return
  19021. }
  19022. return *v, true
  19023. }
  19024. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  19025. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19027. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19028. if !m.op.Is(OpUpdateOne) {
  19029. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19030. }
  19031. if m.id == nil || m.oldValue == nil {
  19032. return v, errors.New("OldStatus requires an ID field in the mutation")
  19033. }
  19034. oldValue, err := m.oldValue(ctx)
  19035. if err != nil {
  19036. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19037. }
  19038. return oldValue.Status, nil
  19039. }
  19040. // AddStatus adds u to the "status" field.
  19041. func (m *MessageRecordsMutation) AddStatus(u int8) {
  19042. if m.addstatus != nil {
  19043. *m.addstatus += u
  19044. } else {
  19045. m.addstatus = &u
  19046. }
  19047. }
  19048. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19049. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  19050. v := m.addstatus
  19051. if v == nil {
  19052. return
  19053. }
  19054. return *v, true
  19055. }
  19056. // ClearStatus clears the value of the "status" field.
  19057. func (m *MessageRecordsMutation) ClearStatus() {
  19058. m.status = nil
  19059. m.addstatus = nil
  19060. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  19061. }
  19062. // StatusCleared returns if the "status" field was cleared in this mutation.
  19063. func (m *MessageRecordsMutation) StatusCleared() bool {
  19064. _, ok := m.clearedFields[messagerecords.FieldStatus]
  19065. return ok
  19066. }
  19067. // ResetStatus resets all changes to the "status" field.
  19068. func (m *MessageRecordsMutation) ResetStatus() {
  19069. m.status = nil
  19070. m.addstatus = nil
  19071. delete(m.clearedFields, messagerecords.FieldStatus)
  19072. }
  19073. // SetBotWxid sets the "bot_wxid" field.
  19074. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  19075. m.bot_wxid = &s
  19076. }
  19077. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  19078. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  19079. v := m.bot_wxid
  19080. if v == nil {
  19081. return
  19082. }
  19083. return *v, true
  19084. }
  19085. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19086. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19088. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19089. if !m.op.Is(OpUpdateOne) {
  19090. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19091. }
  19092. if m.id == nil || m.oldValue == nil {
  19093. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19094. }
  19095. oldValue, err := m.oldValue(ctx)
  19096. if err != nil {
  19097. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19098. }
  19099. return oldValue.BotWxid, nil
  19100. }
  19101. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19102. func (m *MessageRecordsMutation) ResetBotWxid() {
  19103. m.bot_wxid = nil
  19104. }
  19105. // SetContactID sets the "contact_id" field.
  19106. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19107. m.message_contact = &u
  19108. }
  19109. // ContactID returns the value of the "contact_id" field in the mutation.
  19110. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19111. v := m.message_contact
  19112. if v == nil {
  19113. return
  19114. }
  19115. return *v, true
  19116. }
  19117. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19118. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19120. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19121. if !m.op.Is(OpUpdateOne) {
  19122. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19123. }
  19124. if m.id == nil || m.oldValue == nil {
  19125. return v, errors.New("OldContactID requires an ID field in the mutation")
  19126. }
  19127. oldValue, err := m.oldValue(ctx)
  19128. if err != nil {
  19129. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19130. }
  19131. return oldValue.ContactID, nil
  19132. }
  19133. // ClearContactID clears the value of the "contact_id" field.
  19134. func (m *MessageRecordsMutation) ClearContactID() {
  19135. m.message_contact = nil
  19136. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19137. }
  19138. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19139. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19140. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19141. return ok
  19142. }
  19143. // ResetContactID resets all changes to the "contact_id" field.
  19144. func (m *MessageRecordsMutation) ResetContactID() {
  19145. m.message_contact = nil
  19146. delete(m.clearedFields, messagerecords.FieldContactID)
  19147. }
  19148. // SetContactType sets the "contact_type" field.
  19149. func (m *MessageRecordsMutation) SetContactType(i int) {
  19150. m.contact_type = &i
  19151. m.addcontact_type = nil
  19152. }
  19153. // ContactType returns the value of the "contact_type" field in the mutation.
  19154. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19155. v := m.contact_type
  19156. if v == nil {
  19157. return
  19158. }
  19159. return *v, true
  19160. }
  19161. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19162. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19164. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19165. if !m.op.Is(OpUpdateOne) {
  19166. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19167. }
  19168. if m.id == nil || m.oldValue == nil {
  19169. return v, errors.New("OldContactType requires an ID field in the mutation")
  19170. }
  19171. oldValue, err := m.oldValue(ctx)
  19172. if err != nil {
  19173. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19174. }
  19175. return oldValue.ContactType, nil
  19176. }
  19177. // AddContactType adds i to the "contact_type" field.
  19178. func (m *MessageRecordsMutation) AddContactType(i int) {
  19179. if m.addcontact_type != nil {
  19180. *m.addcontact_type += i
  19181. } else {
  19182. m.addcontact_type = &i
  19183. }
  19184. }
  19185. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19186. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19187. v := m.addcontact_type
  19188. if v == nil {
  19189. return
  19190. }
  19191. return *v, true
  19192. }
  19193. // ResetContactType resets all changes to the "contact_type" field.
  19194. func (m *MessageRecordsMutation) ResetContactType() {
  19195. m.contact_type = nil
  19196. m.addcontact_type = nil
  19197. }
  19198. // SetContactWxid sets the "contact_wxid" field.
  19199. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19200. m.contact_wxid = &s
  19201. }
  19202. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19203. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19204. v := m.contact_wxid
  19205. if v == nil {
  19206. return
  19207. }
  19208. return *v, true
  19209. }
  19210. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19211. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19213. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19214. if !m.op.Is(OpUpdateOne) {
  19215. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19216. }
  19217. if m.id == nil || m.oldValue == nil {
  19218. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19219. }
  19220. oldValue, err := m.oldValue(ctx)
  19221. if err != nil {
  19222. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19223. }
  19224. return oldValue.ContactWxid, nil
  19225. }
  19226. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19227. func (m *MessageRecordsMutation) ResetContactWxid() {
  19228. m.contact_wxid = nil
  19229. }
  19230. // SetContentType sets the "content_type" field.
  19231. func (m *MessageRecordsMutation) SetContentType(i int) {
  19232. m.content_type = &i
  19233. m.addcontent_type = nil
  19234. }
  19235. // ContentType returns the value of the "content_type" field in the mutation.
  19236. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19237. v := m.content_type
  19238. if v == nil {
  19239. return
  19240. }
  19241. return *v, true
  19242. }
  19243. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19244. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19246. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19247. if !m.op.Is(OpUpdateOne) {
  19248. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19249. }
  19250. if m.id == nil || m.oldValue == nil {
  19251. return v, errors.New("OldContentType requires an ID field in the mutation")
  19252. }
  19253. oldValue, err := m.oldValue(ctx)
  19254. if err != nil {
  19255. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19256. }
  19257. return oldValue.ContentType, nil
  19258. }
  19259. // AddContentType adds i to the "content_type" field.
  19260. func (m *MessageRecordsMutation) AddContentType(i int) {
  19261. if m.addcontent_type != nil {
  19262. *m.addcontent_type += i
  19263. } else {
  19264. m.addcontent_type = &i
  19265. }
  19266. }
  19267. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19268. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19269. v := m.addcontent_type
  19270. if v == nil {
  19271. return
  19272. }
  19273. return *v, true
  19274. }
  19275. // ResetContentType resets all changes to the "content_type" field.
  19276. func (m *MessageRecordsMutation) ResetContentType() {
  19277. m.content_type = nil
  19278. m.addcontent_type = nil
  19279. }
  19280. // SetContent sets the "content" field.
  19281. func (m *MessageRecordsMutation) SetContent(s string) {
  19282. m.content = &s
  19283. }
  19284. // Content returns the value of the "content" field in the mutation.
  19285. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19286. v := m.content
  19287. if v == nil {
  19288. return
  19289. }
  19290. return *v, true
  19291. }
  19292. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19293. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19295. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19296. if !m.op.Is(OpUpdateOne) {
  19297. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19298. }
  19299. if m.id == nil || m.oldValue == nil {
  19300. return v, errors.New("OldContent requires an ID field in the mutation")
  19301. }
  19302. oldValue, err := m.oldValue(ctx)
  19303. if err != nil {
  19304. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19305. }
  19306. return oldValue.Content, nil
  19307. }
  19308. // ResetContent resets all changes to the "content" field.
  19309. func (m *MessageRecordsMutation) ResetContent() {
  19310. m.content = nil
  19311. }
  19312. // SetMeta sets the "meta" field.
  19313. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19314. m.meta = &ct
  19315. }
  19316. // Meta returns the value of the "meta" field in the mutation.
  19317. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19318. v := m.meta
  19319. if v == nil {
  19320. return
  19321. }
  19322. return *v, true
  19323. }
  19324. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19325. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19327. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19328. if !m.op.Is(OpUpdateOne) {
  19329. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19330. }
  19331. if m.id == nil || m.oldValue == nil {
  19332. return v, errors.New("OldMeta requires an ID field in the mutation")
  19333. }
  19334. oldValue, err := m.oldValue(ctx)
  19335. if err != nil {
  19336. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19337. }
  19338. return oldValue.Meta, nil
  19339. }
  19340. // ClearMeta clears the value of the "meta" field.
  19341. func (m *MessageRecordsMutation) ClearMeta() {
  19342. m.meta = nil
  19343. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19344. }
  19345. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19346. func (m *MessageRecordsMutation) MetaCleared() bool {
  19347. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19348. return ok
  19349. }
  19350. // ResetMeta resets all changes to the "meta" field.
  19351. func (m *MessageRecordsMutation) ResetMeta() {
  19352. m.meta = nil
  19353. delete(m.clearedFields, messagerecords.FieldMeta)
  19354. }
  19355. // SetErrorDetail sets the "error_detail" field.
  19356. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19357. m.error_detail = &s
  19358. }
  19359. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19360. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19361. v := m.error_detail
  19362. if v == nil {
  19363. return
  19364. }
  19365. return *v, true
  19366. }
  19367. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19368. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19370. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19371. if !m.op.Is(OpUpdateOne) {
  19372. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19373. }
  19374. if m.id == nil || m.oldValue == nil {
  19375. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19376. }
  19377. oldValue, err := m.oldValue(ctx)
  19378. if err != nil {
  19379. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19380. }
  19381. return oldValue.ErrorDetail, nil
  19382. }
  19383. // ResetErrorDetail resets all changes to the "error_detail" field.
  19384. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19385. m.error_detail = nil
  19386. }
  19387. // SetSendTime sets the "send_time" field.
  19388. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19389. m.send_time = &t
  19390. }
  19391. // SendTime returns the value of the "send_time" field in the mutation.
  19392. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19393. v := m.send_time
  19394. if v == nil {
  19395. return
  19396. }
  19397. return *v, true
  19398. }
  19399. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  19400. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19402. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19403. if !m.op.Is(OpUpdateOne) {
  19404. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19405. }
  19406. if m.id == nil || m.oldValue == nil {
  19407. return v, errors.New("OldSendTime requires an ID field in the mutation")
  19408. }
  19409. oldValue, err := m.oldValue(ctx)
  19410. if err != nil {
  19411. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  19412. }
  19413. return oldValue.SendTime, nil
  19414. }
  19415. // ClearSendTime clears the value of the "send_time" field.
  19416. func (m *MessageRecordsMutation) ClearSendTime() {
  19417. m.send_time = nil
  19418. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19419. }
  19420. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19421. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19422. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19423. return ok
  19424. }
  19425. // ResetSendTime resets all changes to the "send_time" field.
  19426. func (m *MessageRecordsMutation) ResetSendTime() {
  19427. m.send_time = nil
  19428. delete(m.clearedFields, messagerecords.FieldSendTime)
  19429. }
  19430. // SetSourceType sets the "source_type" field.
  19431. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19432. m.source_type = &i
  19433. m.addsource_type = nil
  19434. }
  19435. // SourceType returns the value of the "source_type" field in the mutation.
  19436. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19437. v := m.source_type
  19438. if v == nil {
  19439. return
  19440. }
  19441. return *v, true
  19442. }
  19443. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19444. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19446. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19447. if !m.op.Is(OpUpdateOne) {
  19448. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19449. }
  19450. if m.id == nil || m.oldValue == nil {
  19451. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19452. }
  19453. oldValue, err := m.oldValue(ctx)
  19454. if err != nil {
  19455. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19456. }
  19457. return oldValue.SourceType, nil
  19458. }
  19459. // AddSourceType adds i to the "source_type" field.
  19460. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19461. if m.addsource_type != nil {
  19462. *m.addsource_type += i
  19463. } else {
  19464. m.addsource_type = &i
  19465. }
  19466. }
  19467. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19468. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19469. v := m.addsource_type
  19470. if v == nil {
  19471. return
  19472. }
  19473. return *v, true
  19474. }
  19475. // ResetSourceType resets all changes to the "source_type" field.
  19476. func (m *MessageRecordsMutation) ResetSourceType() {
  19477. m.source_type = nil
  19478. m.addsource_type = nil
  19479. }
  19480. // SetSourceID sets the "source_id" field.
  19481. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19482. m.sop_stage = &u
  19483. }
  19484. // SourceID returns the value of the "source_id" field in the mutation.
  19485. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19486. v := m.sop_stage
  19487. if v == nil {
  19488. return
  19489. }
  19490. return *v, true
  19491. }
  19492. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19493. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19495. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19496. if !m.op.Is(OpUpdateOne) {
  19497. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19498. }
  19499. if m.id == nil || m.oldValue == nil {
  19500. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19501. }
  19502. oldValue, err := m.oldValue(ctx)
  19503. if err != nil {
  19504. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19505. }
  19506. return oldValue.SourceID, nil
  19507. }
  19508. // ClearSourceID clears the value of the "source_id" field.
  19509. func (m *MessageRecordsMutation) ClearSourceID() {
  19510. m.sop_stage = nil
  19511. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19512. }
  19513. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19514. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19515. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19516. return ok
  19517. }
  19518. // ResetSourceID resets all changes to the "source_id" field.
  19519. func (m *MessageRecordsMutation) ResetSourceID() {
  19520. m.sop_stage = nil
  19521. delete(m.clearedFields, messagerecords.FieldSourceID)
  19522. }
  19523. // SetSubSourceID sets the "sub_source_id" field.
  19524. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19525. m.sop_node = &u
  19526. }
  19527. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19528. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19529. v := m.sop_node
  19530. if v == nil {
  19531. return
  19532. }
  19533. return *v, true
  19534. }
  19535. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19536. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19538. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19539. if !m.op.Is(OpUpdateOne) {
  19540. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19541. }
  19542. if m.id == nil || m.oldValue == nil {
  19543. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19544. }
  19545. oldValue, err := m.oldValue(ctx)
  19546. if err != nil {
  19547. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19548. }
  19549. return oldValue.SubSourceID, nil
  19550. }
  19551. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19552. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19553. m.sop_node = nil
  19554. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19555. }
  19556. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19557. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19558. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19559. return ok
  19560. }
  19561. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19562. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19563. m.sop_node = nil
  19564. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19565. }
  19566. // SetOrganizationID sets the "organization_id" field.
  19567. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19568. m.organization_id = &u
  19569. m.addorganization_id = nil
  19570. }
  19571. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19572. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19573. v := m.organization_id
  19574. if v == nil {
  19575. return
  19576. }
  19577. return *v, true
  19578. }
  19579. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19580. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19582. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19583. if !m.op.Is(OpUpdateOne) {
  19584. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19585. }
  19586. if m.id == nil || m.oldValue == nil {
  19587. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19588. }
  19589. oldValue, err := m.oldValue(ctx)
  19590. if err != nil {
  19591. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19592. }
  19593. return oldValue.OrganizationID, nil
  19594. }
  19595. // AddOrganizationID adds u to the "organization_id" field.
  19596. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19597. if m.addorganization_id != nil {
  19598. *m.addorganization_id += u
  19599. } else {
  19600. m.addorganization_id = &u
  19601. }
  19602. }
  19603. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19604. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19605. v := m.addorganization_id
  19606. if v == nil {
  19607. return
  19608. }
  19609. return *v, true
  19610. }
  19611. // ClearOrganizationID clears the value of the "organization_id" field.
  19612. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19613. m.organization_id = nil
  19614. m.addorganization_id = nil
  19615. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19616. }
  19617. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19618. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19619. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19620. return ok
  19621. }
  19622. // ResetOrganizationID resets all changes to the "organization_id" field.
  19623. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19624. m.organization_id = nil
  19625. m.addorganization_id = nil
  19626. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19627. }
  19628. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19629. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19630. m.sop_stage = &id
  19631. }
  19632. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19633. func (m *MessageRecordsMutation) ClearSopStage() {
  19634. m.clearedsop_stage = true
  19635. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19636. }
  19637. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  19638. func (m *MessageRecordsMutation) SopStageCleared() bool {
  19639. return m.SourceIDCleared() || m.clearedsop_stage
  19640. }
  19641. // SopStageID returns the "sop_stage" edge ID in the mutation.
  19642. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  19643. if m.sop_stage != nil {
  19644. return *m.sop_stage, true
  19645. }
  19646. return
  19647. }
  19648. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  19649. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19650. // SopStageID instead. It exists only for internal usage by the builders.
  19651. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  19652. if id := m.sop_stage; id != nil {
  19653. ids = append(ids, *id)
  19654. }
  19655. return
  19656. }
  19657. // ResetSopStage resets all changes to the "sop_stage" edge.
  19658. func (m *MessageRecordsMutation) ResetSopStage() {
  19659. m.sop_stage = nil
  19660. m.clearedsop_stage = false
  19661. }
  19662. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  19663. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  19664. m.sop_node = &id
  19665. }
  19666. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  19667. func (m *MessageRecordsMutation) ClearSopNode() {
  19668. m.clearedsop_node = true
  19669. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19670. }
  19671. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  19672. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  19673. return m.SubSourceIDCleared() || m.clearedsop_node
  19674. }
  19675. // SopNodeID returns the "sop_node" edge ID in the mutation.
  19676. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  19677. if m.sop_node != nil {
  19678. return *m.sop_node, true
  19679. }
  19680. return
  19681. }
  19682. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  19683. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19684. // SopNodeID instead. It exists only for internal usage by the builders.
  19685. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  19686. if id := m.sop_node; id != nil {
  19687. ids = append(ids, *id)
  19688. }
  19689. return
  19690. }
  19691. // ResetSopNode resets all changes to the "sop_node" edge.
  19692. func (m *MessageRecordsMutation) ResetSopNode() {
  19693. m.sop_node = nil
  19694. m.clearedsop_node = false
  19695. }
  19696. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  19697. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  19698. m.message_contact = &id
  19699. }
  19700. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  19701. func (m *MessageRecordsMutation) ClearMessageContact() {
  19702. m.clearedmessage_contact = true
  19703. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19704. }
  19705. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  19706. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  19707. return m.ContactIDCleared() || m.clearedmessage_contact
  19708. }
  19709. // MessageContactID returns the "message_contact" edge ID in the mutation.
  19710. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  19711. if m.message_contact != nil {
  19712. return *m.message_contact, true
  19713. }
  19714. return
  19715. }
  19716. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  19717. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19718. // MessageContactID instead. It exists only for internal usage by the builders.
  19719. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  19720. if id := m.message_contact; id != nil {
  19721. ids = append(ids, *id)
  19722. }
  19723. return
  19724. }
  19725. // ResetMessageContact resets all changes to the "message_contact" edge.
  19726. func (m *MessageRecordsMutation) ResetMessageContact() {
  19727. m.message_contact = nil
  19728. m.clearedmessage_contact = false
  19729. }
  19730. // Where appends a list predicates to the MessageRecordsMutation builder.
  19731. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  19732. m.predicates = append(m.predicates, ps...)
  19733. }
  19734. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  19735. // users can use type-assertion to append predicates that do not depend on any generated package.
  19736. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  19737. p := make([]predicate.MessageRecords, len(ps))
  19738. for i := range ps {
  19739. p[i] = ps[i]
  19740. }
  19741. m.Where(p...)
  19742. }
  19743. // Op returns the operation name.
  19744. func (m *MessageRecordsMutation) Op() Op {
  19745. return m.op
  19746. }
  19747. // SetOp allows setting the mutation operation.
  19748. func (m *MessageRecordsMutation) SetOp(op Op) {
  19749. m.op = op
  19750. }
  19751. // Type returns the node type of this mutation (MessageRecords).
  19752. func (m *MessageRecordsMutation) Type() string {
  19753. return m.typ
  19754. }
  19755. // Fields returns all fields that were changed during this mutation. Note that in
  19756. // order to get all numeric fields that were incremented/decremented, call
  19757. // AddedFields().
  19758. func (m *MessageRecordsMutation) Fields() []string {
  19759. fields := make([]string, 0, 16)
  19760. if m.created_at != nil {
  19761. fields = append(fields, messagerecords.FieldCreatedAt)
  19762. }
  19763. if m.updated_at != nil {
  19764. fields = append(fields, messagerecords.FieldUpdatedAt)
  19765. }
  19766. if m.status != nil {
  19767. fields = append(fields, messagerecords.FieldStatus)
  19768. }
  19769. if m.bot_wxid != nil {
  19770. fields = append(fields, messagerecords.FieldBotWxid)
  19771. }
  19772. if m.message_contact != nil {
  19773. fields = append(fields, messagerecords.FieldContactID)
  19774. }
  19775. if m.contact_type != nil {
  19776. fields = append(fields, messagerecords.FieldContactType)
  19777. }
  19778. if m.contact_wxid != nil {
  19779. fields = append(fields, messagerecords.FieldContactWxid)
  19780. }
  19781. if m.content_type != nil {
  19782. fields = append(fields, messagerecords.FieldContentType)
  19783. }
  19784. if m.content != nil {
  19785. fields = append(fields, messagerecords.FieldContent)
  19786. }
  19787. if m.meta != nil {
  19788. fields = append(fields, messagerecords.FieldMeta)
  19789. }
  19790. if m.error_detail != nil {
  19791. fields = append(fields, messagerecords.FieldErrorDetail)
  19792. }
  19793. if m.send_time != nil {
  19794. fields = append(fields, messagerecords.FieldSendTime)
  19795. }
  19796. if m.source_type != nil {
  19797. fields = append(fields, messagerecords.FieldSourceType)
  19798. }
  19799. if m.sop_stage != nil {
  19800. fields = append(fields, messagerecords.FieldSourceID)
  19801. }
  19802. if m.sop_node != nil {
  19803. fields = append(fields, messagerecords.FieldSubSourceID)
  19804. }
  19805. if m.organization_id != nil {
  19806. fields = append(fields, messagerecords.FieldOrganizationID)
  19807. }
  19808. return fields
  19809. }
  19810. // Field returns the value of a field with the given name. The second boolean
  19811. // return value indicates that this field was not set, or was not defined in the
  19812. // schema.
  19813. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  19814. switch name {
  19815. case messagerecords.FieldCreatedAt:
  19816. return m.CreatedAt()
  19817. case messagerecords.FieldUpdatedAt:
  19818. return m.UpdatedAt()
  19819. case messagerecords.FieldStatus:
  19820. return m.Status()
  19821. case messagerecords.FieldBotWxid:
  19822. return m.BotWxid()
  19823. case messagerecords.FieldContactID:
  19824. return m.ContactID()
  19825. case messagerecords.FieldContactType:
  19826. return m.ContactType()
  19827. case messagerecords.FieldContactWxid:
  19828. return m.ContactWxid()
  19829. case messagerecords.FieldContentType:
  19830. return m.ContentType()
  19831. case messagerecords.FieldContent:
  19832. return m.Content()
  19833. case messagerecords.FieldMeta:
  19834. return m.Meta()
  19835. case messagerecords.FieldErrorDetail:
  19836. return m.ErrorDetail()
  19837. case messagerecords.FieldSendTime:
  19838. return m.SendTime()
  19839. case messagerecords.FieldSourceType:
  19840. return m.SourceType()
  19841. case messagerecords.FieldSourceID:
  19842. return m.SourceID()
  19843. case messagerecords.FieldSubSourceID:
  19844. return m.SubSourceID()
  19845. case messagerecords.FieldOrganizationID:
  19846. return m.OrganizationID()
  19847. }
  19848. return nil, false
  19849. }
  19850. // OldField returns the old value of the field from the database. An error is
  19851. // returned if the mutation operation is not UpdateOne, or the query to the
  19852. // database failed.
  19853. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19854. switch name {
  19855. case messagerecords.FieldCreatedAt:
  19856. return m.OldCreatedAt(ctx)
  19857. case messagerecords.FieldUpdatedAt:
  19858. return m.OldUpdatedAt(ctx)
  19859. case messagerecords.FieldStatus:
  19860. return m.OldStatus(ctx)
  19861. case messagerecords.FieldBotWxid:
  19862. return m.OldBotWxid(ctx)
  19863. case messagerecords.FieldContactID:
  19864. return m.OldContactID(ctx)
  19865. case messagerecords.FieldContactType:
  19866. return m.OldContactType(ctx)
  19867. case messagerecords.FieldContactWxid:
  19868. return m.OldContactWxid(ctx)
  19869. case messagerecords.FieldContentType:
  19870. return m.OldContentType(ctx)
  19871. case messagerecords.FieldContent:
  19872. return m.OldContent(ctx)
  19873. case messagerecords.FieldMeta:
  19874. return m.OldMeta(ctx)
  19875. case messagerecords.FieldErrorDetail:
  19876. return m.OldErrorDetail(ctx)
  19877. case messagerecords.FieldSendTime:
  19878. return m.OldSendTime(ctx)
  19879. case messagerecords.FieldSourceType:
  19880. return m.OldSourceType(ctx)
  19881. case messagerecords.FieldSourceID:
  19882. return m.OldSourceID(ctx)
  19883. case messagerecords.FieldSubSourceID:
  19884. return m.OldSubSourceID(ctx)
  19885. case messagerecords.FieldOrganizationID:
  19886. return m.OldOrganizationID(ctx)
  19887. }
  19888. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  19889. }
  19890. // SetField sets the value of a field with the given name. It returns an error if
  19891. // the field is not defined in the schema, or if the type mismatched the field
  19892. // type.
  19893. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  19894. switch name {
  19895. case messagerecords.FieldCreatedAt:
  19896. v, ok := value.(time.Time)
  19897. if !ok {
  19898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19899. }
  19900. m.SetCreatedAt(v)
  19901. return nil
  19902. case messagerecords.FieldUpdatedAt:
  19903. v, ok := value.(time.Time)
  19904. if !ok {
  19905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19906. }
  19907. m.SetUpdatedAt(v)
  19908. return nil
  19909. case messagerecords.FieldStatus:
  19910. v, ok := value.(uint8)
  19911. if !ok {
  19912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19913. }
  19914. m.SetStatus(v)
  19915. return nil
  19916. case messagerecords.FieldBotWxid:
  19917. v, ok := value.(string)
  19918. if !ok {
  19919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19920. }
  19921. m.SetBotWxid(v)
  19922. return nil
  19923. case messagerecords.FieldContactID:
  19924. v, ok := value.(uint64)
  19925. if !ok {
  19926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19927. }
  19928. m.SetContactID(v)
  19929. return nil
  19930. case messagerecords.FieldContactType:
  19931. v, ok := value.(int)
  19932. if !ok {
  19933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19934. }
  19935. m.SetContactType(v)
  19936. return nil
  19937. case messagerecords.FieldContactWxid:
  19938. v, ok := value.(string)
  19939. if !ok {
  19940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19941. }
  19942. m.SetContactWxid(v)
  19943. return nil
  19944. case messagerecords.FieldContentType:
  19945. v, ok := value.(int)
  19946. if !ok {
  19947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19948. }
  19949. m.SetContentType(v)
  19950. return nil
  19951. case messagerecords.FieldContent:
  19952. v, ok := value.(string)
  19953. if !ok {
  19954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19955. }
  19956. m.SetContent(v)
  19957. return nil
  19958. case messagerecords.FieldMeta:
  19959. v, ok := value.(custom_types.Meta)
  19960. if !ok {
  19961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19962. }
  19963. m.SetMeta(v)
  19964. return nil
  19965. case messagerecords.FieldErrorDetail:
  19966. v, ok := value.(string)
  19967. if !ok {
  19968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19969. }
  19970. m.SetErrorDetail(v)
  19971. return nil
  19972. case messagerecords.FieldSendTime:
  19973. v, ok := value.(time.Time)
  19974. if !ok {
  19975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19976. }
  19977. m.SetSendTime(v)
  19978. return nil
  19979. case messagerecords.FieldSourceType:
  19980. v, ok := value.(int)
  19981. if !ok {
  19982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19983. }
  19984. m.SetSourceType(v)
  19985. return nil
  19986. case messagerecords.FieldSourceID:
  19987. v, ok := value.(uint64)
  19988. if !ok {
  19989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19990. }
  19991. m.SetSourceID(v)
  19992. return nil
  19993. case messagerecords.FieldSubSourceID:
  19994. v, ok := value.(uint64)
  19995. if !ok {
  19996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19997. }
  19998. m.SetSubSourceID(v)
  19999. return nil
  20000. case messagerecords.FieldOrganizationID:
  20001. v, ok := value.(uint64)
  20002. if !ok {
  20003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20004. }
  20005. m.SetOrganizationID(v)
  20006. return nil
  20007. }
  20008. return fmt.Errorf("unknown MessageRecords field %s", name)
  20009. }
  20010. // AddedFields returns all numeric fields that were incremented/decremented during
  20011. // this mutation.
  20012. func (m *MessageRecordsMutation) AddedFields() []string {
  20013. var fields []string
  20014. if m.addstatus != nil {
  20015. fields = append(fields, messagerecords.FieldStatus)
  20016. }
  20017. if m.addcontact_type != nil {
  20018. fields = append(fields, messagerecords.FieldContactType)
  20019. }
  20020. if m.addcontent_type != nil {
  20021. fields = append(fields, messagerecords.FieldContentType)
  20022. }
  20023. if m.addsource_type != nil {
  20024. fields = append(fields, messagerecords.FieldSourceType)
  20025. }
  20026. if m.addorganization_id != nil {
  20027. fields = append(fields, messagerecords.FieldOrganizationID)
  20028. }
  20029. return fields
  20030. }
  20031. // AddedField returns the numeric value that was incremented/decremented on a field
  20032. // with the given name. The second boolean return value indicates that this field
  20033. // was not set, or was not defined in the schema.
  20034. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  20035. switch name {
  20036. case messagerecords.FieldStatus:
  20037. return m.AddedStatus()
  20038. case messagerecords.FieldContactType:
  20039. return m.AddedContactType()
  20040. case messagerecords.FieldContentType:
  20041. return m.AddedContentType()
  20042. case messagerecords.FieldSourceType:
  20043. return m.AddedSourceType()
  20044. case messagerecords.FieldOrganizationID:
  20045. return m.AddedOrganizationID()
  20046. }
  20047. return nil, false
  20048. }
  20049. // AddField adds the value to the field with the given name. It returns an error if
  20050. // the field is not defined in the schema, or if the type mismatched the field
  20051. // type.
  20052. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  20053. switch name {
  20054. case messagerecords.FieldStatus:
  20055. v, ok := value.(int8)
  20056. if !ok {
  20057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20058. }
  20059. m.AddStatus(v)
  20060. return nil
  20061. case messagerecords.FieldContactType:
  20062. v, ok := value.(int)
  20063. if !ok {
  20064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20065. }
  20066. m.AddContactType(v)
  20067. return nil
  20068. case messagerecords.FieldContentType:
  20069. v, ok := value.(int)
  20070. if !ok {
  20071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20072. }
  20073. m.AddContentType(v)
  20074. return nil
  20075. case messagerecords.FieldSourceType:
  20076. v, ok := value.(int)
  20077. if !ok {
  20078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20079. }
  20080. m.AddSourceType(v)
  20081. return nil
  20082. case messagerecords.FieldOrganizationID:
  20083. v, ok := value.(int64)
  20084. if !ok {
  20085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20086. }
  20087. m.AddOrganizationID(v)
  20088. return nil
  20089. }
  20090. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20091. }
  20092. // ClearedFields returns all nullable fields that were cleared during this
  20093. // mutation.
  20094. func (m *MessageRecordsMutation) ClearedFields() []string {
  20095. var fields []string
  20096. if m.FieldCleared(messagerecords.FieldStatus) {
  20097. fields = append(fields, messagerecords.FieldStatus)
  20098. }
  20099. if m.FieldCleared(messagerecords.FieldContactID) {
  20100. fields = append(fields, messagerecords.FieldContactID)
  20101. }
  20102. if m.FieldCleared(messagerecords.FieldMeta) {
  20103. fields = append(fields, messagerecords.FieldMeta)
  20104. }
  20105. if m.FieldCleared(messagerecords.FieldSendTime) {
  20106. fields = append(fields, messagerecords.FieldSendTime)
  20107. }
  20108. if m.FieldCleared(messagerecords.FieldSourceID) {
  20109. fields = append(fields, messagerecords.FieldSourceID)
  20110. }
  20111. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20112. fields = append(fields, messagerecords.FieldSubSourceID)
  20113. }
  20114. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20115. fields = append(fields, messagerecords.FieldOrganizationID)
  20116. }
  20117. return fields
  20118. }
  20119. // FieldCleared returns a boolean indicating if a field with the given name was
  20120. // cleared in this mutation.
  20121. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20122. _, ok := m.clearedFields[name]
  20123. return ok
  20124. }
  20125. // ClearField clears the value of the field with the given name. It returns an
  20126. // error if the field is not defined in the schema.
  20127. func (m *MessageRecordsMutation) ClearField(name string) error {
  20128. switch name {
  20129. case messagerecords.FieldStatus:
  20130. m.ClearStatus()
  20131. return nil
  20132. case messagerecords.FieldContactID:
  20133. m.ClearContactID()
  20134. return nil
  20135. case messagerecords.FieldMeta:
  20136. m.ClearMeta()
  20137. return nil
  20138. case messagerecords.FieldSendTime:
  20139. m.ClearSendTime()
  20140. return nil
  20141. case messagerecords.FieldSourceID:
  20142. m.ClearSourceID()
  20143. return nil
  20144. case messagerecords.FieldSubSourceID:
  20145. m.ClearSubSourceID()
  20146. return nil
  20147. case messagerecords.FieldOrganizationID:
  20148. m.ClearOrganizationID()
  20149. return nil
  20150. }
  20151. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20152. }
  20153. // ResetField resets all changes in the mutation for the field with the given name.
  20154. // It returns an error if the field is not defined in the schema.
  20155. func (m *MessageRecordsMutation) ResetField(name string) error {
  20156. switch name {
  20157. case messagerecords.FieldCreatedAt:
  20158. m.ResetCreatedAt()
  20159. return nil
  20160. case messagerecords.FieldUpdatedAt:
  20161. m.ResetUpdatedAt()
  20162. return nil
  20163. case messagerecords.FieldStatus:
  20164. m.ResetStatus()
  20165. return nil
  20166. case messagerecords.FieldBotWxid:
  20167. m.ResetBotWxid()
  20168. return nil
  20169. case messagerecords.FieldContactID:
  20170. m.ResetContactID()
  20171. return nil
  20172. case messagerecords.FieldContactType:
  20173. m.ResetContactType()
  20174. return nil
  20175. case messagerecords.FieldContactWxid:
  20176. m.ResetContactWxid()
  20177. return nil
  20178. case messagerecords.FieldContentType:
  20179. m.ResetContentType()
  20180. return nil
  20181. case messagerecords.FieldContent:
  20182. m.ResetContent()
  20183. return nil
  20184. case messagerecords.FieldMeta:
  20185. m.ResetMeta()
  20186. return nil
  20187. case messagerecords.FieldErrorDetail:
  20188. m.ResetErrorDetail()
  20189. return nil
  20190. case messagerecords.FieldSendTime:
  20191. m.ResetSendTime()
  20192. return nil
  20193. case messagerecords.FieldSourceType:
  20194. m.ResetSourceType()
  20195. return nil
  20196. case messagerecords.FieldSourceID:
  20197. m.ResetSourceID()
  20198. return nil
  20199. case messagerecords.FieldSubSourceID:
  20200. m.ResetSubSourceID()
  20201. return nil
  20202. case messagerecords.FieldOrganizationID:
  20203. m.ResetOrganizationID()
  20204. return nil
  20205. }
  20206. return fmt.Errorf("unknown MessageRecords field %s", name)
  20207. }
  20208. // AddedEdges returns all edge names that were set/added in this mutation.
  20209. func (m *MessageRecordsMutation) AddedEdges() []string {
  20210. edges := make([]string, 0, 3)
  20211. if m.sop_stage != nil {
  20212. edges = append(edges, messagerecords.EdgeSopStage)
  20213. }
  20214. if m.sop_node != nil {
  20215. edges = append(edges, messagerecords.EdgeSopNode)
  20216. }
  20217. if m.message_contact != nil {
  20218. edges = append(edges, messagerecords.EdgeMessageContact)
  20219. }
  20220. return edges
  20221. }
  20222. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20223. // name in this mutation.
  20224. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20225. switch name {
  20226. case messagerecords.EdgeSopStage:
  20227. if id := m.sop_stage; id != nil {
  20228. return []ent.Value{*id}
  20229. }
  20230. case messagerecords.EdgeSopNode:
  20231. if id := m.sop_node; id != nil {
  20232. return []ent.Value{*id}
  20233. }
  20234. case messagerecords.EdgeMessageContact:
  20235. if id := m.message_contact; id != nil {
  20236. return []ent.Value{*id}
  20237. }
  20238. }
  20239. return nil
  20240. }
  20241. // RemovedEdges returns all edge names that were removed in this mutation.
  20242. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20243. edges := make([]string, 0, 3)
  20244. return edges
  20245. }
  20246. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20247. // the given name in this mutation.
  20248. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20249. return nil
  20250. }
  20251. // ClearedEdges returns all edge names that were cleared in this mutation.
  20252. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20253. edges := make([]string, 0, 3)
  20254. if m.clearedsop_stage {
  20255. edges = append(edges, messagerecords.EdgeSopStage)
  20256. }
  20257. if m.clearedsop_node {
  20258. edges = append(edges, messagerecords.EdgeSopNode)
  20259. }
  20260. if m.clearedmessage_contact {
  20261. edges = append(edges, messagerecords.EdgeMessageContact)
  20262. }
  20263. return edges
  20264. }
  20265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20266. // was cleared in this mutation.
  20267. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20268. switch name {
  20269. case messagerecords.EdgeSopStage:
  20270. return m.clearedsop_stage
  20271. case messagerecords.EdgeSopNode:
  20272. return m.clearedsop_node
  20273. case messagerecords.EdgeMessageContact:
  20274. return m.clearedmessage_contact
  20275. }
  20276. return false
  20277. }
  20278. // ClearEdge clears the value of the edge with the given name. It returns an error
  20279. // if that edge is not defined in the schema.
  20280. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20281. switch name {
  20282. case messagerecords.EdgeSopStage:
  20283. m.ClearSopStage()
  20284. return nil
  20285. case messagerecords.EdgeSopNode:
  20286. m.ClearSopNode()
  20287. return nil
  20288. case messagerecords.EdgeMessageContact:
  20289. m.ClearMessageContact()
  20290. return nil
  20291. }
  20292. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20293. }
  20294. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20295. // It returns an error if the edge is not defined in the schema.
  20296. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20297. switch name {
  20298. case messagerecords.EdgeSopStage:
  20299. m.ResetSopStage()
  20300. return nil
  20301. case messagerecords.EdgeSopNode:
  20302. m.ResetSopNode()
  20303. return nil
  20304. case messagerecords.EdgeMessageContact:
  20305. m.ResetMessageContact()
  20306. return nil
  20307. }
  20308. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20309. }
  20310. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20311. type MsgMutation struct {
  20312. config
  20313. op Op
  20314. typ string
  20315. id *uint64
  20316. created_at *time.Time
  20317. updated_at *time.Time
  20318. deleted_at *time.Time
  20319. status *uint8
  20320. addstatus *int8
  20321. fromwxid *string
  20322. toid *string
  20323. msgtype *int32
  20324. addmsgtype *int32
  20325. msg *string
  20326. batch_no *string
  20327. cc *string
  20328. phone *string
  20329. clearedFields map[string]struct{}
  20330. done bool
  20331. oldValue func(context.Context) (*Msg, error)
  20332. predicates []predicate.Msg
  20333. }
  20334. var _ ent.Mutation = (*MsgMutation)(nil)
  20335. // msgOption allows management of the mutation configuration using functional options.
  20336. type msgOption func(*MsgMutation)
  20337. // newMsgMutation creates new mutation for the Msg entity.
  20338. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20339. m := &MsgMutation{
  20340. config: c,
  20341. op: op,
  20342. typ: TypeMsg,
  20343. clearedFields: make(map[string]struct{}),
  20344. }
  20345. for _, opt := range opts {
  20346. opt(m)
  20347. }
  20348. return m
  20349. }
  20350. // withMsgID sets the ID field of the mutation.
  20351. func withMsgID(id uint64) msgOption {
  20352. return func(m *MsgMutation) {
  20353. var (
  20354. err error
  20355. once sync.Once
  20356. value *Msg
  20357. )
  20358. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20359. once.Do(func() {
  20360. if m.done {
  20361. err = errors.New("querying old values post mutation is not allowed")
  20362. } else {
  20363. value, err = m.Client().Msg.Get(ctx, id)
  20364. }
  20365. })
  20366. return value, err
  20367. }
  20368. m.id = &id
  20369. }
  20370. }
  20371. // withMsg sets the old Msg of the mutation.
  20372. func withMsg(node *Msg) msgOption {
  20373. return func(m *MsgMutation) {
  20374. m.oldValue = func(context.Context) (*Msg, error) {
  20375. return node, nil
  20376. }
  20377. m.id = &node.ID
  20378. }
  20379. }
  20380. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20381. // executed in a transaction (ent.Tx), a transactional client is returned.
  20382. func (m MsgMutation) Client() *Client {
  20383. client := &Client{config: m.config}
  20384. client.init()
  20385. return client
  20386. }
  20387. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20388. // it returns an error otherwise.
  20389. func (m MsgMutation) Tx() (*Tx, error) {
  20390. if _, ok := m.driver.(*txDriver); !ok {
  20391. return nil, errors.New("ent: mutation is not running in a transaction")
  20392. }
  20393. tx := &Tx{config: m.config}
  20394. tx.init()
  20395. return tx, nil
  20396. }
  20397. // SetID sets the value of the id field. Note that this
  20398. // operation is only accepted on creation of Msg entities.
  20399. func (m *MsgMutation) SetID(id uint64) {
  20400. m.id = &id
  20401. }
  20402. // ID returns the ID value in the mutation. Note that the ID is only available
  20403. // if it was provided to the builder or after it was returned from the database.
  20404. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20405. if m.id == nil {
  20406. return
  20407. }
  20408. return *m.id, true
  20409. }
  20410. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20411. // That means, if the mutation is applied within a transaction with an isolation level such
  20412. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20413. // or updated by the mutation.
  20414. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20415. switch {
  20416. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20417. id, exists := m.ID()
  20418. if exists {
  20419. return []uint64{id}, nil
  20420. }
  20421. fallthrough
  20422. case m.op.Is(OpUpdate | OpDelete):
  20423. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20424. default:
  20425. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20426. }
  20427. }
  20428. // SetCreatedAt sets the "created_at" field.
  20429. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20430. m.created_at = &t
  20431. }
  20432. // CreatedAt returns the value of the "created_at" field in the mutation.
  20433. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20434. v := m.created_at
  20435. if v == nil {
  20436. return
  20437. }
  20438. return *v, true
  20439. }
  20440. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20441. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20443. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20444. if !m.op.Is(OpUpdateOne) {
  20445. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20446. }
  20447. if m.id == nil || m.oldValue == nil {
  20448. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20449. }
  20450. oldValue, err := m.oldValue(ctx)
  20451. if err != nil {
  20452. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20453. }
  20454. return oldValue.CreatedAt, nil
  20455. }
  20456. // ResetCreatedAt resets all changes to the "created_at" field.
  20457. func (m *MsgMutation) ResetCreatedAt() {
  20458. m.created_at = nil
  20459. }
  20460. // SetUpdatedAt sets the "updated_at" field.
  20461. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20462. m.updated_at = &t
  20463. }
  20464. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20465. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20466. v := m.updated_at
  20467. if v == nil {
  20468. return
  20469. }
  20470. return *v, true
  20471. }
  20472. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20473. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20475. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20476. if !m.op.Is(OpUpdateOne) {
  20477. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20478. }
  20479. if m.id == nil || m.oldValue == nil {
  20480. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20481. }
  20482. oldValue, err := m.oldValue(ctx)
  20483. if err != nil {
  20484. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20485. }
  20486. return oldValue.UpdatedAt, nil
  20487. }
  20488. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20489. func (m *MsgMutation) ResetUpdatedAt() {
  20490. m.updated_at = nil
  20491. }
  20492. // SetDeletedAt sets the "deleted_at" field.
  20493. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20494. m.deleted_at = &t
  20495. }
  20496. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20497. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20498. v := m.deleted_at
  20499. if v == nil {
  20500. return
  20501. }
  20502. return *v, true
  20503. }
  20504. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20505. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20507. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20508. if !m.op.Is(OpUpdateOne) {
  20509. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20510. }
  20511. if m.id == nil || m.oldValue == nil {
  20512. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20513. }
  20514. oldValue, err := m.oldValue(ctx)
  20515. if err != nil {
  20516. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20517. }
  20518. return oldValue.DeletedAt, nil
  20519. }
  20520. // ClearDeletedAt clears the value of the "deleted_at" field.
  20521. func (m *MsgMutation) ClearDeletedAt() {
  20522. m.deleted_at = nil
  20523. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20524. }
  20525. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20526. func (m *MsgMutation) DeletedAtCleared() bool {
  20527. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20528. return ok
  20529. }
  20530. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20531. func (m *MsgMutation) ResetDeletedAt() {
  20532. m.deleted_at = nil
  20533. delete(m.clearedFields, msg.FieldDeletedAt)
  20534. }
  20535. // SetStatus sets the "status" field.
  20536. func (m *MsgMutation) SetStatus(u uint8) {
  20537. m.status = &u
  20538. m.addstatus = nil
  20539. }
  20540. // Status returns the value of the "status" field in the mutation.
  20541. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20542. v := m.status
  20543. if v == nil {
  20544. return
  20545. }
  20546. return *v, true
  20547. }
  20548. // OldStatus returns the old "status" field's value of the Msg entity.
  20549. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20551. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20552. if !m.op.Is(OpUpdateOne) {
  20553. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20554. }
  20555. if m.id == nil || m.oldValue == nil {
  20556. return v, errors.New("OldStatus requires an ID field in the mutation")
  20557. }
  20558. oldValue, err := m.oldValue(ctx)
  20559. if err != nil {
  20560. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20561. }
  20562. return oldValue.Status, nil
  20563. }
  20564. // AddStatus adds u to the "status" field.
  20565. func (m *MsgMutation) AddStatus(u int8) {
  20566. if m.addstatus != nil {
  20567. *m.addstatus += u
  20568. } else {
  20569. m.addstatus = &u
  20570. }
  20571. }
  20572. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20573. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20574. v := m.addstatus
  20575. if v == nil {
  20576. return
  20577. }
  20578. return *v, true
  20579. }
  20580. // ClearStatus clears the value of the "status" field.
  20581. func (m *MsgMutation) ClearStatus() {
  20582. m.status = nil
  20583. m.addstatus = nil
  20584. m.clearedFields[msg.FieldStatus] = struct{}{}
  20585. }
  20586. // StatusCleared returns if the "status" field was cleared in this mutation.
  20587. func (m *MsgMutation) StatusCleared() bool {
  20588. _, ok := m.clearedFields[msg.FieldStatus]
  20589. return ok
  20590. }
  20591. // ResetStatus resets all changes to the "status" field.
  20592. func (m *MsgMutation) ResetStatus() {
  20593. m.status = nil
  20594. m.addstatus = nil
  20595. delete(m.clearedFields, msg.FieldStatus)
  20596. }
  20597. // SetFromwxid sets the "fromwxid" field.
  20598. func (m *MsgMutation) SetFromwxid(s string) {
  20599. m.fromwxid = &s
  20600. }
  20601. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20602. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20603. v := m.fromwxid
  20604. if v == nil {
  20605. return
  20606. }
  20607. return *v, true
  20608. }
  20609. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20610. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20612. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20613. if !m.op.Is(OpUpdateOne) {
  20614. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20615. }
  20616. if m.id == nil || m.oldValue == nil {
  20617. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20618. }
  20619. oldValue, err := m.oldValue(ctx)
  20620. if err != nil {
  20621. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20622. }
  20623. return oldValue.Fromwxid, nil
  20624. }
  20625. // ClearFromwxid clears the value of the "fromwxid" field.
  20626. func (m *MsgMutation) ClearFromwxid() {
  20627. m.fromwxid = nil
  20628. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20629. }
  20630. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20631. func (m *MsgMutation) FromwxidCleared() bool {
  20632. _, ok := m.clearedFields[msg.FieldFromwxid]
  20633. return ok
  20634. }
  20635. // ResetFromwxid resets all changes to the "fromwxid" field.
  20636. func (m *MsgMutation) ResetFromwxid() {
  20637. m.fromwxid = nil
  20638. delete(m.clearedFields, msg.FieldFromwxid)
  20639. }
  20640. // SetToid sets the "toid" field.
  20641. func (m *MsgMutation) SetToid(s string) {
  20642. m.toid = &s
  20643. }
  20644. // Toid returns the value of the "toid" field in the mutation.
  20645. func (m *MsgMutation) Toid() (r string, exists bool) {
  20646. v := m.toid
  20647. if v == nil {
  20648. return
  20649. }
  20650. return *v, true
  20651. }
  20652. // OldToid returns the old "toid" field's value of the Msg entity.
  20653. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20655. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  20656. if !m.op.Is(OpUpdateOne) {
  20657. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  20658. }
  20659. if m.id == nil || m.oldValue == nil {
  20660. return v, errors.New("OldToid requires an ID field in the mutation")
  20661. }
  20662. oldValue, err := m.oldValue(ctx)
  20663. if err != nil {
  20664. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  20665. }
  20666. return oldValue.Toid, nil
  20667. }
  20668. // ClearToid clears the value of the "toid" field.
  20669. func (m *MsgMutation) ClearToid() {
  20670. m.toid = nil
  20671. m.clearedFields[msg.FieldToid] = struct{}{}
  20672. }
  20673. // ToidCleared returns if the "toid" field was cleared in this mutation.
  20674. func (m *MsgMutation) ToidCleared() bool {
  20675. _, ok := m.clearedFields[msg.FieldToid]
  20676. return ok
  20677. }
  20678. // ResetToid resets all changes to the "toid" field.
  20679. func (m *MsgMutation) ResetToid() {
  20680. m.toid = nil
  20681. delete(m.clearedFields, msg.FieldToid)
  20682. }
  20683. // SetMsgtype sets the "msgtype" field.
  20684. func (m *MsgMutation) SetMsgtype(i int32) {
  20685. m.msgtype = &i
  20686. m.addmsgtype = nil
  20687. }
  20688. // Msgtype returns the value of the "msgtype" field in the mutation.
  20689. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  20690. v := m.msgtype
  20691. if v == nil {
  20692. return
  20693. }
  20694. return *v, true
  20695. }
  20696. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  20697. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20699. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  20700. if !m.op.Is(OpUpdateOne) {
  20701. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  20702. }
  20703. if m.id == nil || m.oldValue == nil {
  20704. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  20705. }
  20706. oldValue, err := m.oldValue(ctx)
  20707. if err != nil {
  20708. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  20709. }
  20710. return oldValue.Msgtype, nil
  20711. }
  20712. // AddMsgtype adds i to the "msgtype" field.
  20713. func (m *MsgMutation) AddMsgtype(i int32) {
  20714. if m.addmsgtype != nil {
  20715. *m.addmsgtype += i
  20716. } else {
  20717. m.addmsgtype = &i
  20718. }
  20719. }
  20720. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  20721. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  20722. v := m.addmsgtype
  20723. if v == nil {
  20724. return
  20725. }
  20726. return *v, true
  20727. }
  20728. // ClearMsgtype clears the value of the "msgtype" field.
  20729. func (m *MsgMutation) ClearMsgtype() {
  20730. m.msgtype = nil
  20731. m.addmsgtype = nil
  20732. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  20733. }
  20734. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  20735. func (m *MsgMutation) MsgtypeCleared() bool {
  20736. _, ok := m.clearedFields[msg.FieldMsgtype]
  20737. return ok
  20738. }
  20739. // ResetMsgtype resets all changes to the "msgtype" field.
  20740. func (m *MsgMutation) ResetMsgtype() {
  20741. m.msgtype = nil
  20742. m.addmsgtype = nil
  20743. delete(m.clearedFields, msg.FieldMsgtype)
  20744. }
  20745. // SetMsg sets the "msg" field.
  20746. func (m *MsgMutation) SetMsg(s string) {
  20747. m.msg = &s
  20748. }
  20749. // Msg returns the value of the "msg" field in the mutation.
  20750. func (m *MsgMutation) Msg() (r string, exists bool) {
  20751. v := m.msg
  20752. if v == nil {
  20753. return
  20754. }
  20755. return *v, true
  20756. }
  20757. // OldMsg returns the old "msg" field's value of the Msg entity.
  20758. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20760. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  20761. if !m.op.Is(OpUpdateOne) {
  20762. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  20763. }
  20764. if m.id == nil || m.oldValue == nil {
  20765. return v, errors.New("OldMsg requires an ID field in the mutation")
  20766. }
  20767. oldValue, err := m.oldValue(ctx)
  20768. if err != nil {
  20769. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  20770. }
  20771. return oldValue.Msg, nil
  20772. }
  20773. // ClearMsg clears the value of the "msg" field.
  20774. func (m *MsgMutation) ClearMsg() {
  20775. m.msg = nil
  20776. m.clearedFields[msg.FieldMsg] = struct{}{}
  20777. }
  20778. // MsgCleared returns if the "msg" field was cleared in this mutation.
  20779. func (m *MsgMutation) MsgCleared() bool {
  20780. _, ok := m.clearedFields[msg.FieldMsg]
  20781. return ok
  20782. }
  20783. // ResetMsg resets all changes to the "msg" field.
  20784. func (m *MsgMutation) ResetMsg() {
  20785. m.msg = nil
  20786. delete(m.clearedFields, msg.FieldMsg)
  20787. }
  20788. // SetBatchNo sets the "batch_no" field.
  20789. func (m *MsgMutation) SetBatchNo(s string) {
  20790. m.batch_no = &s
  20791. }
  20792. // BatchNo returns the value of the "batch_no" field in the mutation.
  20793. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  20794. v := m.batch_no
  20795. if v == nil {
  20796. return
  20797. }
  20798. return *v, true
  20799. }
  20800. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  20801. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20803. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  20804. if !m.op.Is(OpUpdateOne) {
  20805. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  20806. }
  20807. if m.id == nil || m.oldValue == nil {
  20808. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  20809. }
  20810. oldValue, err := m.oldValue(ctx)
  20811. if err != nil {
  20812. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  20813. }
  20814. return oldValue.BatchNo, nil
  20815. }
  20816. // ClearBatchNo clears the value of the "batch_no" field.
  20817. func (m *MsgMutation) ClearBatchNo() {
  20818. m.batch_no = nil
  20819. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  20820. }
  20821. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  20822. func (m *MsgMutation) BatchNoCleared() bool {
  20823. _, ok := m.clearedFields[msg.FieldBatchNo]
  20824. return ok
  20825. }
  20826. // ResetBatchNo resets all changes to the "batch_no" field.
  20827. func (m *MsgMutation) ResetBatchNo() {
  20828. m.batch_no = nil
  20829. delete(m.clearedFields, msg.FieldBatchNo)
  20830. }
  20831. // SetCc sets the "cc" field.
  20832. func (m *MsgMutation) SetCc(s string) {
  20833. m.cc = &s
  20834. }
  20835. // Cc returns the value of the "cc" field in the mutation.
  20836. func (m *MsgMutation) Cc() (r string, exists bool) {
  20837. v := m.cc
  20838. if v == nil {
  20839. return
  20840. }
  20841. return *v, true
  20842. }
  20843. // OldCc returns the old "cc" field's value of the Msg entity.
  20844. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20846. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  20847. if !m.op.Is(OpUpdateOne) {
  20848. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  20849. }
  20850. if m.id == nil || m.oldValue == nil {
  20851. return v, errors.New("OldCc requires an ID field in the mutation")
  20852. }
  20853. oldValue, err := m.oldValue(ctx)
  20854. if err != nil {
  20855. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  20856. }
  20857. return oldValue.Cc, nil
  20858. }
  20859. // ResetCc resets all changes to the "cc" field.
  20860. func (m *MsgMutation) ResetCc() {
  20861. m.cc = nil
  20862. }
  20863. // SetPhone sets the "phone" field.
  20864. func (m *MsgMutation) SetPhone(s string) {
  20865. m.phone = &s
  20866. }
  20867. // Phone returns the value of the "phone" field in the mutation.
  20868. func (m *MsgMutation) Phone() (r string, exists bool) {
  20869. v := m.phone
  20870. if v == nil {
  20871. return
  20872. }
  20873. return *v, true
  20874. }
  20875. // OldPhone returns the old "phone" field's value of the Msg entity.
  20876. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20878. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  20879. if !m.op.Is(OpUpdateOne) {
  20880. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  20881. }
  20882. if m.id == nil || m.oldValue == nil {
  20883. return v, errors.New("OldPhone requires an ID field in the mutation")
  20884. }
  20885. oldValue, err := m.oldValue(ctx)
  20886. if err != nil {
  20887. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  20888. }
  20889. return oldValue.Phone, nil
  20890. }
  20891. // ResetPhone resets all changes to the "phone" field.
  20892. func (m *MsgMutation) ResetPhone() {
  20893. m.phone = nil
  20894. }
  20895. // Where appends a list predicates to the MsgMutation builder.
  20896. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  20897. m.predicates = append(m.predicates, ps...)
  20898. }
  20899. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  20900. // users can use type-assertion to append predicates that do not depend on any generated package.
  20901. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  20902. p := make([]predicate.Msg, len(ps))
  20903. for i := range ps {
  20904. p[i] = ps[i]
  20905. }
  20906. m.Where(p...)
  20907. }
  20908. // Op returns the operation name.
  20909. func (m *MsgMutation) Op() Op {
  20910. return m.op
  20911. }
  20912. // SetOp allows setting the mutation operation.
  20913. func (m *MsgMutation) SetOp(op Op) {
  20914. m.op = op
  20915. }
  20916. // Type returns the node type of this mutation (Msg).
  20917. func (m *MsgMutation) Type() string {
  20918. return m.typ
  20919. }
  20920. // Fields returns all fields that were changed during this mutation. Note that in
  20921. // order to get all numeric fields that were incremented/decremented, call
  20922. // AddedFields().
  20923. func (m *MsgMutation) Fields() []string {
  20924. fields := make([]string, 0, 11)
  20925. if m.created_at != nil {
  20926. fields = append(fields, msg.FieldCreatedAt)
  20927. }
  20928. if m.updated_at != nil {
  20929. fields = append(fields, msg.FieldUpdatedAt)
  20930. }
  20931. if m.deleted_at != nil {
  20932. fields = append(fields, msg.FieldDeletedAt)
  20933. }
  20934. if m.status != nil {
  20935. fields = append(fields, msg.FieldStatus)
  20936. }
  20937. if m.fromwxid != nil {
  20938. fields = append(fields, msg.FieldFromwxid)
  20939. }
  20940. if m.toid != nil {
  20941. fields = append(fields, msg.FieldToid)
  20942. }
  20943. if m.msgtype != nil {
  20944. fields = append(fields, msg.FieldMsgtype)
  20945. }
  20946. if m.msg != nil {
  20947. fields = append(fields, msg.FieldMsg)
  20948. }
  20949. if m.batch_no != nil {
  20950. fields = append(fields, msg.FieldBatchNo)
  20951. }
  20952. if m.cc != nil {
  20953. fields = append(fields, msg.FieldCc)
  20954. }
  20955. if m.phone != nil {
  20956. fields = append(fields, msg.FieldPhone)
  20957. }
  20958. return fields
  20959. }
  20960. // Field returns the value of a field with the given name. The second boolean
  20961. // return value indicates that this field was not set, or was not defined in the
  20962. // schema.
  20963. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  20964. switch name {
  20965. case msg.FieldCreatedAt:
  20966. return m.CreatedAt()
  20967. case msg.FieldUpdatedAt:
  20968. return m.UpdatedAt()
  20969. case msg.FieldDeletedAt:
  20970. return m.DeletedAt()
  20971. case msg.FieldStatus:
  20972. return m.Status()
  20973. case msg.FieldFromwxid:
  20974. return m.Fromwxid()
  20975. case msg.FieldToid:
  20976. return m.Toid()
  20977. case msg.FieldMsgtype:
  20978. return m.Msgtype()
  20979. case msg.FieldMsg:
  20980. return m.Msg()
  20981. case msg.FieldBatchNo:
  20982. return m.BatchNo()
  20983. case msg.FieldCc:
  20984. return m.Cc()
  20985. case msg.FieldPhone:
  20986. return m.Phone()
  20987. }
  20988. return nil, false
  20989. }
  20990. // OldField returns the old value of the field from the database. An error is
  20991. // returned if the mutation operation is not UpdateOne, or the query to the
  20992. // database failed.
  20993. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20994. switch name {
  20995. case msg.FieldCreatedAt:
  20996. return m.OldCreatedAt(ctx)
  20997. case msg.FieldUpdatedAt:
  20998. return m.OldUpdatedAt(ctx)
  20999. case msg.FieldDeletedAt:
  21000. return m.OldDeletedAt(ctx)
  21001. case msg.FieldStatus:
  21002. return m.OldStatus(ctx)
  21003. case msg.FieldFromwxid:
  21004. return m.OldFromwxid(ctx)
  21005. case msg.FieldToid:
  21006. return m.OldToid(ctx)
  21007. case msg.FieldMsgtype:
  21008. return m.OldMsgtype(ctx)
  21009. case msg.FieldMsg:
  21010. return m.OldMsg(ctx)
  21011. case msg.FieldBatchNo:
  21012. return m.OldBatchNo(ctx)
  21013. case msg.FieldCc:
  21014. return m.OldCc(ctx)
  21015. case msg.FieldPhone:
  21016. return m.OldPhone(ctx)
  21017. }
  21018. return nil, fmt.Errorf("unknown Msg field %s", name)
  21019. }
  21020. // SetField sets the value of a field with the given name. It returns an error if
  21021. // the field is not defined in the schema, or if the type mismatched the field
  21022. // type.
  21023. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  21024. switch name {
  21025. case msg.FieldCreatedAt:
  21026. v, ok := value.(time.Time)
  21027. if !ok {
  21028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21029. }
  21030. m.SetCreatedAt(v)
  21031. return nil
  21032. case msg.FieldUpdatedAt:
  21033. v, ok := value.(time.Time)
  21034. if !ok {
  21035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21036. }
  21037. m.SetUpdatedAt(v)
  21038. return nil
  21039. case msg.FieldDeletedAt:
  21040. v, ok := value.(time.Time)
  21041. if !ok {
  21042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21043. }
  21044. m.SetDeletedAt(v)
  21045. return nil
  21046. case msg.FieldStatus:
  21047. v, ok := value.(uint8)
  21048. if !ok {
  21049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21050. }
  21051. m.SetStatus(v)
  21052. return nil
  21053. case msg.FieldFromwxid:
  21054. v, ok := value.(string)
  21055. if !ok {
  21056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21057. }
  21058. m.SetFromwxid(v)
  21059. return nil
  21060. case msg.FieldToid:
  21061. v, ok := value.(string)
  21062. if !ok {
  21063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21064. }
  21065. m.SetToid(v)
  21066. return nil
  21067. case msg.FieldMsgtype:
  21068. v, ok := value.(int32)
  21069. if !ok {
  21070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21071. }
  21072. m.SetMsgtype(v)
  21073. return nil
  21074. case msg.FieldMsg:
  21075. v, ok := value.(string)
  21076. if !ok {
  21077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21078. }
  21079. m.SetMsg(v)
  21080. return nil
  21081. case msg.FieldBatchNo:
  21082. v, ok := value.(string)
  21083. if !ok {
  21084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21085. }
  21086. m.SetBatchNo(v)
  21087. return nil
  21088. case msg.FieldCc:
  21089. v, ok := value.(string)
  21090. if !ok {
  21091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21092. }
  21093. m.SetCc(v)
  21094. return nil
  21095. case msg.FieldPhone:
  21096. v, ok := value.(string)
  21097. if !ok {
  21098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21099. }
  21100. m.SetPhone(v)
  21101. return nil
  21102. }
  21103. return fmt.Errorf("unknown Msg field %s", name)
  21104. }
  21105. // AddedFields returns all numeric fields that were incremented/decremented during
  21106. // this mutation.
  21107. func (m *MsgMutation) AddedFields() []string {
  21108. var fields []string
  21109. if m.addstatus != nil {
  21110. fields = append(fields, msg.FieldStatus)
  21111. }
  21112. if m.addmsgtype != nil {
  21113. fields = append(fields, msg.FieldMsgtype)
  21114. }
  21115. return fields
  21116. }
  21117. // AddedField returns the numeric value that was incremented/decremented on a field
  21118. // with the given name. The second boolean return value indicates that this field
  21119. // was not set, or was not defined in the schema.
  21120. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21121. switch name {
  21122. case msg.FieldStatus:
  21123. return m.AddedStatus()
  21124. case msg.FieldMsgtype:
  21125. return m.AddedMsgtype()
  21126. }
  21127. return nil, false
  21128. }
  21129. // AddField adds the value to the field with the given name. It returns an error if
  21130. // the field is not defined in the schema, or if the type mismatched the field
  21131. // type.
  21132. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21133. switch name {
  21134. case msg.FieldStatus:
  21135. v, ok := value.(int8)
  21136. if !ok {
  21137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21138. }
  21139. m.AddStatus(v)
  21140. return nil
  21141. case msg.FieldMsgtype:
  21142. v, ok := value.(int32)
  21143. if !ok {
  21144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21145. }
  21146. m.AddMsgtype(v)
  21147. return nil
  21148. }
  21149. return fmt.Errorf("unknown Msg numeric field %s", name)
  21150. }
  21151. // ClearedFields returns all nullable fields that were cleared during this
  21152. // mutation.
  21153. func (m *MsgMutation) ClearedFields() []string {
  21154. var fields []string
  21155. if m.FieldCleared(msg.FieldDeletedAt) {
  21156. fields = append(fields, msg.FieldDeletedAt)
  21157. }
  21158. if m.FieldCleared(msg.FieldStatus) {
  21159. fields = append(fields, msg.FieldStatus)
  21160. }
  21161. if m.FieldCleared(msg.FieldFromwxid) {
  21162. fields = append(fields, msg.FieldFromwxid)
  21163. }
  21164. if m.FieldCleared(msg.FieldToid) {
  21165. fields = append(fields, msg.FieldToid)
  21166. }
  21167. if m.FieldCleared(msg.FieldMsgtype) {
  21168. fields = append(fields, msg.FieldMsgtype)
  21169. }
  21170. if m.FieldCleared(msg.FieldMsg) {
  21171. fields = append(fields, msg.FieldMsg)
  21172. }
  21173. if m.FieldCleared(msg.FieldBatchNo) {
  21174. fields = append(fields, msg.FieldBatchNo)
  21175. }
  21176. return fields
  21177. }
  21178. // FieldCleared returns a boolean indicating if a field with the given name was
  21179. // cleared in this mutation.
  21180. func (m *MsgMutation) FieldCleared(name string) bool {
  21181. _, ok := m.clearedFields[name]
  21182. return ok
  21183. }
  21184. // ClearField clears the value of the field with the given name. It returns an
  21185. // error if the field is not defined in the schema.
  21186. func (m *MsgMutation) ClearField(name string) error {
  21187. switch name {
  21188. case msg.FieldDeletedAt:
  21189. m.ClearDeletedAt()
  21190. return nil
  21191. case msg.FieldStatus:
  21192. m.ClearStatus()
  21193. return nil
  21194. case msg.FieldFromwxid:
  21195. m.ClearFromwxid()
  21196. return nil
  21197. case msg.FieldToid:
  21198. m.ClearToid()
  21199. return nil
  21200. case msg.FieldMsgtype:
  21201. m.ClearMsgtype()
  21202. return nil
  21203. case msg.FieldMsg:
  21204. m.ClearMsg()
  21205. return nil
  21206. case msg.FieldBatchNo:
  21207. m.ClearBatchNo()
  21208. return nil
  21209. }
  21210. return fmt.Errorf("unknown Msg nullable field %s", name)
  21211. }
  21212. // ResetField resets all changes in the mutation for the field with the given name.
  21213. // It returns an error if the field is not defined in the schema.
  21214. func (m *MsgMutation) ResetField(name string) error {
  21215. switch name {
  21216. case msg.FieldCreatedAt:
  21217. m.ResetCreatedAt()
  21218. return nil
  21219. case msg.FieldUpdatedAt:
  21220. m.ResetUpdatedAt()
  21221. return nil
  21222. case msg.FieldDeletedAt:
  21223. m.ResetDeletedAt()
  21224. return nil
  21225. case msg.FieldStatus:
  21226. m.ResetStatus()
  21227. return nil
  21228. case msg.FieldFromwxid:
  21229. m.ResetFromwxid()
  21230. return nil
  21231. case msg.FieldToid:
  21232. m.ResetToid()
  21233. return nil
  21234. case msg.FieldMsgtype:
  21235. m.ResetMsgtype()
  21236. return nil
  21237. case msg.FieldMsg:
  21238. m.ResetMsg()
  21239. return nil
  21240. case msg.FieldBatchNo:
  21241. m.ResetBatchNo()
  21242. return nil
  21243. case msg.FieldCc:
  21244. m.ResetCc()
  21245. return nil
  21246. case msg.FieldPhone:
  21247. m.ResetPhone()
  21248. return nil
  21249. }
  21250. return fmt.Errorf("unknown Msg field %s", name)
  21251. }
  21252. // AddedEdges returns all edge names that were set/added in this mutation.
  21253. func (m *MsgMutation) AddedEdges() []string {
  21254. edges := make([]string, 0, 0)
  21255. return edges
  21256. }
  21257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21258. // name in this mutation.
  21259. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21260. return nil
  21261. }
  21262. // RemovedEdges returns all edge names that were removed in this mutation.
  21263. func (m *MsgMutation) RemovedEdges() []string {
  21264. edges := make([]string, 0, 0)
  21265. return edges
  21266. }
  21267. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21268. // the given name in this mutation.
  21269. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21270. return nil
  21271. }
  21272. // ClearedEdges returns all edge names that were cleared in this mutation.
  21273. func (m *MsgMutation) ClearedEdges() []string {
  21274. edges := make([]string, 0, 0)
  21275. return edges
  21276. }
  21277. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21278. // was cleared in this mutation.
  21279. func (m *MsgMutation) EdgeCleared(name string) bool {
  21280. return false
  21281. }
  21282. // ClearEdge clears the value of the edge with the given name. It returns an error
  21283. // if that edge is not defined in the schema.
  21284. func (m *MsgMutation) ClearEdge(name string) error {
  21285. return fmt.Errorf("unknown Msg unique edge %s", name)
  21286. }
  21287. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21288. // It returns an error if the edge is not defined in the schema.
  21289. func (m *MsgMutation) ResetEdge(name string) error {
  21290. return fmt.Errorf("unknown Msg edge %s", name)
  21291. }
  21292. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21293. type PayRechargeMutation struct {
  21294. config
  21295. op Op
  21296. typ string
  21297. id *uint64
  21298. created_at *time.Time
  21299. updated_at *time.Time
  21300. deleted_at *time.Time
  21301. user_id *string
  21302. number *float32
  21303. addnumber *float32
  21304. status *int
  21305. addstatus *int
  21306. money *float32
  21307. addmoney *float32
  21308. out_trade_no *string
  21309. organization_id *uint64
  21310. addorganization_id *int64
  21311. clearedFields map[string]struct{}
  21312. done bool
  21313. oldValue func(context.Context) (*PayRecharge, error)
  21314. predicates []predicate.PayRecharge
  21315. }
  21316. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21317. // payrechargeOption allows management of the mutation configuration using functional options.
  21318. type payrechargeOption func(*PayRechargeMutation)
  21319. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21320. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21321. m := &PayRechargeMutation{
  21322. config: c,
  21323. op: op,
  21324. typ: TypePayRecharge,
  21325. clearedFields: make(map[string]struct{}),
  21326. }
  21327. for _, opt := range opts {
  21328. opt(m)
  21329. }
  21330. return m
  21331. }
  21332. // withPayRechargeID sets the ID field of the mutation.
  21333. func withPayRechargeID(id uint64) payrechargeOption {
  21334. return func(m *PayRechargeMutation) {
  21335. var (
  21336. err error
  21337. once sync.Once
  21338. value *PayRecharge
  21339. )
  21340. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21341. once.Do(func() {
  21342. if m.done {
  21343. err = errors.New("querying old values post mutation is not allowed")
  21344. } else {
  21345. value, err = m.Client().PayRecharge.Get(ctx, id)
  21346. }
  21347. })
  21348. return value, err
  21349. }
  21350. m.id = &id
  21351. }
  21352. }
  21353. // withPayRecharge sets the old PayRecharge of the mutation.
  21354. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21355. return func(m *PayRechargeMutation) {
  21356. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21357. return node, nil
  21358. }
  21359. m.id = &node.ID
  21360. }
  21361. }
  21362. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21363. // executed in a transaction (ent.Tx), a transactional client is returned.
  21364. func (m PayRechargeMutation) Client() *Client {
  21365. client := &Client{config: m.config}
  21366. client.init()
  21367. return client
  21368. }
  21369. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21370. // it returns an error otherwise.
  21371. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21372. if _, ok := m.driver.(*txDriver); !ok {
  21373. return nil, errors.New("ent: mutation is not running in a transaction")
  21374. }
  21375. tx := &Tx{config: m.config}
  21376. tx.init()
  21377. return tx, nil
  21378. }
  21379. // SetID sets the value of the id field. Note that this
  21380. // operation is only accepted on creation of PayRecharge entities.
  21381. func (m *PayRechargeMutation) SetID(id uint64) {
  21382. m.id = &id
  21383. }
  21384. // ID returns the ID value in the mutation. Note that the ID is only available
  21385. // if it was provided to the builder or after it was returned from the database.
  21386. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21387. if m.id == nil {
  21388. return
  21389. }
  21390. return *m.id, true
  21391. }
  21392. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21393. // That means, if the mutation is applied within a transaction with an isolation level such
  21394. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21395. // or updated by the mutation.
  21396. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21397. switch {
  21398. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21399. id, exists := m.ID()
  21400. if exists {
  21401. return []uint64{id}, nil
  21402. }
  21403. fallthrough
  21404. case m.op.Is(OpUpdate | OpDelete):
  21405. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21406. default:
  21407. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21408. }
  21409. }
  21410. // SetCreatedAt sets the "created_at" field.
  21411. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21412. m.created_at = &t
  21413. }
  21414. // CreatedAt returns the value of the "created_at" field in the mutation.
  21415. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21416. v := m.created_at
  21417. if v == nil {
  21418. return
  21419. }
  21420. return *v, true
  21421. }
  21422. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21423. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21425. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21426. if !m.op.Is(OpUpdateOne) {
  21427. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21428. }
  21429. if m.id == nil || m.oldValue == nil {
  21430. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21431. }
  21432. oldValue, err := m.oldValue(ctx)
  21433. if err != nil {
  21434. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21435. }
  21436. return oldValue.CreatedAt, nil
  21437. }
  21438. // ResetCreatedAt resets all changes to the "created_at" field.
  21439. func (m *PayRechargeMutation) ResetCreatedAt() {
  21440. m.created_at = nil
  21441. }
  21442. // SetUpdatedAt sets the "updated_at" field.
  21443. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21444. m.updated_at = &t
  21445. }
  21446. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21447. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21448. v := m.updated_at
  21449. if v == nil {
  21450. return
  21451. }
  21452. return *v, true
  21453. }
  21454. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21455. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21457. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21458. if !m.op.Is(OpUpdateOne) {
  21459. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21460. }
  21461. if m.id == nil || m.oldValue == nil {
  21462. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21463. }
  21464. oldValue, err := m.oldValue(ctx)
  21465. if err != nil {
  21466. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21467. }
  21468. return oldValue.UpdatedAt, nil
  21469. }
  21470. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21471. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21472. m.updated_at = nil
  21473. }
  21474. // SetDeletedAt sets the "deleted_at" field.
  21475. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21476. m.deleted_at = &t
  21477. }
  21478. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21479. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21480. v := m.deleted_at
  21481. if v == nil {
  21482. return
  21483. }
  21484. return *v, true
  21485. }
  21486. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21487. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21489. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21490. if !m.op.Is(OpUpdateOne) {
  21491. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21492. }
  21493. if m.id == nil || m.oldValue == nil {
  21494. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21495. }
  21496. oldValue, err := m.oldValue(ctx)
  21497. if err != nil {
  21498. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21499. }
  21500. return oldValue.DeletedAt, nil
  21501. }
  21502. // ClearDeletedAt clears the value of the "deleted_at" field.
  21503. func (m *PayRechargeMutation) ClearDeletedAt() {
  21504. m.deleted_at = nil
  21505. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21506. }
  21507. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21508. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21509. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21510. return ok
  21511. }
  21512. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21513. func (m *PayRechargeMutation) ResetDeletedAt() {
  21514. m.deleted_at = nil
  21515. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21516. }
  21517. // SetUserID sets the "user_id" field.
  21518. func (m *PayRechargeMutation) SetUserID(s string) {
  21519. m.user_id = &s
  21520. }
  21521. // UserID returns the value of the "user_id" field in the mutation.
  21522. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21523. v := m.user_id
  21524. if v == nil {
  21525. return
  21526. }
  21527. return *v, true
  21528. }
  21529. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21530. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21532. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21533. if !m.op.Is(OpUpdateOne) {
  21534. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21535. }
  21536. if m.id == nil || m.oldValue == nil {
  21537. return v, errors.New("OldUserID requires an ID field in the mutation")
  21538. }
  21539. oldValue, err := m.oldValue(ctx)
  21540. if err != nil {
  21541. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21542. }
  21543. return oldValue.UserID, nil
  21544. }
  21545. // ResetUserID resets all changes to the "user_id" field.
  21546. func (m *PayRechargeMutation) ResetUserID() {
  21547. m.user_id = nil
  21548. }
  21549. // SetNumber sets the "number" field.
  21550. func (m *PayRechargeMutation) SetNumber(f float32) {
  21551. m.number = &f
  21552. m.addnumber = nil
  21553. }
  21554. // Number returns the value of the "number" field in the mutation.
  21555. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21556. v := m.number
  21557. if v == nil {
  21558. return
  21559. }
  21560. return *v, true
  21561. }
  21562. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21563. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21565. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21566. if !m.op.Is(OpUpdateOne) {
  21567. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21568. }
  21569. if m.id == nil || m.oldValue == nil {
  21570. return v, errors.New("OldNumber requires an ID field in the mutation")
  21571. }
  21572. oldValue, err := m.oldValue(ctx)
  21573. if err != nil {
  21574. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21575. }
  21576. return oldValue.Number, nil
  21577. }
  21578. // AddNumber adds f to the "number" field.
  21579. func (m *PayRechargeMutation) AddNumber(f float32) {
  21580. if m.addnumber != nil {
  21581. *m.addnumber += f
  21582. } else {
  21583. m.addnumber = &f
  21584. }
  21585. }
  21586. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21587. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21588. v := m.addnumber
  21589. if v == nil {
  21590. return
  21591. }
  21592. return *v, true
  21593. }
  21594. // ResetNumber resets all changes to the "number" field.
  21595. func (m *PayRechargeMutation) ResetNumber() {
  21596. m.number = nil
  21597. m.addnumber = nil
  21598. }
  21599. // SetStatus sets the "status" field.
  21600. func (m *PayRechargeMutation) SetStatus(i int) {
  21601. m.status = &i
  21602. m.addstatus = nil
  21603. }
  21604. // Status returns the value of the "status" field in the mutation.
  21605. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21606. v := m.status
  21607. if v == nil {
  21608. return
  21609. }
  21610. return *v, true
  21611. }
  21612. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21613. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21615. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21616. if !m.op.Is(OpUpdateOne) {
  21617. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21618. }
  21619. if m.id == nil || m.oldValue == nil {
  21620. return v, errors.New("OldStatus requires an ID field in the mutation")
  21621. }
  21622. oldValue, err := m.oldValue(ctx)
  21623. if err != nil {
  21624. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21625. }
  21626. return oldValue.Status, nil
  21627. }
  21628. // AddStatus adds i to the "status" field.
  21629. func (m *PayRechargeMutation) AddStatus(i int) {
  21630. if m.addstatus != nil {
  21631. *m.addstatus += i
  21632. } else {
  21633. m.addstatus = &i
  21634. }
  21635. }
  21636. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21637. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  21638. v := m.addstatus
  21639. if v == nil {
  21640. return
  21641. }
  21642. return *v, true
  21643. }
  21644. // ClearStatus clears the value of the "status" field.
  21645. func (m *PayRechargeMutation) ClearStatus() {
  21646. m.status = nil
  21647. m.addstatus = nil
  21648. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  21649. }
  21650. // StatusCleared returns if the "status" field was cleared in this mutation.
  21651. func (m *PayRechargeMutation) StatusCleared() bool {
  21652. _, ok := m.clearedFields[payrecharge.FieldStatus]
  21653. return ok
  21654. }
  21655. // ResetStatus resets all changes to the "status" field.
  21656. func (m *PayRechargeMutation) ResetStatus() {
  21657. m.status = nil
  21658. m.addstatus = nil
  21659. delete(m.clearedFields, payrecharge.FieldStatus)
  21660. }
  21661. // SetMoney sets the "money" field.
  21662. func (m *PayRechargeMutation) SetMoney(f float32) {
  21663. m.money = &f
  21664. m.addmoney = nil
  21665. }
  21666. // Money returns the value of the "money" field in the mutation.
  21667. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  21668. v := m.money
  21669. if v == nil {
  21670. return
  21671. }
  21672. return *v, true
  21673. }
  21674. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  21675. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21677. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  21678. if !m.op.Is(OpUpdateOne) {
  21679. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  21680. }
  21681. if m.id == nil || m.oldValue == nil {
  21682. return v, errors.New("OldMoney requires an ID field in the mutation")
  21683. }
  21684. oldValue, err := m.oldValue(ctx)
  21685. if err != nil {
  21686. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  21687. }
  21688. return oldValue.Money, nil
  21689. }
  21690. // AddMoney adds f to the "money" field.
  21691. func (m *PayRechargeMutation) AddMoney(f float32) {
  21692. if m.addmoney != nil {
  21693. *m.addmoney += f
  21694. } else {
  21695. m.addmoney = &f
  21696. }
  21697. }
  21698. // AddedMoney returns the value that was added to the "money" field in this mutation.
  21699. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  21700. v := m.addmoney
  21701. if v == nil {
  21702. return
  21703. }
  21704. return *v, true
  21705. }
  21706. // ClearMoney clears the value of the "money" field.
  21707. func (m *PayRechargeMutation) ClearMoney() {
  21708. m.money = nil
  21709. m.addmoney = nil
  21710. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  21711. }
  21712. // MoneyCleared returns if the "money" field was cleared in this mutation.
  21713. func (m *PayRechargeMutation) MoneyCleared() bool {
  21714. _, ok := m.clearedFields[payrecharge.FieldMoney]
  21715. return ok
  21716. }
  21717. // ResetMoney resets all changes to the "money" field.
  21718. func (m *PayRechargeMutation) ResetMoney() {
  21719. m.money = nil
  21720. m.addmoney = nil
  21721. delete(m.clearedFields, payrecharge.FieldMoney)
  21722. }
  21723. // SetOutTradeNo sets the "out_trade_no" field.
  21724. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  21725. m.out_trade_no = &s
  21726. }
  21727. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  21728. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  21729. v := m.out_trade_no
  21730. if v == nil {
  21731. return
  21732. }
  21733. return *v, true
  21734. }
  21735. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  21736. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21738. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  21739. if !m.op.Is(OpUpdateOne) {
  21740. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  21741. }
  21742. if m.id == nil || m.oldValue == nil {
  21743. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  21744. }
  21745. oldValue, err := m.oldValue(ctx)
  21746. if err != nil {
  21747. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  21748. }
  21749. return oldValue.OutTradeNo, nil
  21750. }
  21751. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  21752. func (m *PayRechargeMutation) ClearOutTradeNo() {
  21753. m.out_trade_no = nil
  21754. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  21755. }
  21756. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  21757. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  21758. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  21759. return ok
  21760. }
  21761. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  21762. func (m *PayRechargeMutation) ResetOutTradeNo() {
  21763. m.out_trade_no = nil
  21764. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  21765. }
  21766. // SetOrganizationID sets the "organization_id" field.
  21767. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  21768. m.organization_id = &u
  21769. m.addorganization_id = nil
  21770. }
  21771. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21772. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  21773. v := m.organization_id
  21774. if v == nil {
  21775. return
  21776. }
  21777. return *v, true
  21778. }
  21779. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  21780. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21782. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21783. if !m.op.Is(OpUpdateOne) {
  21784. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21785. }
  21786. if m.id == nil || m.oldValue == nil {
  21787. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21788. }
  21789. oldValue, err := m.oldValue(ctx)
  21790. if err != nil {
  21791. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21792. }
  21793. return oldValue.OrganizationID, nil
  21794. }
  21795. // AddOrganizationID adds u to the "organization_id" field.
  21796. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  21797. if m.addorganization_id != nil {
  21798. *m.addorganization_id += u
  21799. } else {
  21800. m.addorganization_id = &u
  21801. }
  21802. }
  21803. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21804. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  21805. v := m.addorganization_id
  21806. if v == nil {
  21807. return
  21808. }
  21809. return *v, true
  21810. }
  21811. // ResetOrganizationID resets all changes to the "organization_id" field.
  21812. func (m *PayRechargeMutation) ResetOrganizationID() {
  21813. m.organization_id = nil
  21814. m.addorganization_id = nil
  21815. }
  21816. // Where appends a list predicates to the PayRechargeMutation builder.
  21817. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  21818. m.predicates = append(m.predicates, ps...)
  21819. }
  21820. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  21821. // users can use type-assertion to append predicates that do not depend on any generated package.
  21822. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  21823. p := make([]predicate.PayRecharge, len(ps))
  21824. for i := range ps {
  21825. p[i] = ps[i]
  21826. }
  21827. m.Where(p...)
  21828. }
  21829. // Op returns the operation name.
  21830. func (m *PayRechargeMutation) Op() Op {
  21831. return m.op
  21832. }
  21833. // SetOp allows setting the mutation operation.
  21834. func (m *PayRechargeMutation) SetOp(op Op) {
  21835. m.op = op
  21836. }
  21837. // Type returns the node type of this mutation (PayRecharge).
  21838. func (m *PayRechargeMutation) Type() string {
  21839. return m.typ
  21840. }
  21841. // Fields returns all fields that were changed during this mutation. Note that in
  21842. // order to get all numeric fields that were incremented/decremented, call
  21843. // AddedFields().
  21844. func (m *PayRechargeMutation) Fields() []string {
  21845. fields := make([]string, 0, 9)
  21846. if m.created_at != nil {
  21847. fields = append(fields, payrecharge.FieldCreatedAt)
  21848. }
  21849. if m.updated_at != nil {
  21850. fields = append(fields, payrecharge.FieldUpdatedAt)
  21851. }
  21852. if m.deleted_at != nil {
  21853. fields = append(fields, payrecharge.FieldDeletedAt)
  21854. }
  21855. if m.user_id != nil {
  21856. fields = append(fields, payrecharge.FieldUserID)
  21857. }
  21858. if m.number != nil {
  21859. fields = append(fields, payrecharge.FieldNumber)
  21860. }
  21861. if m.status != nil {
  21862. fields = append(fields, payrecharge.FieldStatus)
  21863. }
  21864. if m.money != nil {
  21865. fields = append(fields, payrecharge.FieldMoney)
  21866. }
  21867. if m.out_trade_no != nil {
  21868. fields = append(fields, payrecharge.FieldOutTradeNo)
  21869. }
  21870. if m.organization_id != nil {
  21871. fields = append(fields, payrecharge.FieldOrganizationID)
  21872. }
  21873. return fields
  21874. }
  21875. // Field returns the value of a field with the given name. The second boolean
  21876. // return value indicates that this field was not set, or was not defined in the
  21877. // schema.
  21878. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  21879. switch name {
  21880. case payrecharge.FieldCreatedAt:
  21881. return m.CreatedAt()
  21882. case payrecharge.FieldUpdatedAt:
  21883. return m.UpdatedAt()
  21884. case payrecharge.FieldDeletedAt:
  21885. return m.DeletedAt()
  21886. case payrecharge.FieldUserID:
  21887. return m.UserID()
  21888. case payrecharge.FieldNumber:
  21889. return m.Number()
  21890. case payrecharge.FieldStatus:
  21891. return m.Status()
  21892. case payrecharge.FieldMoney:
  21893. return m.Money()
  21894. case payrecharge.FieldOutTradeNo:
  21895. return m.OutTradeNo()
  21896. case payrecharge.FieldOrganizationID:
  21897. return m.OrganizationID()
  21898. }
  21899. return nil, false
  21900. }
  21901. // OldField returns the old value of the field from the database. An error is
  21902. // returned if the mutation operation is not UpdateOne, or the query to the
  21903. // database failed.
  21904. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21905. switch name {
  21906. case payrecharge.FieldCreatedAt:
  21907. return m.OldCreatedAt(ctx)
  21908. case payrecharge.FieldUpdatedAt:
  21909. return m.OldUpdatedAt(ctx)
  21910. case payrecharge.FieldDeletedAt:
  21911. return m.OldDeletedAt(ctx)
  21912. case payrecharge.FieldUserID:
  21913. return m.OldUserID(ctx)
  21914. case payrecharge.FieldNumber:
  21915. return m.OldNumber(ctx)
  21916. case payrecharge.FieldStatus:
  21917. return m.OldStatus(ctx)
  21918. case payrecharge.FieldMoney:
  21919. return m.OldMoney(ctx)
  21920. case payrecharge.FieldOutTradeNo:
  21921. return m.OldOutTradeNo(ctx)
  21922. case payrecharge.FieldOrganizationID:
  21923. return m.OldOrganizationID(ctx)
  21924. }
  21925. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  21926. }
  21927. // SetField sets the value of a field with the given name. It returns an error if
  21928. // the field is not defined in the schema, or if the type mismatched the field
  21929. // type.
  21930. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  21931. switch name {
  21932. case payrecharge.FieldCreatedAt:
  21933. v, ok := value.(time.Time)
  21934. if !ok {
  21935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21936. }
  21937. m.SetCreatedAt(v)
  21938. return nil
  21939. case payrecharge.FieldUpdatedAt:
  21940. v, ok := value.(time.Time)
  21941. if !ok {
  21942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21943. }
  21944. m.SetUpdatedAt(v)
  21945. return nil
  21946. case payrecharge.FieldDeletedAt:
  21947. v, ok := value.(time.Time)
  21948. if !ok {
  21949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21950. }
  21951. m.SetDeletedAt(v)
  21952. return nil
  21953. case payrecharge.FieldUserID:
  21954. v, ok := value.(string)
  21955. if !ok {
  21956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21957. }
  21958. m.SetUserID(v)
  21959. return nil
  21960. case payrecharge.FieldNumber:
  21961. v, ok := value.(float32)
  21962. if !ok {
  21963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21964. }
  21965. m.SetNumber(v)
  21966. return nil
  21967. case payrecharge.FieldStatus:
  21968. v, ok := value.(int)
  21969. if !ok {
  21970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21971. }
  21972. m.SetStatus(v)
  21973. return nil
  21974. case payrecharge.FieldMoney:
  21975. v, ok := value.(float32)
  21976. if !ok {
  21977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21978. }
  21979. m.SetMoney(v)
  21980. return nil
  21981. case payrecharge.FieldOutTradeNo:
  21982. v, ok := value.(string)
  21983. if !ok {
  21984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21985. }
  21986. m.SetOutTradeNo(v)
  21987. return nil
  21988. case payrecharge.FieldOrganizationID:
  21989. v, ok := value.(uint64)
  21990. if !ok {
  21991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21992. }
  21993. m.SetOrganizationID(v)
  21994. return nil
  21995. }
  21996. return fmt.Errorf("unknown PayRecharge field %s", name)
  21997. }
  21998. // AddedFields returns all numeric fields that were incremented/decremented during
  21999. // this mutation.
  22000. func (m *PayRechargeMutation) AddedFields() []string {
  22001. var fields []string
  22002. if m.addnumber != nil {
  22003. fields = append(fields, payrecharge.FieldNumber)
  22004. }
  22005. if m.addstatus != nil {
  22006. fields = append(fields, payrecharge.FieldStatus)
  22007. }
  22008. if m.addmoney != nil {
  22009. fields = append(fields, payrecharge.FieldMoney)
  22010. }
  22011. if m.addorganization_id != nil {
  22012. fields = append(fields, payrecharge.FieldOrganizationID)
  22013. }
  22014. return fields
  22015. }
  22016. // AddedField returns the numeric value that was incremented/decremented on a field
  22017. // with the given name. The second boolean return value indicates that this field
  22018. // was not set, or was not defined in the schema.
  22019. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  22020. switch name {
  22021. case payrecharge.FieldNumber:
  22022. return m.AddedNumber()
  22023. case payrecharge.FieldStatus:
  22024. return m.AddedStatus()
  22025. case payrecharge.FieldMoney:
  22026. return m.AddedMoney()
  22027. case payrecharge.FieldOrganizationID:
  22028. return m.AddedOrganizationID()
  22029. }
  22030. return nil, false
  22031. }
  22032. // AddField adds the value to the field with the given name. It returns an error if
  22033. // the field is not defined in the schema, or if the type mismatched the field
  22034. // type.
  22035. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  22036. switch name {
  22037. case payrecharge.FieldNumber:
  22038. v, ok := value.(float32)
  22039. if !ok {
  22040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22041. }
  22042. m.AddNumber(v)
  22043. return nil
  22044. case payrecharge.FieldStatus:
  22045. v, ok := value.(int)
  22046. if !ok {
  22047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22048. }
  22049. m.AddStatus(v)
  22050. return nil
  22051. case payrecharge.FieldMoney:
  22052. v, ok := value.(float32)
  22053. if !ok {
  22054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22055. }
  22056. m.AddMoney(v)
  22057. return nil
  22058. case payrecharge.FieldOrganizationID:
  22059. v, ok := value.(int64)
  22060. if !ok {
  22061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22062. }
  22063. m.AddOrganizationID(v)
  22064. return nil
  22065. }
  22066. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  22067. }
  22068. // ClearedFields returns all nullable fields that were cleared during this
  22069. // mutation.
  22070. func (m *PayRechargeMutation) ClearedFields() []string {
  22071. var fields []string
  22072. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  22073. fields = append(fields, payrecharge.FieldDeletedAt)
  22074. }
  22075. if m.FieldCleared(payrecharge.FieldStatus) {
  22076. fields = append(fields, payrecharge.FieldStatus)
  22077. }
  22078. if m.FieldCleared(payrecharge.FieldMoney) {
  22079. fields = append(fields, payrecharge.FieldMoney)
  22080. }
  22081. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22082. fields = append(fields, payrecharge.FieldOutTradeNo)
  22083. }
  22084. return fields
  22085. }
  22086. // FieldCleared returns a boolean indicating if a field with the given name was
  22087. // cleared in this mutation.
  22088. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22089. _, ok := m.clearedFields[name]
  22090. return ok
  22091. }
  22092. // ClearField clears the value of the field with the given name. It returns an
  22093. // error if the field is not defined in the schema.
  22094. func (m *PayRechargeMutation) ClearField(name string) error {
  22095. switch name {
  22096. case payrecharge.FieldDeletedAt:
  22097. m.ClearDeletedAt()
  22098. return nil
  22099. case payrecharge.FieldStatus:
  22100. m.ClearStatus()
  22101. return nil
  22102. case payrecharge.FieldMoney:
  22103. m.ClearMoney()
  22104. return nil
  22105. case payrecharge.FieldOutTradeNo:
  22106. m.ClearOutTradeNo()
  22107. return nil
  22108. }
  22109. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22110. }
  22111. // ResetField resets all changes in the mutation for the field with the given name.
  22112. // It returns an error if the field is not defined in the schema.
  22113. func (m *PayRechargeMutation) ResetField(name string) error {
  22114. switch name {
  22115. case payrecharge.FieldCreatedAt:
  22116. m.ResetCreatedAt()
  22117. return nil
  22118. case payrecharge.FieldUpdatedAt:
  22119. m.ResetUpdatedAt()
  22120. return nil
  22121. case payrecharge.FieldDeletedAt:
  22122. m.ResetDeletedAt()
  22123. return nil
  22124. case payrecharge.FieldUserID:
  22125. m.ResetUserID()
  22126. return nil
  22127. case payrecharge.FieldNumber:
  22128. m.ResetNumber()
  22129. return nil
  22130. case payrecharge.FieldStatus:
  22131. m.ResetStatus()
  22132. return nil
  22133. case payrecharge.FieldMoney:
  22134. m.ResetMoney()
  22135. return nil
  22136. case payrecharge.FieldOutTradeNo:
  22137. m.ResetOutTradeNo()
  22138. return nil
  22139. case payrecharge.FieldOrganizationID:
  22140. m.ResetOrganizationID()
  22141. return nil
  22142. }
  22143. return fmt.Errorf("unknown PayRecharge field %s", name)
  22144. }
  22145. // AddedEdges returns all edge names that were set/added in this mutation.
  22146. func (m *PayRechargeMutation) AddedEdges() []string {
  22147. edges := make([]string, 0, 0)
  22148. return edges
  22149. }
  22150. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22151. // name in this mutation.
  22152. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22153. return nil
  22154. }
  22155. // RemovedEdges returns all edge names that were removed in this mutation.
  22156. func (m *PayRechargeMutation) RemovedEdges() []string {
  22157. edges := make([]string, 0, 0)
  22158. return edges
  22159. }
  22160. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22161. // the given name in this mutation.
  22162. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22163. return nil
  22164. }
  22165. // ClearedEdges returns all edge names that were cleared in this mutation.
  22166. func (m *PayRechargeMutation) ClearedEdges() []string {
  22167. edges := make([]string, 0, 0)
  22168. return edges
  22169. }
  22170. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22171. // was cleared in this mutation.
  22172. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22173. return false
  22174. }
  22175. // ClearEdge clears the value of the edge with the given name. It returns an error
  22176. // if that edge is not defined in the schema.
  22177. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22178. return fmt.Errorf("unknown PayRecharge 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 *PayRechargeMutation) ResetEdge(name string) error {
  22183. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22184. }
  22185. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22186. type ServerMutation struct {
  22187. config
  22188. op Op
  22189. typ string
  22190. id *uint64
  22191. created_at *time.Time
  22192. updated_at *time.Time
  22193. status *uint8
  22194. addstatus *int8
  22195. deleted_at *time.Time
  22196. name *string
  22197. public_ip *string
  22198. private_ip *string
  22199. admin_port *string
  22200. clearedFields map[string]struct{}
  22201. wxs map[uint64]struct{}
  22202. removedwxs map[uint64]struct{}
  22203. clearedwxs bool
  22204. done bool
  22205. oldValue func(context.Context) (*Server, error)
  22206. predicates []predicate.Server
  22207. }
  22208. var _ ent.Mutation = (*ServerMutation)(nil)
  22209. // serverOption allows management of the mutation configuration using functional options.
  22210. type serverOption func(*ServerMutation)
  22211. // newServerMutation creates new mutation for the Server entity.
  22212. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22213. m := &ServerMutation{
  22214. config: c,
  22215. op: op,
  22216. typ: TypeServer,
  22217. clearedFields: make(map[string]struct{}),
  22218. }
  22219. for _, opt := range opts {
  22220. opt(m)
  22221. }
  22222. return m
  22223. }
  22224. // withServerID sets the ID field of the mutation.
  22225. func withServerID(id uint64) serverOption {
  22226. return func(m *ServerMutation) {
  22227. var (
  22228. err error
  22229. once sync.Once
  22230. value *Server
  22231. )
  22232. m.oldValue = func(ctx context.Context) (*Server, error) {
  22233. once.Do(func() {
  22234. if m.done {
  22235. err = errors.New("querying old values post mutation is not allowed")
  22236. } else {
  22237. value, err = m.Client().Server.Get(ctx, id)
  22238. }
  22239. })
  22240. return value, err
  22241. }
  22242. m.id = &id
  22243. }
  22244. }
  22245. // withServer sets the old Server of the mutation.
  22246. func withServer(node *Server) serverOption {
  22247. return func(m *ServerMutation) {
  22248. m.oldValue = func(context.Context) (*Server, error) {
  22249. return node, nil
  22250. }
  22251. m.id = &node.ID
  22252. }
  22253. }
  22254. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22255. // executed in a transaction (ent.Tx), a transactional client is returned.
  22256. func (m ServerMutation) Client() *Client {
  22257. client := &Client{config: m.config}
  22258. client.init()
  22259. return client
  22260. }
  22261. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22262. // it returns an error otherwise.
  22263. func (m ServerMutation) Tx() (*Tx, error) {
  22264. if _, ok := m.driver.(*txDriver); !ok {
  22265. return nil, errors.New("ent: mutation is not running in a transaction")
  22266. }
  22267. tx := &Tx{config: m.config}
  22268. tx.init()
  22269. return tx, nil
  22270. }
  22271. // SetID sets the value of the id field. Note that this
  22272. // operation is only accepted on creation of Server entities.
  22273. func (m *ServerMutation) SetID(id uint64) {
  22274. m.id = &id
  22275. }
  22276. // ID returns the ID value in the mutation. Note that the ID is only available
  22277. // if it was provided to the builder or after it was returned from the database.
  22278. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22279. if m.id == nil {
  22280. return
  22281. }
  22282. return *m.id, true
  22283. }
  22284. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22285. // That means, if the mutation is applied within a transaction with an isolation level such
  22286. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22287. // or updated by the mutation.
  22288. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22289. switch {
  22290. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22291. id, exists := m.ID()
  22292. if exists {
  22293. return []uint64{id}, nil
  22294. }
  22295. fallthrough
  22296. case m.op.Is(OpUpdate | OpDelete):
  22297. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22298. default:
  22299. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22300. }
  22301. }
  22302. // SetCreatedAt sets the "created_at" field.
  22303. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22304. m.created_at = &t
  22305. }
  22306. // CreatedAt returns the value of the "created_at" field in the mutation.
  22307. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22308. v := m.created_at
  22309. if v == nil {
  22310. return
  22311. }
  22312. return *v, true
  22313. }
  22314. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22315. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22317. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22318. if !m.op.Is(OpUpdateOne) {
  22319. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22320. }
  22321. if m.id == nil || m.oldValue == nil {
  22322. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22323. }
  22324. oldValue, err := m.oldValue(ctx)
  22325. if err != nil {
  22326. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22327. }
  22328. return oldValue.CreatedAt, nil
  22329. }
  22330. // ResetCreatedAt resets all changes to the "created_at" field.
  22331. func (m *ServerMutation) ResetCreatedAt() {
  22332. m.created_at = nil
  22333. }
  22334. // SetUpdatedAt sets the "updated_at" field.
  22335. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22336. m.updated_at = &t
  22337. }
  22338. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22339. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22340. v := m.updated_at
  22341. if v == nil {
  22342. return
  22343. }
  22344. return *v, true
  22345. }
  22346. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22347. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22349. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22350. if !m.op.Is(OpUpdateOne) {
  22351. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22352. }
  22353. if m.id == nil || m.oldValue == nil {
  22354. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22355. }
  22356. oldValue, err := m.oldValue(ctx)
  22357. if err != nil {
  22358. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22359. }
  22360. return oldValue.UpdatedAt, nil
  22361. }
  22362. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22363. func (m *ServerMutation) ResetUpdatedAt() {
  22364. m.updated_at = nil
  22365. }
  22366. // SetStatus sets the "status" field.
  22367. func (m *ServerMutation) SetStatus(u uint8) {
  22368. m.status = &u
  22369. m.addstatus = nil
  22370. }
  22371. // Status returns the value of the "status" field in the mutation.
  22372. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22373. v := m.status
  22374. if v == nil {
  22375. return
  22376. }
  22377. return *v, true
  22378. }
  22379. // OldStatus returns the old "status" field's value of the Server entity.
  22380. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22382. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22383. if !m.op.Is(OpUpdateOne) {
  22384. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22385. }
  22386. if m.id == nil || m.oldValue == nil {
  22387. return v, errors.New("OldStatus requires an ID field in the mutation")
  22388. }
  22389. oldValue, err := m.oldValue(ctx)
  22390. if err != nil {
  22391. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22392. }
  22393. return oldValue.Status, nil
  22394. }
  22395. // AddStatus adds u to the "status" field.
  22396. func (m *ServerMutation) AddStatus(u int8) {
  22397. if m.addstatus != nil {
  22398. *m.addstatus += u
  22399. } else {
  22400. m.addstatus = &u
  22401. }
  22402. }
  22403. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22404. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22405. v := m.addstatus
  22406. if v == nil {
  22407. return
  22408. }
  22409. return *v, true
  22410. }
  22411. // ClearStatus clears the value of the "status" field.
  22412. func (m *ServerMutation) ClearStatus() {
  22413. m.status = nil
  22414. m.addstatus = nil
  22415. m.clearedFields[server.FieldStatus] = struct{}{}
  22416. }
  22417. // StatusCleared returns if the "status" field was cleared in this mutation.
  22418. func (m *ServerMutation) StatusCleared() bool {
  22419. _, ok := m.clearedFields[server.FieldStatus]
  22420. return ok
  22421. }
  22422. // ResetStatus resets all changes to the "status" field.
  22423. func (m *ServerMutation) ResetStatus() {
  22424. m.status = nil
  22425. m.addstatus = nil
  22426. delete(m.clearedFields, server.FieldStatus)
  22427. }
  22428. // SetDeletedAt sets the "deleted_at" field.
  22429. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22430. m.deleted_at = &t
  22431. }
  22432. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22433. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22434. v := m.deleted_at
  22435. if v == nil {
  22436. return
  22437. }
  22438. return *v, true
  22439. }
  22440. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22441. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22443. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22444. if !m.op.Is(OpUpdateOne) {
  22445. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22446. }
  22447. if m.id == nil || m.oldValue == nil {
  22448. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22449. }
  22450. oldValue, err := m.oldValue(ctx)
  22451. if err != nil {
  22452. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22453. }
  22454. return oldValue.DeletedAt, nil
  22455. }
  22456. // ClearDeletedAt clears the value of the "deleted_at" field.
  22457. func (m *ServerMutation) ClearDeletedAt() {
  22458. m.deleted_at = nil
  22459. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22460. }
  22461. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22462. func (m *ServerMutation) DeletedAtCleared() bool {
  22463. _, ok := m.clearedFields[server.FieldDeletedAt]
  22464. return ok
  22465. }
  22466. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22467. func (m *ServerMutation) ResetDeletedAt() {
  22468. m.deleted_at = nil
  22469. delete(m.clearedFields, server.FieldDeletedAt)
  22470. }
  22471. // SetName sets the "name" field.
  22472. func (m *ServerMutation) SetName(s string) {
  22473. m.name = &s
  22474. }
  22475. // Name returns the value of the "name" field in the mutation.
  22476. func (m *ServerMutation) Name() (r string, exists bool) {
  22477. v := m.name
  22478. if v == nil {
  22479. return
  22480. }
  22481. return *v, true
  22482. }
  22483. // OldName returns the old "name" field's value of the Server entity.
  22484. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22486. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22487. if !m.op.Is(OpUpdateOne) {
  22488. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22489. }
  22490. if m.id == nil || m.oldValue == nil {
  22491. return v, errors.New("OldName requires an ID field in the mutation")
  22492. }
  22493. oldValue, err := m.oldValue(ctx)
  22494. if err != nil {
  22495. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22496. }
  22497. return oldValue.Name, nil
  22498. }
  22499. // ResetName resets all changes to the "name" field.
  22500. func (m *ServerMutation) ResetName() {
  22501. m.name = nil
  22502. }
  22503. // SetPublicIP sets the "public_ip" field.
  22504. func (m *ServerMutation) SetPublicIP(s string) {
  22505. m.public_ip = &s
  22506. }
  22507. // PublicIP returns the value of the "public_ip" field in the mutation.
  22508. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22509. v := m.public_ip
  22510. if v == nil {
  22511. return
  22512. }
  22513. return *v, true
  22514. }
  22515. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22516. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22518. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22519. if !m.op.Is(OpUpdateOne) {
  22520. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22521. }
  22522. if m.id == nil || m.oldValue == nil {
  22523. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22524. }
  22525. oldValue, err := m.oldValue(ctx)
  22526. if err != nil {
  22527. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22528. }
  22529. return oldValue.PublicIP, nil
  22530. }
  22531. // ResetPublicIP resets all changes to the "public_ip" field.
  22532. func (m *ServerMutation) ResetPublicIP() {
  22533. m.public_ip = nil
  22534. }
  22535. // SetPrivateIP sets the "private_ip" field.
  22536. func (m *ServerMutation) SetPrivateIP(s string) {
  22537. m.private_ip = &s
  22538. }
  22539. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22540. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22541. v := m.private_ip
  22542. if v == nil {
  22543. return
  22544. }
  22545. return *v, true
  22546. }
  22547. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22548. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22550. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22551. if !m.op.Is(OpUpdateOne) {
  22552. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22553. }
  22554. if m.id == nil || m.oldValue == nil {
  22555. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22556. }
  22557. oldValue, err := m.oldValue(ctx)
  22558. if err != nil {
  22559. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22560. }
  22561. return oldValue.PrivateIP, nil
  22562. }
  22563. // ResetPrivateIP resets all changes to the "private_ip" field.
  22564. func (m *ServerMutation) ResetPrivateIP() {
  22565. m.private_ip = nil
  22566. }
  22567. // SetAdminPort sets the "admin_port" field.
  22568. func (m *ServerMutation) SetAdminPort(s string) {
  22569. m.admin_port = &s
  22570. }
  22571. // AdminPort returns the value of the "admin_port" field in the mutation.
  22572. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22573. v := m.admin_port
  22574. if v == nil {
  22575. return
  22576. }
  22577. return *v, true
  22578. }
  22579. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22580. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22582. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22583. if !m.op.Is(OpUpdateOne) {
  22584. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22585. }
  22586. if m.id == nil || m.oldValue == nil {
  22587. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22588. }
  22589. oldValue, err := m.oldValue(ctx)
  22590. if err != nil {
  22591. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22592. }
  22593. return oldValue.AdminPort, nil
  22594. }
  22595. // ResetAdminPort resets all changes to the "admin_port" field.
  22596. func (m *ServerMutation) ResetAdminPort() {
  22597. m.admin_port = nil
  22598. }
  22599. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22600. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22601. if m.wxs == nil {
  22602. m.wxs = make(map[uint64]struct{})
  22603. }
  22604. for i := range ids {
  22605. m.wxs[ids[i]] = struct{}{}
  22606. }
  22607. }
  22608. // ClearWxs clears the "wxs" edge to the Wx entity.
  22609. func (m *ServerMutation) ClearWxs() {
  22610. m.clearedwxs = true
  22611. }
  22612. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22613. func (m *ServerMutation) WxsCleared() bool {
  22614. return m.clearedwxs
  22615. }
  22616. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22617. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22618. if m.removedwxs == nil {
  22619. m.removedwxs = make(map[uint64]struct{})
  22620. }
  22621. for i := range ids {
  22622. delete(m.wxs, ids[i])
  22623. m.removedwxs[ids[i]] = struct{}{}
  22624. }
  22625. }
  22626. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22627. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22628. for id := range m.removedwxs {
  22629. ids = append(ids, id)
  22630. }
  22631. return
  22632. }
  22633. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22634. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22635. for id := range m.wxs {
  22636. ids = append(ids, id)
  22637. }
  22638. return
  22639. }
  22640. // ResetWxs resets all changes to the "wxs" edge.
  22641. func (m *ServerMutation) ResetWxs() {
  22642. m.wxs = nil
  22643. m.clearedwxs = false
  22644. m.removedwxs = nil
  22645. }
  22646. // Where appends a list predicates to the ServerMutation builder.
  22647. func (m *ServerMutation) Where(ps ...predicate.Server) {
  22648. m.predicates = append(m.predicates, ps...)
  22649. }
  22650. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  22651. // users can use type-assertion to append predicates that do not depend on any generated package.
  22652. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  22653. p := make([]predicate.Server, len(ps))
  22654. for i := range ps {
  22655. p[i] = ps[i]
  22656. }
  22657. m.Where(p...)
  22658. }
  22659. // Op returns the operation name.
  22660. func (m *ServerMutation) Op() Op {
  22661. return m.op
  22662. }
  22663. // SetOp allows setting the mutation operation.
  22664. func (m *ServerMutation) SetOp(op Op) {
  22665. m.op = op
  22666. }
  22667. // Type returns the node type of this mutation (Server).
  22668. func (m *ServerMutation) Type() string {
  22669. return m.typ
  22670. }
  22671. // Fields returns all fields that were changed during this mutation. Note that in
  22672. // order to get all numeric fields that were incremented/decremented, call
  22673. // AddedFields().
  22674. func (m *ServerMutation) Fields() []string {
  22675. fields := make([]string, 0, 8)
  22676. if m.created_at != nil {
  22677. fields = append(fields, server.FieldCreatedAt)
  22678. }
  22679. if m.updated_at != nil {
  22680. fields = append(fields, server.FieldUpdatedAt)
  22681. }
  22682. if m.status != nil {
  22683. fields = append(fields, server.FieldStatus)
  22684. }
  22685. if m.deleted_at != nil {
  22686. fields = append(fields, server.FieldDeletedAt)
  22687. }
  22688. if m.name != nil {
  22689. fields = append(fields, server.FieldName)
  22690. }
  22691. if m.public_ip != nil {
  22692. fields = append(fields, server.FieldPublicIP)
  22693. }
  22694. if m.private_ip != nil {
  22695. fields = append(fields, server.FieldPrivateIP)
  22696. }
  22697. if m.admin_port != nil {
  22698. fields = append(fields, server.FieldAdminPort)
  22699. }
  22700. return fields
  22701. }
  22702. // Field returns the value of a field with the given name. The second boolean
  22703. // return value indicates that this field was not set, or was not defined in the
  22704. // schema.
  22705. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  22706. switch name {
  22707. case server.FieldCreatedAt:
  22708. return m.CreatedAt()
  22709. case server.FieldUpdatedAt:
  22710. return m.UpdatedAt()
  22711. case server.FieldStatus:
  22712. return m.Status()
  22713. case server.FieldDeletedAt:
  22714. return m.DeletedAt()
  22715. case server.FieldName:
  22716. return m.Name()
  22717. case server.FieldPublicIP:
  22718. return m.PublicIP()
  22719. case server.FieldPrivateIP:
  22720. return m.PrivateIP()
  22721. case server.FieldAdminPort:
  22722. return m.AdminPort()
  22723. }
  22724. return nil, false
  22725. }
  22726. // OldField returns the old value of the field from the database. An error is
  22727. // returned if the mutation operation is not UpdateOne, or the query to the
  22728. // database failed.
  22729. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22730. switch name {
  22731. case server.FieldCreatedAt:
  22732. return m.OldCreatedAt(ctx)
  22733. case server.FieldUpdatedAt:
  22734. return m.OldUpdatedAt(ctx)
  22735. case server.FieldStatus:
  22736. return m.OldStatus(ctx)
  22737. case server.FieldDeletedAt:
  22738. return m.OldDeletedAt(ctx)
  22739. case server.FieldName:
  22740. return m.OldName(ctx)
  22741. case server.FieldPublicIP:
  22742. return m.OldPublicIP(ctx)
  22743. case server.FieldPrivateIP:
  22744. return m.OldPrivateIP(ctx)
  22745. case server.FieldAdminPort:
  22746. return m.OldAdminPort(ctx)
  22747. }
  22748. return nil, fmt.Errorf("unknown Server field %s", name)
  22749. }
  22750. // SetField sets the value of a field with the given name. It returns an error if
  22751. // the field is not defined in the schema, or if the type mismatched the field
  22752. // type.
  22753. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  22754. switch name {
  22755. case server.FieldCreatedAt:
  22756. v, ok := value.(time.Time)
  22757. if !ok {
  22758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22759. }
  22760. m.SetCreatedAt(v)
  22761. return nil
  22762. case server.FieldUpdatedAt:
  22763. v, ok := value.(time.Time)
  22764. if !ok {
  22765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22766. }
  22767. m.SetUpdatedAt(v)
  22768. return nil
  22769. case server.FieldStatus:
  22770. v, ok := value.(uint8)
  22771. if !ok {
  22772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22773. }
  22774. m.SetStatus(v)
  22775. return nil
  22776. case server.FieldDeletedAt:
  22777. v, ok := value.(time.Time)
  22778. if !ok {
  22779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22780. }
  22781. m.SetDeletedAt(v)
  22782. return nil
  22783. case server.FieldName:
  22784. v, ok := value.(string)
  22785. if !ok {
  22786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22787. }
  22788. m.SetName(v)
  22789. return nil
  22790. case server.FieldPublicIP:
  22791. v, ok := value.(string)
  22792. if !ok {
  22793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22794. }
  22795. m.SetPublicIP(v)
  22796. return nil
  22797. case server.FieldPrivateIP:
  22798. v, ok := value.(string)
  22799. if !ok {
  22800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22801. }
  22802. m.SetPrivateIP(v)
  22803. return nil
  22804. case server.FieldAdminPort:
  22805. v, ok := value.(string)
  22806. if !ok {
  22807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22808. }
  22809. m.SetAdminPort(v)
  22810. return nil
  22811. }
  22812. return fmt.Errorf("unknown Server field %s", name)
  22813. }
  22814. // AddedFields returns all numeric fields that were incremented/decremented during
  22815. // this mutation.
  22816. func (m *ServerMutation) AddedFields() []string {
  22817. var fields []string
  22818. if m.addstatus != nil {
  22819. fields = append(fields, server.FieldStatus)
  22820. }
  22821. return fields
  22822. }
  22823. // AddedField returns the numeric value that was incremented/decremented on a field
  22824. // with the given name. The second boolean return value indicates that this field
  22825. // was not set, or was not defined in the schema.
  22826. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  22827. switch name {
  22828. case server.FieldStatus:
  22829. return m.AddedStatus()
  22830. }
  22831. return nil, false
  22832. }
  22833. // AddField adds the value to the field with the given name. It returns an error if
  22834. // the field is not defined in the schema, or if the type mismatched the field
  22835. // type.
  22836. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  22837. switch name {
  22838. case server.FieldStatus:
  22839. v, ok := value.(int8)
  22840. if !ok {
  22841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22842. }
  22843. m.AddStatus(v)
  22844. return nil
  22845. }
  22846. return fmt.Errorf("unknown Server numeric field %s", name)
  22847. }
  22848. // ClearedFields returns all nullable fields that were cleared during this
  22849. // mutation.
  22850. func (m *ServerMutation) ClearedFields() []string {
  22851. var fields []string
  22852. if m.FieldCleared(server.FieldStatus) {
  22853. fields = append(fields, server.FieldStatus)
  22854. }
  22855. if m.FieldCleared(server.FieldDeletedAt) {
  22856. fields = append(fields, server.FieldDeletedAt)
  22857. }
  22858. return fields
  22859. }
  22860. // FieldCleared returns a boolean indicating if a field with the given name was
  22861. // cleared in this mutation.
  22862. func (m *ServerMutation) FieldCleared(name string) bool {
  22863. _, ok := m.clearedFields[name]
  22864. return ok
  22865. }
  22866. // ClearField clears the value of the field with the given name. It returns an
  22867. // error if the field is not defined in the schema.
  22868. func (m *ServerMutation) ClearField(name string) error {
  22869. switch name {
  22870. case server.FieldStatus:
  22871. m.ClearStatus()
  22872. return nil
  22873. case server.FieldDeletedAt:
  22874. m.ClearDeletedAt()
  22875. return nil
  22876. }
  22877. return fmt.Errorf("unknown Server nullable field %s", name)
  22878. }
  22879. // ResetField resets all changes in the mutation for the field with the given name.
  22880. // It returns an error if the field is not defined in the schema.
  22881. func (m *ServerMutation) ResetField(name string) error {
  22882. switch name {
  22883. case server.FieldCreatedAt:
  22884. m.ResetCreatedAt()
  22885. return nil
  22886. case server.FieldUpdatedAt:
  22887. m.ResetUpdatedAt()
  22888. return nil
  22889. case server.FieldStatus:
  22890. m.ResetStatus()
  22891. return nil
  22892. case server.FieldDeletedAt:
  22893. m.ResetDeletedAt()
  22894. return nil
  22895. case server.FieldName:
  22896. m.ResetName()
  22897. return nil
  22898. case server.FieldPublicIP:
  22899. m.ResetPublicIP()
  22900. return nil
  22901. case server.FieldPrivateIP:
  22902. m.ResetPrivateIP()
  22903. return nil
  22904. case server.FieldAdminPort:
  22905. m.ResetAdminPort()
  22906. return nil
  22907. }
  22908. return fmt.Errorf("unknown Server field %s", name)
  22909. }
  22910. // AddedEdges returns all edge names that were set/added in this mutation.
  22911. func (m *ServerMutation) AddedEdges() []string {
  22912. edges := make([]string, 0, 1)
  22913. if m.wxs != nil {
  22914. edges = append(edges, server.EdgeWxs)
  22915. }
  22916. return edges
  22917. }
  22918. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22919. // name in this mutation.
  22920. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  22921. switch name {
  22922. case server.EdgeWxs:
  22923. ids := make([]ent.Value, 0, len(m.wxs))
  22924. for id := range m.wxs {
  22925. ids = append(ids, id)
  22926. }
  22927. return ids
  22928. }
  22929. return nil
  22930. }
  22931. // RemovedEdges returns all edge names that were removed in this mutation.
  22932. func (m *ServerMutation) RemovedEdges() []string {
  22933. edges := make([]string, 0, 1)
  22934. if m.removedwxs != nil {
  22935. edges = append(edges, server.EdgeWxs)
  22936. }
  22937. return edges
  22938. }
  22939. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22940. // the given name in this mutation.
  22941. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  22942. switch name {
  22943. case server.EdgeWxs:
  22944. ids := make([]ent.Value, 0, len(m.removedwxs))
  22945. for id := range m.removedwxs {
  22946. ids = append(ids, id)
  22947. }
  22948. return ids
  22949. }
  22950. return nil
  22951. }
  22952. // ClearedEdges returns all edge names that were cleared in this mutation.
  22953. func (m *ServerMutation) ClearedEdges() []string {
  22954. edges := make([]string, 0, 1)
  22955. if m.clearedwxs {
  22956. edges = append(edges, server.EdgeWxs)
  22957. }
  22958. return edges
  22959. }
  22960. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22961. // was cleared in this mutation.
  22962. func (m *ServerMutation) EdgeCleared(name string) bool {
  22963. switch name {
  22964. case server.EdgeWxs:
  22965. return m.clearedwxs
  22966. }
  22967. return false
  22968. }
  22969. // ClearEdge clears the value of the edge with the given name. It returns an error
  22970. // if that edge is not defined in the schema.
  22971. func (m *ServerMutation) ClearEdge(name string) error {
  22972. switch name {
  22973. }
  22974. return fmt.Errorf("unknown Server unique edge %s", name)
  22975. }
  22976. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22977. // It returns an error if the edge is not defined in the schema.
  22978. func (m *ServerMutation) ResetEdge(name string) error {
  22979. switch name {
  22980. case server.EdgeWxs:
  22981. m.ResetWxs()
  22982. return nil
  22983. }
  22984. return fmt.Errorf("unknown Server edge %s", name)
  22985. }
  22986. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  22987. type SopNodeMutation struct {
  22988. config
  22989. op Op
  22990. typ string
  22991. id *uint64
  22992. created_at *time.Time
  22993. updated_at *time.Time
  22994. status *uint8
  22995. addstatus *int8
  22996. deleted_at *time.Time
  22997. parent_id *uint64
  22998. addparent_id *int64
  22999. name *string
  23000. condition_type *int
  23001. addcondition_type *int
  23002. condition_list *[]string
  23003. appendcondition_list []string
  23004. no_reply_condition *uint64
  23005. addno_reply_condition *int64
  23006. no_reply_unit *string
  23007. action_message *[]custom_types.Action
  23008. appendaction_message []custom_types.Action
  23009. action_label_add *[]uint64
  23010. appendaction_label_add []uint64
  23011. action_label_del *[]uint64
  23012. appendaction_label_del []uint64
  23013. action_forward **custom_types.ActionForward
  23014. clearedFields map[string]struct{}
  23015. sop_stage *uint64
  23016. clearedsop_stage bool
  23017. node_messages map[uint64]struct{}
  23018. removednode_messages map[uint64]struct{}
  23019. clearednode_messages bool
  23020. done bool
  23021. oldValue func(context.Context) (*SopNode, error)
  23022. predicates []predicate.SopNode
  23023. }
  23024. var _ ent.Mutation = (*SopNodeMutation)(nil)
  23025. // sopnodeOption allows management of the mutation configuration using functional options.
  23026. type sopnodeOption func(*SopNodeMutation)
  23027. // newSopNodeMutation creates new mutation for the SopNode entity.
  23028. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  23029. m := &SopNodeMutation{
  23030. config: c,
  23031. op: op,
  23032. typ: TypeSopNode,
  23033. clearedFields: make(map[string]struct{}),
  23034. }
  23035. for _, opt := range opts {
  23036. opt(m)
  23037. }
  23038. return m
  23039. }
  23040. // withSopNodeID sets the ID field of the mutation.
  23041. func withSopNodeID(id uint64) sopnodeOption {
  23042. return func(m *SopNodeMutation) {
  23043. var (
  23044. err error
  23045. once sync.Once
  23046. value *SopNode
  23047. )
  23048. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  23049. once.Do(func() {
  23050. if m.done {
  23051. err = errors.New("querying old values post mutation is not allowed")
  23052. } else {
  23053. value, err = m.Client().SopNode.Get(ctx, id)
  23054. }
  23055. })
  23056. return value, err
  23057. }
  23058. m.id = &id
  23059. }
  23060. }
  23061. // withSopNode sets the old SopNode of the mutation.
  23062. func withSopNode(node *SopNode) sopnodeOption {
  23063. return func(m *SopNodeMutation) {
  23064. m.oldValue = func(context.Context) (*SopNode, error) {
  23065. return node, nil
  23066. }
  23067. m.id = &node.ID
  23068. }
  23069. }
  23070. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23071. // executed in a transaction (ent.Tx), a transactional client is returned.
  23072. func (m SopNodeMutation) Client() *Client {
  23073. client := &Client{config: m.config}
  23074. client.init()
  23075. return client
  23076. }
  23077. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23078. // it returns an error otherwise.
  23079. func (m SopNodeMutation) Tx() (*Tx, error) {
  23080. if _, ok := m.driver.(*txDriver); !ok {
  23081. return nil, errors.New("ent: mutation is not running in a transaction")
  23082. }
  23083. tx := &Tx{config: m.config}
  23084. tx.init()
  23085. return tx, nil
  23086. }
  23087. // SetID sets the value of the id field. Note that this
  23088. // operation is only accepted on creation of SopNode entities.
  23089. func (m *SopNodeMutation) SetID(id uint64) {
  23090. m.id = &id
  23091. }
  23092. // ID returns the ID value in the mutation. Note that the ID is only available
  23093. // if it was provided to the builder or after it was returned from the database.
  23094. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23095. if m.id == nil {
  23096. return
  23097. }
  23098. return *m.id, true
  23099. }
  23100. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23101. // That means, if the mutation is applied within a transaction with an isolation level such
  23102. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23103. // or updated by the mutation.
  23104. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23105. switch {
  23106. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23107. id, exists := m.ID()
  23108. if exists {
  23109. return []uint64{id}, nil
  23110. }
  23111. fallthrough
  23112. case m.op.Is(OpUpdate | OpDelete):
  23113. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23114. default:
  23115. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23116. }
  23117. }
  23118. // SetCreatedAt sets the "created_at" field.
  23119. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23120. m.created_at = &t
  23121. }
  23122. // CreatedAt returns the value of the "created_at" field in the mutation.
  23123. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23124. v := m.created_at
  23125. if v == nil {
  23126. return
  23127. }
  23128. return *v, true
  23129. }
  23130. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23131. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23133. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23134. if !m.op.Is(OpUpdateOne) {
  23135. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23136. }
  23137. if m.id == nil || m.oldValue == nil {
  23138. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23139. }
  23140. oldValue, err := m.oldValue(ctx)
  23141. if err != nil {
  23142. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23143. }
  23144. return oldValue.CreatedAt, nil
  23145. }
  23146. // ResetCreatedAt resets all changes to the "created_at" field.
  23147. func (m *SopNodeMutation) ResetCreatedAt() {
  23148. m.created_at = nil
  23149. }
  23150. // SetUpdatedAt sets the "updated_at" field.
  23151. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23152. m.updated_at = &t
  23153. }
  23154. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23155. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23156. v := m.updated_at
  23157. if v == nil {
  23158. return
  23159. }
  23160. return *v, true
  23161. }
  23162. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23163. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23165. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23166. if !m.op.Is(OpUpdateOne) {
  23167. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23168. }
  23169. if m.id == nil || m.oldValue == nil {
  23170. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23171. }
  23172. oldValue, err := m.oldValue(ctx)
  23173. if err != nil {
  23174. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23175. }
  23176. return oldValue.UpdatedAt, nil
  23177. }
  23178. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23179. func (m *SopNodeMutation) ResetUpdatedAt() {
  23180. m.updated_at = nil
  23181. }
  23182. // SetStatus sets the "status" field.
  23183. func (m *SopNodeMutation) SetStatus(u uint8) {
  23184. m.status = &u
  23185. m.addstatus = nil
  23186. }
  23187. // Status returns the value of the "status" field in the mutation.
  23188. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23189. v := m.status
  23190. if v == nil {
  23191. return
  23192. }
  23193. return *v, true
  23194. }
  23195. // OldStatus returns the old "status" field's value of the SopNode entity.
  23196. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23198. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23199. if !m.op.Is(OpUpdateOne) {
  23200. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23201. }
  23202. if m.id == nil || m.oldValue == nil {
  23203. return v, errors.New("OldStatus requires an ID field in the mutation")
  23204. }
  23205. oldValue, err := m.oldValue(ctx)
  23206. if err != nil {
  23207. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23208. }
  23209. return oldValue.Status, nil
  23210. }
  23211. // AddStatus adds u to the "status" field.
  23212. func (m *SopNodeMutation) AddStatus(u int8) {
  23213. if m.addstatus != nil {
  23214. *m.addstatus += u
  23215. } else {
  23216. m.addstatus = &u
  23217. }
  23218. }
  23219. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23220. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23221. v := m.addstatus
  23222. if v == nil {
  23223. return
  23224. }
  23225. return *v, true
  23226. }
  23227. // ClearStatus clears the value of the "status" field.
  23228. func (m *SopNodeMutation) ClearStatus() {
  23229. m.status = nil
  23230. m.addstatus = nil
  23231. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23232. }
  23233. // StatusCleared returns if the "status" field was cleared in this mutation.
  23234. func (m *SopNodeMutation) StatusCleared() bool {
  23235. _, ok := m.clearedFields[sopnode.FieldStatus]
  23236. return ok
  23237. }
  23238. // ResetStatus resets all changes to the "status" field.
  23239. func (m *SopNodeMutation) ResetStatus() {
  23240. m.status = nil
  23241. m.addstatus = nil
  23242. delete(m.clearedFields, sopnode.FieldStatus)
  23243. }
  23244. // SetDeletedAt sets the "deleted_at" field.
  23245. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23246. m.deleted_at = &t
  23247. }
  23248. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23249. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23250. v := m.deleted_at
  23251. if v == nil {
  23252. return
  23253. }
  23254. return *v, true
  23255. }
  23256. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23257. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23259. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23260. if !m.op.Is(OpUpdateOne) {
  23261. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23262. }
  23263. if m.id == nil || m.oldValue == nil {
  23264. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23265. }
  23266. oldValue, err := m.oldValue(ctx)
  23267. if err != nil {
  23268. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23269. }
  23270. return oldValue.DeletedAt, nil
  23271. }
  23272. // ClearDeletedAt clears the value of the "deleted_at" field.
  23273. func (m *SopNodeMutation) ClearDeletedAt() {
  23274. m.deleted_at = nil
  23275. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23276. }
  23277. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23278. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23279. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23280. return ok
  23281. }
  23282. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23283. func (m *SopNodeMutation) ResetDeletedAt() {
  23284. m.deleted_at = nil
  23285. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23286. }
  23287. // SetStageID sets the "stage_id" field.
  23288. func (m *SopNodeMutation) SetStageID(u uint64) {
  23289. m.sop_stage = &u
  23290. }
  23291. // StageID returns the value of the "stage_id" field in the mutation.
  23292. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23293. v := m.sop_stage
  23294. if v == nil {
  23295. return
  23296. }
  23297. return *v, true
  23298. }
  23299. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23300. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23302. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23303. if !m.op.Is(OpUpdateOne) {
  23304. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23305. }
  23306. if m.id == nil || m.oldValue == nil {
  23307. return v, errors.New("OldStageID requires an ID field in the mutation")
  23308. }
  23309. oldValue, err := m.oldValue(ctx)
  23310. if err != nil {
  23311. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23312. }
  23313. return oldValue.StageID, nil
  23314. }
  23315. // ResetStageID resets all changes to the "stage_id" field.
  23316. func (m *SopNodeMutation) ResetStageID() {
  23317. m.sop_stage = nil
  23318. }
  23319. // SetParentID sets the "parent_id" field.
  23320. func (m *SopNodeMutation) SetParentID(u uint64) {
  23321. m.parent_id = &u
  23322. m.addparent_id = nil
  23323. }
  23324. // ParentID returns the value of the "parent_id" field in the mutation.
  23325. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23326. v := m.parent_id
  23327. if v == nil {
  23328. return
  23329. }
  23330. return *v, true
  23331. }
  23332. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23333. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23335. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23336. if !m.op.Is(OpUpdateOne) {
  23337. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23338. }
  23339. if m.id == nil || m.oldValue == nil {
  23340. return v, errors.New("OldParentID requires an ID field in the mutation")
  23341. }
  23342. oldValue, err := m.oldValue(ctx)
  23343. if err != nil {
  23344. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23345. }
  23346. return oldValue.ParentID, nil
  23347. }
  23348. // AddParentID adds u to the "parent_id" field.
  23349. func (m *SopNodeMutation) AddParentID(u int64) {
  23350. if m.addparent_id != nil {
  23351. *m.addparent_id += u
  23352. } else {
  23353. m.addparent_id = &u
  23354. }
  23355. }
  23356. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23357. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23358. v := m.addparent_id
  23359. if v == nil {
  23360. return
  23361. }
  23362. return *v, true
  23363. }
  23364. // ResetParentID resets all changes to the "parent_id" field.
  23365. func (m *SopNodeMutation) ResetParentID() {
  23366. m.parent_id = nil
  23367. m.addparent_id = nil
  23368. }
  23369. // SetName sets the "name" field.
  23370. func (m *SopNodeMutation) SetName(s string) {
  23371. m.name = &s
  23372. }
  23373. // Name returns the value of the "name" field in the mutation.
  23374. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23375. v := m.name
  23376. if v == nil {
  23377. return
  23378. }
  23379. return *v, true
  23380. }
  23381. // OldName returns the old "name" field's value of the SopNode entity.
  23382. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23384. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23385. if !m.op.Is(OpUpdateOne) {
  23386. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23387. }
  23388. if m.id == nil || m.oldValue == nil {
  23389. return v, errors.New("OldName requires an ID field in the mutation")
  23390. }
  23391. oldValue, err := m.oldValue(ctx)
  23392. if err != nil {
  23393. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23394. }
  23395. return oldValue.Name, nil
  23396. }
  23397. // ResetName resets all changes to the "name" field.
  23398. func (m *SopNodeMutation) ResetName() {
  23399. m.name = nil
  23400. }
  23401. // SetConditionType sets the "condition_type" field.
  23402. func (m *SopNodeMutation) SetConditionType(i int) {
  23403. m.condition_type = &i
  23404. m.addcondition_type = nil
  23405. }
  23406. // ConditionType returns the value of the "condition_type" field in the mutation.
  23407. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23408. v := m.condition_type
  23409. if v == nil {
  23410. return
  23411. }
  23412. return *v, true
  23413. }
  23414. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23415. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23417. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23418. if !m.op.Is(OpUpdateOne) {
  23419. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23420. }
  23421. if m.id == nil || m.oldValue == nil {
  23422. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23423. }
  23424. oldValue, err := m.oldValue(ctx)
  23425. if err != nil {
  23426. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23427. }
  23428. return oldValue.ConditionType, nil
  23429. }
  23430. // AddConditionType adds i to the "condition_type" field.
  23431. func (m *SopNodeMutation) AddConditionType(i int) {
  23432. if m.addcondition_type != nil {
  23433. *m.addcondition_type += i
  23434. } else {
  23435. m.addcondition_type = &i
  23436. }
  23437. }
  23438. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23439. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23440. v := m.addcondition_type
  23441. if v == nil {
  23442. return
  23443. }
  23444. return *v, true
  23445. }
  23446. // ResetConditionType resets all changes to the "condition_type" field.
  23447. func (m *SopNodeMutation) ResetConditionType() {
  23448. m.condition_type = nil
  23449. m.addcondition_type = nil
  23450. }
  23451. // SetConditionList sets the "condition_list" field.
  23452. func (m *SopNodeMutation) SetConditionList(s []string) {
  23453. m.condition_list = &s
  23454. m.appendcondition_list = nil
  23455. }
  23456. // ConditionList returns the value of the "condition_list" field in the mutation.
  23457. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23458. v := m.condition_list
  23459. if v == nil {
  23460. return
  23461. }
  23462. return *v, true
  23463. }
  23464. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23465. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23467. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23468. if !m.op.Is(OpUpdateOne) {
  23469. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23470. }
  23471. if m.id == nil || m.oldValue == nil {
  23472. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23473. }
  23474. oldValue, err := m.oldValue(ctx)
  23475. if err != nil {
  23476. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23477. }
  23478. return oldValue.ConditionList, nil
  23479. }
  23480. // AppendConditionList adds s to the "condition_list" field.
  23481. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23482. m.appendcondition_list = append(m.appendcondition_list, s...)
  23483. }
  23484. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23485. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23486. if len(m.appendcondition_list) == 0 {
  23487. return nil, false
  23488. }
  23489. return m.appendcondition_list, true
  23490. }
  23491. // ClearConditionList clears the value of the "condition_list" field.
  23492. func (m *SopNodeMutation) ClearConditionList() {
  23493. m.condition_list = nil
  23494. m.appendcondition_list = nil
  23495. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23496. }
  23497. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23498. func (m *SopNodeMutation) ConditionListCleared() bool {
  23499. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23500. return ok
  23501. }
  23502. // ResetConditionList resets all changes to the "condition_list" field.
  23503. func (m *SopNodeMutation) ResetConditionList() {
  23504. m.condition_list = nil
  23505. m.appendcondition_list = nil
  23506. delete(m.clearedFields, sopnode.FieldConditionList)
  23507. }
  23508. // SetNoReplyCondition sets the "no_reply_condition" field.
  23509. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23510. m.no_reply_condition = &u
  23511. m.addno_reply_condition = nil
  23512. }
  23513. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23514. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23515. v := m.no_reply_condition
  23516. if v == nil {
  23517. return
  23518. }
  23519. return *v, true
  23520. }
  23521. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23522. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23524. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23525. if !m.op.Is(OpUpdateOne) {
  23526. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23527. }
  23528. if m.id == nil || m.oldValue == nil {
  23529. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23530. }
  23531. oldValue, err := m.oldValue(ctx)
  23532. if err != nil {
  23533. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23534. }
  23535. return oldValue.NoReplyCondition, nil
  23536. }
  23537. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23538. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23539. if m.addno_reply_condition != nil {
  23540. *m.addno_reply_condition += u
  23541. } else {
  23542. m.addno_reply_condition = &u
  23543. }
  23544. }
  23545. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23546. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23547. v := m.addno_reply_condition
  23548. if v == nil {
  23549. return
  23550. }
  23551. return *v, true
  23552. }
  23553. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23554. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23555. m.no_reply_condition = nil
  23556. m.addno_reply_condition = nil
  23557. }
  23558. // SetNoReplyUnit sets the "no_reply_unit" field.
  23559. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23560. m.no_reply_unit = &s
  23561. }
  23562. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23563. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23564. v := m.no_reply_unit
  23565. if v == nil {
  23566. return
  23567. }
  23568. return *v, true
  23569. }
  23570. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  23571. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23573. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23574. if !m.op.Is(OpUpdateOne) {
  23575. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23576. }
  23577. if m.id == nil || m.oldValue == nil {
  23578. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  23579. }
  23580. oldValue, err := m.oldValue(ctx)
  23581. if err != nil {
  23582. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  23583. }
  23584. return oldValue.NoReplyUnit, nil
  23585. }
  23586. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23587. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23588. m.no_reply_unit = nil
  23589. }
  23590. // SetActionMessage sets the "action_message" field.
  23591. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23592. m.action_message = &ct
  23593. m.appendaction_message = nil
  23594. }
  23595. // ActionMessage returns the value of the "action_message" field in the mutation.
  23596. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23597. v := m.action_message
  23598. if v == nil {
  23599. return
  23600. }
  23601. return *v, true
  23602. }
  23603. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23604. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23606. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23607. if !m.op.Is(OpUpdateOne) {
  23608. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23609. }
  23610. if m.id == nil || m.oldValue == nil {
  23611. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23612. }
  23613. oldValue, err := m.oldValue(ctx)
  23614. if err != nil {
  23615. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23616. }
  23617. return oldValue.ActionMessage, nil
  23618. }
  23619. // AppendActionMessage adds ct to the "action_message" field.
  23620. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23621. m.appendaction_message = append(m.appendaction_message, ct...)
  23622. }
  23623. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23624. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23625. if len(m.appendaction_message) == 0 {
  23626. return nil, false
  23627. }
  23628. return m.appendaction_message, true
  23629. }
  23630. // ClearActionMessage clears the value of the "action_message" field.
  23631. func (m *SopNodeMutation) ClearActionMessage() {
  23632. m.action_message = nil
  23633. m.appendaction_message = nil
  23634. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23635. }
  23636. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23637. func (m *SopNodeMutation) ActionMessageCleared() bool {
  23638. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  23639. return ok
  23640. }
  23641. // ResetActionMessage resets all changes to the "action_message" field.
  23642. func (m *SopNodeMutation) ResetActionMessage() {
  23643. m.action_message = nil
  23644. m.appendaction_message = nil
  23645. delete(m.clearedFields, sopnode.FieldActionMessage)
  23646. }
  23647. // SetActionLabelAdd sets the "action_label_add" field.
  23648. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  23649. m.action_label_add = &u
  23650. m.appendaction_label_add = nil
  23651. }
  23652. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23653. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23654. v := m.action_label_add
  23655. if v == nil {
  23656. return
  23657. }
  23658. return *v, true
  23659. }
  23660. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  23661. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23663. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23664. if !m.op.Is(OpUpdateOne) {
  23665. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23666. }
  23667. if m.id == nil || m.oldValue == nil {
  23668. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23669. }
  23670. oldValue, err := m.oldValue(ctx)
  23671. if err != nil {
  23672. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23673. }
  23674. return oldValue.ActionLabelAdd, nil
  23675. }
  23676. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23677. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  23678. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23679. }
  23680. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23681. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23682. if len(m.appendaction_label_add) == 0 {
  23683. return nil, false
  23684. }
  23685. return m.appendaction_label_add, true
  23686. }
  23687. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23688. func (m *SopNodeMutation) ClearActionLabelAdd() {
  23689. m.action_label_add = nil
  23690. m.appendaction_label_add = nil
  23691. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  23692. }
  23693. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23694. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  23695. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  23696. return ok
  23697. }
  23698. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23699. func (m *SopNodeMutation) ResetActionLabelAdd() {
  23700. m.action_label_add = nil
  23701. m.appendaction_label_add = nil
  23702. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  23703. }
  23704. // SetActionLabelDel sets the "action_label_del" field.
  23705. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  23706. m.action_label_del = &u
  23707. m.appendaction_label_del = nil
  23708. }
  23709. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23710. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  23711. v := m.action_label_del
  23712. if v == nil {
  23713. return
  23714. }
  23715. return *v, true
  23716. }
  23717. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  23718. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23720. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23721. if !m.op.Is(OpUpdateOne) {
  23722. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23723. }
  23724. if m.id == nil || m.oldValue == nil {
  23725. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23726. }
  23727. oldValue, err := m.oldValue(ctx)
  23728. if err != nil {
  23729. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23730. }
  23731. return oldValue.ActionLabelDel, nil
  23732. }
  23733. // AppendActionLabelDel adds u to the "action_label_del" field.
  23734. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  23735. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23736. }
  23737. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23738. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23739. if len(m.appendaction_label_del) == 0 {
  23740. return nil, false
  23741. }
  23742. return m.appendaction_label_del, true
  23743. }
  23744. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23745. func (m *SopNodeMutation) ClearActionLabelDel() {
  23746. m.action_label_del = nil
  23747. m.appendaction_label_del = nil
  23748. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  23749. }
  23750. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23751. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  23752. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  23753. return ok
  23754. }
  23755. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23756. func (m *SopNodeMutation) ResetActionLabelDel() {
  23757. m.action_label_del = nil
  23758. m.appendaction_label_del = nil
  23759. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  23760. }
  23761. // SetActionForward sets the "action_forward" field.
  23762. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23763. m.action_forward = &ctf
  23764. }
  23765. // ActionForward returns the value of the "action_forward" field in the mutation.
  23766. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23767. v := m.action_forward
  23768. if v == nil {
  23769. return
  23770. }
  23771. return *v, true
  23772. }
  23773. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  23774. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23776. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23777. if !m.op.Is(OpUpdateOne) {
  23778. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23779. }
  23780. if m.id == nil || m.oldValue == nil {
  23781. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23782. }
  23783. oldValue, err := m.oldValue(ctx)
  23784. if err != nil {
  23785. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23786. }
  23787. return oldValue.ActionForward, nil
  23788. }
  23789. // ClearActionForward clears the value of the "action_forward" field.
  23790. func (m *SopNodeMutation) ClearActionForward() {
  23791. m.action_forward = nil
  23792. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  23793. }
  23794. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23795. func (m *SopNodeMutation) ActionForwardCleared() bool {
  23796. _, ok := m.clearedFields[sopnode.FieldActionForward]
  23797. return ok
  23798. }
  23799. // ResetActionForward resets all changes to the "action_forward" field.
  23800. func (m *SopNodeMutation) ResetActionForward() {
  23801. m.action_forward = nil
  23802. delete(m.clearedFields, sopnode.FieldActionForward)
  23803. }
  23804. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23805. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  23806. m.sop_stage = &id
  23807. }
  23808. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23809. func (m *SopNodeMutation) ClearSopStage() {
  23810. m.clearedsop_stage = true
  23811. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  23812. }
  23813. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23814. func (m *SopNodeMutation) SopStageCleared() bool {
  23815. return m.clearedsop_stage
  23816. }
  23817. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23818. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  23819. if m.sop_stage != nil {
  23820. return *m.sop_stage, true
  23821. }
  23822. return
  23823. }
  23824. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23825. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23826. // SopStageID instead. It exists only for internal usage by the builders.
  23827. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  23828. if id := m.sop_stage; id != nil {
  23829. ids = append(ids, *id)
  23830. }
  23831. return
  23832. }
  23833. // ResetSopStage resets all changes to the "sop_stage" edge.
  23834. func (m *SopNodeMutation) ResetSopStage() {
  23835. m.sop_stage = nil
  23836. m.clearedsop_stage = false
  23837. }
  23838. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  23839. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  23840. if m.node_messages == nil {
  23841. m.node_messages = make(map[uint64]struct{})
  23842. }
  23843. for i := range ids {
  23844. m.node_messages[ids[i]] = struct{}{}
  23845. }
  23846. }
  23847. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  23848. func (m *SopNodeMutation) ClearNodeMessages() {
  23849. m.clearednode_messages = true
  23850. }
  23851. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  23852. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  23853. return m.clearednode_messages
  23854. }
  23855. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  23856. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  23857. if m.removednode_messages == nil {
  23858. m.removednode_messages = make(map[uint64]struct{})
  23859. }
  23860. for i := range ids {
  23861. delete(m.node_messages, ids[i])
  23862. m.removednode_messages[ids[i]] = struct{}{}
  23863. }
  23864. }
  23865. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  23866. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  23867. for id := range m.removednode_messages {
  23868. ids = append(ids, id)
  23869. }
  23870. return
  23871. }
  23872. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  23873. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  23874. for id := range m.node_messages {
  23875. ids = append(ids, id)
  23876. }
  23877. return
  23878. }
  23879. // ResetNodeMessages resets all changes to the "node_messages" edge.
  23880. func (m *SopNodeMutation) ResetNodeMessages() {
  23881. m.node_messages = nil
  23882. m.clearednode_messages = false
  23883. m.removednode_messages = nil
  23884. }
  23885. // Where appends a list predicates to the SopNodeMutation builder.
  23886. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  23887. m.predicates = append(m.predicates, ps...)
  23888. }
  23889. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  23890. // users can use type-assertion to append predicates that do not depend on any generated package.
  23891. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  23892. p := make([]predicate.SopNode, len(ps))
  23893. for i := range ps {
  23894. p[i] = ps[i]
  23895. }
  23896. m.Where(p...)
  23897. }
  23898. // Op returns the operation name.
  23899. func (m *SopNodeMutation) Op() Op {
  23900. return m.op
  23901. }
  23902. // SetOp allows setting the mutation operation.
  23903. func (m *SopNodeMutation) SetOp(op Op) {
  23904. m.op = op
  23905. }
  23906. // Type returns the node type of this mutation (SopNode).
  23907. func (m *SopNodeMutation) Type() string {
  23908. return m.typ
  23909. }
  23910. // Fields returns all fields that were changed during this mutation. Note that in
  23911. // order to get all numeric fields that were incremented/decremented, call
  23912. // AddedFields().
  23913. func (m *SopNodeMutation) Fields() []string {
  23914. fields := make([]string, 0, 15)
  23915. if m.created_at != nil {
  23916. fields = append(fields, sopnode.FieldCreatedAt)
  23917. }
  23918. if m.updated_at != nil {
  23919. fields = append(fields, sopnode.FieldUpdatedAt)
  23920. }
  23921. if m.status != nil {
  23922. fields = append(fields, sopnode.FieldStatus)
  23923. }
  23924. if m.deleted_at != nil {
  23925. fields = append(fields, sopnode.FieldDeletedAt)
  23926. }
  23927. if m.sop_stage != nil {
  23928. fields = append(fields, sopnode.FieldStageID)
  23929. }
  23930. if m.parent_id != nil {
  23931. fields = append(fields, sopnode.FieldParentID)
  23932. }
  23933. if m.name != nil {
  23934. fields = append(fields, sopnode.FieldName)
  23935. }
  23936. if m.condition_type != nil {
  23937. fields = append(fields, sopnode.FieldConditionType)
  23938. }
  23939. if m.condition_list != nil {
  23940. fields = append(fields, sopnode.FieldConditionList)
  23941. }
  23942. if m.no_reply_condition != nil {
  23943. fields = append(fields, sopnode.FieldNoReplyCondition)
  23944. }
  23945. if m.no_reply_unit != nil {
  23946. fields = append(fields, sopnode.FieldNoReplyUnit)
  23947. }
  23948. if m.action_message != nil {
  23949. fields = append(fields, sopnode.FieldActionMessage)
  23950. }
  23951. if m.action_label_add != nil {
  23952. fields = append(fields, sopnode.FieldActionLabelAdd)
  23953. }
  23954. if m.action_label_del != nil {
  23955. fields = append(fields, sopnode.FieldActionLabelDel)
  23956. }
  23957. if m.action_forward != nil {
  23958. fields = append(fields, sopnode.FieldActionForward)
  23959. }
  23960. return fields
  23961. }
  23962. // Field returns the value of a field with the given name. The second boolean
  23963. // return value indicates that this field was not set, or was not defined in the
  23964. // schema.
  23965. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  23966. switch name {
  23967. case sopnode.FieldCreatedAt:
  23968. return m.CreatedAt()
  23969. case sopnode.FieldUpdatedAt:
  23970. return m.UpdatedAt()
  23971. case sopnode.FieldStatus:
  23972. return m.Status()
  23973. case sopnode.FieldDeletedAt:
  23974. return m.DeletedAt()
  23975. case sopnode.FieldStageID:
  23976. return m.StageID()
  23977. case sopnode.FieldParentID:
  23978. return m.ParentID()
  23979. case sopnode.FieldName:
  23980. return m.Name()
  23981. case sopnode.FieldConditionType:
  23982. return m.ConditionType()
  23983. case sopnode.FieldConditionList:
  23984. return m.ConditionList()
  23985. case sopnode.FieldNoReplyCondition:
  23986. return m.NoReplyCondition()
  23987. case sopnode.FieldNoReplyUnit:
  23988. return m.NoReplyUnit()
  23989. case sopnode.FieldActionMessage:
  23990. return m.ActionMessage()
  23991. case sopnode.FieldActionLabelAdd:
  23992. return m.ActionLabelAdd()
  23993. case sopnode.FieldActionLabelDel:
  23994. return m.ActionLabelDel()
  23995. case sopnode.FieldActionForward:
  23996. return m.ActionForward()
  23997. }
  23998. return nil, false
  23999. }
  24000. // OldField returns the old value of the field from the database. An error is
  24001. // returned if the mutation operation is not UpdateOne, or the query to the
  24002. // database failed.
  24003. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24004. switch name {
  24005. case sopnode.FieldCreatedAt:
  24006. return m.OldCreatedAt(ctx)
  24007. case sopnode.FieldUpdatedAt:
  24008. return m.OldUpdatedAt(ctx)
  24009. case sopnode.FieldStatus:
  24010. return m.OldStatus(ctx)
  24011. case sopnode.FieldDeletedAt:
  24012. return m.OldDeletedAt(ctx)
  24013. case sopnode.FieldStageID:
  24014. return m.OldStageID(ctx)
  24015. case sopnode.FieldParentID:
  24016. return m.OldParentID(ctx)
  24017. case sopnode.FieldName:
  24018. return m.OldName(ctx)
  24019. case sopnode.FieldConditionType:
  24020. return m.OldConditionType(ctx)
  24021. case sopnode.FieldConditionList:
  24022. return m.OldConditionList(ctx)
  24023. case sopnode.FieldNoReplyCondition:
  24024. return m.OldNoReplyCondition(ctx)
  24025. case sopnode.FieldNoReplyUnit:
  24026. return m.OldNoReplyUnit(ctx)
  24027. case sopnode.FieldActionMessage:
  24028. return m.OldActionMessage(ctx)
  24029. case sopnode.FieldActionLabelAdd:
  24030. return m.OldActionLabelAdd(ctx)
  24031. case sopnode.FieldActionLabelDel:
  24032. return m.OldActionLabelDel(ctx)
  24033. case sopnode.FieldActionForward:
  24034. return m.OldActionForward(ctx)
  24035. }
  24036. return nil, fmt.Errorf("unknown SopNode field %s", name)
  24037. }
  24038. // SetField sets the value of a field with the given name. It returns an error if
  24039. // the field is not defined in the schema, or if the type mismatched the field
  24040. // type.
  24041. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  24042. switch name {
  24043. case sopnode.FieldCreatedAt:
  24044. v, ok := value.(time.Time)
  24045. if !ok {
  24046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24047. }
  24048. m.SetCreatedAt(v)
  24049. return nil
  24050. case sopnode.FieldUpdatedAt:
  24051. v, ok := value.(time.Time)
  24052. if !ok {
  24053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24054. }
  24055. m.SetUpdatedAt(v)
  24056. return nil
  24057. case sopnode.FieldStatus:
  24058. v, ok := value.(uint8)
  24059. if !ok {
  24060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24061. }
  24062. m.SetStatus(v)
  24063. return nil
  24064. case sopnode.FieldDeletedAt:
  24065. v, ok := value.(time.Time)
  24066. if !ok {
  24067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24068. }
  24069. m.SetDeletedAt(v)
  24070. return nil
  24071. case sopnode.FieldStageID:
  24072. v, ok := value.(uint64)
  24073. if !ok {
  24074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24075. }
  24076. m.SetStageID(v)
  24077. return nil
  24078. case sopnode.FieldParentID:
  24079. v, ok := value.(uint64)
  24080. if !ok {
  24081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24082. }
  24083. m.SetParentID(v)
  24084. return nil
  24085. case sopnode.FieldName:
  24086. v, ok := value.(string)
  24087. if !ok {
  24088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24089. }
  24090. m.SetName(v)
  24091. return nil
  24092. case sopnode.FieldConditionType:
  24093. v, ok := value.(int)
  24094. if !ok {
  24095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24096. }
  24097. m.SetConditionType(v)
  24098. return nil
  24099. case sopnode.FieldConditionList:
  24100. v, ok := value.([]string)
  24101. if !ok {
  24102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24103. }
  24104. m.SetConditionList(v)
  24105. return nil
  24106. case sopnode.FieldNoReplyCondition:
  24107. v, ok := value.(uint64)
  24108. if !ok {
  24109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24110. }
  24111. m.SetNoReplyCondition(v)
  24112. return nil
  24113. case sopnode.FieldNoReplyUnit:
  24114. v, ok := value.(string)
  24115. if !ok {
  24116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24117. }
  24118. m.SetNoReplyUnit(v)
  24119. return nil
  24120. case sopnode.FieldActionMessage:
  24121. v, ok := value.([]custom_types.Action)
  24122. if !ok {
  24123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24124. }
  24125. m.SetActionMessage(v)
  24126. return nil
  24127. case sopnode.FieldActionLabelAdd:
  24128. v, ok := value.([]uint64)
  24129. if !ok {
  24130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24131. }
  24132. m.SetActionLabelAdd(v)
  24133. return nil
  24134. case sopnode.FieldActionLabelDel:
  24135. v, ok := value.([]uint64)
  24136. if !ok {
  24137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24138. }
  24139. m.SetActionLabelDel(v)
  24140. return nil
  24141. case sopnode.FieldActionForward:
  24142. v, ok := value.(*custom_types.ActionForward)
  24143. if !ok {
  24144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24145. }
  24146. m.SetActionForward(v)
  24147. return nil
  24148. }
  24149. return fmt.Errorf("unknown SopNode field %s", name)
  24150. }
  24151. // AddedFields returns all numeric fields that were incremented/decremented during
  24152. // this mutation.
  24153. func (m *SopNodeMutation) AddedFields() []string {
  24154. var fields []string
  24155. if m.addstatus != nil {
  24156. fields = append(fields, sopnode.FieldStatus)
  24157. }
  24158. if m.addparent_id != nil {
  24159. fields = append(fields, sopnode.FieldParentID)
  24160. }
  24161. if m.addcondition_type != nil {
  24162. fields = append(fields, sopnode.FieldConditionType)
  24163. }
  24164. if m.addno_reply_condition != nil {
  24165. fields = append(fields, sopnode.FieldNoReplyCondition)
  24166. }
  24167. return fields
  24168. }
  24169. // AddedField returns the numeric value that was incremented/decremented on a field
  24170. // with the given name. The second boolean return value indicates that this field
  24171. // was not set, or was not defined in the schema.
  24172. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24173. switch name {
  24174. case sopnode.FieldStatus:
  24175. return m.AddedStatus()
  24176. case sopnode.FieldParentID:
  24177. return m.AddedParentID()
  24178. case sopnode.FieldConditionType:
  24179. return m.AddedConditionType()
  24180. case sopnode.FieldNoReplyCondition:
  24181. return m.AddedNoReplyCondition()
  24182. }
  24183. return nil, false
  24184. }
  24185. // AddField adds the value to the field with the given name. It returns an error if
  24186. // the field is not defined in the schema, or if the type mismatched the field
  24187. // type.
  24188. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24189. switch name {
  24190. case sopnode.FieldStatus:
  24191. v, ok := value.(int8)
  24192. if !ok {
  24193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24194. }
  24195. m.AddStatus(v)
  24196. return nil
  24197. case sopnode.FieldParentID:
  24198. v, ok := value.(int64)
  24199. if !ok {
  24200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24201. }
  24202. m.AddParentID(v)
  24203. return nil
  24204. case sopnode.FieldConditionType:
  24205. v, ok := value.(int)
  24206. if !ok {
  24207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24208. }
  24209. m.AddConditionType(v)
  24210. return nil
  24211. case sopnode.FieldNoReplyCondition:
  24212. v, ok := value.(int64)
  24213. if !ok {
  24214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24215. }
  24216. m.AddNoReplyCondition(v)
  24217. return nil
  24218. }
  24219. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24220. }
  24221. // ClearedFields returns all nullable fields that were cleared during this
  24222. // mutation.
  24223. func (m *SopNodeMutation) ClearedFields() []string {
  24224. var fields []string
  24225. if m.FieldCleared(sopnode.FieldStatus) {
  24226. fields = append(fields, sopnode.FieldStatus)
  24227. }
  24228. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24229. fields = append(fields, sopnode.FieldDeletedAt)
  24230. }
  24231. if m.FieldCleared(sopnode.FieldConditionList) {
  24232. fields = append(fields, sopnode.FieldConditionList)
  24233. }
  24234. if m.FieldCleared(sopnode.FieldActionMessage) {
  24235. fields = append(fields, sopnode.FieldActionMessage)
  24236. }
  24237. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24238. fields = append(fields, sopnode.FieldActionLabelAdd)
  24239. }
  24240. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24241. fields = append(fields, sopnode.FieldActionLabelDel)
  24242. }
  24243. if m.FieldCleared(sopnode.FieldActionForward) {
  24244. fields = append(fields, sopnode.FieldActionForward)
  24245. }
  24246. return fields
  24247. }
  24248. // FieldCleared returns a boolean indicating if a field with the given name was
  24249. // cleared in this mutation.
  24250. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24251. _, ok := m.clearedFields[name]
  24252. return ok
  24253. }
  24254. // ClearField clears the value of the field with the given name. It returns an
  24255. // error if the field is not defined in the schema.
  24256. func (m *SopNodeMutation) ClearField(name string) error {
  24257. switch name {
  24258. case sopnode.FieldStatus:
  24259. m.ClearStatus()
  24260. return nil
  24261. case sopnode.FieldDeletedAt:
  24262. m.ClearDeletedAt()
  24263. return nil
  24264. case sopnode.FieldConditionList:
  24265. m.ClearConditionList()
  24266. return nil
  24267. case sopnode.FieldActionMessage:
  24268. m.ClearActionMessage()
  24269. return nil
  24270. case sopnode.FieldActionLabelAdd:
  24271. m.ClearActionLabelAdd()
  24272. return nil
  24273. case sopnode.FieldActionLabelDel:
  24274. m.ClearActionLabelDel()
  24275. return nil
  24276. case sopnode.FieldActionForward:
  24277. m.ClearActionForward()
  24278. return nil
  24279. }
  24280. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24281. }
  24282. // ResetField resets all changes in the mutation for the field with the given name.
  24283. // It returns an error if the field is not defined in the schema.
  24284. func (m *SopNodeMutation) ResetField(name string) error {
  24285. switch name {
  24286. case sopnode.FieldCreatedAt:
  24287. m.ResetCreatedAt()
  24288. return nil
  24289. case sopnode.FieldUpdatedAt:
  24290. m.ResetUpdatedAt()
  24291. return nil
  24292. case sopnode.FieldStatus:
  24293. m.ResetStatus()
  24294. return nil
  24295. case sopnode.FieldDeletedAt:
  24296. m.ResetDeletedAt()
  24297. return nil
  24298. case sopnode.FieldStageID:
  24299. m.ResetStageID()
  24300. return nil
  24301. case sopnode.FieldParentID:
  24302. m.ResetParentID()
  24303. return nil
  24304. case sopnode.FieldName:
  24305. m.ResetName()
  24306. return nil
  24307. case sopnode.FieldConditionType:
  24308. m.ResetConditionType()
  24309. return nil
  24310. case sopnode.FieldConditionList:
  24311. m.ResetConditionList()
  24312. return nil
  24313. case sopnode.FieldNoReplyCondition:
  24314. m.ResetNoReplyCondition()
  24315. return nil
  24316. case sopnode.FieldNoReplyUnit:
  24317. m.ResetNoReplyUnit()
  24318. return nil
  24319. case sopnode.FieldActionMessage:
  24320. m.ResetActionMessage()
  24321. return nil
  24322. case sopnode.FieldActionLabelAdd:
  24323. m.ResetActionLabelAdd()
  24324. return nil
  24325. case sopnode.FieldActionLabelDel:
  24326. m.ResetActionLabelDel()
  24327. return nil
  24328. case sopnode.FieldActionForward:
  24329. m.ResetActionForward()
  24330. return nil
  24331. }
  24332. return fmt.Errorf("unknown SopNode field %s", name)
  24333. }
  24334. // AddedEdges returns all edge names that were set/added in this mutation.
  24335. func (m *SopNodeMutation) AddedEdges() []string {
  24336. edges := make([]string, 0, 2)
  24337. if m.sop_stage != nil {
  24338. edges = append(edges, sopnode.EdgeSopStage)
  24339. }
  24340. if m.node_messages != nil {
  24341. edges = append(edges, sopnode.EdgeNodeMessages)
  24342. }
  24343. return edges
  24344. }
  24345. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24346. // name in this mutation.
  24347. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24348. switch name {
  24349. case sopnode.EdgeSopStage:
  24350. if id := m.sop_stage; id != nil {
  24351. return []ent.Value{*id}
  24352. }
  24353. case sopnode.EdgeNodeMessages:
  24354. ids := make([]ent.Value, 0, len(m.node_messages))
  24355. for id := range m.node_messages {
  24356. ids = append(ids, id)
  24357. }
  24358. return ids
  24359. }
  24360. return nil
  24361. }
  24362. // RemovedEdges returns all edge names that were removed in this mutation.
  24363. func (m *SopNodeMutation) RemovedEdges() []string {
  24364. edges := make([]string, 0, 2)
  24365. if m.removednode_messages != nil {
  24366. edges = append(edges, sopnode.EdgeNodeMessages)
  24367. }
  24368. return edges
  24369. }
  24370. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24371. // the given name in this mutation.
  24372. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24373. switch name {
  24374. case sopnode.EdgeNodeMessages:
  24375. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24376. for id := range m.removednode_messages {
  24377. ids = append(ids, id)
  24378. }
  24379. return ids
  24380. }
  24381. return nil
  24382. }
  24383. // ClearedEdges returns all edge names that were cleared in this mutation.
  24384. func (m *SopNodeMutation) ClearedEdges() []string {
  24385. edges := make([]string, 0, 2)
  24386. if m.clearedsop_stage {
  24387. edges = append(edges, sopnode.EdgeSopStage)
  24388. }
  24389. if m.clearednode_messages {
  24390. edges = append(edges, sopnode.EdgeNodeMessages)
  24391. }
  24392. return edges
  24393. }
  24394. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24395. // was cleared in this mutation.
  24396. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24397. switch name {
  24398. case sopnode.EdgeSopStage:
  24399. return m.clearedsop_stage
  24400. case sopnode.EdgeNodeMessages:
  24401. return m.clearednode_messages
  24402. }
  24403. return false
  24404. }
  24405. // ClearEdge clears the value of the edge with the given name. It returns an error
  24406. // if that edge is not defined in the schema.
  24407. func (m *SopNodeMutation) ClearEdge(name string) error {
  24408. switch name {
  24409. case sopnode.EdgeSopStage:
  24410. m.ClearSopStage()
  24411. return nil
  24412. }
  24413. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24414. }
  24415. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24416. // It returns an error if the edge is not defined in the schema.
  24417. func (m *SopNodeMutation) ResetEdge(name string) error {
  24418. switch name {
  24419. case sopnode.EdgeSopStage:
  24420. m.ResetSopStage()
  24421. return nil
  24422. case sopnode.EdgeNodeMessages:
  24423. m.ResetNodeMessages()
  24424. return nil
  24425. }
  24426. return fmt.Errorf("unknown SopNode edge %s", name)
  24427. }
  24428. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24429. type SopStageMutation struct {
  24430. config
  24431. op Op
  24432. typ string
  24433. id *uint64
  24434. created_at *time.Time
  24435. updated_at *time.Time
  24436. status *uint8
  24437. addstatus *int8
  24438. deleted_at *time.Time
  24439. name *string
  24440. condition_type *int
  24441. addcondition_type *int
  24442. condition_operator *int
  24443. addcondition_operator *int
  24444. condition_list *[]custom_types.Condition
  24445. appendcondition_list []custom_types.Condition
  24446. action_message *[]custom_types.Action
  24447. appendaction_message []custom_types.Action
  24448. action_label_add *[]uint64
  24449. appendaction_label_add []uint64
  24450. action_label_del *[]uint64
  24451. appendaction_label_del []uint64
  24452. action_forward **custom_types.ActionForward
  24453. index_sort *int
  24454. addindex_sort *int
  24455. clearedFields map[string]struct{}
  24456. sop_task *uint64
  24457. clearedsop_task bool
  24458. stage_nodes map[uint64]struct{}
  24459. removedstage_nodes map[uint64]struct{}
  24460. clearedstage_nodes bool
  24461. stage_messages map[uint64]struct{}
  24462. removedstage_messages map[uint64]struct{}
  24463. clearedstage_messages bool
  24464. done bool
  24465. oldValue func(context.Context) (*SopStage, error)
  24466. predicates []predicate.SopStage
  24467. }
  24468. var _ ent.Mutation = (*SopStageMutation)(nil)
  24469. // sopstageOption allows management of the mutation configuration using functional options.
  24470. type sopstageOption func(*SopStageMutation)
  24471. // newSopStageMutation creates new mutation for the SopStage entity.
  24472. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24473. m := &SopStageMutation{
  24474. config: c,
  24475. op: op,
  24476. typ: TypeSopStage,
  24477. clearedFields: make(map[string]struct{}),
  24478. }
  24479. for _, opt := range opts {
  24480. opt(m)
  24481. }
  24482. return m
  24483. }
  24484. // withSopStageID sets the ID field of the mutation.
  24485. func withSopStageID(id uint64) sopstageOption {
  24486. return func(m *SopStageMutation) {
  24487. var (
  24488. err error
  24489. once sync.Once
  24490. value *SopStage
  24491. )
  24492. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24493. once.Do(func() {
  24494. if m.done {
  24495. err = errors.New("querying old values post mutation is not allowed")
  24496. } else {
  24497. value, err = m.Client().SopStage.Get(ctx, id)
  24498. }
  24499. })
  24500. return value, err
  24501. }
  24502. m.id = &id
  24503. }
  24504. }
  24505. // withSopStage sets the old SopStage of the mutation.
  24506. func withSopStage(node *SopStage) sopstageOption {
  24507. return func(m *SopStageMutation) {
  24508. m.oldValue = func(context.Context) (*SopStage, error) {
  24509. return node, nil
  24510. }
  24511. m.id = &node.ID
  24512. }
  24513. }
  24514. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24515. // executed in a transaction (ent.Tx), a transactional client is returned.
  24516. func (m SopStageMutation) Client() *Client {
  24517. client := &Client{config: m.config}
  24518. client.init()
  24519. return client
  24520. }
  24521. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24522. // it returns an error otherwise.
  24523. func (m SopStageMutation) Tx() (*Tx, error) {
  24524. if _, ok := m.driver.(*txDriver); !ok {
  24525. return nil, errors.New("ent: mutation is not running in a transaction")
  24526. }
  24527. tx := &Tx{config: m.config}
  24528. tx.init()
  24529. return tx, nil
  24530. }
  24531. // SetID sets the value of the id field. Note that this
  24532. // operation is only accepted on creation of SopStage entities.
  24533. func (m *SopStageMutation) SetID(id uint64) {
  24534. m.id = &id
  24535. }
  24536. // ID returns the ID value in the mutation. Note that the ID is only available
  24537. // if it was provided to the builder or after it was returned from the database.
  24538. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24539. if m.id == nil {
  24540. return
  24541. }
  24542. return *m.id, true
  24543. }
  24544. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24545. // That means, if the mutation is applied within a transaction with an isolation level such
  24546. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24547. // or updated by the mutation.
  24548. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24549. switch {
  24550. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24551. id, exists := m.ID()
  24552. if exists {
  24553. return []uint64{id}, nil
  24554. }
  24555. fallthrough
  24556. case m.op.Is(OpUpdate | OpDelete):
  24557. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24558. default:
  24559. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24560. }
  24561. }
  24562. // SetCreatedAt sets the "created_at" field.
  24563. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24564. m.created_at = &t
  24565. }
  24566. // CreatedAt returns the value of the "created_at" field in the mutation.
  24567. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24568. v := m.created_at
  24569. if v == nil {
  24570. return
  24571. }
  24572. return *v, true
  24573. }
  24574. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24575. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24577. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24578. if !m.op.Is(OpUpdateOne) {
  24579. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24580. }
  24581. if m.id == nil || m.oldValue == nil {
  24582. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24583. }
  24584. oldValue, err := m.oldValue(ctx)
  24585. if err != nil {
  24586. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24587. }
  24588. return oldValue.CreatedAt, nil
  24589. }
  24590. // ResetCreatedAt resets all changes to the "created_at" field.
  24591. func (m *SopStageMutation) ResetCreatedAt() {
  24592. m.created_at = nil
  24593. }
  24594. // SetUpdatedAt sets the "updated_at" field.
  24595. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24596. m.updated_at = &t
  24597. }
  24598. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24599. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24600. v := m.updated_at
  24601. if v == nil {
  24602. return
  24603. }
  24604. return *v, true
  24605. }
  24606. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24607. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24609. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24610. if !m.op.Is(OpUpdateOne) {
  24611. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24612. }
  24613. if m.id == nil || m.oldValue == nil {
  24614. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24615. }
  24616. oldValue, err := m.oldValue(ctx)
  24617. if err != nil {
  24618. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24619. }
  24620. return oldValue.UpdatedAt, nil
  24621. }
  24622. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24623. func (m *SopStageMutation) ResetUpdatedAt() {
  24624. m.updated_at = nil
  24625. }
  24626. // SetStatus sets the "status" field.
  24627. func (m *SopStageMutation) SetStatus(u uint8) {
  24628. m.status = &u
  24629. m.addstatus = nil
  24630. }
  24631. // Status returns the value of the "status" field in the mutation.
  24632. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24633. v := m.status
  24634. if v == nil {
  24635. return
  24636. }
  24637. return *v, true
  24638. }
  24639. // OldStatus returns the old "status" field's value of the SopStage entity.
  24640. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24642. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24643. if !m.op.Is(OpUpdateOne) {
  24644. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24645. }
  24646. if m.id == nil || m.oldValue == nil {
  24647. return v, errors.New("OldStatus requires an ID field in the mutation")
  24648. }
  24649. oldValue, err := m.oldValue(ctx)
  24650. if err != nil {
  24651. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24652. }
  24653. return oldValue.Status, nil
  24654. }
  24655. // AddStatus adds u to the "status" field.
  24656. func (m *SopStageMutation) AddStatus(u int8) {
  24657. if m.addstatus != nil {
  24658. *m.addstatus += u
  24659. } else {
  24660. m.addstatus = &u
  24661. }
  24662. }
  24663. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24664. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  24665. v := m.addstatus
  24666. if v == nil {
  24667. return
  24668. }
  24669. return *v, true
  24670. }
  24671. // ClearStatus clears the value of the "status" field.
  24672. func (m *SopStageMutation) ClearStatus() {
  24673. m.status = nil
  24674. m.addstatus = nil
  24675. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  24676. }
  24677. // StatusCleared returns if the "status" field was cleared in this mutation.
  24678. func (m *SopStageMutation) StatusCleared() bool {
  24679. _, ok := m.clearedFields[sopstage.FieldStatus]
  24680. return ok
  24681. }
  24682. // ResetStatus resets all changes to the "status" field.
  24683. func (m *SopStageMutation) ResetStatus() {
  24684. m.status = nil
  24685. m.addstatus = nil
  24686. delete(m.clearedFields, sopstage.FieldStatus)
  24687. }
  24688. // SetDeletedAt sets the "deleted_at" field.
  24689. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  24690. m.deleted_at = &t
  24691. }
  24692. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24693. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  24694. v := m.deleted_at
  24695. if v == nil {
  24696. return
  24697. }
  24698. return *v, true
  24699. }
  24700. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  24701. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24703. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24704. if !m.op.Is(OpUpdateOne) {
  24705. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24706. }
  24707. if m.id == nil || m.oldValue == nil {
  24708. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24709. }
  24710. oldValue, err := m.oldValue(ctx)
  24711. if err != nil {
  24712. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24713. }
  24714. return oldValue.DeletedAt, nil
  24715. }
  24716. // ClearDeletedAt clears the value of the "deleted_at" field.
  24717. func (m *SopStageMutation) ClearDeletedAt() {
  24718. m.deleted_at = nil
  24719. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  24720. }
  24721. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24722. func (m *SopStageMutation) DeletedAtCleared() bool {
  24723. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  24724. return ok
  24725. }
  24726. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24727. func (m *SopStageMutation) ResetDeletedAt() {
  24728. m.deleted_at = nil
  24729. delete(m.clearedFields, sopstage.FieldDeletedAt)
  24730. }
  24731. // SetTaskID sets the "task_id" field.
  24732. func (m *SopStageMutation) SetTaskID(u uint64) {
  24733. m.sop_task = &u
  24734. }
  24735. // TaskID returns the value of the "task_id" field in the mutation.
  24736. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  24737. v := m.sop_task
  24738. if v == nil {
  24739. return
  24740. }
  24741. return *v, true
  24742. }
  24743. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  24744. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24746. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  24747. if !m.op.Is(OpUpdateOne) {
  24748. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  24749. }
  24750. if m.id == nil || m.oldValue == nil {
  24751. return v, errors.New("OldTaskID requires an ID field in the mutation")
  24752. }
  24753. oldValue, err := m.oldValue(ctx)
  24754. if err != nil {
  24755. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  24756. }
  24757. return oldValue.TaskID, nil
  24758. }
  24759. // ResetTaskID resets all changes to the "task_id" field.
  24760. func (m *SopStageMutation) ResetTaskID() {
  24761. m.sop_task = nil
  24762. }
  24763. // SetName sets the "name" field.
  24764. func (m *SopStageMutation) SetName(s string) {
  24765. m.name = &s
  24766. }
  24767. // Name returns the value of the "name" field in the mutation.
  24768. func (m *SopStageMutation) Name() (r string, exists bool) {
  24769. v := m.name
  24770. if v == nil {
  24771. return
  24772. }
  24773. return *v, true
  24774. }
  24775. // OldName returns the old "name" field's value of the SopStage entity.
  24776. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24778. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  24779. if !m.op.Is(OpUpdateOne) {
  24780. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24781. }
  24782. if m.id == nil || m.oldValue == nil {
  24783. return v, errors.New("OldName requires an ID field in the mutation")
  24784. }
  24785. oldValue, err := m.oldValue(ctx)
  24786. if err != nil {
  24787. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24788. }
  24789. return oldValue.Name, nil
  24790. }
  24791. // ResetName resets all changes to the "name" field.
  24792. func (m *SopStageMutation) ResetName() {
  24793. m.name = nil
  24794. }
  24795. // SetConditionType sets the "condition_type" field.
  24796. func (m *SopStageMutation) SetConditionType(i int) {
  24797. m.condition_type = &i
  24798. m.addcondition_type = nil
  24799. }
  24800. // ConditionType returns the value of the "condition_type" field in the mutation.
  24801. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  24802. v := m.condition_type
  24803. if v == nil {
  24804. return
  24805. }
  24806. return *v, true
  24807. }
  24808. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  24809. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24811. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24812. if !m.op.Is(OpUpdateOne) {
  24813. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24814. }
  24815. if m.id == nil || m.oldValue == nil {
  24816. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24817. }
  24818. oldValue, err := m.oldValue(ctx)
  24819. if err != nil {
  24820. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24821. }
  24822. return oldValue.ConditionType, nil
  24823. }
  24824. // AddConditionType adds i to the "condition_type" field.
  24825. func (m *SopStageMutation) AddConditionType(i int) {
  24826. if m.addcondition_type != nil {
  24827. *m.addcondition_type += i
  24828. } else {
  24829. m.addcondition_type = &i
  24830. }
  24831. }
  24832. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24833. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  24834. v := m.addcondition_type
  24835. if v == nil {
  24836. return
  24837. }
  24838. return *v, true
  24839. }
  24840. // ResetConditionType resets all changes to the "condition_type" field.
  24841. func (m *SopStageMutation) ResetConditionType() {
  24842. m.condition_type = nil
  24843. m.addcondition_type = nil
  24844. }
  24845. // SetConditionOperator sets the "condition_operator" field.
  24846. func (m *SopStageMutation) SetConditionOperator(i int) {
  24847. m.condition_operator = &i
  24848. m.addcondition_operator = nil
  24849. }
  24850. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  24851. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  24852. v := m.condition_operator
  24853. if v == nil {
  24854. return
  24855. }
  24856. return *v, true
  24857. }
  24858. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  24859. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24861. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  24862. if !m.op.Is(OpUpdateOne) {
  24863. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  24864. }
  24865. if m.id == nil || m.oldValue == nil {
  24866. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  24867. }
  24868. oldValue, err := m.oldValue(ctx)
  24869. if err != nil {
  24870. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  24871. }
  24872. return oldValue.ConditionOperator, nil
  24873. }
  24874. // AddConditionOperator adds i to the "condition_operator" field.
  24875. func (m *SopStageMutation) AddConditionOperator(i int) {
  24876. if m.addcondition_operator != nil {
  24877. *m.addcondition_operator += i
  24878. } else {
  24879. m.addcondition_operator = &i
  24880. }
  24881. }
  24882. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  24883. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  24884. v := m.addcondition_operator
  24885. if v == nil {
  24886. return
  24887. }
  24888. return *v, true
  24889. }
  24890. // ResetConditionOperator resets all changes to the "condition_operator" field.
  24891. func (m *SopStageMutation) ResetConditionOperator() {
  24892. m.condition_operator = nil
  24893. m.addcondition_operator = nil
  24894. }
  24895. // SetConditionList sets the "condition_list" field.
  24896. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  24897. m.condition_list = &ct
  24898. m.appendcondition_list = nil
  24899. }
  24900. // ConditionList returns the value of the "condition_list" field in the mutation.
  24901. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  24902. v := m.condition_list
  24903. if v == nil {
  24904. return
  24905. }
  24906. return *v, true
  24907. }
  24908. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  24909. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24911. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  24912. if !m.op.Is(OpUpdateOne) {
  24913. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24914. }
  24915. if m.id == nil || m.oldValue == nil {
  24916. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24917. }
  24918. oldValue, err := m.oldValue(ctx)
  24919. if err != nil {
  24920. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24921. }
  24922. return oldValue.ConditionList, nil
  24923. }
  24924. // AppendConditionList adds ct to the "condition_list" field.
  24925. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  24926. m.appendcondition_list = append(m.appendcondition_list, ct...)
  24927. }
  24928. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  24929. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  24930. if len(m.appendcondition_list) == 0 {
  24931. return nil, false
  24932. }
  24933. return m.appendcondition_list, true
  24934. }
  24935. // ResetConditionList resets all changes to the "condition_list" field.
  24936. func (m *SopStageMutation) ResetConditionList() {
  24937. m.condition_list = nil
  24938. m.appendcondition_list = nil
  24939. }
  24940. // SetActionMessage sets the "action_message" field.
  24941. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  24942. m.action_message = &ct
  24943. m.appendaction_message = nil
  24944. }
  24945. // ActionMessage returns the value of the "action_message" field in the mutation.
  24946. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  24947. v := m.action_message
  24948. if v == nil {
  24949. return
  24950. }
  24951. return *v, true
  24952. }
  24953. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  24954. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24956. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  24957. if !m.op.Is(OpUpdateOne) {
  24958. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  24959. }
  24960. if m.id == nil || m.oldValue == nil {
  24961. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  24962. }
  24963. oldValue, err := m.oldValue(ctx)
  24964. if err != nil {
  24965. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  24966. }
  24967. return oldValue.ActionMessage, nil
  24968. }
  24969. // AppendActionMessage adds ct to the "action_message" field.
  24970. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  24971. m.appendaction_message = append(m.appendaction_message, ct...)
  24972. }
  24973. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  24974. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  24975. if len(m.appendaction_message) == 0 {
  24976. return nil, false
  24977. }
  24978. return m.appendaction_message, true
  24979. }
  24980. // ClearActionMessage clears the value of the "action_message" field.
  24981. func (m *SopStageMutation) ClearActionMessage() {
  24982. m.action_message = nil
  24983. m.appendaction_message = nil
  24984. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  24985. }
  24986. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24987. func (m *SopStageMutation) ActionMessageCleared() bool {
  24988. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  24989. return ok
  24990. }
  24991. // ResetActionMessage resets all changes to the "action_message" field.
  24992. func (m *SopStageMutation) ResetActionMessage() {
  24993. m.action_message = nil
  24994. m.appendaction_message = nil
  24995. delete(m.clearedFields, sopstage.FieldActionMessage)
  24996. }
  24997. // SetActionLabelAdd sets the "action_label_add" field.
  24998. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  24999. m.action_label_add = &u
  25000. m.appendaction_label_add = nil
  25001. }
  25002. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25003. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25004. v := m.action_label_add
  25005. if v == nil {
  25006. return
  25007. }
  25008. return *v, true
  25009. }
  25010. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  25011. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25013. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25014. if !m.op.Is(OpUpdateOne) {
  25015. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25016. }
  25017. if m.id == nil || m.oldValue == nil {
  25018. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25019. }
  25020. oldValue, err := m.oldValue(ctx)
  25021. if err != nil {
  25022. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25023. }
  25024. return oldValue.ActionLabelAdd, nil
  25025. }
  25026. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25027. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  25028. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25029. }
  25030. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25031. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25032. if len(m.appendaction_label_add) == 0 {
  25033. return nil, false
  25034. }
  25035. return m.appendaction_label_add, true
  25036. }
  25037. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25038. func (m *SopStageMutation) ClearActionLabelAdd() {
  25039. m.action_label_add = nil
  25040. m.appendaction_label_add = nil
  25041. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  25042. }
  25043. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25044. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  25045. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  25046. return ok
  25047. }
  25048. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25049. func (m *SopStageMutation) ResetActionLabelAdd() {
  25050. m.action_label_add = nil
  25051. m.appendaction_label_add = nil
  25052. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  25053. }
  25054. // SetActionLabelDel sets the "action_label_del" field.
  25055. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  25056. m.action_label_del = &u
  25057. m.appendaction_label_del = nil
  25058. }
  25059. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25060. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  25061. v := m.action_label_del
  25062. if v == nil {
  25063. return
  25064. }
  25065. return *v, true
  25066. }
  25067. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  25068. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25070. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25071. if !m.op.Is(OpUpdateOne) {
  25072. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25073. }
  25074. if m.id == nil || m.oldValue == nil {
  25075. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25076. }
  25077. oldValue, err := m.oldValue(ctx)
  25078. if err != nil {
  25079. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25080. }
  25081. return oldValue.ActionLabelDel, nil
  25082. }
  25083. // AppendActionLabelDel adds u to the "action_label_del" field.
  25084. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25085. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25086. }
  25087. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25088. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25089. if len(m.appendaction_label_del) == 0 {
  25090. return nil, false
  25091. }
  25092. return m.appendaction_label_del, true
  25093. }
  25094. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25095. func (m *SopStageMutation) ClearActionLabelDel() {
  25096. m.action_label_del = nil
  25097. m.appendaction_label_del = nil
  25098. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25099. }
  25100. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25101. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25102. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25103. return ok
  25104. }
  25105. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25106. func (m *SopStageMutation) ResetActionLabelDel() {
  25107. m.action_label_del = nil
  25108. m.appendaction_label_del = nil
  25109. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25110. }
  25111. // SetActionForward sets the "action_forward" field.
  25112. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25113. m.action_forward = &ctf
  25114. }
  25115. // ActionForward returns the value of the "action_forward" field in the mutation.
  25116. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25117. v := m.action_forward
  25118. if v == nil {
  25119. return
  25120. }
  25121. return *v, true
  25122. }
  25123. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25124. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25126. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25127. if !m.op.Is(OpUpdateOne) {
  25128. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25129. }
  25130. if m.id == nil || m.oldValue == nil {
  25131. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25132. }
  25133. oldValue, err := m.oldValue(ctx)
  25134. if err != nil {
  25135. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25136. }
  25137. return oldValue.ActionForward, nil
  25138. }
  25139. // ClearActionForward clears the value of the "action_forward" field.
  25140. func (m *SopStageMutation) ClearActionForward() {
  25141. m.action_forward = nil
  25142. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25143. }
  25144. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25145. func (m *SopStageMutation) ActionForwardCleared() bool {
  25146. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25147. return ok
  25148. }
  25149. // ResetActionForward resets all changes to the "action_forward" field.
  25150. func (m *SopStageMutation) ResetActionForward() {
  25151. m.action_forward = nil
  25152. delete(m.clearedFields, sopstage.FieldActionForward)
  25153. }
  25154. // SetIndexSort sets the "index_sort" field.
  25155. func (m *SopStageMutation) SetIndexSort(i int) {
  25156. m.index_sort = &i
  25157. m.addindex_sort = nil
  25158. }
  25159. // IndexSort returns the value of the "index_sort" field in the mutation.
  25160. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25161. v := m.index_sort
  25162. if v == nil {
  25163. return
  25164. }
  25165. return *v, true
  25166. }
  25167. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25168. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25170. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25171. if !m.op.Is(OpUpdateOne) {
  25172. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25173. }
  25174. if m.id == nil || m.oldValue == nil {
  25175. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25176. }
  25177. oldValue, err := m.oldValue(ctx)
  25178. if err != nil {
  25179. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25180. }
  25181. return oldValue.IndexSort, nil
  25182. }
  25183. // AddIndexSort adds i to the "index_sort" field.
  25184. func (m *SopStageMutation) AddIndexSort(i int) {
  25185. if m.addindex_sort != nil {
  25186. *m.addindex_sort += i
  25187. } else {
  25188. m.addindex_sort = &i
  25189. }
  25190. }
  25191. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25192. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25193. v := m.addindex_sort
  25194. if v == nil {
  25195. return
  25196. }
  25197. return *v, true
  25198. }
  25199. // ClearIndexSort clears the value of the "index_sort" field.
  25200. func (m *SopStageMutation) ClearIndexSort() {
  25201. m.index_sort = nil
  25202. m.addindex_sort = nil
  25203. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25204. }
  25205. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25206. func (m *SopStageMutation) IndexSortCleared() bool {
  25207. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25208. return ok
  25209. }
  25210. // ResetIndexSort resets all changes to the "index_sort" field.
  25211. func (m *SopStageMutation) ResetIndexSort() {
  25212. m.index_sort = nil
  25213. m.addindex_sort = nil
  25214. delete(m.clearedFields, sopstage.FieldIndexSort)
  25215. }
  25216. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25217. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25218. m.sop_task = &id
  25219. }
  25220. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25221. func (m *SopStageMutation) ClearSopTask() {
  25222. m.clearedsop_task = true
  25223. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25224. }
  25225. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25226. func (m *SopStageMutation) SopTaskCleared() bool {
  25227. return m.clearedsop_task
  25228. }
  25229. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25230. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25231. if m.sop_task != nil {
  25232. return *m.sop_task, true
  25233. }
  25234. return
  25235. }
  25236. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25237. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25238. // SopTaskID instead. It exists only for internal usage by the builders.
  25239. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25240. if id := m.sop_task; id != nil {
  25241. ids = append(ids, *id)
  25242. }
  25243. return
  25244. }
  25245. // ResetSopTask resets all changes to the "sop_task" edge.
  25246. func (m *SopStageMutation) ResetSopTask() {
  25247. m.sop_task = nil
  25248. m.clearedsop_task = false
  25249. }
  25250. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25251. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25252. if m.stage_nodes == nil {
  25253. m.stage_nodes = make(map[uint64]struct{})
  25254. }
  25255. for i := range ids {
  25256. m.stage_nodes[ids[i]] = struct{}{}
  25257. }
  25258. }
  25259. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25260. func (m *SopStageMutation) ClearStageNodes() {
  25261. m.clearedstage_nodes = true
  25262. }
  25263. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25264. func (m *SopStageMutation) StageNodesCleared() bool {
  25265. return m.clearedstage_nodes
  25266. }
  25267. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25268. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25269. if m.removedstage_nodes == nil {
  25270. m.removedstage_nodes = make(map[uint64]struct{})
  25271. }
  25272. for i := range ids {
  25273. delete(m.stage_nodes, ids[i])
  25274. m.removedstage_nodes[ids[i]] = struct{}{}
  25275. }
  25276. }
  25277. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25278. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25279. for id := range m.removedstage_nodes {
  25280. ids = append(ids, id)
  25281. }
  25282. return
  25283. }
  25284. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25285. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25286. for id := range m.stage_nodes {
  25287. ids = append(ids, id)
  25288. }
  25289. return
  25290. }
  25291. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25292. func (m *SopStageMutation) ResetStageNodes() {
  25293. m.stage_nodes = nil
  25294. m.clearedstage_nodes = false
  25295. m.removedstage_nodes = nil
  25296. }
  25297. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25298. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25299. if m.stage_messages == nil {
  25300. m.stage_messages = make(map[uint64]struct{})
  25301. }
  25302. for i := range ids {
  25303. m.stage_messages[ids[i]] = struct{}{}
  25304. }
  25305. }
  25306. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25307. func (m *SopStageMutation) ClearStageMessages() {
  25308. m.clearedstage_messages = true
  25309. }
  25310. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25311. func (m *SopStageMutation) StageMessagesCleared() bool {
  25312. return m.clearedstage_messages
  25313. }
  25314. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25315. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25316. if m.removedstage_messages == nil {
  25317. m.removedstage_messages = make(map[uint64]struct{})
  25318. }
  25319. for i := range ids {
  25320. delete(m.stage_messages, ids[i])
  25321. m.removedstage_messages[ids[i]] = struct{}{}
  25322. }
  25323. }
  25324. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25325. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25326. for id := range m.removedstage_messages {
  25327. ids = append(ids, id)
  25328. }
  25329. return
  25330. }
  25331. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25332. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25333. for id := range m.stage_messages {
  25334. ids = append(ids, id)
  25335. }
  25336. return
  25337. }
  25338. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25339. func (m *SopStageMutation) ResetStageMessages() {
  25340. m.stage_messages = nil
  25341. m.clearedstage_messages = false
  25342. m.removedstage_messages = nil
  25343. }
  25344. // Where appends a list predicates to the SopStageMutation builder.
  25345. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25346. m.predicates = append(m.predicates, ps...)
  25347. }
  25348. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25349. // users can use type-assertion to append predicates that do not depend on any generated package.
  25350. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25351. p := make([]predicate.SopStage, len(ps))
  25352. for i := range ps {
  25353. p[i] = ps[i]
  25354. }
  25355. m.Where(p...)
  25356. }
  25357. // Op returns the operation name.
  25358. func (m *SopStageMutation) Op() Op {
  25359. return m.op
  25360. }
  25361. // SetOp allows setting the mutation operation.
  25362. func (m *SopStageMutation) SetOp(op Op) {
  25363. m.op = op
  25364. }
  25365. // Type returns the node type of this mutation (SopStage).
  25366. func (m *SopStageMutation) Type() string {
  25367. return m.typ
  25368. }
  25369. // Fields returns all fields that were changed during this mutation. Note that in
  25370. // order to get all numeric fields that were incremented/decremented, call
  25371. // AddedFields().
  25372. func (m *SopStageMutation) Fields() []string {
  25373. fields := make([]string, 0, 14)
  25374. if m.created_at != nil {
  25375. fields = append(fields, sopstage.FieldCreatedAt)
  25376. }
  25377. if m.updated_at != nil {
  25378. fields = append(fields, sopstage.FieldUpdatedAt)
  25379. }
  25380. if m.status != nil {
  25381. fields = append(fields, sopstage.FieldStatus)
  25382. }
  25383. if m.deleted_at != nil {
  25384. fields = append(fields, sopstage.FieldDeletedAt)
  25385. }
  25386. if m.sop_task != nil {
  25387. fields = append(fields, sopstage.FieldTaskID)
  25388. }
  25389. if m.name != nil {
  25390. fields = append(fields, sopstage.FieldName)
  25391. }
  25392. if m.condition_type != nil {
  25393. fields = append(fields, sopstage.FieldConditionType)
  25394. }
  25395. if m.condition_operator != nil {
  25396. fields = append(fields, sopstage.FieldConditionOperator)
  25397. }
  25398. if m.condition_list != nil {
  25399. fields = append(fields, sopstage.FieldConditionList)
  25400. }
  25401. if m.action_message != nil {
  25402. fields = append(fields, sopstage.FieldActionMessage)
  25403. }
  25404. if m.action_label_add != nil {
  25405. fields = append(fields, sopstage.FieldActionLabelAdd)
  25406. }
  25407. if m.action_label_del != nil {
  25408. fields = append(fields, sopstage.FieldActionLabelDel)
  25409. }
  25410. if m.action_forward != nil {
  25411. fields = append(fields, sopstage.FieldActionForward)
  25412. }
  25413. if m.index_sort != nil {
  25414. fields = append(fields, sopstage.FieldIndexSort)
  25415. }
  25416. return fields
  25417. }
  25418. // Field returns the value of a field with the given name. The second boolean
  25419. // return value indicates that this field was not set, or was not defined in the
  25420. // schema.
  25421. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25422. switch name {
  25423. case sopstage.FieldCreatedAt:
  25424. return m.CreatedAt()
  25425. case sopstage.FieldUpdatedAt:
  25426. return m.UpdatedAt()
  25427. case sopstage.FieldStatus:
  25428. return m.Status()
  25429. case sopstage.FieldDeletedAt:
  25430. return m.DeletedAt()
  25431. case sopstage.FieldTaskID:
  25432. return m.TaskID()
  25433. case sopstage.FieldName:
  25434. return m.Name()
  25435. case sopstage.FieldConditionType:
  25436. return m.ConditionType()
  25437. case sopstage.FieldConditionOperator:
  25438. return m.ConditionOperator()
  25439. case sopstage.FieldConditionList:
  25440. return m.ConditionList()
  25441. case sopstage.FieldActionMessage:
  25442. return m.ActionMessage()
  25443. case sopstage.FieldActionLabelAdd:
  25444. return m.ActionLabelAdd()
  25445. case sopstage.FieldActionLabelDel:
  25446. return m.ActionLabelDel()
  25447. case sopstage.FieldActionForward:
  25448. return m.ActionForward()
  25449. case sopstage.FieldIndexSort:
  25450. return m.IndexSort()
  25451. }
  25452. return nil, false
  25453. }
  25454. // OldField returns the old value of the field from the database. An error is
  25455. // returned if the mutation operation is not UpdateOne, or the query to the
  25456. // database failed.
  25457. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25458. switch name {
  25459. case sopstage.FieldCreatedAt:
  25460. return m.OldCreatedAt(ctx)
  25461. case sopstage.FieldUpdatedAt:
  25462. return m.OldUpdatedAt(ctx)
  25463. case sopstage.FieldStatus:
  25464. return m.OldStatus(ctx)
  25465. case sopstage.FieldDeletedAt:
  25466. return m.OldDeletedAt(ctx)
  25467. case sopstage.FieldTaskID:
  25468. return m.OldTaskID(ctx)
  25469. case sopstage.FieldName:
  25470. return m.OldName(ctx)
  25471. case sopstage.FieldConditionType:
  25472. return m.OldConditionType(ctx)
  25473. case sopstage.FieldConditionOperator:
  25474. return m.OldConditionOperator(ctx)
  25475. case sopstage.FieldConditionList:
  25476. return m.OldConditionList(ctx)
  25477. case sopstage.FieldActionMessage:
  25478. return m.OldActionMessage(ctx)
  25479. case sopstage.FieldActionLabelAdd:
  25480. return m.OldActionLabelAdd(ctx)
  25481. case sopstage.FieldActionLabelDel:
  25482. return m.OldActionLabelDel(ctx)
  25483. case sopstage.FieldActionForward:
  25484. return m.OldActionForward(ctx)
  25485. case sopstage.FieldIndexSort:
  25486. return m.OldIndexSort(ctx)
  25487. }
  25488. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25489. }
  25490. // SetField sets the value of a field with the given name. It returns an error if
  25491. // the field is not defined in the schema, or if the type mismatched the field
  25492. // type.
  25493. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25494. switch name {
  25495. case sopstage.FieldCreatedAt:
  25496. v, ok := value.(time.Time)
  25497. if !ok {
  25498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25499. }
  25500. m.SetCreatedAt(v)
  25501. return nil
  25502. case sopstage.FieldUpdatedAt:
  25503. v, ok := value.(time.Time)
  25504. if !ok {
  25505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25506. }
  25507. m.SetUpdatedAt(v)
  25508. return nil
  25509. case sopstage.FieldStatus:
  25510. v, ok := value.(uint8)
  25511. if !ok {
  25512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25513. }
  25514. m.SetStatus(v)
  25515. return nil
  25516. case sopstage.FieldDeletedAt:
  25517. v, ok := value.(time.Time)
  25518. if !ok {
  25519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25520. }
  25521. m.SetDeletedAt(v)
  25522. return nil
  25523. case sopstage.FieldTaskID:
  25524. v, ok := value.(uint64)
  25525. if !ok {
  25526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25527. }
  25528. m.SetTaskID(v)
  25529. return nil
  25530. case sopstage.FieldName:
  25531. v, ok := value.(string)
  25532. if !ok {
  25533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25534. }
  25535. m.SetName(v)
  25536. return nil
  25537. case sopstage.FieldConditionType:
  25538. v, ok := value.(int)
  25539. if !ok {
  25540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25541. }
  25542. m.SetConditionType(v)
  25543. return nil
  25544. case sopstage.FieldConditionOperator:
  25545. v, ok := value.(int)
  25546. if !ok {
  25547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25548. }
  25549. m.SetConditionOperator(v)
  25550. return nil
  25551. case sopstage.FieldConditionList:
  25552. v, ok := value.([]custom_types.Condition)
  25553. if !ok {
  25554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25555. }
  25556. m.SetConditionList(v)
  25557. return nil
  25558. case sopstage.FieldActionMessage:
  25559. v, ok := value.([]custom_types.Action)
  25560. if !ok {
  25561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25562. }
  25563. m.SetActionMessage(v)
  25564. return nil
  25565. case sopstage.FieldActionLabelAdd:
  25566. v, ok := value.([]uint64)
  25567. if !ok {
  25568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25569. }
  25570. m.SetActionLabelAdd(v)
  25571. return nil
  25572. case sopstage.FieldActionLabelDel:
  25573. v, ok := value.([]uint64)
  25574. if !ok {
  25575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25576. }
  25577. m.SetActionLabelDel(v)
  25578. return nil
  25579. case sopstage.FieldActionForward:
  25580. v, ok := value.(*custom_types.ActionForward)
  25581. if !ok {
  25582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25583. }
  25584. m.SetActionForward(v)
  25585. return nil
  25586. case sopstage.FieldIndexSort:
  25587. v, ok := value.(int)
  25588. if !ok {
  25589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25590. }
  25591. m.SetIndexSort(v)
  25592. return nil
  25593. }
  25594. return fmt.Errorf("unknown SopStage field %s", name)
  25595. }
  25596. // AddedFields returns all numeric fields that were incremented/decremented during
  25597. // this mutation.
  25598. func (m *SopStageMutation) AddedFields() []string {
  25599. var fields []string
  25600. if m.addstatus != nil {
  25601. fields = append(fields, sopstage.FieldStatus)
  25602. }
  25603. if m.addcondition_type != nil {
  25604. fields = append(fields, sopstage.FieldConditionType)
  25605. }
  25606. if m.addcondition_operator != nil {
  25607. fields = append(fields, sopstage.FieldConditionOperator)
  25608. }
  25609. if m.addindex_sort != nil {
  25610. fields = append(fields, sopstage.FieldIndexSort)
  25611. }
  25612. return fields
  25613. }
  25614. // AddedField returns the numeric value that was incremented/decremented on a field
  25615. // with the given name. The second boolean return value indicates that this field
  25616. // was not set, or was not defined in the schema.
  25617. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25618. switch name {
  25619. case sopstage.FieldStatus:
  25620. return m.AddedStatus()
  25621. case sopstage.FieldConditionType:
  25622. return m.AddedConditionType()
  25623. case sopstage.FieldConditionOperator:
  25624. return m.AddedConditionOperator()
  25625. case sopstage.FieldIndexSort:
  25626. return m.AddedIndexSort()
  25627. }
  25628. return nil, false
  25629. }
  25630. // AddField adds the value to the field with the given name. It returns an error if
  25631. // the field is not defined in the schema, or if the type mismatched the field
  25632. // type.
  25633. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25634. switch name {
  25635. case sopstage.FieldStatus:
  25636. v, ok := value.(int8)
  25637. if !ok {
  25638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25639. }
  25640. m.AddStatus(v)
  25641. return nil
  25642. case sopstage.FieldConditionType:
  25643. v, ok := value.(int)
  25644. if !ok {
  25645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25646. }
  25647. m.AddConditionType(v)
  25648. return nil
  25649. case sopstage.FieldConditionOperator:
  25650. v, ok := value.(int)
  25651. if !ok {
  25652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25653. }
  25654. m.AddConditionOperator(v)
  25655. return nil
  25656. case sopstage.FieldIndexSort:
  25657. v, ok := value.(int)
  25658. if !ok {
  25659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25660. }
  25661. m.AddIndexSort(v)
  25662. return nil
  25663. }
  25664. return fmt.Errorf("unknown SopStage numeric field %s", name)
  25665. }
  25666. // ClearedFields returns all nullable fields that were cleared during this
  25667. // mutation.
  25668. func (m *SopStageMutation) ClearedFields() []string {
  25669. var fields []string
  25670. if m.FieldCleared(sopstage.FieldStatus) {
  25671. fields = append(fields, sopstage.FieldStatus)
  25672. }
  25673. if m.FieldCleared(sopstage.FieldDeletedAt) {
  25674. fields = append(fields, sopstage.FieldDeletedAt)
  25675. }
  25676. if m.FieldCleared(sopstage.FieldActionMessage) {
  25677. fields = append(fields, sopstage.FieldActionMessage)
  25678. }
  25679. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  25680. fields = append(fields, sopstage.FieldActionLabelAdd)
  25681. }
  25682. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  25683. fields = append(fields, sopstage.FieldActionLabelDel)
  25684. }
  25685. if m.FieldCleared(sopstage.FieldActionForward) {
  25686. fields = append(fields, sopstage.FieldActionForward)
  25687. }
  25688. if m.FieldCleared(sopstage.FieldIndexSort) {
  25689. fields = append(fields, sopstage.FieldIndexSort)
  25690. }
  25691. return fields
  25692. }
  25693. // FieldCleared returns a boolean indicating if a field with the given name was
  25694. // cleared in this mutation.
  25695. func (m *SopStageMutation) FieldCleared(name string) bool {
  25696. _, ok := m.clearedFields[name]
  25697. return ok
  25698. }
  25699. // ClearField clears the value of the field with the given name. It returns an
  25700. // error if the field is not defined in the schema.
  25701. func (m *SopStageMutation) ClearField(name string) error {
  25702. switch name {
  25703. case sopstage.FieldStatus:
  25704. m.ClearStatus()
  25705. return nil
  25706. case sopstage.FieldDeletedAt:
  25707. m.ClearDeletedAt()
  25708. return nil
  25709. case sopstage.FieldActionMessage:
  25710. m.ClearActionMessage()
  25711. return nil
  25712. case sopstage.FieldActionLabelAdd:
  25713. m.ClearActionLabelAdd()
  25714. return nil
  25715. case sopstage.FieldActionLabelDel:
  25716. m.ClearActionLabelDel()
  25717. return nil
  25718. case sopstage.FieldActionForward:
  25719. m.ClearActionForward()
  25720. return nil
  25721. case sopstage.FieldIndexSort:
  25722. m.ClearIndexSort()
  25723. return nil
  25724. }
  25725. return fmt.Errorf("unknown SopStage nullable field %s", name)
  25726. }
  25727. // ResetField resets all changes in the mutation for the field with the given name.
  25728. // It returns an error if the field is not defined in the schema.
  25729. func (m *SopStageMutation) ResetField(name string) error {
  25730. switch name {
  25731. case sopstage.FieldCreatedAt:
  25732. m.ResetCreatedAt()
  25733. return nil
  25734. case sopstage.FieldUpdatedAt:
  25735. m.ResetUpdatedAt()
  25736. return nil
  25737. case sopstage.FieldStatus:
  25738. m.ResetStatus()
  25739. return nil
  25740. case sopstage.FieldDeletedAt:
  25741. m.ResetDeletedAt()
  25742. return nil
  25743. case sopstage.FieldTaskID:
  25744. m.ResetTaskID()
  25745. return nil
  25746. case sopstage.FieldName:
  25747. m.ResetName()
  25748. return nil
  25749. case sopstage.FieldConditionType:
  25750. m.ResetConditionType()
  25751. return nil
  25752. case sopstage.FieldConditionOperator:
  25753. m.ResetConditionOperator()
  25754. return nil
  25755. case sopstage.FieldConditionList:
  25756. m.ResetConditionList()
  25757. return nil
  25758. case sopstage.FieldActionMessage:
  25759. m.ResetActionMessage()
  25760. return nil
  25761. case sopstage.FieldActionLabelAdd:
  25762. m.ResetActionLabelAdd()
  25763. return nil
  25764. case sopstage.FieldActionLabelDel:
  25765. m.ResetActionLabelDel()
  25766. return nil
  25767. case sopstage.FieldActionForward:
  25768. m.ResetActionForward()
  25769. return nil
  25770. case sopstage.FieldIndexSort:
  25771. m.ResetIndexSort()
  25772. return nil
  25773. }
  25774. return fmt.Errorf("unknown SopStage field %s", name)
  25775. }
  25776. // AddedEdges returns all edge names that were set/added in this mutation.
  25777. func (m *SopStageMutation) AddedEdges() []string {
  25778. edges := make([]string, 0, 3)
  25779. if m.sop_task != nil {
  25780. edges = append(edges, sopstage.EdgeSopTask)
  25781. }
  25782. if m.stage_nodes != nil {
  25783. edges = append(edges, sopstage.EdgeStageNodes)
  25784. }
  25785. if m.stage_messages != nil {
  25786. edges = append(edges, sopstage.EdgeStageMessages)
  25787. }
  25788. return edges
  25789. }
  25790. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25791. // name in this mutation.
  25792. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  25793. switch name {
  25794. case sopstage.EdgeSopTask:
  25795. if id := m.sop_task; id != nil {
  25796. return []ent.Value{*id}
  25797. }
  25798. case sopstage.EdgeStageNodes:
  25799. ids := make([]ent.Value, 0, len(m.stage_nodes))
  25800. for id := range m.stage_nodes {
  25801. ids = append(ids, id)
  25802. }
  25803. return ids
  25804. case sopstage.EdgeStageMessages:
  25805. ids := make([]ent.Value, 0, len(m.stage_messages))
  25806. for id := range m.stage_messages {
  25807. ids = append(ids, id)
  25808. }
  25809. return ids
  25810. }
  25811. return nil
  25812. }
  25813. // RemovedEdges returns all edge names that were removed in this mutation.
  25814. func (m *SopStageMutation) RemovedEdges() []string {
  25815. edges := make([]string, 0, 3)
  25816. if m.removedstage_nodes != nil {
  25817. edges = append(edges, sopstage.EdgeStageNodes)
  25818. }
  25819. if m.removedstage_messages != nil {
  25820. edges = append(edges, sopstage.EdgeStageMessages)
  25821. }
  25822. return edges
  25823. }
  25824. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25825. // the given name in this mutation.
  25826. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  25827. switch name {
  25828. case sopstage.EdgeStageNodes:
  25829. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  25830. for id := range m.removedstage_nodes {
  25831. ids = append(ids, id)
  25832. }
  25833. return ids
  25834. case sopstage.EdgeStageMessages:
  25835. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  25836. for id := range m.removedstage_messages {
  25837. ids = append(ids, id)
  25838. }
  25839. return ids
  25840. }
  25841. return nil
  25842. }
  25843. // ClearedEdges returns all edge names that were cleared in this mutation.
  25844. func (m *SopStageMutation) ClearedEdges() []string {
  25845. edges := make([]string, 0, 3)
  25846. if m.clearedsop_task {
  25847. edges = append(edges, sopstage.EdgeSopTask)
  25848. }
  25849. if m.clearedstage_nodes {
  25850. edges = append(edges, sopstage.EdgeStageNodes)
  25851. }
  25852. if m.clearedstage_messages {
  25853. edges = append(edges, sopstage.EdgeStageMessages)
  25854. }
  25855. return edges
  25856. }
  25857. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25858. // was cleared in this mutation.
  25859. func (m *SopStageMutation) EdgeCleared(name string) bool {
  25860. switch name {
  25861. case sopstage.EdgeSopTask:
  25862. return m.clearedsop_task
  25863. case sopstage.EdgeStageNodes:
  25864. return m.clearedstage_nodes
  25865. case sopstage.EdgeStageMessages:
  25866. return m.clearedstage_messages
  25867. }
  25868. return false
  25869. }
  25870. // ClearEdge clears the value of the edge with the given name. It returns an error
  25871. // if that edge is not defined in the schema.
  25872. func (m *SopStageMutation) ClearEdge(name string) error {
  25873. switch name {
  25874. case sopstage.EdgeSopTask:
  25875. m.ClearSopTask()
  25876. return nil
  25877. }
  25878. return fmt.Errorf("unknown SopStage unique edge %s", name)
  25879. }
  25880. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25881. // It returns an error if the edge is not defined in the schema.
  25882. func (m *SopStageMutation) ResetEdge(name string) error {
  25883. switch name {
  25884. case sopstage.EdgeSopTask:
  25885. m.ResetSopTask()
  25886. return nil
  25887. case sopstage.EdgeStageNodes:
  25888. m.ResetStageNodes()
  25889. return nil
  25890. case sopstage.EdgeStageMessages:
  25891. m.ResetStageMessages()
  25892. return nil
  25893. }
  25894. return fmt.Errorf("unknown SopStage edge %s", name)
  25895. }
  25896. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  25897. type SopTaskMutation struct {
  25898. config
  25899. op Op
  25900. typ string
  25901. id *uint64
  25902. created_at *time.Time
  25903. updated_at *time.Time
  25904. status *uint8
  25905. addstatus *int8
  25906. deleted_at *time.Time
  25907. name *string
  25908. bot_wxid_list *[]string
  25909. appendbot_wxid_list []string
  25910. _type *int
  25911. add_type *int
  25912. plan_start_time *time.Time
  25913. plan_end_time *time.Time
  25914. creator_id *string
  25915. organization_id *uint64
  25916. addorganization_id *int64
  25917. token *[]string
  25918. appendtoken []string
  25919. clearedFields map[string]struct{}
  25920. task_stages map[uint64]struct{}
  25921. removedtask_stages map[uint64]struct{}
  25922. clearedtask_stages bool
  25923. done bool
  25924. oldValue func(context.Context) (*SopTask, error)
  25925. predicates []predicate.SopTask
  25926. }
  25927. var _ ent.Mutation = (*SopTaskMutation)(nil)
  25928. // soptaskOption allows management of the mutation configuration using functional options.
  25929. type soptaskOption func(*SopTaskMutation)
  25930. // newSopTaskMutation creates new mutation for the SopTask entity.
  25931. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  25932. m := &SopTaskMutation{
  25933. config: c,
  25934. op: op,
  25935. typ: TypeSopTask,
  25936. clearedFields: make(map[string]struct{}),
  25937. }
  25938. for _, opt := range opts {
  25939. opt(m)
  25940. }
  25941. return m
  25942. }
  25943. // withSopTaskID sets the ID field of the mutation.
  25944. func withSopTaskID(id uint64) soptaskOption {
  25945. return func(m *SopTaskMutation) {
  25946. var (
  25947. err error
  25948. once sync.Once
  25949. value *SopTask
  25950. )
  25951. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  25952. once.Do(func() {
  25953. if m.done {
  25954. err = errors.New("querying old values post mutation is not allowed")
  25955. } else {
  25956. value, err = m.Client().SopTask.Get(ctx, id)
  25957. }
  25958. })
  25959. return value, err
  25960. }
  25961. m.id = &id
  25962. }
  25963. }
  25964. // withSopTask sets the old SopTask of the mutation.
  25965. func withSopTask(node *SopTask) soptaskOption {
  25966. return func(m *SopTaskMutation) {
  25967. m.oldValue = func(context.Context) (*SopTask, error) {
  25968. return node, nil
  25969. }
  25970. m.id = &node.ID
  25971. }
  25972. }
  25973. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25974. // executed in a transaction (ent.Tx), a transactional client is returned.
  25975. func (m SopTaskMutation) Client() *Client {
  25976. client := &Client{config: m.config}
  25977. client.init()
  25978. return client
  25979. }
  25980. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25981. // it returns an error otherwise.
  25982. func (m SopTaskMutation) Tx() (*Tx, error) {
  25983. if _, ok := m.driver.(*txDriver); !ok {
  25984. return nil, errors.New("ent: mutation is not running in a transaction")
  25985. }
  25986. tx := &Tx{config: m.config}
  25987. tx.init()
  25988. return tx, nil
  25989. }
  25990. // SetID sets the value of the id field. Note that this
  25991. // operation is only accepted on creation of SopTask entities.
  25992. func (m *SopTaskMutation) SetID(id uint64) {
  25993. m.id = &id
  25994. }
  25995. // ID returns the ID value in the mutation. Note that the ID is only available
  25996. // if it was provided to the builder or after it was returned from the database.
  25997. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  25998. if m.id == nil {
  25999. return
  26000. }
  26001. return *m.id, true
  26002. }
  26003. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26004. // That means, if the mutation is applied within a transaction with an isolation level such
  26005. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26006. // or updated by the mutation.
  26007. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  26008. switch {
  26009. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26010. id, exists := m.ID()
  26011. if exists {
  26012. return []uint64{id}, nil
  26013. }
  26014. fallthrough
  26015. case m.op.Is(OpUpdate | OpDelete):
  26016. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  26017. default:
  26018. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26019. }
  26020. }
  26021. // SetCreatedAt sets the "created_at" field.
  26022. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  26023. m.created_at = &t
  26024. }
  26025. // CreatedAt returns the value of the "created_at" field in the mutation.
  26026. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  26027. v := m.created_at
  26028. if v == nil {
  26029. return
  26030. }
  26031. return *v, true
  26032. }
  26033. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  26034. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26036. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26037. if !m.op.Is(OpUpdateOne) {
  26038. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26039. }
  26040. if m.id == nil || m.oldValue == nil {
  26041. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26042. }
  26043. oldValue, err := m.oldValue(ctx)
  26044. if err != nil {
  26045. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26046. }
  26047. return oldValue.CreatedAt, nil
  26048. }
  26049. // ResetCreatedAt resets all changes to the "created_at" field.
  26050. func (m *SopTaskMutation) ResetCreatedAt() {
  26051. m.created_at = nil
  26052. }
  26053. // SetUpdatedAt sets the "updated_at" field.
  26054. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  26055. m.updated_at = &t
  26056. }
  26057. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26058. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  26059. v := m.updated_at
  26060. if v == nil {
  26061. return
  26062. }
  26063. return *v, true
  26064. }
  26065. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  26066. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26068. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26069. if !m.op.Is(OpUpdateOne) {
  26070. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26071. }
  26072. if m.id == nil || m.oldValue == nil {
  26073. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26074. }
  26075. oldValue, err := m.oldValue(ctx)
  26076. if err != nil {
  26077. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26078. }
  26079. return oldValue.UpdatedAt, nil
  26080. }
  26081. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26082. func (m *SopTaskMutation) ResetUpdatedAt() {
  26083. m.updated_at = nil
  26084. }
  26085. // SetStatus sets the "status" field.
  26086. func (m *SopTaskMutation) SetStatus(u uint8) {
  26087. m.status = &u
  26088. m.addstatus = nil
  26089. }
  26090. // Status returns the value of the "status" field in the mutation.
  26091. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26092. v := m.status
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // OldStatus returns the old "status" field's value of the SopTask entity.
  26099. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26101. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26102. if !m.op.Is(OpUpdateOne) {
  26103. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26104. }
  26105. if m.id == nil || m.oldValue == nil {
  26106. return v, errors.New("OldStatus requires an ID field in the mutation")
  26107. }
  26108. oldValue, err := m.oldValue(ctx)
  26109. if err != nil {
  26110. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26111. }
  26112. return oldValue.Status, nil
  26113. }
  26114. // AddStatus adds u to the "status" field.
  26115. func (m *SopTaskMutation) AddStatus(u int8) {
  26116. if m.addstatus != nil {
  26117. *m.addstatus += u
  26118. } else {
  26119. m.addstatus = &u
  26120. }
  26121. }
  26122. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26123. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26124. v := m.addstatus
  26125. if v == nil {
  26126. return
  26127. }
  26128. return *v, true
  26129. }
  26130. // ClearStatus clears the value of the "status" field.
  26131. func (m *SopTaskMutation) ClearStatus() {
  26132. m.status = nil
  26133. m.addstatus = nil
  26134. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26135. }
  26136. // StatusCleared returns if the "status" field was cleared in this mutation.
  26137. func (m *SopTaskMutation) StatusCleared() bool {
  26138. _, ok := m.clearedFields[soptask.FieldStatus]
  26139. return ok
  26140. }
  26141. // ResetStatus resets all changes to the "status" field.
  26142. func (m *SopTaskMutation) ResetStatus() {
  26143. m.status = nil
  26144. m.addstatus = nil
  26145. delete(m.clearedFields, soptask.FieldStatus)
  26146. }
  26147. // SetDeletedAt sets the "deleted_at" field.
  26148. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26149. m.deleted_at = &t
  26150. }
  26151. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26152. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26153. v := m.deleted_at
  26154. if v == nil {
  26155. return
  26156. }
  26157. return *v, true
  26158. }
  26159. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26160. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26162. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26163. if !m.op.Is(OpUpdateOne) {
  26164. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26165. }
  26166. if m.id == nil || m.oldValue == nil {
  26167. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26168. }
  26169. oldValue, err := m.oldValue(ctx)
  26170. if err != nil {
  26171. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26172. }
  26173. return oldValue.DeletedAt, nil
  26174. }
  26175. // ClearDeletedAt clears the value of the "deleted_at" field.
  26176. func (m *SopTaskMutation) ClearDeletedAt() {
  26177. m.deleted_at = nil
  26178. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26179. }
  26180. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26181. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26182. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26183. return ok
  26184. }
  26185. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26186. func (m *SopTaskMutation) ResetDeletedAt() {
  26187. m.deleted_at = nil
  26188. delete(m.clearedFields, soptask.FieldDeletedAt)
  26189. }
  26190. // SetName sets the "name" field.
  26191. func (m *SopTaskMutation) SetName(s string) {
  26192. m.name = &s
  26193. }
  26194. // Name returns the value of the "name" field in the mutation.
  26195. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26196. v := m.name
  26197. if v == nil {
  26198. return
  26199. }
  26200. return *v, true
  26201. }
  26202. // OldName returns the old "name" field's value of the SopTask entity.
  26203. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26205. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26206. if !m.op.Is(OpUpdateOne) {
  26207. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26208. }
  26209. if m.id == nil || m.oldValue == nil {
  26210. return v, errors.New("OldName requires an ID field in the mutation")
  26211. }
  26212. oldValue, err := m.oldValue(ctx)
  26213. if err != nil {
  26214. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26215. }
  26216. return oldValue.Name, nil
  26217. }
  26218. // ResetName resets all changes to the "name" field.
  26219. func (m *SopTaskMutation) ResetName() {
  26220. m.name = nil
  26221. }
  26222. // SetBotWxidList sets the "bot_wxid_list" field.
  26223. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26224. m.bot_wxid_list = &s
  26225. m.appendbot_wxid_list = nil
  26226. }
  26227. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26228. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26229. v := m.bot_wxid_list
  26230. if v == nil {
  26231. return
  26232. }
  26233. return *v, true
  26234. }
  26235. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26236. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26238. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26239. if !m.op.Is(OpUpdateOne) {
  26240. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26241. }
  26242. if m.id == nil || m.oldValue == nil {
  26243. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26244. }
  26245. oldValue, err := m.oldValue(ctx)
  26246. if err != nil {
  26247. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26248. }
  26249. return oldValue.BotWxidList, nil
  26250. }
  26251. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26252. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26253. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26254. }
  26255. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26256. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26257. if len(m.appendbot_wxid_list) == 0 {
  26258. return nil, false
  26259. }
  26260. return m.appendbot_wxid_list, true
  26261. }
  26262. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26263. func (m *SopTaskMutation) ClearBotWxidList() {
  26264. m.bot_wxid_list = nil
  26265. m.appendbot_wxid_list = nil
  26266. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26267. }
  26268. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26269. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26270. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26271. return ok
  26272. }
  26273. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26274. func (m *SopTaskMutation) ResetBotWxidList() {
  26275. m.bot_wxid_list = nil
  26276. m.appendbot_wxid_list = nil
  26277. delete(m.clearedFields, soptask.FieldBotWxidList)
  26278. }
  26279. // SetType sets the "type" field.
  26280. func (m *SopTaskMutation) SetType(i int) {
  26281. m._type = &i
  26282. m.add_type = nil
  26283. }
  26284. // GetType returns the value of the "type" field in the mutation.
  26285. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26286. v := m._type
  26287. if v == nil {
  26288. return
  26289. }
  26290. return *v, true
  26291. }
  26292. // OldType returns the old "type" field's value of the SopTask entity.
  26293. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26295. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26296. if !m.op.Is(OpUpdateOne) {
  26297. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26298. }
  26299. if m.id == nil || m.oldValue == nil {
  26300. return v, errors.New("OldType requires an ID field in the mutation")
  26301. }
  26302. oldValue, err := m.oldValue(ctx)
  26303. if err != nil {
  26304. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26305. }
  26306. return oldValue.Type, nil
  26307. }
  26308. // AddType adds i to the "type" field.
  26309. func (m *SopTaskMutation) AddType(i int) {
  26310. if m.add_type != nil {
  26311. *m.add_type += i
  26312. } else {
  26313. m.add_type = &i
  26314. }
  26315. }
  26316. // AddedType returns the value that was added to the "type" field in this mutation.
  26317. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26318. v := m.add_type
  26319. if v == nil {
  26320. return
  26321. }
  26322. return *v, true
  26323. }
  26324. // ResetType resets all changes to the "type" field.
  26325. func (m *SopTaskMutation) ResetType() {
  26326. m._type = nil
  26327. m.add_type = nil
  26328. }
  26329. // SetPlanStartTime sets the "plan_start_time" field.
  26330. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26331. m.plan_start_time = &t
  26332. }
  26333. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26334. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26335. v := m.plan_start_time
  26336. if v == nil {
  26337. return
  26338. }
  26339. return *v, true
  26340. }
  26341. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26342. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26344. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26345. if !m.op.Is(OpUpdateOne) {
  26346. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26347. }
  26348. if m.id == nil || m.oldValue == nil {
  26349. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26350. }
  26351. oldValue, err := m.oldValue(ctx)
  26352. if err != nil {
  26353. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26354. }
  26355. return oldValue.PlanStartTime, nil
  26356. }
  26357. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26358. func (m *SopTaskMutation) ClearPlanStartTime() {
  26359. m.plan_start_time = nil
  26360. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26361. }
  26362. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26363. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26364. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26365. return ok
  26366. }
  26367. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26368. func (m *SopTaskMutation) ResetPlanStartTime() {
  26369. m.plan_start_time = nil
  26370. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26371. }
  26372. // SetPlanEndTime sets the "plan_end_time" field.
  26373. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26374. m.plan_end_time = &t
  26375. }
  26376. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26377. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26378. v := m.plan_end_time
  26379. if v == nil {
  26380. return
  26381. }
  26382. return *v, true
  26383. }
  26384. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26385. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26387. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26388. if !m.op.Is(OpUpdateOne) {
  26389. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26390. }
  26391. if m.id == nil || m.oldValue == nil {
  26392. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26393. }
  26394. oldValue, err := m.oldValue(ctx)
  26395. if err != nil {
  26396. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26397. }
  26398. return oldValue.PlanEndTime, nil
  26399. }
  26400. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26401. func (m *SopTaskMutation) ClearPlanEndTime() {
  26402. m.plan_end_time = nil
  26403. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26404. }
  26405. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26406. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26407. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26408. return ok
  26409. }
  26410. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26411. func (m *SopTaskMutation) ResetPlanEndTime() {
  26412. m.plan_end_time = nil
  26413. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26414. }
  26415. // SetCreatorID sets the "creator_id" field.
  26416. func (m *SopTaskMutation) SetCreatorID(s string) {
  26417. m.creator_id = &s
  26418. }
  26419. // CreatorID returns the value of the "creator_id" field in the mutation.
  26420. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26421. v := m.creator_id
  26422. if v == nil {
  26423. return
  26424. }
  26425. return *v, true
  26426. }
  26427. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26428. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26430. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26431. if !m.op.Is(OpUpdateOne) {
  26432. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26433. }
  26434. if m.id == nil || m.oldValue == nil {
  26435. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26436. }
  26437. oldValue, err := m.oldValue(ctx)
  26438. if err != nil {
  26439. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26440. }
  26441. return oldValue.CreatorID, nil
  26442. }
  26443. // ClearCreatorID clears the value of the "creator_id" field.
  26444. func (m *SopTaskMutation) ClearCreatorID() {
  26445. m.creator_id = nil
  26446. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26447. }
  26448. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26449. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26450. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26451. return ok
  26452. }
  26453. // ResetCreatorID resets all changes to the "creator_id" field.
  26454. func (m *SopTaskMutation) ResetCreatorID() {
  26455. m.creator_id = nil
  26456. delete(m.clearedFields, soptask.FieldCreatorID)
  26457. }
  26458. // SetOrganizationID sets the "organization_id" field.
  26459. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26460. m.organization_id = &u
  26461. m.addorganization_id = nil
  26462. }
  26463. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26464. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26465. v := m.organization_id
  26466. if v == nil {
  26467. return
  26468. }
  26469. return *v, true
  26470. }
  26471. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26472. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26474. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26475. if !m.op.Is(OpUpdateOne) {
  26476. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26477. }
  26478. if m.id == nil || m.oldValue == nil {
  26479. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26480. }
  26481. oldValue, err := m.oldValue(ctx)
  26482. if err != nil {
  26483. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26484. }
  26485. return oldValue.OrganizationID, nil
  26486. }
  26487. // AddOrganizationID adds u to the "organization_id" field.
  26488. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26489. if m.addorganization_id != nil {
  26490. *m.addorganization_id += u
  26491. } else {
  26492. m.addorganization_id = &u
  26493. }
  26494. }
  26495. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26496. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26497. v := m.addorganization_id
  26498. if v == nil {
  26499. return
  26500. }
  26501. return *v, true
  26502. }
  26503. // ClearOrganizationID clears the value of the "organization_id" field.
  26504. func (m *SopTaskMutation) ClearOrganizationID() {
  26505. m.organization_id = nil
  26506. m.addorganization_id = nil
  26507. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26508. }
  26509. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26510. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26511. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26512. return ok
  26513. }
  26514. // ResetOrganizationID resets all changes to the "organization_id" field.
  26515. func (m *SopTaskMutation) ResetOrganizationID() {
  26516. m.organization_id = nil
  26517. m.addorganization_id = nil
  26518. delete(m.clearedFields, soptask.FieldOrganizationID)
  26519. }
  26520. // SetToken sets the "token" field.
  26521. func (m *SopTaskMutation) SetToken(s []string) {
  26522. m.token = &s
  26523. m.appendtoken = nil
  26524. }
  26525. // Token returns the value of the "token" field in the mutation.
  26526. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26527. v := m.token
  26528. if v == nil {
  26529. return
  26530. }
  26531. return *v, true
  26532. }
  26533. // OldToken returns the old "token" field's value of the SopTask entity.
  26534. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26536. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26537. if !m.op.Is(OpUpdateOne) {
  26538. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26539. }
  26540. if m.id == nil || m.oldValue == nil {
  26541. return v, errors.New("OldToken requires an ID field in the mutation")
  26542. }
  26543. oldValue, err := m.oldValue(ctx)
  26544. if err != nil {
  26545. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26546. }
  26547. return oldValue.Token, nil
  26548. }
  26549. // AppendToken adds s to the "token" field.
  26550. func (m *SopTaskMutation) AppendToken(s []string) {
  26551. m.appendtoken = append(m.appendtoken, s...)
  26552. }
  26553. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26554. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26555. if len(m.appendtoken) == 0 {
  26556. return nil, false
  26557. }
  26558. return m.appendtoken, true
  26559. }
  26560. // ClearToken clears the value of the "token" field.
  26561. func (m *SopTaskMutation) ClearToken() {
  26562. m.token = nil
  26563. m.appendtoken = nil
  26564. m.clearedFields[soptask.FieldToken] = struct{}{}
  26565. }
  26566. // TokenCleared returns if the "token" field was cleared in this mutation.
  26567. func (m *SopTaskMutation) TokenCleared() bool {
  26568. _, ok := m.clearedFields[soptask.FieldToken]
  26569. return ok
  26570. }
  26571. // ResetToken resets all changes to the "token" field.
  26572. func (m *SopTaskMutation) ResetToken() {
  26573. m.token = nil
  26574. m.appendtoken = nil
  26575. delete(m.clearedFields, soptask.FieldToken)
  26576. }
  26577. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26578. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26579. if m.task_stages == nil {
  26580. m.task_stages = make(map[uint64]struct{})
  26581. }
  26582. for i := range ids {
  26583. m.task_stages[ids[i]] = struct{}{}
  26584. }
  26585. }
  26586. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26587. func (m *SopTaskMutation) ClearTaskStages() {
  26588. m.clearedtask_stages = true
  26589. }
  26590. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26591. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26592. return m.clearedtask_stages
  26593. }
  26594. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26595. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26596. if m.removedtask_stages == nil {
  26597. m.removedtask_stages = make(map[uint64]struct{})
  26598. }
  26599. for i := range ids {
  26600. delete(m.task_stages, ids[i])
  26601. m.removedtask_stages[ids[i]] = struct{}{}
  26602. }
  26603. }
  26604. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26605. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26606. for id := range m.removedtask_stages {
  26607. ids = append(ids, id)
  26608. }
  26609. return
  26610. }
  26611. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26612. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26613. for id := range m.task_stages {
  26614. ids = append(ids, id)
  26615. }
  26616. return
  26617. }
  26618. // ResetTaskStages resets all changes to the "task_stages" edge.
  26619. func (m *SopTaskMutation) ResetTaskStages() {
  26620. m.task_stages = nil
  26621. m.clearedtask_stages = false
  26622. m.removedtask_stages = nil
  26623. }
  26624. // Where appends a list predicates to the SopTaskMutation builder.
  26625. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26626. m.predicates = append(m.predicates, ps...)
  26627. }
  26628. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26629. // users can use type-assertion to append predicates that do not depend on any generated package.
  26630. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26631. p := make([]predicate.SopTask, len(ps))
  26632. for i := range ps {
  26633. p[i] = ps[i]
  26634. }
  26635. m.Where(p...)
  26636. }
  26637. // Op returns the operation name.
  26638. func (m *SopTaskMutation) Op() Op {
  26639. return m.op
  26640. }
  26641. // SetOp allows setting the mutation operation.
  26642. func (m *SopTaskMutation) SetOp(op Op) {
  26643. m.op = op
  26644. }
  26645. // Type returns the node type of this mutation (SopTask).
  26646. func (m *SopTaskMutation) Type() string {
  26647. return m.typ
  26648. }
  26649. // Fields returns all fields that were changed during this mutation. Note that in
  26650. // order to get all numeric fields that were incremented/decremented, call
  26651. // AddedFields().
  26652. func (m *SopTaskMutation) Fields() []string {
  26653. fields := make([]string, 0, 12)
  26654. if m.created_at != nil {
  26655. fields = append(fields, soptask.FieldCreatedAt)
  26656. }
  26657. if m.updated_at != nil {
  26658. fields = append(fields, soptask.FieldUpdatedAt)
  26659. }
  26660. if m.status != nil {
  26661. fields = append(fields, soptask.FieldStatus)
  26662. }
  26663. if m.deleted_at != nil {
  26664. fields = append(fields, soptask.FieldDeletedAt)
  26665. }
  26666. if m.name != nil {
  26667. fields = append(fields, soptask.FieldName)
  26668. }
  26669. if m.bot_wxid_list != nil {
  26670. fields = append(fields, soptask.FieldBotWxidList)
  26671. }
  26672. if m._type != nil {
  26673. fields = append(fields, soptask.FieldType)
  26674. }
  26675. if m.plan_start_time != nil {
  26676. fields = append(fields, soptask.FieldPlanStartTime)
  26677. }
  26678. if m.plan_end_time != nil {
  26679. fields = append(fields, soptask.FieldPlanEndTime)
  26680. }
  26681. if m.creator_id != nil {
  26682. fields = append(fields, soptask.FieldCreatorID)
  26683. }
  26684. if m.organization_id != nil {
  26685. fields = append(fields, soptask.FieldOrganizationID)
  26686. }
  26687. if m.token != nil {
  26688. fields = append(fields, soptask.FieldToken)
  26689. }
  26690. return fields
  26691. }
  26692. // Field returns the value of a field with the given name. The second boolean
  26693. // return value indicates that this field was not set, or was not defined in the
  26694. // schema.
  26695. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  26696. switch name {
  26697. case soptask.FieldCreatedAt:
  26698. return m.CreatedAt()
  26699. case soptask.FieldUpdatedAt:
  26700. return m.UpdatedAt()
  26701. case soptask.FieldStatus:
  26702. return m.Status()
  26703. case soptask.FieldDeletedAt:
  26704. return m.DeletedAt()
  26705. case soptask.FieldName:
  26706. return m.Name()
  26707. case soptask.FieldBotWxidList:
  26708. return m.BotWxidList()
  26709. case soptask.FieldType:
  26710. return m.GetType()
  26711. case soptask.FieldPlanStartTime:
  26712. return m.PlanStartTime()
  26713. case soptask.FieldPlanEndTime:
  26714. return m.PlanEndTime()
  26715. case soptask.FieldCreatorID:
  26716. return m.CreatorID()
  26717. case soptask.FieldOrganizationID:
  26718. return m.OrganizationID()
  26719. case soptask.FieldToken:
  26720. return m.Token()
  26721. }
  26722. return nil, false
  26723. }
  26724. // OldField returns the old value of the field from the database. An error is
  26725. // returned if the mutation operation is not UpdateOne, or the query to the
  26726. // database failed.
  26727. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26728. switch name {
  26729. case soptask.FieldCreatedAt:
  26730. return m.OldCreatedAt(ctx)
  26731. case soptask.FieldUpdatedAt:
  26732. return m.OldUpdatedAt(ctx)
  26733. case soptask.FieldStatus:
  26734. return m.OldStatus(ctx)
  26735. case soptask.FieldDeletedAt:
  26736. return m.OldDeletedAt(ctx)
  26737. case soptask.FieldName:
  26738. return m.OldName(ctx)
  26739. case soptask.FieldBotWxidList:
  26740. return m.OldBotWxidList(ctx)
  26741. case soptask.FieldType:
  26742. return m.OldType(ctx)
  26743. case soptask.FieldPlanStartTime:
  26744. return m.OldPlanStartTime(ctx)
  26745. case soptask.FieldPlanEndTime:
  26746. return m.OldPlanEndTime(ctx)
  26747. case soptask.FieldCreatorID:
  26748. return m.OldCreatorID(ctx)
  26749. case soptask.FieldOrganizationID:
  26750. return m.OldOrganizationID(ctx)
  26751. case soptask.FieldToken:
  26752. return m.OldToken(ctx)
  26753. }
  26754. return nil, fmt.Errorf("unknown SopTask field %s", name)
  26755. }
  26756. // SetField sets the value of a field with the given name. It returns an error if
  26757. // the field is not defined in the schema, or if the type mismatched the field
  26758. // type.
  26759. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  26760. switch name {
  26761. case soptask.FieldCreatedAt:
  26762. v, ok := value.(time.Time)
  26763. if !ok {
  26764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26765. }
  26766. m.SetCreatedAt(v)
  26767. return nil
  26768. case soptask.FieldUpdatedAt:
  26769. v, ok := value.(time.Time)
  26770. if !ok {
  26771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26772. }
  26773. m.SetUpdatedAt(v)
  26774. return nil
  26775. case soptask.FieldStatus:
  26776. v, ok := value.(uint8)
  26777. if !ok {
  26778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26779. }
  26780. m.SetStatus(v)
  26781. return nil
  26782. case soptask.FieldDeletedAt:
  26783. v, ok := value.(time.Time)
  26784. if !ok {
  26785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26786. }
  26787. m.SetDeletedAt(v)
  26788. return nil
  26789. case soptask.FieldName:
  26790. v, ok := value.(string)
  26791. if !ok {
  26792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26793. }
  26794. m.SetName(v)
  26795. return nil
  26796. case soptask.FieldBotWxidList:
  26797. v, ok := value.([]string)
  26798. if !ok {
  26799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26800. }
  26801. m.SetBotWxidList(v)
  26802. return nil
  26803. case soptask.FieldType:
  26804. v, ok := value.(int)
  26805. if !ok {
  26806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26807. }
  26808. m.SetType(v)
  26809. return nil
  26810. case soptask.FieldPlanStartTime:
  26811. v, ok := value.(time.Time)
  26812. if !ok {
  26813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26814. }
  26815. m.SetPlanStartTime(v)
  26816. return nil
  26817. case soptask.FieldPlanEndTime:
  26818. v, ok := value.(time.Time)
  26819. if !ok {
  26820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26821. }
  26822. m.SetPlanEndTime(v)
  26823. return nil
  26824. case soptask.FieldCreatorID:
  26825. v, ok := value.(string)
  26826. if !ok {
  26827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26828. }
  26829. m.SetCreatorID(v)
  26830. return nil
  26831. case soptask.FieldOrganizationID:
  26832. v, ok := value.(uint64)
  26833. if !ok {
  26834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26835. }
  26836. m.SetOrganizationID(v)
  26837. return nil
  26838. case soptask.FieldToken:
  26839. v, ok := value.([]string)
  26840. if !ok {
  26841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26842. }
  26843. m.SetToken(v)
  26844. return nil
  26845. }
  26846. return fmt.Errorf("unknown SopTask field %s", name)
  26847. }
  26848. // AddedFields returns all numeric fields that were incremented/decremented during
  26849. // this mutation.
  26850. func (m *SopTaskMutation) AddedFields() []string {
  26851. var fields []string
  26852. if m.addstatus != nil {
  26853. fields = append(fields, soptask.FieldStatus)
  26854. }
  26855. if m.add_type != nil {
  26856. fields = append(fields, soptask.FieldType)
  26857. }
  26858. if m.addorganization_id != nil {
  26859. fields = append(fields, soptask.FieldOrganizationID)
  26860. }
  26861. return fields
  26862. }
  26863. // AddedField returns the numeric value that was incremented/decremented on a field
  26864. // with the given name. The second boolean return value indicates that this field
  26865. // was not set, or was not defined in the schema.
  26866. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  26867. switch name {
  26868. case soptask.FieldStatus:
  26869. return m.AddedStatus()
  26870. case soptask.FieldType:
  26871. return m.AddedType()
  26872. case soptask.FieldOrganizationID:
  26873. return m.AddedOrganizationID()
  26874. }
  26875. return nil, false
  26876. }
  26877. // AddField adds the value to the field with the given name. It returns an error if
  26878. // the field is not defined in the schema, or if the type mismatched the field
  26879. // type.
  26880. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  26881. switch name {
  26882. case soptask.FieldStatus:
  26883. v, ok := value.(int8)
  26884. if !ok {
  26885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26886. }
  26887. m.AddStatus(v)
  26888. return nil
  26889. case soptask.FieldType:
  26890. v, ok := value.(int)
  26891. if !ok {
  26892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26893. }
  26894. m.AddType(v)
  26895. return nil
  26896. case soptask.FieldOrganizationID:
  26897. v, ok := value.(int64)
  26898. if !ok {
  26899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26900. }
  26901. m.AddOrganizationID(v)
  26902. return nil
  26903. }
  26904. return fmt.Errorf("unknown SopTask numeric field %s", name)
  26905. }
  26906. // ClearedFields returns all nullable fields that were cleared during this
  26907. // mutation.
  26908. func (m *SopTaskMutation) ClearedFields() []string {
  26909. var fields []string
  26910. if m.FieldCleared(soptask.FieldStatus) {
  26911. fields = append(fields, soptask.FieldStatus)
  26912. }
  26913. if m.FieldCleared(soptask.FieldDeletedAt) {
  26914. fields = append(fields, soptask.FieldDeletedAt)
  26915. }
  26916. if m.FieldCleared(soptask.FieldBotWxidList) {
  26917. fields = append(fields, soptask.FieldBotWxidList)
  26918. }
  26919. if m.FieldCleared(soptask.FieldPlanStartTime) {
  26920. fields = append(fields, soptask.FieldPlanStartTime)
  26921. }
  26922. if m.FieldCleared(soptask.FieldPlanEndTime) {
  26923. fields = append(fields, soptask.FieldPlanEndTime)
  26924. }
  26925. if m.FieldCleared(soptask.FieldCreatorID) {
  26926. fields = append(fields, soptask.FieldCreatorID)
  26927. }
  26928. if m.FieldCleared(soptask.FieldOrganizationID) {
  26929. fields = append(fields, soptask.FieldOrganizationID)
  26930. }
  26931. if m.FieldCleared(soptask.FieldToken) {
  26932. fields = append(fields, soptask.FieldToken)
  26933. }
  26934. return fields
  26935. }
  26936. // FieldCleared returns a boolean indicating if a field with the given name was
  26937. // cleared in this mutation.
  26938. func (m *SopTaskMutation) FieldCleared(name string) bool {
  26939. _, ok := m.clearedFields[name]
  26940. return ok
  26941. }
  26942. // ClearField clears the value of the field with the given name. It returns an
  26943. // error if the field is not defined in the schema.
  26944. func (m *SopTaskMutation) ClearField(name string) error {
  26945. switch name {
  26946. case soptask.FieldStatus:
  26947. m.ClearStatus()
  26948. return nil
  26949. case soptask.FieldDeletedAt:
  26950. m.ClearDeletedAt()
  26951. return nil
  26952. case soptask.FieldBotWxidList:
  26953. m.ClearBotWxidList()
  26954. return nil
  26955. case soptask.FieldPlanStartTime:
  26956. m.ClearPlanStartTime()
  26957. return nil
  26958. case soptask.FieldPlanEndTime:
  26959. m.ClearPlanEndTime()
  26960. return nil
  26961. case soptask.FieldCreatorID:
  26962. m.ClearCreatorID()
  26963. return nil
  26964. case soptask.FieldOrganizationID:
  26965. m.ClearOrganizationID()
  26966. return nil
  26967. case soptask.FieldToken:
  26968. m.ClearToken()
  26969. return nil
  26970. }
  26971. return fmt.Errorf("unknown SopTask nullable field %s", name)
  26972. }
  26973. // ResetField resets all changes in the mutation for the field with the given name.
  26974. // It returns an error if the field is not defined in the schema.
  26975. func (m *SopTaskMutation) ResetField(name string) error {
  26976. switch name {
  26977. case soptask.FieldCreatedAt:
  26978. m.ResetCreatedAt()
  26979. return nil
  26980. case soptask.FieldUpdatedAt:
  26981. m.ResetUpdatedAt()
  26982. return nil
  26983. case soptask.FieldStatus:
  26984. m.ResetStatus()
  26985. return nil
  26986. case soptask.FieldDeletedAt:
  26987. m.ResetDeletedAt()
  26988. return nil
  26989. case soptask.FieldName:
  26990. m.ResetName()
  26991. return nil
  26992. case soptask.FieldBotWxidList:
  26993. m.ResetBotWxidList()
  26994. return nil
  26995. case soptask.FieldType:
  26996. m.ResetType()
  26997. return nil
  26998. case soptask.FieldPlanStartTime:
  26999. m.ResetPlanStartTime()
  27000. return nil
  27001. case soptask.FieldPlanEndTime:
  27002. m.ResetPlanEndTime()
  27003. return nil
  27004. case soptask.FieldCreatorID:
  27005. m.ResetCreatorID()
  27006. return nil
  27007. case soptask.FieldOrganizationID:
  27008. m.ResetOrganizationID()
  27009. return nil
  27010. case soptask.FieldToken:
  27011. m.ResetToken()
  27012. return nil
  27013. }
  27014. return fmt.Errorf("unknown SopTask field %s", name)
  27015. }
  27016. // AddedEdges returns all edge names that were set/added in this mutation.
  27017. func (m *SopTaskMutation) AddedEdges() []string {
  27018. edges := make([]string, 0, 1)
  27019. if m.task_stages != nil {
  27020. edges = append(edges, soptask.EdgeTaskStages)
  27021. }
  27022. return edges
  27023. }
  27024. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27025. // name in this mutation.
  27026. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  27027. switch name {
  27028. case soptask.EdgeTaskStages:
  27029. ids := make([]ent.Value, 0, len(m.task_stages))
  27030. for id := range m.task_stages {
  27031. ids = append(ids, id)
  27032. }
  27033. return ids
  27034. }
  27035. return nil
  27036. }
  27037. // RemovedEdges returns all edge names that were removed in this mutation.
  27038. func (m *SopTaskMutation) RemovedEdges() []string {
  27039. edges := make([]string, 0, 1)
  27040. if m.removedtask_stages != nil {
  27041. edges = append(edges, soptask.EdgeTaskStages)
  27042. }
  27043. return edges
  27044. }
  27045. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27046. // the given name in this mutation.
  27047. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  27048. switch name {
  27049. case soptask.EdgeTaskStages:
  27050. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  27051. for id := range m.removedtask_stages {
  27052. ids = append(ids, id)
  27053. }
  27054. return ids
  27055. }
  27056. return nil
  27057. }
  27058. // ClearedEdges returns all edge names that were cleared in this mutation.
  27059. func (m *SopTaskMutation) ClearedEdges() []string {
  27060. edges := make([]string, 0, 1)
  27061. if m.clearedtask_stages {
  27062. edges = append(edges, soptask.EdgeTaskStages)
  27063. }
  27064. return edges
  27065. }
  27066. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27067. // was cleared in this mutation.
  27068. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  27069. switch name {
  27070. case soptask.EdgeTaskStages:
  27071. return m.clearedtask_stages
  27072. }
  27073. return false
  27074. }
  27075. // ClearEdge clears the value of the edge with the given name. It returns an error
  27076. // if that edge is not defined in the schema.
  27077. func (m *SopTaskMutation) ClearEdge(name string) error {
  27078. switch name {
  27079. }
  27080. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27081. }
  27082. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27083. // It returns an error if the edge is not defined in the schema.
  27084. func (m *SopTaskMutation) ResetEdge(name string) error {
  27085. switch name {
  27086. case soptask.EdgeTaskStages:
  27087. m.ResetTaskStages()
  27088. return nil
  27089. }
  27090. return fmt.Errorf("unknown SopTask edge %s", name)
  27091. }
  27092. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27093. type TokenMutation struct {
  27094. config
  27095. op Op
  27096. typ string
  27097. id *uint64
  27098. created_at *time.Time
  27099. updated_at *time.Time
  27100. deleted_at *time.Time
  27101. expire_at *time.Time
  27102. token *string
  27103. mac *string
  27104. organization_id *uint64
  27105. addorganization_id *int64
  27106. custom_agent_base *string
  27107. custom_agent_key *string
  27108. openai_base *string
  27109. openai_key *string
  27110. clearedFields map[string]struct{}
  27111. agent *uint64
  27112. clearedagent bool
  27113. done bool
  27114. oldValue func(context.Context) (*Token, error)
  27115. predicates []predicate.Token
  27116. }
  27117. var _ ent.Mutation = (*TokenMutation)(nil)
  27118. // tokenOption allows management of the mutation configuration using functional options.
  27119. type tokenOption func(*TokenMutation)
  27120. // newTokenMutation creates new mutation for the Token entity.
  27121. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27122. m := &TokenMutation{
  27123. config: c,
  27124. op: op,
  27125. typ: TypeToken,
  27126. clearedFields: make(map[string]struct{}),
  27127. }
  27128. for _, opt := range opts {
  27129. opt(m)
  27130. }
  27131. return m
  27132. }
  27133. // withTokenID sets the ID field of the mutation.
  27134. func withTokenID(id uint64) tokenOption {
  27135. return func(m *TokenMutation) {
  27136. var (
  27137. err error
  27138. once sync.Once
  27139. value *Token
  27140. )
  27141. m.oldValue = func(ctx context.Context) (*Token, error) {
  27142. once.Do(func() {
  27143. if m.done {
  27144. err = errors.New("querying old values post mutation is not allowed")
  27145. } else {
  27146. value, err = m.Client().Token.Get(ctx, id)
  27147. }
  27148. })
  27149. return value, err
  27150. }
  27151. m.id = &id
  27152. }
  27153. }
  27154. // withToken sets the old Token of the mutation.
  27155. func withToken(node *Token) tokenOption {
  27156. return func(m *TokenMutation) {
  27157. m.oldValue = func(context.Context) (*Token, error) {
  27158. return node, nil
  27159. }
  27160. m.id = &node.ID
  27161. }
  27162. }
  27163. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27164. // executed in a transaction (ent.Tx), a transactional client is returned.
  27165. func (m TokenMutation) Client() *Client {
  27166. client := &Client{config: m.config}
  27167. client.init()
  27168. return client
  27169. }
  27170. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27171. // it returns an error otherwise.
  27172. func (m TokenMutation) Tx() (*Tx, error) {
  27173. if _, ok := m.driver.(*txDriver); !ok {
  27174. return nil, errors.New("ent: mutation is not running in a transaction")
  27175. }
  27176. tx := &Tx{config: m.config}
  27177. tx.init()
  27178. return tx, nil
  27179. }
  27180. // SetID sets the value of the id field. Note that this
  27181. // operation is only accepted on creation of Token entities.
  27182. func (m *TokenMutation) SetID(id uint64) {
  27183. m.id = &id
  27184. }
  27185. // ID returns the ID value in the mutation. Note that the ID is only available
  27186. // if it was provided to the builder or after it was returned from the database.
  27187. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27188. if m.id == nil {
  27189. return
  27190. }
  27191. return *m.id, true
  27192. }
  27193. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27194. // That means, if the mutation is applied within a transaction with an isolation level such
  27195. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27196. // or updated by the mutation.
  27197. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27198. switch {
  27199. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27200. id, exists := m.ID()
  27201. if exists {
  27202. return []uint64{id}, nil
  27203. }
  27204. fallthrough
  27205. case m.op.Is(OpUpdate | OpDelete):
  27206. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27207. default:
  27208. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27209. }
  27210. }
  27211. // SetCreatedAt sets the "created_at" field.
  27212. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27213. m.created_at = &t
  27214. }
  27215. // CreatedAt returns the value of the "created_at" field in the mutation.
  27216. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27217. v := m.created_at
  27218. if v == nil {
  27219. return
  27220. }
  27221. return *v, true
  27222. }
  27223. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27224. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27226. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27227. if !m.op.Is(OpUpdateOne) {
  27228. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27229. }
  27230. if m.id == nil || m.oldValue == nil {
  27231. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27232. }
  27233. oldValue, err := m.oldValue(ctx)
  27234. if err != nil {
  27235. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27236. }
  27237. return oldValue.CreatedAt, nil
  27238. }
  27239. // ResetCreatedAt resets all changes to the "created_at" field.
  27240. func (m *TokenMutation) ResetCreatedAt() {
  27241. m.created_at = nil
  27242. }
  27243. // SetUpdatedAt sets the "updated_at" field.
  27244. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27245. m.updated_at = &t
  27246. }
  27247. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27248. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27249. v := m.updated_at
  27250. if v == nil {
  27251. return
  27252. }
  27253. return *v, true
  27254. }
  27255. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27256. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27258. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27259. if !m.op.Is(OpUpdateOne) {
  27260. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27261. }
  27262. if m.id == nil || m.oldValue == nil {
  27263. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27264. }
  27265. oldValue, err := m.oldValue(ctx)
  27266. if err != nil {
  27267. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27268. }
  27269. return oldValue.UpdatedAt, nil
  27270. }
  27271. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27272. func (m *TokenMutation) ResetUpdatedAt() {
  27273. m.updated_at = nil
  27274. }
  27275. // SetDeletedAt sets the "deleted_at" field.
  27276. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27277. m.deleted_at = &t
  27278. }
  27279. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27280. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27281. v := m.deleted_at
  27282. if v == nil {
  27283. return
  27284. }
  27285. return *v, true
  27286. }
  27287. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27288. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27290. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27291. if !m.op.Is(OpUpdateOne) {
  27292. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27293. }
  27294. if m.id == nil || m.oldValue == nil {
  27295. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27296. }
  27297. oldValue, err := m.oldValue(ctx)
  27298. if err != nil {
  27299. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27300. }
  27301. return oldValue.DeletedAt, nil
  27302. }
  27303. // ClearDeletedAt clears the value of the "deleted_at" field.
  27304. func (m *TokenMutation) ClearDeletedAt() {
  27305. m.deleted_at = nil
  27306. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27307. }
  27308. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27309. func (m *TokenMutation) DeletedAtCleared() bool {
  27310. _, ok := m.clearedFields[token.FieldDeletedAt]
  27311. return ok
  27312. }
  27313. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27314. func (m *TokenMutation) ResetDeletedAt() {
  27315. m.deleted_at = nil
  27316. delete(m.clearedFields, token.FieldDeletedAt)
  27317. }
  27318. // SetExpireAt sets the "expire_at" field.
  27319. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27320. m.expire_at = &t
  27321. }
  27322. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27323. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27324. v := m.expire_at
  27325. if v == nil {
  27326. return
  27327. }
  27328. return *v, true
  27329. }
  27330. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27331. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27333. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27334. if !m.op.Is(OpUpdateOne) {
  27335. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27336. }
  27337. if m.id == nil || m.oldValue == nil {
  27338. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27339. }
  27340. oldValue, err := m.oldValue(ctx)
  27341. if err != nil {
  27342. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27343. }
  27344. return oldValue.ExpireAt, nil
  27345. }
  27346. // ClearExpireAt clears the value of the "expire_at" field.
  27347. func (m *TokenMutation) ClearExpireAt() {
  27348. m.expire_at = nil
  27349. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27350. }
  27351. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27352. func (m *TokenMutation) ExpireAtCleared() bool {
  27353. _, ok := m.clearedFields[token.FieldExpireAt]
  27354. return ok
  27355. }
  27356. // ResetExpireAt resets all changes to the "expire_at" field.
  27357. func (m *TokenMutation) ResetExpireAt() {
  27358. m.expire_at = nil
  27359. delete(m.clearedFields, token.FieldExpireAt)
  27360. }
  27361. // SetToken sets the "token" field.
  27362. func (m *TokenMutation) SetToken(s string) {
  27363. m.token = &s
  27364. }
  27365. // Token returns the value of the "token" field in the mutation.
  27366. func (m *TokenMutation) Token() (r string, exists bool) {
  27367. v := m.token
  27368. if v == nil {
  27369. return
  27370. }
  27371. return *v, true
  27372. }
  27373. // OldToken returns the old "token" field's value of the Token entity.
  27374. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27376. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27377. if !m.op.Is(OpUpdateOne) {
  27378. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27379. }
  27380. if m.id == nil || m.oldValue == nil {
  27381. return v, errors.New("OldToken requires an ID field in the mutation")
  27382. }
  27383. oldValue, err := m.oldValue(ctx)
  27384. if err != nil {
  27385. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27386. }
  27387. return oldValue.Token, nil
  27388. }
  27389. // ClearToken clears the value of the "token" field.
  27390. func (m *TokenMutation) ClearToken() {
  27391. m.token = nil
  27392. m.clearedFields[token.FieldToken] = struct{}{}
  27393. }
  27394. // TokenCleared returns if the "token" field was cleared in this mutation.
  27395. func (m *TokenMutation) TokenCleared() bool {
  27396. _, ok := m.clearedFields[token.FieldToken]
  27397. return ok
  27398. }
  27399. // ResetToken resets all changes to the "token" field.
  27400. func (m *TokenMutation) ResetToken() {
  27401. m.token = nil
  27402. delete(m.clearedFields, token.FieldToken)
  27403. }
  27404. // SetMAC sets the "mac" field.
  27405. func (m *TokenMutation) SetMAC(s string) {
  27406. m.mac = &s
  27407. }
  27408. // MAC returns the value of the "mac" field in the mutation.
  27409. func (m *TokenMutation) MAC() (r string, exists bool) {
  27410. v := m.mac
  27411. if v == nil {
  27412. return
  27413. }
  27414. return *v, true
  27415. }
  27416. // OldMAC returns the old "mac" field's value of the Token entity.
  27417. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27419. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27420. if !m.op.Is(OpUpdateOne) {
  27421. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27422. }
  27423. if m.id == nil || m.oldValue == nil {
  27424. return v, errors.New("OldMAC requires an ID field in the mutation")
  27425. }
  27426. oldValue, err := m.oldValue(ctx)
  27427. if err != nil {
  27428. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27429. }
  27430. return oldValue.MAC, nil
  27431. }
  27432. // ClearMAC clears the value of the "mac" field.
  27433. func (m *TokenMutation) ClearMAC() {
  27434. m.mac = nil
  27435. m.clearedFields[token.FieldMAC] = struct{}{}
  27436. }
  27437. // MACCleared returns if the "mac" field was cleared in this mutation.
  27438. func (m *TokenMutation) MACCleared() bool {
  27439. _, ok := m.clearedFields[token.FieldMAC]
  27440. return ok
  27441. }
  27442. // ResetMAC resets all changes to the "mac" field.
  27443. func (m *TokenMutation) ResetMAC() {
  27444. m.mac = nil
  27445. delete(m.clearedFields, token.FieldMAC)
  27446. }
  27447. // SetOrganizationID sets the "organization_id" field.
  27448. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27449. m.organization_id = &u
  27450. m.addorganization_id = nil
  27451. }
  27452. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27453. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27454. v := m.organization_id
  27455. if v == nil {
  27456. return
  27457. }
  27458. return *v, true
  27459. }
  27460. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27461. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27463. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27464. if !m.op.Is(OpUpdateOne) {
  27465. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27466. }
  27467. if m.id == nil || m.oldValue == nil {
  27468. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27469. }
  27470. oldValue, err := m.oldValue(ctx)
  27471. if err != nil {
  27472. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27473. }
  27474. return oldValue.OrganizationID, nil
  27475. }
  27476. // AddOrganizationID adds u to the "organization_id" field.
  27477. func (m *TokenMutation) AddOrganizationID(u int64) {
  27478. if m.addorganization_id != nil {
  27479. *m.addorganization_id += u
  27480. } else {
  27481. m.addorganization_id = &u
  27482. }
  27483. }
  27484. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27485. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27486. v := m.addorganization_id
  27487. if v == nil {
  27488. return
  27489. }
  27490. return *v, true
  27491. }
  27492. // ResetOrganizationID resets all changes to the "organization_id" field.
  27493. func (m *TokenMutation) ResetOrganizationID() {
  27494. m.organization_id = nil
  27495. m.addorganization_id = nil
  27496. }
  27497. // SetAgentID sets the "agent_id" field.
  27498. func (m *TokenMutation) SetAgentID(u uint64) {
  27499. m.agent = &u
  27500. }
  27501. // AgentID returns the value of the "agent_id" field in the mutation.
  27502. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27503. v := m.agent
  27504. if v == nil {
  27505. return
  27506. }
  27507. return *v, true
  27508. }
  27509. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27510. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27512. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27513. if !m.op.Is(OpUpdateOne) {
  27514. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27515. }
  27516. if m.id == nil || m.oldValue == nil {
  27517. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27518. }
  27519. oldValue, err := m.oldValue(ctx)
  27520. if err != nil {
  27521. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27522. }
  27523. return oldValue.AgentID, nil
  27524. }
  27525. // ResetAgentID resets all changes to the "agent_id" field.
  27526. func (m *TokenMutation) ResetAgentID() {
  27527. m.agent = nil
  27528. }
  27529. // SetCustomAgentBase sets the "custom_agent_base" field.
  27530. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27531. m.custom_agent_base = &s
  27532. }
  27533. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27534. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27535. v := m.custom_agent_base
  27536. if v == nil {
  27537. return
  27538. }
  27539. return *v, true
  27540. }
  27541. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27542. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27544. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27545. if !m.op.Is(OpUpdateOne) {
  27546. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27547. }
  27548. if m.id == nil || m.oldValue == nil {
  27549. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27550. }
  27551. oldValue, err := m.oldValue(ctx)
  27552. if err != nil {
  27553. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27554. }
  27555. return oldValue.CustomAgentBase, nil
  27556. }
  27557. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27558. func (m *TokenMutation) ClearCustomAgentBase() {
  27559. m.custom_agent_base = nil
  27560. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27561. }
  27562. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27563. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27564. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27565. return ok
  27566. }
  27567. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27568. func (m *TokenMutation) ResetCustomAgentBase() {
  27569. m.custom_agent_base = nil
  27570. delete(m.clearedFields, token.FieldCustomAgentBase)
  27571. }
  27572. // SetCustomAgentKey sets the "custom_agent_key" field.
  27573. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27574. m.custom_agent_key = &s
  27575. }
  27576. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27577. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27578. v := m.custom_agent_key
  27579. if v == nil {
  27580. return
  27581. }
  27582. return *v, true
  27583. }
  27584. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27585. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27587. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27588. if !m.op.Is(OpUpdateOne) {
  27589. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27590. }
  27591. if m.id == nil || m.oldValue == nil {
  27592. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27593. }
  27594. oldValue, err := m.oldValue(ctx)
  27595. if err != nil {
  27596. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27597. }
  27598. return oldValue.CustomAgentKey, nil
  27599. }
  27600. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27601. func (m *TokenMutation) ClearCustomAgentKey() {
  27602. m.custom_agent_key = nil
  27603. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27604. }
  27605. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27606. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27607. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27608. return ok
  27609. }
  27610. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27611. func (m *TokenMutation) ResetCustomAgentKey() {
  27612. m.custom_agent_key = nil
  27613. delete(m.clearedFields, token.FieldCustomAgentKey)
  27614. }
  27615. // SetOpenaiBase sets the "openai_base" field.
  27616. func (m *TokenMutation) SetOpenaiBase(s string) {
  27617. m.openai_base = &s
  27618. }
  27619. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27620. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27621. v := m.openai_base
  27622. if v == nil {
  27623. return
  27624. }
  27625. return *v, true
  27626. }
  27627. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27628. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27630. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27631. if !m.op.Is(OpUpdateOne) {
  27632. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27633. }
  27634. if m.id == nil || m.oldValue == nil {
  27635. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  27636. }
  27637. oldValue, err := m.oldValue(ctx)
  27638. if err != nil {
  27639. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  27640. }
  27641. return oldValue.OpenaiBase, nil
  27642. }
  27643. // ClearOpenaiBase clears the value of the "openai_base" field.
  27644. func (m *TokenMutation) ClearOpenaiBase() {
  27645. m.openai_base = nil
  27646. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  27647. }
  27648. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  27649. func (m *TokenMutation) OpenaiBaseCleared() bool {
  27650. _, ok := m.clearedFields[token.FieldOpenaiBase]
  27651. return ok
  27652. }
  27653. // ResetOpenaiBase resets all changes to the "openai_base" field.
  27654. func (m *TokenMutation) ResetOpenaiBase() {
  27655. m.openai_base = nil
  27656. delete(m.clearedFields, token.FieldOpenaiBase)
  27657. }
  27658. // SetOpenaiKey sets the "openai_key" field.
  27659. func (m *TokenMutation) SetOpenaiKey(s string) {
  27660. m.openai_key = &s
  27661. }
  27662. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  27663. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  27664. v := m.openai_key
  27665. if v == nil {
  27666. return
  27667. }
  27668. return *v, true
  27669. }
  27670. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  27671. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27673. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  27674. if !m.op.Is(OpUpdateOne) {
  27675. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  27676. }
  27677. if m.id == nil || m.oldValue == nil {
  27678. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  27679. }
  27680. oldValue, err := m.oldValue(ctx)
  27681. if err != nil {
  27682. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  27683. }
  27684. return oldValue.OpenaiKey, nil
  27685. }
  27686. // ClearOpenaiKey clears the value of the "openai_key" field.
  27687. func (m *TokenMutation) ClearOpenaiKey() {
  27688. m.openai_key = nil
  27689. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  27690. }
  27691. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  27692. func (m *TokenMutation) OpenaiKeyCleared() bool {
  27693. _, ok := m.clearedFields[token.FieldOpenaiKey]
  27694. return ok
  27695. }
  27696. // ResetOpenaiKey resets all changes to the "openai_key" field.
  27697. func (m *TokenMutation) ResetOpenaiKey() {
  27698. m.openai_key = nil
  27699. delete(m.clearedFields, token.FieldOpenaiKey)
  27700. }
  27701. // ClearAgent clears the "agent" edge to the Agent entity.
  27702. func (m *TokenMutation) ClearAgent() {
  27703. m.clearedagent = true
  27704. m.clearedFields[token.FieldAgentID] = struct{}{}
  27705. }
  27706. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  27707. func (m *TokenMutation) AgentCleared() bool {
  27708. return m.clearedagent
  27709. }
  27710. // AgentIDs returns the "agent" edge IDs in the mutation.
  27711. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27712. // AgentID instead. It exists only for internal usage by the builders.
  27713. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  27714. if id := m.agent; id != nil {
  27715. ids = append(ids, *id)
  27716. }
  27717. return
  27718. }
  27719. // ResetAgent resets all changes to the "agent" edge.
  27720. func (m *TokenMutation) ResetAgent() {
  27721. m.agent = nil
  27722. m.clearedagent = false
  27723. }
  27724. // Where appends a list predicates to the TokenMutation builder.
  27725. func (m *TokenMutation) Where(ps ...predicate.Token) {
  27726. m.predicates = append(m.predicates, ps...)
  27727. }
  27728. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  27729. // users can use type-assertion to append predicates that do not depend on any generated package.
  27730. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  27731. p := make([]predicate.Token, len(ps))
  27732. for i := range ps {
  27733. p[i] = ps[i]
  27734. }
  27735. m.Where(p...)
  27736. }
  27737. // Op returns the operation name.
  27738. func (m *TokenMutation) Op() Op {
  27739. return m.op
  27740. }
  27741. // SetOp allows setting the mutation operation.
  27742. func (m *TokenMutation) SetOp(op Op) {
  27743. m.op = op
  27744. }
  27745. // Type returns the node type of this mutation (Token).
  27746. func (m *TokenMutation) Type() string {
  27747. return m.typ
  27748. }
  27749. // Fields returns all fields that were changed during this mutation. Note that in
  27750. // order to get all numeric fields that were incremented/decremented, call
  27751. // AddedFields().
  27752. func (m *TokenMutation) Fields() []string {
  27753. fields := make([]string, 0, 12)
  27754. if m.created_at != nil {
  27755. fields = append(fields, token.FieldCreatedAt)
  27756. }
  27757. if m.updated_at != nil {
  27758. fields = append(fields, token.FieldUpdatedAt)
  27759. }
  27760. if m.deleted_at != nil {
  27761. fields = append(fields, token.FieldDeletedAt)
  27762. }
  27763. if m.expire_at != nil {
  27764. fields = append(fields, token.FieldExpireAt)
  27765. }
  27766. if m.token != nil {
  27767. fields = append(fields, token.FieldToken)
  27768. }
  27769. if m.mac != nil {
  27770. fields = append(fields, token.FieldMAC)
  27771. }
  27772. if m.organization_id != nil {
  27773. fields = append(fields, token.FieldOrganizationID)
  27774. }
  27775. if m.agent != nil {
  27776. fields = append(fields, token.FieldAgentID)
  27777. }
  27778. if m.custom_agent_base != nil {
  27779. fields = append(fields, token.FieldCustomAgentBase)
  27780. }
  27781. if m.custom_agent_key != nil {
  27782. fields = append(fields, token.FieldCustomAgentKey)
  27783. }
  27784. if m.openai_base != nil {
  27785. fields = append(fields, token.FieldOpenaiBase)
  27786. }
  27787. if m.openai_key != nil {
  27788. fields = append(fields, token.FieldOpenaiKey)
  27789. }
  27790. return fields
  27791. }
  27792. // Field returns the value of a field with the given name. The second boolean
  27793. // return value indicates that this field was not set, or was not defined in the
  27794. // schema.
  27795. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  27796. switch name {
  27797. case token.FieldCreatedAt:
  27798. return m.CreatedAt()
  27799. case token.FieldUpdatedAt:
  27800. return m.UpdatedAt()
  27801. case token.FieldDeletedAt:
  27802. return m.DeletedAt()
  27803. case token.FieldExpireAt:
  27804. return m.ExpireAt()
  27805. case token.FieldToken:
  27806. return m.Token()
  27807. case token.FieldMAC:
  27808. return m.MAC()
  27809. case token.FieldOrganizationID:
  27810. return m.OrganizationID()
  27811. case token.FieldAgentID:
  27812. return m.AgentID()
  27813. case token.FieldCustomAgentBase:
  27814. return m.CustomAgentBase()
  27815. case token.FieldCustomAgentKey:
  27816. return m.CustomAgentKey()
  27817. case token.FieldOpenaiBase:
  27818. return m.OpenaiBase()
  27819. case token.FieldOpenaiKey:
  27820. return m.OpenaiKey()
  27821. }
  27822. return nil, false
  27823. }
  27824. // OldField returns the old value of the field from the database. An error is
  27825. // returned if the mutation operation is not UpdateOne, or the query to the
  27826. // database failed.
  27827. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27828. switch name {
  27829. case token.FieldCreatedAt:
  27830. return m.OldCreatedAt(ctx)
  27831. case token.FieldUpdatedAt:
  27832. return m.OldUpdatedAt(ctx)
  27833. case token.FieldDeletedAt:
  27834. return m.OldDeletedAt(ctx)
  27835. case token.FieldExpireAt:
  27836. return m.OldExpireAt(ctx)
  27837. case token.FieldToken:
  27838. return m.OldToken(ctx)
  27839. case token.FieldMAC:
  27840. return m.OldMAC(ctx)
  27841. case token.FieldOrganizationID:
  27842. return m.OldOrganizationID(ctx)
  27843. case token.FieldAgentID:
  27844. return m.OldAgentID(ctx)
  27845. case token.FieldCustomAgentBase:
  27846. return m.OldCustomAgentBase(ctx)
  27847. case token.FieldCustomAgentKey:
  27848. return m.OldCustomAgentKey(ctx)
  27849. case token.FieldOpenaiBase:
  27850. return m.OldOpenaiBase(ctx)
  27851. case token.FieldOpenaiKey:
  27852. return m.OldOpenaiKey(ctx)
  27853. }
  27854. return nil, fmt.Errorf("unknown Token field %s", name)
  27855. }
  27856. // SetField sets the value of a field with the given name. It returns an error if
  27857. // the field is not defined in the schema, or if the type mismatched the field
  27858. // type.
  27859. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  27860. switch name {
  27861. case token.FieldCreatedAt:
  27862. v, ok := value.(time.Time)
  27863. if !ok {
  27864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27865. }
  27866. m.SetCreatedAt(v)
  27867. return nil
  27868. case token.FieldUpdatedAt:
  27869. v, ok := value.(time.Time)
  27870. if !ok {
  27871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27872. }
  27873. m.SetUpdatedAt(v)
  27874. return nil
  27875. case token.FieldDeletedAt:
  27876. v, ok := value.(time.Time)
  27877. if !ok {
  27878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27879. }
  27880. m.SetDeletedAt(v)
  27881. return nil
  27882. case token.FieldExpireAt:
  27883. v, ok := value.(time.Time)
  27884. if !ok {
  27885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27886. }
  27887. m.SetExpireAt(v)
  27888. return nil
  27889. case token.FieldToken:
  27890. v, ok := value.(string)
  27891. if !ok {
  27892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27893. }
  27894. m.SetToken(v)
  27895. return nil
  27896. case token.FieldMAC:
  27897. v, ok := value.(string)
  27898. if !ok {
  27899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27900. }
  27901. m.SetMAC(v)
  27902. return nil
  27903. case token.FieldOrganizationID:
  27904. v, ok := value.(uint64)
  27905. if !ok {
  27906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27907. }
  27908. m.SetOrganizationID(v)
  27909. return nil
  27910. case token.FieldAgentID:
  27911. v, ok := value.(uint64)
  27912. if !ok {
  27913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27914. }
  27915. m.SetAgentID(v)
  27916. return nil
  27917. case token.FieldCustomAgentBase:
  27918. v, ok := value.(string)
  27919. if !ok {
  27920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27921. }
  27922. m.SetCustomAgentBase(v)
  27923. return nil
  27924. case token.FieldCustomAgentKey:
  27925. v, ok := value.(string)
  27926. if !ok {
  27927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27928. }
  27929. m.SetCustomAgentKey(v)
  27930. return nil
  27931. case token.FieldOpenaiBase:
  27932. v, ok := value.(string)
  27933. if !ok {
  27934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27935. }
  27936. m.SetOpenaiBase(v)
  27937. return nil
  27938. case token.FieldOpenaiKey:
  27939. v, ok := value.(string)
  27940. if !ok {
  27941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27942. }
  27943. m.SetOpenaiKey(v)
  27944. return nil
  27945. }
  27946. return fmt.Errorf("unknown Token field %s", name)
  27947. }
  27948. // AddedFields returns all numeric fields that were incremented/decremented during
  27949. // this mutation.
  27950. func (m *TokenMutation) AddedFields() []string {
  27951. var fields []string
  27952. if m.addorganization_id != nil {
  27953. fields = append(fields, token.FieldOrganizationID)
  27954. }
  27955. return fields
  27956. }
  27957. // AddedField returns the numeric value that was incremented/decremented on a field
  27958. // with the given name. The second boolean return value indicates that this field
  27959. // was not set, or was not defined in the schema.
  27960. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  27961. switch name {
  27962. case token.FieldOrganizationID:
  27963. return m.AddedOrganizationID()
  27964. }
  27965. return nil, false
  27966. }
  27967. // AddField adds the value to the field with the given name. It returns an error if
  27968. // the field is not defined in the schema, or if the type mismatched the field
  27969. // type.
  27970. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  27971. switch name {
  27972. case token.FieldOrganizationID:
  27973. v, ok := value.(int64)
  27974. if !ok {
  27975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27976. }
  27977. m.AddOrganizationID(v)
  27978. return nil
  27979. }
  27980. return fmt.Errorf("unknown Token numeric field %s", name)
  27981. }
  27982. // ClearedFields returns all nullable fields that were cleared during this
  27983. // mutation.
  27984. func (m *TokenMutation) ClearedFields() []string {
  27985. var fields []string
  27986. if m.FieldCleared(token.FieldDeletedAt) {
  27987. fields = append(fields, token.FieldDeletedAt)
  27988. }
  27989. if m.FieldCleared(token.FieldExpireAt) {
  27990. fields = append(fields, token.FieldExpireAt)
  27991. }
  27992. if m.FieldCleared(token.FieldToken) {
  27993. fields = append(fields, token.FieldToken)
  27994. }
  27995. if m.FieldCleared(token.FieldMAC) {
  27996. fields = append(fields, token.FieldMAC)
  27997. }
  27998. if m.FieldCleared(token.FieldCustomAgentBase) {
  27999. fields = append(fields, token.FieldCustomAgentBase)
  28000. }
  28001. if m.FieldCleared(token.FieldCustomAgentKey) {
  28002. fields = append(fields, token.FieldCustomAgentKey)
  28003. }
  28004. if m.FieldCleared(token.FieldOpenaiBase) {
  28005. fields = append(fields, token.FieldOpenaiBase)
  28006. }
  28007. if m.FieldCleared(token.FieldOpenaiKey) {
  28008. fields = append(fields, token.FieldOpenaiKey)
  28009. }
  28010. return fields
  28011. }
  28012. // FieldCleared returns a boolean indicating if a field with the given name was
  28013. // cleared in this mutation.
  28014. func (m *TokenMutation) FieldCleared(name string) bool {
  28015. _, ok := m.clearedFields[name]
  28016. return ok
  28017. }
  28018. // ClearField clears the value of the field with the given name. It returns an
  28019. // error if the field is not defined in the schema.
  28020. func (m *TokenMutation) ClearField(name string) error {
  28021. switch name {
  28022. case token.FieldDeletedAt:
  28023. m.ClearDeletedAt()
  28024. return nil
  28025. case token.FieldExpireAt:
  28026. m.ClearExpireAt()
  28027. return nil
  28028. case token.FieldToken:
  28029. m.ClearToken()
  28030. return nil
  28031. case token.FieldMAC:
  28032. m.ClearMAC()
  28033. return nil
  28034. case token.FieldCustomAgentBase:
  28035. m.ClearCustomAgentBase()
  28036. return nil
  28037. case token.FieldCustomAgentKey:
  28038. m.ClearCustomAgentKey()
  28039. return nil
  28040. case token.FieldOpenaiBase:
  28041. m.ClearOpenaiBase()
  28042. return nil
  28043. case token.FieldOpenaiKey:
  28044. m.ClearOpenaiKey()
  28045. return nil
  28046. }
  28047. return fmt.Errorf("unknown Token nullable field %s", name)
  28048. }
  28049. // ResetField resets all changes in the mutation for the field with the given name.
  28050. // It returns an error if the field is not defined in the schema.
  28051. func (m *TokenMutation) ResetField(name string) error {
  28052. switch name {
  28053. case token.FieldCreatedAt:
  28054. m.ResetCreatedAt()
  28055. return nil
  28056. case token.FieldUpdatedAt:
  28057. m.ResetUpdatedAt()
  28058. return nil
  28059. case token.FieldDeletedAt:
  28060. m.ResetDeletedAt()
  28061. return nil
  28062. case token.FieldExpireAt:
  28063. m.ResetExpireAt()
  28064. return nil
  28065. case token.FieldToken:
  28066. m.ResetToken()
  28067. return nil
  28068. case token.FieldMAC:
  28069. m.ResetMAC()
  28070. return nil
  28071. case token.FieldOrganizationID:
  28072. m.ResetOrganizationID()
  28073. return nil
  28074. case token.FieldAgentID:
  28075. m.ResetAgentID()
  28076. return nil
  28077. case token.FieldCustomAgentBase:
  28078. m.ResetCustomAgentBase()
  28079. return nil
  28080. case token.FieldCustomAgentKey:
  28081. m.ResetCustomAgentKey()
  28082. return nil
  28083. case token.FieldOpenaiBase:
  28084. m.ResetOpenaiBase()
  28085. return nil
  28086. case token.FieldOpenaiKey:
  28087. m.ResetOpenaiKey()
  28088. return nil
  28089. }
  28090. return fmt.Errorf("unknown Token field %s", name)
  28091. }
  28092. // AddedEdges returns all edge names that were set/added in this mutation.
  28093. func (m *TokenMutation) AddedEdges() []string {
  28094. edges := make([]string, 0, 1)
  28095. if m.agent != nil {
  28096. edges = append(edges, token.EdgeAgent)
  28097. }
  28098. return edges
  28099. }
  28100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28101. // name in this mutation.
  28102. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28103. switch name {
  28104. case token.EdgeAgent:
  28105. if id := m.agent; id != nil {
  28106. return []ent.Value{*id}
  28107. }
  28108. }
  28109. return nil
  28110. }
  28111. // RemovedEdges returns all edge names that were removed in this mutation.
  28112. func (m *TokenMutation) RemovedEdges() []string {
  28113. edges := make([]string, 0, 1)
  28114. return edges
  28115. }
  28116. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28117. // the given name in this mutation.
  28118. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28119. return nil
  28120. }
  28121. // ClearedEdges returns all edge names that were cleared in this mutation.
  28122. func (m *TokenMutation) ClearedEdges() []string {
  28123. edges := make([]string, 0, 1)
  28124. if m.clearedagent {
  28125. edges = append(edges, token.EdgeAgent)
  28126. }
  28127. return edges
  28128. }
  28129. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28130. // was cleared in this mutation.
  28131. func (m *TokenMutation) EdgeCleared(name string) bool {
  28132. switch name {
  28133. case token.EdgeAgent:
  28134. return m.clearedagent
  28135. }
  28136. return false
  28137. }
  28138. // ClearEdge clears the value of the edge with the given name. It returns an error
  28139. // if that edge is not defined in the schema.
  28140. func (m *TokenMutation) ClearEdge(name string) error {
  28141. switch name {
  28142. case token.EdgeAgent:
  28143. m.ClearAgent()
  28144. return nil
  28145. }
  28146. return fmt.Errorf("unknown Token unique edge %s", name)
  28147. }
  28148. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28149. // It returns an error if the edge is not defined in the schema.
  28150. func (m *TokenMutation) ResetEdge(name string) error {
  28151. switch name {
  28152. case token.EdgeAgent:
  28153. m.ResetAgent()
  28154. return nil
  28155. }
  28156. return fmt.Errorf("unknown Token edge %s", name)
  28157. }
  28158. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28159. type TutorialMutation struct {
  28160. config
  28161. op Op
  28162. typ string
  28163. id *uint64
  28164. created_at *time.Time
  28165. updated_at *time.Time
  28166. deleted_at *time.Time
  28167. index *int
  28168. addindex *int
  28169. title *string
  28170. content *string
  28171. organization_id *uint64
  28172. addorganization_id *int64
  28173. clearedFields map[string]struct{}
  28174. employee *uint64
  28175. clearedemployee bool
  28176. done bool
  28177. oldValue func(context.Context) (*Tutorial, error)
  28178. predicates []predicate.Tutorial
  28179. }
  28180. var _ ent.Mutation = (*TutorialMutation)(nil)
  28181. // tutorialOption allows management of the mutation configuration using functional options.
  28182. type tutorialOption func(*TutorialMutation)
  28183. // newTutorialMutation creates new mutation for the Tutorial entity.
  28184. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28185. m := &TutorialMutation{
  28186. config: c,
  28187. op: op,
  28188. typ: TypeTutorial,
  28189. clearedFields: make(map[string]struct{}),
  28190. }
  28191. for _, opt := range opts {
  28192. opt(m)
  28193. }
  28194. return m
  28195. }
  28196. // withTutorialID sets the ID field of the mutation.
  28197. func withTutorialID(id uint64) tutorialOption {
  28198. return func(m *TutorialMutation) {
  28199. var (
  28200. err error
  28201. once sync.Once
  28202. value *Tutorial
  28203. )
  28204. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28205. once.Do(func() {
  28206. if m.done {
  28207. err = errors.New("querying old values post mutation is not allowed")
  28208. } else {
  28209. value, err = m.Client().Tutorial.Get(ctx, id)
  28210. }
  28211. })
  28212. return value, err
  28213. }
  28214. m.id = &id
  28215. }
  28216. }
  28217. // withTutorial sets the old Tutorial of the mutation.
  28218. func withTutorial(node *Tutorial) tutorialOption {
  28219. return func(m *TutorialMutation) {
  28220. m.oldValue = func(context.Context) (*Tutorial, error) {
  28221. return node, nil
  28222. }
  28223. m.id = &node.ID
  28224. }
  28225. }
  28226. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28227. // executed in a transaction (ent.Tx), a transactional client is returned.
  28228. func (m TutorialMutation) Client() *Client {
  28229. client := &Client{config: m.config}
  28230. client.init()
  28231. return client
  28232. }
  28233. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28234. // it returns an error otherwise.
  28235. func (m TutorialMutation) Tx() (*Tx, error) {
  28236. if _, ok := m.driver.(*txDriver); !ok {
  28237. return nil, errors.New("ent: mutation is not running in a transaction")
  28238. }
  28239. tx := &Tx{config: m.config}
  28240. tx.init()
  28241. return tx, nil
  28242. }
  28243. // SetID sets the value of the id field. Note that this
  28244. // operation is only accepted on creation of Tutorial entities.
  28245. func (m *TutorialMutation) SetID(id uint64) {
  28246. m.id = &id
  28247. }
  28248. // ID returns the ID value in the mutation. Note that the ID is only available
  28249. // if it was provided to the builder or after it was returned from the database.
  28250. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28251. if m.id == nil {
  28252. return
  28253. }
  28254. return *m.id, true
  28255. }
  28256. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28257. // That means, if the mutation is applied within a transaction with an isolation level such
  28258. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28259. // or updated by the mutation.
  28260. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28261. switch {
  28262. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28263. id, exists := m.ID()
  28264. if exists {
  28265. return []uint64{id}, nil
  28266. }
  28267. fallthrough
  28268. case m.op.Is(OpUpdate | OpDelete):
  28269. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28270. default:
  28271. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28272. }
  28273. }
  28274. // SetCreatedAt sets the "created_at" field.
  28275. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28276. m.created_at = &t
  28277. }
  28278. // CreatedAt returns the value of the "created_at" field in the mutation.
  28279. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28280. v := m.created_at
  28281. if v == nil {
  28282. return
  28283. }
  28284. return *v, true
  28285. }
  28286. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28287. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28289. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28290. if !m.op.Is(OpUpdateOne) {
  28291. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28292. }
  28293. if m.id == nil || m.oldValue == nil {
  28294. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28295. }
  28296. oldValue, err := m.oldValue(ctx)
  28297. if err != nil {
  28298. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28299. }
  28300. return oldValue.CreatedAt, nil
  28301. }
  28302. // ResetCreatedAt resets all changes to the "created_at" field.
  28303. func (m *TutorialMutation) ResetCreatedAt() {
  28304. m.created_at = nil
  28305. }
  28306. // SetUpdatedAt sets the "updated_at" field.
  28307. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28308. m.updated_at = &t
  28309. }
  28310. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28311. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28312. v := m.updated_at
  28313. if v == nil {
  28314. return
  28315. }
  28316. return *v, true
  28317. }
  28318. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28319. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28321. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28322. if !m.op.Is(OpUpdateOne) {
  28323. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28324. }
  28325. if m.id == nil || m.oldValue == nil {
  28326. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28327. }
  28328. oldValue, err := m.oldValue(ctx)
  28329. if err != nil {
  28330. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28331. }
  28332. return oldValue.UpdatedAt, nil
  28333. }
  28334. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28335. func (m *TutorialMutation) ResetUpdatedAt() {
  28336. m.updated_at = nil
  28337. }
  28338. // SetDeletedAt sets the "deleted_at" field.
  28339. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28340. m.deleted_at = &t
  28341. }
  28342. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28343. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28344. v := m.deleted_at
  28345. if v == nil {
  28346. return
  28347. }
  28348. return *v, true
  28349. }
  28350. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28351. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28353. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28354. if !m.op.Is(OpUpdateOne) {
  28355. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28356. }
  28357. if m.id == nil || m.oldValue == nil {
  28358. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28359. }
  28360. oldValue, err := m.oldValue(ctx)
  28361. if err != nil {
  28362. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28363. }
  28364. return oldValue.DeletedAt, nil
  28365. }
  28366. // ClearDeletedAt clears the value of the "deleted_at" field.
  28367. func (m *TutorialMutation) ClearDeletedAt() {
  28368. m.deleted_at = nil
  28369. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28370. }
  28371. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28372. func (m *TutorialMutation) DeletedAtCleared() bool {
  28373. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28374. return ok
  28375. }
  28376. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28377. func (m *TutorialMutation) ResetDeletedAt() {
  28378. m.deleted_at = nil
  28379. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28380. }
  28381. // SetEmployeeID sets the "employee_id" field.
  28382. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28383. m.employee = &u
  28384. }
  28385. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28386. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28387. v := m.employee
  28388. if v == nil {
  28389. return
  28390. }
  28391. return *v, true
  28392. }
  28393. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28394. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28396. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28397. if !m.op.Is(OpUpdateOne) {
  28398. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28399. }
  28400. if m.id == nil || m.oldValue == nil {
  28401. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28402. }
  28403. oldValue, err := m.oldValue(ctx)
  28404. if err != nil {
  28405. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28406. }
  28407. return oldValue.EmployeeID, nil
  28408. }
  28409. // ResetEmployeeID resets all changes to the "employee_id" field.
  28410. func (m *TutorialMutation) ResetEmployeeID() {
  28411. m.employee = nil
  28412. }
  28413. // SetIndex sets the "index" field.
  28414. func (m *TutorialMutation) SetIndex(i int) {
  28415. m.index = &i
  28416. m.addindex = nil
  28417. }
  28418. // Index returns the value of the "index" field in the mutation.
  28419. func (m *TutorialMutation) Index() (r int, exists bool) {
  28420. v := m.index
  28421. if v == nil {
  28422. return
  28423. }
  28424. return *v, true
  28425. }
  28426. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28427. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28429. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28430. if !m.op.Is(OpUpdateOne) {
  28431. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28432. }
  28433. if m.id == nil || m.oldValue == nil {
  28434. return v, errors.New("OldIndex requires an ID field in the mutation")
  28435. }
  28436. oldValue, err := m.oldValue(ctx)
  28437. if err != nil {
  28438. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28439. }
  28440. return oldValue.Index, nil
  28441. }
  28442. // AddIndex adds i to the "index" field.
  28443. func (m *TutorialMutation) AddIndex(i int) {
  28444. if m.addindex != nil {
  28445. *m.addindex += i
  28446. } else {
  28447. m.addindex = &i
  28448. }
  28449. }
  28450. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28451. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28452. v := m.addindex
  28453. if v == nil {
  28454. return
  28455. }
  28456. return *v, true
  28457. }
  28458. // ResetIndex resets all changes to the "index" field.
  28459. func (m *TutorialMutation) ResetIndex() {
  28460. m.index = nil
  28461. m.addindex = nil
  28462. }
  28463. // SetTitle sets the "title" field.
  28464. func (m *TutorialMutation) SetTitle(s string) {
  28465. m.title = &s
  28466. }
  28467. // Title returns the value of the "title" field in the mutation.
  28468. func (m *TutorialMutation) Title() (r string, exists bool) {
  28469. v := m.title
  28470. if v == nil {
  28471. return
  28472. }
  28473. return *v, true
  28474. }
  28475. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28476. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28478. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28479. if !m.op.Is(OpUpdateOne) {
  28480. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28481. }
  28482. if m.id == nil || m.oldValue == nil {
  28483. return v, errors.New("OldTitle requires an ID field in the mutation")
  28484. }
  28485. oldValue, err := m.oldValue(ctx)
  28486. if err != nil {
  28487. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28488. }
  28489. return oldValue.Title, nil
  28490. }
  28491. // ResetTitle resets all changes to the "title" field.
  28492. func (m *TutorialMutation) ResetTitle() {
  28493. m.title = nil
  28494. }
  28495. // SetContent sets the "content" field.
  28496. func (m *TutorialMutation) SetContent(s string) {
  28497. m.content = &s
  28498. }
  28499. // Content returns the value of the "content" field in the mutation.
  28500. func (m *TutorialMutation) Content() (r string, exists bool) {
  28501. v := m.content
  28502. if v == nil {
  28503. return
  28504. }
  28505. return *v, true
  28506. }
  28507. // OldContent returns the old "content" field's value of the Tutorial entity.
  28508. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28510. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28511. if !m.op.Is(OpUpdateOne) {
  28512. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28513. }
  28514. if m.id == nil || m.oldValue == nil {
  28515. return v, errors.New("OldContent requires an ID field in the mutation")
  28516. }
  28517. oldValue, err := m.oldValue(ctx)
  28518. if err != nil {
  28519. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28520. }
  28521. return oldValue.Content, nil
  28522. }
  28523. // ResetContent resets all changes to the "content" field.
  28524. func (m *TutorialMutation) ResetContent() {
  28525. m.content = nil
  28526. }
  28527. // SetOrganizationID sets the "organization_id" field.
  28528. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28529. m.organization_id = &u
  28530. m.addorganization_id = nil
  28531. }
  28532. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28533. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28534. v := m.organization_id
  28535. if v == nil {
  28536. return
  28537. }
  28538. return *v, true
  28539. }
  28540. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28541. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28543. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28544. if !m.op.Is(OpUpdateOne) {
  28545. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28546. }
  28547. if m.id == nil || m.oldValue == nil {
  28548. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28549. }
  28550. oldValue, err := m.oldValue(ctx)
  28551. if err != nil {
  28552. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28553. }
  28554. return oldValue.OrganizationID, nil
  28555. }
  28556. // AddOrganizationID adds u to the "organization_id" field.
  28557. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28558. if m.addorganization_id != nil {
  28559. *m.addorganization_id += u
  28560. } else {
  28561. m.addorganization_id = &u
  28562. }
  28563. }
  28564. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28565. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28566. v := m.addorganization_id
  28567. if v == nil {
  28568. return
  28569. }
  28570. return *v, true
  28571. }
  28572. // ResetOrganizationID resets all changes to the "organization_id" field.
  28573. func (m *TutorialMutation) ResetOrganizationID() {
  28574. m.organization_id = nil
  28575. m.addorganization_id = nil
  28576. }
  28577. // ClearEmployee clears the "employee" edge to the Employee entity.
  28578. func (m *TutorialMutation) ClearEmployee() {
  28579. m.clearedemployee = true
  28580. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28581. }
  28582. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28583. func (m *TutorialMutation) EmployeeCleared() bool {
  28584. return m.clearedemployee
  28585. }
  28586. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28587. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28588. // EmployeeID instead. It exists only for internal usage by the builders.
  28589. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28590. if id := m.employee; id != nil {
  28591. ids = append(ids, *id)
  28592. }
  28593. return
  28594. }
  28595. // ResetEmployee resets all changes to the "employee" edge.
  28596. func (m *TutorialMutation) ResetEmployee() {
  28597. m.employee = nil
  28598. m.clearedemployee = false
  28599. }
  28600. // Where appends a list predicates to the TutorialMutation builder.
  28601. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28602. m.predicates = append(m.predicates, ps...)
  28603. }
  28604. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28605. // users can use type-assertion to append predicates that do not depend on any generated package.
  28606. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28607. p := make([]predicate.Tutorial, len(ps))
  28608. for i := range ps {
  28609. p[i] = ps[i]
  28610. }
  28611. m.Where(p...)
  28612. }
  28613. // Op returns the operation name.
  28614. func (m *TutorialMutation) Op() Op {
  28615. return m.op
  28616. }
  28617. // SetOp allows setting the mutation operation.
  28618. func (m *TutorialMutation) SetOp(op Op) {
  28619. m.op = op
  28620. }
  28621. // Type returns the node type of this mutation (Tutorial).
  28622. func (m *TutorialMutation) Type() string {
  28623. return m.typ
  28624. }
  28625. // Fields returns all fields that were changed during this mutation. Note that in
  28626. // order to get all numeric fields that were incremented/decremented, call
  28627. // AddedFields().
  28628. func (m *TutorialMutation) Fields() []string {
  28629. fields := make([]string, 0, 8)
  28630. if m.created_at != nil {
  28631. fields = append(fields, tutorial.FieldCreatedAt)
  28632. }
  28633. if m.updated_at != nil {
  28634. fields = append(fields, tutorial.FieldUpdatedAt)
  28635. }
  28636. if m.deleted_at != nil {
  28637. fields = append(fields, tutorial.FieldDeletedAt)
  28638. }
  28639. if m.employee != nil {
  28640. fields = append(fields, tutorial.FieldEmployeeID)
  28641. }
  28642. if m.index != nil {
  28643. fields = append(fields, tutorial.FieldIndex)
  28644. }
  28645. if m.title != nil {
  28646. fields = append(fields, tutorial.FieldTitle)
  28647. }
  28648. if m.content != nil {
  28649. fields = append(fields, tutorial.FieldContent)
  28650. }
  28651. if m.organization_id != nil {
  28652. fields = append(fields, tutorial.FieldOrganizationID)
  28653. }
  28654. return fields
  28655. }
  28656. // Field returns the value of a field with the given name. The second boolean
  28657. // return value indicates that this field was not set, or was not defined in the
  28658. // schema.
  28659. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  28660. switch name {
  28661. case tutorial.FieldCreatedAt:
  28662. return m.CreatedAt()
  28663. case tutorial.FieldUpdatedAt:
  28664. return m.UpdatedAt()
  28665. case tutorial.FieldDeletedAt:
  28666. return m.DeletedAt()
  28667. case tutorial.FieldEmployeeID:
  28668. return m.EmployeeID()
  28669. case tutorial.FieldIndex:
  28670. return m.Index()
  28671. case tutorial.FieldTitle:
  28672. return m.Title()
  28673. case tutorial.FieldContent:
  28674. return m.Content()
  28675. case tutorial.FieldOrganizationID:
  28676. return m.OrganizationID()
  28677. }
  28678. return nil, false
  28679. }
  28680. // OldField returns the old value of the field from the database. An error is
  28681. // returned if the mutation operation is not UpdateOne, or the query to the
  28682. // database failed.
  28683. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28684. switch name {
  28685. case tutorial.FieldCreatedAt:
  28686. return m.OldCreatedAt(ctx)
  28687. case tutorial.FieldUpdatedAt:
  28688. return m.OldUpdatedAt(ctx)
  28689. case tutorial.FieldDeletedAt:
  28690. return m.OldDeletedAt(ctx)
  28691. case tutorial.FieldEmployeeID:
  28692. return m.OldEmployeeID(ctx)
  28693. case tutorial.FieldIndex:
  28694. return m.OldIndex(ctx)
  28695. case tutorial.FieldTitle:
  28696. return m.OldTitle(ctx)
  28697. case tutorial.FieldContent:
  28698. return m.OldContent(ctx)
  28699. case tutorial.FieldOrganizationID:
  28700. return m.OldOrganizationID(ctx)
  28701. }
  28702. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  28703. }
  28704. // SetField sets the value of a field with the given name. It returns an error if
  28705. // the field is not defined in the schema, or if the type mismatched the field
  28706. // type.
  28707. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  28708. switch name {
  28709. case tutorial.FieldCreatedAt:
  28710. v, ok := value.(time.Time)
  28711. if !ok {
  28712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28713. }
  28714. m.SetCreatedAt(v)
  28715. return nil
  28716. case tutorial.FieldUpdatedAt:
  28717. v, ok := value.(time.Time)
  28718. if !ok {
  28719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28720. }
  28721. m.SetUpdatedAt(v)
  28722. return nil
  28723. case tutorial.FieldDeletedAt:
  28724. v, ok := value.(time.Time)
  28725. if !ok {
  28726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28727. }
  28728. m.SetDeletedAt(v)
  28729. return nil
  28730. case tutorial.FieldEmployeeID:
  28731. v, ok := value.(uint64)
  28732. if !ok {
  28733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28734. }
  28735. m.SetEmployeeID(v)
  28736. return nil
  28737. case tutorial.FieldIndex:
  28738. v, ok := value.(int)
  28739. if !ok {
  28740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28741. }
  28742. m.SetIndex(v)
  28743. return nil
  28744. case tutorial.FieldTitle:
  28745. v, ok := value.(string)
  28746. if !ok {
  28747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28748. }
  28749. m.SetTitle(v)
  28750. return nil
  28751. case tutorial.FieldContent:
  28752. v, ok := value.(string)
  28753. if !ok {
  28754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28755. }
  28756. m.SetContent(v)
  28757. return nil
  28758. case tutorial.FieldOrganizationID:
  28759. v, ok := value.(uint64)
  28760. if !ok {
  28761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28762. }
  28763. m.SetOrganizationID(v)
  28764. return nil
  28765. }
  28766. return fmt.Errorf("unknown Tutorial field %s", name)
  28767. }
  28768. // AddedFields returns all numeric fields that were incremented/decremented during
  28769. // this mutation.
  28770. func (m *TutorialMutation) AddedFields() []string {
  28771. var fields []string
  28772. if m.addindex != nil {
  28773. fields = append(fields, tutorial.FieldIndex)
  28774. }
  28775. if m.addorganization_id != nil {
  28776. fields = append(fields, tutorial.FieldOrganizationID)
  28777. }
  28778. return fields
  28779. }
  28780. // AddedField returns the numeric value that was incremented/decremented on a field
  28781. // with the given name. The second boolean return value indicates that this field
  28782. // was not set, or was not defined in the schema.
  28783. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  28784. switch name {
  28785. case tutorial.FieldIndex:
  28786. return m.AddedIndex()
  28787. case tutorial.FieldOrganizationID:
  28788. return m.AddedOrganizationID()
  28789. }
  28790. return nil, false
  28791. }
  28792. // AddField adds the value to the field with the given name. It returns an error if
  28793. // the field is not defined in the schema, or if the type mismatched the field
  28794. // type.
  28795. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  28796. switch name {
  28797. case tutorial.FieldIndex:
  28798. v, ok := value.(int)
  28799. if !ok {
  28800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28801. }
  28802. m.AddIndex(v)
  28803. return nil
  28804. case tutorial.FieldOrganizationID:
  28805. v, ok := value.(int64)
  28806. if !ok {
  28807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28808. }
  28809. m.AddOrganizationID(v)
  28810. return nil
  28811. }
  28812. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  28813. }
  28814. // ClearedFields returns all nullable fields that were cleared during this
  28815. // mutation.
  28816. func (m *TutorialMutation) ClearedFields() []string {
  28817. var fields []string
  28818. if m.FieldCleared(tutorial.FieldDeletedAt) {
  28819. fields = append(fields, tutorial.FieldDeletedAt)
  28820. }
  28821. return fields
  28822. }
  28823. // FieldCleared returns a boolean indicating if a field with the given name was
  28824. // cleared in this mutation.
  28825. func (m *TutorialMutation) FieldCleared(name string) bool {
  28826. _, ok := m.clearedFields[name]
  28827. return ok
  28828. }
  28829. // ClearField clears the value of the field with the given name. It returns an
  28830. // error if the field is not defined in the schema.
  28831. func (m *TutorialMutation) ClearField(name string) error {
  28832. switch name {
  28833. case tutorial.FieldDeletedAt:
  28834. m.ClearDeletedAt()
  28835. return nil
  28836. }
  28837. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  28838. }
  28839. // ResetField resets all changes in the mutation for the field with the given name.
  28840. // It returns an error if the field is not defined in the schema.
  28841. func (m *TutorialMutation) ResetField(name string) error {
  28842. switch name {
  28843. case tutorial.FieldCreatedAt:
  28844. m.ResetCreatedAt()
  28845. return nil
  28846. case tutorial.FieldUpdatedAt:
  28847. m.ResetUpdatedAt()
  28848. return nil
  28849. case tutorial.FieldDeletedAt:
  28850. m.ResetDeletedAt()
  28851. return nil
  28852. case tutorial.FieldEmployeeID:
  28853. m.ResetEmployeeID()
  28854. return nil
  28855. case tutorial.FieldIndex:
  28856. m.ResetIndex()
  28857. return nil
  28858. case tutorial.FieldTitle:
  28859. m.ResetTitle()
  28860. return nil
  28861. case tutorial.FieldContent:
  28862. m.ResetContent()
  28863. return nil
  28864. case tutorial.FieldOrganizationID:
  28865. m.ResetOrganizationID()
  28866. return nil
  28867. }
  28868. return fmt.Errorf("unknown Tutorial field %s", name)
  28869. }
  28870. // AddedEdges returns all edge names that were set/added in this mutation.
  28871. func (m *TutorialMutation) AddedEdges() []string {
  28872. edges := make([]string, 0, 1)
  28873. if m.employee != nil {
  28874. edges = append(edges, tutorial.EdgeEmployee)
  28875. }
  28876. return edges
  28877. }
  28878. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28879. // name in this mutation.
  28880. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  28881. switch name {
  28882. case tutorial.EdgeEmployee:
  28883. if id := m.employee; id != nil {
  28884. return []ent.Value{*id}
  28885. }
  28886. }
  28887. return nil
  28888. }
  28889. // RemovedEdges returns all edge names that were removed in this mutation.
  28890. func (m *TutorialMutation) RemovedEdges() []string {
  28891. edges := make([]string, 0, 1)
  28892. return edges
  28893. }
  28894. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28895. // the given name in this mutation.
  28896. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  28897. return nil
  28898. }
  28899. // ClearedEdges returns all edge names that were cleared in this mutation.
  28900. func (m *TutorialMutation) ClearedEdges() []string {
  28901. edges := make([]string, 0, 1)
  28902. if m.clearedemployee {
  28903. edges = append(edges, tutorial.EdgeEmployee)
  28904. }
  28905. return edges
  28906. }
  28907. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28908. // was cleared in this mutation.
  28909. func (m *TutorialMutation) EdgeCleared(name string) bool {
  28910. switch name {
  28911. case tutorial.EdgeEmployee:
  28912. return m.clearedemployee
  28913. }
  28914. return false
  28915. }
  28916. // ClearEdge clears the value of the edge with the given name. It returns an error
  28917. // if that edge is not defined in the schema.
  28918. func (m *TutorialMutation) ClearEdge(name string) error {
  28919. switch name {
  28920. case tutorial.EdgeEmployee:
  28921. m.ClearEmployee()
  28922. return nil
  28923. }
  28924. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  28925. }
  28926. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28927. // It returns an error if the edge is not defined in the schema.
  28928. func (m *TutorialMutation) ResetEdge(name string) error {
  28929. switch name {
  28930. case tutorial.EdgeEmployee:
  28931. m.ResetEmployee()
  28932. return nil
  28933. }
  28934. return fmt.Errorf("unknown Tutorial edge %s", name)
  28935. }
  28936. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  28937. type UsageDetailMutation struct {
  28938. config
  28939. op Op
  28940. typ string
  28941. id *uint64
  28942. created_at *time.Time
  28943. updated_at *time.Time
  28944. status *uint8
  28945. addstatus *int8
  28946. _type *int
  28947. add_type *int
  28948. bot_id *string
  28949. receiver_id *string
  28950. app *int
  28951. addapp *int
  28952. session_id *uint64
  28953. addsession_id *int64
  28954. request *string
  28955. response *string
  28956. original_data *custom_types.OriginalData
  28957. total_tokens *uint64
  28958. addtotal_tokens *int64
  28959. prompt_tokens *uint64
  28960. addprompt_tokens *int64
  28961. completion_tokens *uint64
  28962. addcompletion_tokens *int64
  28963. organization_id *uint64
  28964. addorganization_id *int64
  28965. clearedFields map[string]struct{}
  28966. done bool
  28967. oldValue func(context.Context) (*UsageDetail, error)
  28968. predicates []predicate.UsageDetail
  28969. }
  28970. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  28971. // usagedetailOption allows management of the mutation configuration using functional options.
  28972. type usagedetailOption func(*UsageDetailMutation)
  28973. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  28974. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  28975. m := &UsageDetailMutation{
  28976. config: c,
  28977. op: op,
  28978. typ: TypeUsageDetail,
  28979. clearedFields: make(map[string]struct{}),
  28980. }
  28981. for _, opt := range opts {
  28982. opt(m)
  28983. }
  28984. return m
  28985. }
  28986. // withUsageDetailID sets the ID field of the mutation.
  28987. func withUsageDetailID(id uint64) usagedetailOption {
  28988. return func(m *UsageDetailMutation) {
  28989. var (
  28990. err error
  28991. once sync.Once
  28992. value *UsageDetail
  28993. )
  28994. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  28995. once.Do(func() {
  28996. if m.done {
  28997. err = errors.New("querying old values post mutation is not allowed")
  28998. } else {
  28999. value, err = m.Client().UsageDetail.Get(ctx, id)
  29000. }
  29001. })
  29002. return value, err
  29003. }
  29004. m.id = &id
  29005. }
  29006. }
  29007. // withUsageDetail sets the old UsageDetail of the mutation.
  29008. func withUsageDetail(node *UsageDetail) usagedetailOption {
  29009. return func(m *UsageDetailMutation) {
  29010. m.oldValue = func(context.Context) (*UsageDetail, error) {
  29011. return node, nil
  29012. }
  29013. m.id = &node.ID
  29014. }
  29015. }
  29016. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29017. // executed in a transaction (ent.Tx), a transactional client is returned.
  29018. func (m UsageDetailMutation) Client() *Client {
  29019. client := &Client{config: m.config}
  29020. client.init()
  29021. return client
  29022. }
  29023. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29024. // it returns an error otherwise.
  29025. func (m UsageDetailMutation) Tx() (*Tx, error) {
  29026. if _, ok := m.driver.(*txDriver); !ok {
  29027. return nil, errors.New("ent: mutation is not running in a transaction")
  29028. }
  29029. tx := &Tx{config: m.config}
  29030. tx.init()
  29031. return tx, nil
  29032. }
  29033. // SetID sets the value of the id field. Note that this
  29034. // operation is only accepted on creation of UsageDetail entities.
  29035. func (m *UsageDetailMutation) SetID(id uint64) {
  29036. m.id = &id
  29037. }
  29038. // ID returns the ID value in the mutation. Note that the ID is only available
  29039. // if it was provided to the builder or after it was returned from the database.
  29040. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  29041. if m.id == nil {
  29042. return
  29043. }
  29044. return *m.id, true
  29045. }
  29046. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29047. // That means, if the mutation is applied within a transaction with an isolation level such
  29048. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29049. // or updated by the mutation.
  29050. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  29051. switch {
  29052. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29053. id, exists := m.ID()
  29054. if exists {
  29055. return []uint64{id}, nil
  29056. }
  29057. fallthrough
  29058. case m.op.Is(OpUpdate | OpDelete):
  29059. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  29060. default:
  29061. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29062. }
  29063. }
  29064. // SetCreatedAt sets the "created_at" field.
  29065. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  29066. m.created_at = &t
  29067. }
  29068. // CreatedAt returns the value of the "created_at" field in the mutation.
  29069. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  29070. v := m.created_at
  29071. if v == nil {
  29072. return
  29073. }
  29074. return *v, true
  29075. }
  29076. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  29077. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29079. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29080. if !m.op.Is(OpUpdateOne) {
  29081. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29082. }
  29083. if m.id == nil || m.oldValue == nil {
  29084. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29085. }
  29086. oldValue, err := m.oldValue(ctx)
  29087. if err != nil {
  29088. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29089. }
  29090. return oldValue.CreatedAt, nil
  29091. }
  29092. // ResetCreatedAt resets all changes to the "created_at" field.
  29093. func (m *UsageDetailMutation) ResetCreatedAt() {
  29094. m.created_at = nil
  29095. }
  29096. // SetUpdatedAt sets the "updated_at" field.
  29097. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29098. m.updated_at = &t
  29099. }
  29100. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29101. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29102. v := m.updated_at
  29103. if v == nil {
  29104. return
  29105. }
  29106. return *v, true
  29107. }
  29108. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29109. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29111. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29112. if !m.op.Is(OpUpdateOne) {
  29113. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29114. }
  29115. if m.id == nil || m.oldValue == nil {
  29116. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29117. }
  29118. oldValue, err := m.oldValue(ctx)
  29119. if err != nil {
  29120. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29121. }
  29122. return oldValue.UpdatedAt, nil
  29123. }
  29124. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29125. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29126. m.updated_at = nil
  29127. }
  29128. // SetStatus sets the "status" field.
  29129. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29130. m.status = &u
  29131. m.addstatus = nil
  29132. }
  29133. // Status returns the value of the "status" field in the mutation.
  29134. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29135. v := m.status
  29136. if v == nil {
  29137. return
  29138. }
  29139. return *v, true
  29140. }
  29141. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29142. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29144. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29145. if !m.op.Is(OpUpdateOne) {
  29146. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29147. }
  29148. if m.id == nil || m.oldValue == nil {
  29149. return v, errors.New("OldStatus requires an ID field in the mutation")
  29150. }
  29151. oldValue, err := m.oldValue(ctx)
  29152. if err != nil {
  29153. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29154. }
  29155. return oldValue.Status, nil
  29156. }
  29157. // AddStatus adds u to the "status" field.
  29158. func (m *UsageDetailMutation) AddStatus(u int8) {
  29159. if m.addstatus != nil {
  29160. *m.addstatus += u
  29161. } else {
  29162. m.addstatus = &u
  29163. }
  29164. }
  29165. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29166. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29167. v := m.addstatus
  29168. if v == nil {
  29169. return
  29170. }
  29171. return *v, true
  29172. }
  29173. // ClearStatus clears the value of the "status" field.
  29174. func (m *UsageDetailMutation) ClearStatus() {
  29175. m.status = nil
  29176. m.addstatus = nil
  29177. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29178. }
  29179. // StatusCleared returns if the "status" field was cleared in this mutation.
  29180. func (m *UsageDetailMutation) StatusCleared() bool {
  29181. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29182. return ok
  29183. }
  29184. // ResetStatus resets all changes to the "status" field.
  29185. func (m *UsageDetailMutation) ResetStatus() {
  29186. m.status = nil
  29187. m.addstatus = nil
  29188. delete(m.clearedFields, usagedetail.FieldStatus)
  29189. }
  29190. // SetType sets the "type" field.
  29191. func (m *UsageDetailMutation) SetType(i int) {
  29192. m._type = &i
  29193. m.add_type = nil
  29194. }
  29195. // GetType returns the value of the "type" field in the mutation.
  29196. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29197. v := m._type
  29198. if v == nil {
  29199. return
  29200. }
  29201. return *v, true
  29202. }
  29203. // OldType returns the old "type" field's value of the UsageDetail entity.
  29204. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29206. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29207. if !m.op.Is(OpUpdateOne) {
  29208. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29209. }
  29210. if m.id == nil || m.oldValue == nil {
  29211. return v, errors.New("OldType requires an ID field in the mutation")
  29212. }
  29213. oldValue, err := m.oldValue(ctx)
  29214. if err != nil {
  29215. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29216. }
  29217. return oldValue.Type, nil
  29218. }
  29219. // AddType adds i to the "type" field.
  29220. func (m *UsageDetailMutation) AddType(i int) {
  29221. if m.add_type != nil {
  29222. *m.add_type += i
  29223. } else {
  29224. m.add_type = &i
  29225. }
  29226. }
  29227. // AddedType returns the value that was added to the "type" field in this mutation.
  29228. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29229. v := m.add_type
  29230. if v == nil {
  29231. return
  29232. }
  29233. return *v, true
  29234. }
  29235. // ClearType clears the value of the "type" field.
  29236. func (m *UsageDetailMutation) ClearType() {
  29237. m._type = nil
  29238. m.add_type = nil
  29239. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29240. }
  29241. // TypeCleared returns if the "type" field was cleared in this mutation.
  29242. func (m *UsageDetailMutation) TypeCleared() bool {
  29243. _, ok := m.clearedFields[usagedetail.FieldType]
  29244. return ok
  29245. }
  29246. // ResetType resets all changes to the "type" field.
  29247. func (m *UsageDetailMutation) ResetType() {
  29248. m._type = nil
  29249. m.add_type = nil
  29250. delete(m.clearedFields, usagedetail.FieldType)
  29251. }
  29252. // SetBotID sets the "bot_id" field.
  29253. func (m *UsageDetailMutation) SetBotID(s string) {
  29254. m.bot_id = &s
  29255. }
  29256. // BotID returns the value of the "bot_id" field in the mutation.
  29257. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29258. v := m.bot_id
  29259. if v == nil {
  29260. return
  29261. }
  29262. return *v, true
  29263. }
  29264. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  29265. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29267. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  29268. if !m.op.Is(OpUpdateOne) {
  29269. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29270. }
  29271. if m.id == nil || m.oldValue == nil {
  29272. return v, errors.New("OldBotID requires an ID field in the mutation")
  29273. }
  29274. oldValue, err := m.oldValue(ctx)
  29275. if err != nil {
  29276. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29277. }
  29278. return oldValue.BotID, nil
  29279. }
  29280. // ResetBotID resets all changes to the "bot_id" field.
  29281. func (m *UsageDetailMutation) ResetBotID() {
  29282. m.bot_id = nil
  29283. }
  29284. // SetReceiverID sets the "receiver_id" field.
  29285. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29286. m.receiver_id = &s
  29287. }
  29288. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29289. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29290. v := m.receiver_id
  29291. if v == nil {
  29292. return
  29293. }
  29294. return *v, true
  29295. }
  29296. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29297. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29299. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29300. if !m.op.Is(OpUpdateOne) {
  29301. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29302. }
  29303. if m.id == nil || m.oldValue == nil {
  29304. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29305. }
  29306. oldValue, err := m.oldValue(ctx)
  29307. if err != nil {
  29308. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29309. }
  29310. return oldValue.ReceiverID, nil
  29311. }
  29312. // ResetReceiverID resets all changes to the "receiver_id" field.
  29313. func (m *UsageDetailMutation) ResetReceiverID() {
  29314. m.receiver_id = nil
  29315. }
  29316. // SetApp sets the "app" field.
  29317. func (m *UsageDetailMutation) SetApp(i int) {
  29318. m.app = &i
  29319. m.addapp = nil
  29320. }
  29321. // App returns the value of the "app" field in the mutation.
  29322. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29323. v := m.app
  29324. if v == nil {
  29325. return
  29326. }
  29327. return *v, true
  29328. }
  29329. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29330. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29332. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29333. if !m.op.Is(OpUpdateOne) {
  29334. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29335. }
  29336. if m.id == nil || m.oldValue == nil {
  29337. return v, errors.New("OldApp requires an ID field in the mutation")
  29338. }
  29339. oldValue, err := m.oldValue(ctx)
  29340. if err != nil {
  29341. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29342. }
  29343. return oldValue.App, nil
  29344. }
  29345. // AddApp adds i to the "app" field.
  29346. func (m *UsageDetailMutation) AddApp(i int) {
  29347. if m.addapp != nil {
  29348. *m.addapp += i
  29349. } else {
  29350. m.addapp = &i
  29351. }
  29352. }
  29353. // AddedApp returns the value that was added to the "app" field in this mutation.
  29354. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29355. v := m.addapp
  29356. if v == nil {
  29357. return
  29358. }
  29359. return *v, true
  29360. }
  29361. // ClearApp clears the value of the "app" field.
  29362. func (m *UsageDetailMutation) ClearApp() {
  29363. m.app = nil
  29364. m.addapp = nil
  29365. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29366. }
  29367. // AppCleared returns if the "app" field was cleared in this mutation.
  29368. func (m *UsageDetailMutation) AppCleared() bool {
  29369. _, ok := m.clearedFields[usagedetail.FieldApp]
  29370. return ok
  29371. }
  29372. // ResetApp resets all changes to the "app" field.
  29373. func (m *UsageDetailMutation) ResetApp() {
  29374. m.app = nil
  29375. m.addapp = nil
  29376. delete(m.clearedFields, usagedetail.FieldApp)
  29377. }
  29378. // SetSessionID sets the "session_id" field.
  29379. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29380. m.session_id = &u
  29381. m.addsession_id = nil
  29382. }
  29383. // SessionID returns the value of the "session_id" field in the mutation.
  29384. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29385. v := m.session_id
  29386. if v == nil {
  29387. return
  29388. }
  29389. return *v, true
  29390. }
  29391. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29392. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29394. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29395. if !m.op.Is(OpUpdateOne) {
  29396. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29397. }
  29398. if m.id == nil || m.oldValue == nil {
  29399. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29400. }
  29401. oldValue, err := m.oldValue(ctx)
  29402. if err != nil {
  29403. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29404. }
  29405. return oldValue.SessionID, nil
  29406. }
  29407. // AddSessionID adds u to the "session_id" field.
  29408. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29409. if m.addsession_id != nil {
  29410. *m.addsession_id += u
  29411. } else {
  29412. m.addsession_id = &u
  29413. }
  29414. }
  29415. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29416. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29417. v := m.addsession_id
  29418. if v == nil {
  29419. return
  29420. }
  29421. return *v, true
  29422. }
  29423. // ClearSessionID clears the value of the "session_id" field.
  29424. func (m *UsageDetailMutation) ClearSessionID() {
  29425. m.session_id = nil
  29426. m.addsession_id = nil
  29427. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29428. }
  29429. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29430. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29431. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29432. return ok
  29433. }
  29434. // ResetSessionID resets all changes to the "session_id" field.
  29435. func (m *UsageDetailMutation) ResetSessionID() {
  29436. m.session_id = nil
  29437. m.addsession_id = nil
  29438. delete(m.clearedFields, usagedetail.FieldSessionID)
  29439. }
  29440. // SetRequest sets the "request" field.
  29441. func (m *UsageDetailMutation) SetRequest(s string) {
  29442. m.request = &s
  29443. }
  29444. // Request returns the value of the "request" field in the mutation.
  29445. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29446. v := m.request
  29447. if v == nil {
  29448. return
  29449. }
  29450. return *v, true
  29451. }
  29452. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  29453. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29455. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  29456. if !m.op.Is(OpUpdateOne) {
  29457. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29458. }
  29459. if m.id == nil || m.oldValue == nil {
  29460. return v, errors.New("OldRequest requires an ID field in the mutation")
  29461. }
  29462. oldValue, err := m.oldValue(ctx)
  29463. if err != nil {
  29464. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  29465. }
  29466. return oldValue.Request, nil
  29467. }
  29468. // ResetRequest resets all changes to the "request" field.
  29469. func (m *UsageDetailMutation) ResetRequest() {
  29470. m.request = nil
  29471. }
  29472. // SetResponse sets the "response" field.
  29473. func (m *UsageDetailMutation) SetResponse(s string) {
  29474. m.response = &s
  29475. }
  29476. // Response returns the value of the "response" field in the mutation.
  29477. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29478. v := m.response
  29479. if v == nil {
  29480. return
  29481. }
  29482. return *v, true
  29483. }
  29484. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29485. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29487. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29488. if !m.op.Is(OpUpdateOne) {
  29489. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29490. }
  29491. if m.id == nil || m.oldValue == nil {
  29492. return v, errors.New("OldResponse requires an ID field in the mutation")
  29493. }
  29494. oldValue, err := m.oldValue(ctx)
  29495. if err != nil {
  29496. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  29497. }
  29498. return oldValue.Response, nil
  29499. }
  29500. // ResetResponse resets all changes to the "response" field.
  29501. func (m *UsageDetailMutation) ResetResponse() {
  29502. m.response = nil
  29503. }
  29504. // SetOriginalData sets the "original_data" field.
  29505. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29506. m.original_data = &ctd
  29507. }
  29508. // OriginalData returns the value of the "original_data" field in the mutation.
  29509. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29510. v := m.original_data
  29511. if v == nil {
  29512. return
  29513. }
  29514. return *v, true
  29515. }
  29516. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29517. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29519. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29520. if !m.op.Is(OpUpdateOne) {
  29521. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29522. }
  29523. if m.id == nil || m.oldValue == nil {
  29524. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29525. }
  29526. oldValue, err := m.oldValue(ctx)
  29527. if err != nil {
  29528. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29529. }
  29530. return oldValue.OriginalData, nil
  29531. }
  29532. // ResetOriginalData resets all changes to the "original_data" field.
  29533. func (m *UsageDetailMutation) ResetOriginalData() {
  29534. m.original_data = nil
  29535. }
  29536. // SetTotalTokens sets the "total_tokens" field.
  29537. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29538. m.total_tokens = &u
  29539. m.addtotal_tokens = nil
  29540. }
  29541. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29542. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29543. v := m.total_tokens
  29544. if v == nil {
  29545. return
  29546. }
  29547. return *v, true
  29548. }
  29549. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29550. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29552. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29553. if !m.op.Is(OpUpdateOne) {
  29554. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29555. }
  29556. if m.id == nil || m.oldValue == nil {
  29557. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29558. }
  29559. oldValue, err := m.oldValue(ctx)
  29560. if err != nil {
  29561. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29562. }
  29563. return oldValue.TotalTokens, nil
  29564. }
  29565. // AddTotalTokens adds u to the "total_tokens" field.
  29566. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29567. if m.addtotal_tokens != nil {
  29568. *m.addtotal_tokens += u
  29569. } else {
  29570. m.addtotal_tokens = &u
  29571. }
  29572. }
  29573. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29574. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29575. v := m.addtotal_tokens
  29576. if v == nil {
  29577. return
  29578. }
  29579. return *v, true
  29580. }
  29581. // ClearTotalTokens clears the value of the "total_tokens" field.
  29582. func (m *UsageDetailMutation) ClearTotalTokens() {
  29583. m.total_tokens = nil
  29584. m.addtotal_tokens = nil
  29585. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29586. }
  29587. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29588. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29589. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29590. return ok
  29591. }
  29592. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29593. func (m *UsageDetailMutation) ResetTotalTokens() {
  29594. m.total_tokens = nil
  29595. m.addtotal_tokens = nil
  29596. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29597. }
  29598. // SetPromptTokens sets the "prompt_tokens" field.
  29599. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29600. m.prompt_tokens = &u
  29601. m.addprompt_tokens = nil
  29602. }
  29603. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29604. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29605. v := m.prompt_tokens
  29606. if v == nil {
  29607. return
  29608. }
  29609. return *v, true
  29610. }
  29611. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29612. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29614. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29615. if !m.op.Is(OpUpdateOne) {
  29616. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29617. }
  29618. if m.id == nil || m.oldValue == nil {
  29619. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29620. }
  29621. oldValue, err := m.oldValue(ctx)
  29622. if err != nil {
  29623. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29624. }
  29625. return oldValue.PromptTokens, nil
  29626. }
  29627. // AddPromptTokens adds u to the "prompt_tokens" field.
  29628. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29629. if m.addprompt_tokens != nil {
  29630. *m.addprompt_tokens += u
  29631. } else {
  29632. m.addprompt_tokens = &u
  29633. }
  29634. }
  29635. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  29636. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  29637. v := m.addprompt_tokens
  29638. if v == nil {
  29639. return
  29640. }
  29641. return *v, true
  29642. }
  29643. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  29644. func (m *UsageDetailMutation) ClearPromptTokens() {
  29645. m.prompt_tokens = nil
  29646. m.addprompt_tokens = nil
  29647. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  29648. }
  29649. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  29650. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  29651. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  29652. return ok
  29653. }
  29654. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  29655. func (m *UsageDetailMutation) ResetPromptTokens() {
  29656. m.prompt_tokens = nil
  29657. m.addprompt_tokens = nil
  29658. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  29659. }
  29660. // SetCompletionTokens sets the "completion_tokens" field.
  29661. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  29662. m.completion_tokens = &u
  29663. m.addcompletion_tokens = nil
  29664. }
  29665. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  29666. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  29667. v := m.completion_tokens
  29668. if v == nil {
  29669. return
  29670. }
  29671. return *v, true
  29672. }
  29673. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  29674. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29676. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  29677. if !m.op.Is(OpUpdateOne) {
  29678. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  29679. }
  29680. if m.id == nil || m.oldValue == nil {
  29681. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  29682. }
  29683. oldValue, err := m.oldValue(ctx)
  29684. if err != nil {
  29685. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  29686. }
  29687. return oldValue.CompletionTokens, nil
  29688. }
  29689. // AddCompletionTokens adds u to the "completion_tokens" field.
  29690. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  29691. if m.addcompletion_tokens != nil {
  29692. *m.addcompletion_tokens += u
  29693. } else {
  29694. m.addcompletion_tokens = &u
  29695. }
  29696. }
  29697. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  29698. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  29699. v := m.addcompletion_tokens
  29700. if v == nil {
  29701. return
  29702. }
  29703. return *v, true
  29704. }
  29705. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  29706. func (m *UsageDetailMutation) ClearCompletionTokens() {
  29707. m.completion_tokens = nil
  29708. m.addcompletion_tokens = nil
  29709. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  29710. }
  29711. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  29712. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  29713. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  29714. return ok
  29715. }
  29716. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  29717. func (m *UsageDetailMutation) ResetCompletionTokens() {
  29718. m.completion_tokens = nil
  29719. m.addcompletion_tokens = nil
  29720. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  29721. }
  29722. // SetOrganizationID sets the "organization_id" field.
  29723. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  29724. m.organization_id = &u
  29725. m.addorganization_id = nil
  29726. }
  29727. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29728. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  29729. v := m.organization_id
  29730. if v == nil {
  29731. return
  29732. }
  29733. return *v, true
  29734. }
  29735. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  29736. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29738. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29739. if !m.op.Is(OpUpdateOne) {
  29740. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29741. }
  29742. if m.id == nil || m.oldValue == nil {
  29743. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29744. }
  29745. oldValue, err := m.oldValue(ctx)
  29746. if err != nil {
  29747. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29748. }
  29749. return oldValue.OrganizationID, nil
  29750. }
  29751. // AddOrganizationID adds u to the "organization_id" field.
  29752. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  29753. if m.addorganization_id != nil {
  29754. *m.addorganization_id += u
  29755. } else {
  29756. m.addorganization_id = &u
  29757. }
  29758. }
  29759. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29760. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  29761. v := m.addorganization_id
  29762. if v == nil {
  29763. return
  29764. }
  29765. return *v, true
  29766. }
  29767. // ClearOrganizationID clears the value of the "organization_id" field.
  29768. func (m *UsageDetailMutation) ClearOrganizationID() {
  29769. m.organization_id = nil
  29770. m.addorganization_id = nil
  29771. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  29772. }
  29773. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29774. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  29775. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  29776. return ok
  29777. }
  29778. // ResetOrganizationID resets all changes to the "organization_id" field.
  29779. func (m *UsageDetailMutation) ResetOrganizationID() {
  29780. m.organization_id = nil
  29781. m.addorganization_id = nil
  29782. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  29783. }
  29784. // Where appends a list predicates to the UsageDetailMutation builder.
  29785. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  29786. m.predicates = append(m.predicates, ps...)
  29787. }
  29788. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  29789. // users can use type-assertion to append predicates that do not depend on any generated package.
  29790. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  29791. p := make([]predicate.UsageDetail, len(ps))
  29792. for i := range ps {
  29793. p[i] = ps[i]
  29794. }
  29795. m.Where(p...)
  29796. }
  29797. // Op returns the operation name.
  29798. func (m *UsageDetailMutation) Op() Op {
  29799. return m.op
  29800. }
  29801. // SetOp allows setting the mutation operation.
  29802. func (m *UsageDetailMutation) SetOp(op Op) {
  29803. m.op = op
  29804. }
  29805. // Type returns the node type of this mutation (UsageDetail).
  29806. func (m *UsageDetailMutation) Type() string {
  29807. return m.typ
  29808. }
  29809. // Fields returns all fields that were changed during this mutation. Note that in
  29810. // order to get all numeric fields that were incremented/decremented, call
  29811. // AddedFields().
  29812. func (m *UsageDetailMutation) Fields() []string {
  29813. fields := make([]string, 0, 15)
  29814. if m.created_at != nil {
  29815. fields = append(fields, usagedetail.FieldCreatedAt)
  29816. }
  29817. if m.updated_at != nil {
  29818. fields = append(fields, usagedetail.FieldUpdatedAt)
  29819. }
  29820. if m.status != nil {
  29821. fields = append(fields, usagedetail.FieldStatus)
  29822. }
  29823. if m._type != nil {
  29824. fields = append(fields, usagedetail.FieldType)
  29825. }
  29826. if m.bot_id != nil {
  29827. fields = append(fields, usagedetail.FieldBotID)
  29828. }
  29829. if m.receiver_id != nil {
  29830. fields = append(fields, usagedetail.FieldReceiverID)
  29831. }
  29832. if m.app != nil {
  29833. fields = append(fields, usagedetail.FieldApp)
  29834. }
  29835. if m.session_id != nil {
  29836. fields = append(fields, usagedetail.FieldSessionID)
  29837. }
  29838. if m.request != nil {
  29839. fields = append(fields, usagedetail.FieldRequest)
  29840. }
  29841. if m.response != nil {
  29842. fields = append(fields, usagedetail.FieldResponse)
  29843. }
  29844. if m.original_data != nil {
  29845. fields = append(fields, usagedetail.FieldOriginalData)
  29846. }
  29847. if m.total_tokens != nil {
  29848. fields = append(fields, usagedetail.FieldTotalTokens)
  29849. }
  29850. if m.prompt_tokens != nil {
  29851. fields = append(fields, usagedetail.FieldPromptTokens)
  29852. }
  29853. if m.completion_tokens != nil {
  29854. fields = append(fields, usagedetail.FieldCompletionTokens)
  29855. }
  29856. if m.organization_id != nil {
  29857. fields = append(fields, usagedetail.FieldOrganizationID)
  29858. }
  29859. return fields
  29860. }
  29861. // Field returns the value of a field with the given name. The second boolean
  29862. // return value indicates that this field was not set, or was not defined in the
  29863. // schema.
  29864. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  29865. switch name {
  29866. case usagedetail.FieldCreatedAt:
  29867. return m.CreatedAt()
  29868. case usagedetail.FieldUpdatedAt:
  29869. return m.UpdatedAt()
  29870. case usagedetail.FieldStatus:
  29871. return m.Status()
  29872. case usagedetail.FieldType:
  29873. return m.GetType()
  29874. case usagedetail.FieldBotID:
  29875. return m.BotID()
  29876. case usagedetail.FieldReceiverID:
  29877. return m.ReceiverID()
  29878. case usagedetail.FieldApp:
  29879. return m.App()
  29880. case usagedetail.FieldSessionID:
  29881. return m.SessionID()
  29882. case usagedetail.FieldRequest:
  29883. return m.Request()
  29884. case usagedetail.FieldResponse:
  29885. return m.Response()
  29886. case usagedetail.FieldOriginalData:
  29887. return m.OriginalData()
  29888. case usagedetail.FieldTotalTokens:
  29889. return m.TotalTokens()
  29890. case usagedetail.FieldPromptTokens:
  29891. return m.PromptTokens()
  29892. case usagedetail.FieldCompletionTokens:
  29893. return m.CompletionTokens()
  29894. case usagedetail.FieldOrganizationID:
  29895. return m.OrganizationID()
  29896. }
  29897. return nil, false
  29898. }
  29899. // OldField returns the old value of the field from the database. An error is
  29900. // returned if the mutation operation is not UpdateOne, or the query to the
  29901. // database failed.
  29902. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29903. switch name {
  29904. case usagedetail.FieldCreatedAt:
  29905. return m.OldCreatedAt(ctx)
  29906. case usagedetail.FieldUpdatedAt:
  29907. return m.OldUpdatedAt(ctx)
  29908. case usagedetail.FieldStatus:
  29909. return m.OldStatus(ctx)
  29910. case usagedetail.FieldType:
  29911. return m.OldType(ctx)
  29912. case usagedetail.FieldBotID:
  29913. return m.OldBotID(ctx)
  29914. case usagedetail.FieldReceiverID:
  29915. return m.OldReceiverID(ctx)
  29916. case usagedetail.FieldApp:
  29917. return m.OldApp(ctx)
  29918. case usagedetail.FieldSessionID:
  29919. return m.OldSessionID(ctx)
  29920. case usagedetail.FieldRequest:
  29921. return m.OldRequest(ctx)
  29922. case usagedetail.FieldResponse:
  29923. return m.OldResponse(ctx)
  29924. case usagedetail.FieldOriginalData:
  29925. return m.OldOriginalData(ctx)
  29926. case usagedetail.FieldTotalTokens:
  29927. return m.OldTotalTokens(ctx)
  29928. case usagedetail.FieldPromptTokens:
  29929. return m.OldPromptTokens(ctx)
  29930. case usagedetail.FieldCompletionTokens:
  29931. return m.OldCompletionTokens(ctx)
  29932. case usagedetail.FieldOrganizationID:
  29933. return m.OldOrganizationID(ctx)
  29934. }
  29935. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  29936. }
  29937. // SetField sets the value of a field with the given name. It returns an error if
  29938. // the field is not defined in the schema, or if the type mismatched the field
  29939. // type.
  29940. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  29941. switch name {
  29942. case usagedetail.FieldCreatedAt:
  29943. v, ok := value.(time.Time)
  29944. if !ok {
  29945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29946. }
  29947. m.SetCreatedAt(v)
  29948. return nil
  29949. case usagedetail.FieldUpdatedAt:
  29950. v, ok := value.(time.Time)
  29951. if !ok {
  29952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29953. }
  29954. m.SetUpdatedAt(v)
  29955. return nil
  29956. case usagedetail.FieldStatus:
  29957. v, ok := value.(uint8)
  29958. if !ok {
  29959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29960. }
  29961. m.SetStatus(v)
  29962. return nil
  29963. case usagedetail.FieldType:
  29964. v, ok := value.(int)
  29965. if !ok {
  29966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29967. }
  29968. m.SetType(v)
  29969. return nil
  29970. case usagedetail.FieldBotID:
  29971. v, ok := value.(string)
  29972. if !ok {
  29973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29974. }
  29975. m.SetBotID(v)
  29976. return nil
  29977. case usagedetail.FieldReceiverID:
  29978. v, ok := value.(string)
  29979. if !ok {
  29980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29981. }
  29982. m.SetReceiverID(v)
  29983. return nil
  29984. case usagedetail.FieldApp:
  29985. v, ok := value.(int)
  29986. if !ok {
  29987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29988. }
  29989. m.SetApp(v)
  29990. return nil
  29991. case usagedetail.FieldSessionID:
  29992. v, ok := value.(uint64)
  29993. if !ok {
  29994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29995. }
  29996. m.SetSessionID(v)
  29997. return nil
  29998. case usagedetail.FieldRequest:
  29999. v, ok := value.(string)
  30000. if !ok {
  30001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30002. }
  30003. m.SetRequest(v)
  30004. return nil
  30005. case usagedetail.FieldResponse:
  30006. v, ok := value.(string)
  30007. if !ok {
  30008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30009. }
  30010. m.SetResponse(v)
  30011. return nil
  30012. case usagedetail.FieldOriginalData:
  30013. v, ok := value.(custom_types.OriginalData)
  30014. if !ok {
  30015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30016. }
  30017. m.SetOriginalData(v)
  30018. return nil
  30019. case usagedetail.FieldTotalTokens:
  30020. v, ok := value.(uint64)
  30021. if !ok {
  30022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30023. }
  30024. m.SetTotalTokens(v)
  30025. return nil
  30026. case usagedetail.FieldPromptTokens:
  30027. v, ok := value.(uint64)
  30028. if !ok {
  30029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30030. }
  30031. m.SetPromptTokens(v)
  30032. return nil
  30033. case usagedetail.FieldCompletionTokens:
  30034. v, ok := value.(uint64)
  30035. if !ok {
  30036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30037. }
  30038. m.SetCompletionTokens(v)
  30039. return nil
  30040. case usagedetail.FieldOrganizationID:
  30041. v, ok := value.(uint64)
  30042. if !ok {
  30043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30044. }
  30045. m.SetOrganizationID(v)
  30046. return nil
  30047. }
  30048. return fmt.Errorf("unknown UsageDetail field %s", name)
  30049. }
  30050. // AddedFields returns all numeric fields that were incremented/decremented during
  30051. // this mutation.
  30052. func (m *UsageDetailMutation) AddedFields() []string {
  30053. var fields []string
  30054. if m.addstatus != nil {
  30055. fields = append(fields, usagedetail.FieldStatus)
  30056. }
  30057. if m.add_type != nil {
  30058. fields = append(fields, usagedetail.FieldType)
  30059. }
  30060. if m.addapp != nil {
  30061. fields = append(fields, usagedetail.FieldApp)
  30062. }
  30063. if m.addsession_id != nil {
  30064. fields = append(fields, usagedetail.FieldSessionID)
  30065. }
  30066. if m.addtotal_tokens != nil {
  30067. fields = append(fields, usagedetail.FieldTotalTokens)
  30068. }
  30069. if m.addprompt_tokens != nil {
  30070. fields = append(fields, usagedetail.FieldPromptTokens)
  30071. }
  30072. if m.addcompletion_tokens != nil {
  30073. fields = append(fields, usagedetail.FieldCompletionTokens)
  30074. }
  30075. if m.addorganization_id != nil {
  30076. fields = append(fields, usagedetail.FieldOrganizationID)
  30077. }
  30078. return fields
  30079. }
  30080. // AddedField returns the numeric value that was incremented/decremented on a field
  30081. // with the given name. The second boolean return value indicates that this field
  30082. // was not set, or was not defined in the schema.
  30083. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30084. switch name {
  30085. case usagedetail.FieldStatus:
  30086. return m.AddedStatus()
  30087. case usagedetail.FieldType:
  30088. return m.AddedType()
  30089. case usagedetail.FieldApp:
  30090. return m.AddedApp()
  30091. case usagedetail.FieldSessionID:
  30092. return m.AddedSessionID()
  30093. case usagedetail.FieldTotalTokens:
  30094. return m.AddedTotalTokens()
  30095. case usagedetail.FieldPromptTokens:
  30096. return m.AddedPromptTokens()
  30097. case usagedetail.FieldCompletionTokens:
  30098. return m.AddedCompletionTokens()
  30099. case usagedetail.FieldOrganizationID:
  30100. return m.AddedOrganizationID()
  30101. }
  30102. return nil, false
  30103. }
  30104. // AddField adds the value to the field with the given name. It returns an error if
  30105. // the field is not defined in the schema, or if the type mismatched the field
  30106. // type.
  30107. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30108. switch name {
  30109. case usagedetail.FieldStatus:
  30110. v, ok := value.(int8)
  30111. if !ok {
  30112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30113. }
  30114. m.AddStatus(v)
  30115. return nil
  30116. case usagedetail.FieldType:
  30117. v, ok := value.(int)
  30118. if !ok {
  30119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30120. }
  30121. m.AddType(v)
  30122. return nil
  30123. case usagedetail.FieldApp:
  30124. v, ok := value.(int)
  30125. if !ok {
  30126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30127. }
  30128. m.AddApp(v)
  30129. return nil
  30130. case usagedetail.FieldSessionID:
  30131. v, ok := value.(int64)
  30132. if !ok {
  30133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30134. }
  30135. m.AddSessionID(v)
  30136. return nil
  30137. case usagedetail.FieldTotalTokens:
  30138. v, ok := value.(int64)
  30139. if !ok {
  30140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30141. }
  30142. m.AddTotalTokens(v)
  30143. return nil
  30144. case usagedetail.FieldPromptTokens:
  30145. v, ok := value.(int64)
  30146. if !ok {
  30147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30148. }
  30149. m.AddPromptTokens(v)
  30150. return nil
  30151. case usagedetail.FieldCompletionTokens:
  30152. v, ok := value.(int64)
  30153. if !ok {
  30154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30155. }
  30156. m.AddCompletionTokens(v)
  30157. return nil
  30158. case usagedetail.FieldOrganizationID:
  30159. v, ok := value.(int64)
  30160. if !ok {
  30161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30162. }
  30163. m.AddOrganizationID(v)
  30164. return nil
  30165. }
  30166. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30167. }
  30168. // ClearedFields returns all nullable fields that were cleared during this
  30169. // mutation.
  30170. func (m *UsageDetailMutation) ClearedFields() []string {
  30171. var fields []string
  30172. if m.FieldCleared(usagedetail.FieldStatus) {
  30173. fields = append(fields, usagedetail.FieldStatus)
  30174. }
  30175. if m.FieldCleared(usagedetail.FieldType) {
  30176. fields = append(fields, usagedetail.FieldType)
  30177. }
  30178. if m.FieldCleared(usagedetail.FieldApp) {
  30179. fields = append(fields, usagedetail.FieldApp)
  30180. }
  30181. if m.FieldCleared(usagedetail.FieldSessionID) {
  30182. fields = append(fields, usagedetail.FieldSessionID)
  30183. }
  30184. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30185. fields = append(fields, usagedetail.FieldTotalTokens)
  30186. }
  30187. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30188. fields = append(fields, usagedetail.FieldPromptTokens)
  30189. }
  30190. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30191. fields = append(fields, usagedetail.FieldCompletionTokens)
  30192. }
  30193. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30194. fields = append(fields, usagedetail.FieldOrganizationID)
  30195. }
  30196. return fields
  30197. }
  30198. // FieldCleared returns a boolean indicating if a field with the given name was
  30199. // cleared in this mutation.
  30200. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30201. _, ok := m.clearedFields[name]
  30202. return ok
  30203. }
  30204. // ClearField clears the value of the field with the given name. It returns an
  30205. // error if the field is not defined in the schema.
  30206. func (m *UsageDetailMutation) ClearField(name string) error {
  30207. switch name {
  30208. case usagedetail.FieldStatus:
  30209. m.ClearStatus()
  30210. return nil
  30211. case usagedetail.FieldType:
  30212. m.ClearType()
  30213. return nil
  30214. case usagedetail.FieldApp:
  30215. m.ClearApp()
  30216. return nil
  30217. case usagedetail.FieldSessionID:
  30218. m.ClearSessionID()
  30219. return nil
  30220. case usagedetail.FieldTotalTokens:
  30221. m.ClearTotalTokens()
  30222. return nil
  30223. case usagedetail.FieldPromptTokens:
  30224. m.ClearPromptTokens()
  30225. return nil
  30226. case usagedetail.FieldCompletionTokens:
  30227. m.ClearCompletionTokens()
  30228. return nil
  30229. case usagedetail.FieldOrganizationID:
  30230. m.ClearOrganizationID()
  30231. return nil
  30232. }
  30233. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30234. }
  30235. // ResetField resets all changes in the mutation for the field with the given name.
  30236. // It returns an error if the field is not defined in the schema.
  30237. func (m *UsageDetailMutation) ResetField(name string) error {
  30238. switch name {
  30239. case usagedetail.FieldCreatedAt:
  30240. m.ResetCreatedAt()
  30241. return nil
  30242. case usagedetail.FieldUpdatedAt:
  30243. m.ResetUpdatedAt()
  30244. return nil
  30245. case usagedetail.FieldStatus:
  30246. m.ResetStatus()
  30247. return nil
  30248. case usagedetail.FieldType:
  30249. m.ResetType()
  30250. return nil
  30251. case usagedetail.FieldBotID:
  30252. m.ResetBotID()
  30253. return nil
  30254. case usagedetail.FieldReceiverID:
  30255. m.ResetReceiverID()
  30256. return nil
  30257. case usagedetail.FieldApp:
  30258. m.ResetApp()
  30259. return nil
  30260. case usagedetail.FieldSessionID:
  30261. m.ResetSessionID()
  30262. return nil
  30263. case usagedetail.FieldRequest:
  30264. m.ResetRequest()
  30265. return nil
  30266. case usagedetail.FieldResponse:
  30267. m.ResetResponse()
  30268. return nil
  30269. case usagedetail.FieldOriginalData:
  30270. m.ResetOriginalData()
  30271. return nil
  30272. case usagedetail.FieldTotalTokens:
  30273. m.ResetTotalTokens()
  30274. return nil
  30275. case usagedetail.FieldPromptTokens:
  30276. m.ResetPromptTokens()
  30277. return nil
  30278. case usagedetail.FieldCompletionTokens:
  30279. m.ResetCompletionTokens()
  30280. return nil
  30281. case usagedetail.FieldOrganizationID:
  30282. m.ResetOrganizationID()
  30283. return nil
  30284. }
  30285. return fmt.Errorf("unknown UsageDetail field %s", name)
  30286. }
  30287. // AddedEdges returns all edge names that were set/added in this mutation.
  30288. func (m *UsageDetailMutation) AddedEdges() []string {
  30289. edges := make([]string, 0, 0)
  30290. return edges
  30291. }
  30292. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30293. // name in this mutation.
  30294. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30295. return nil
  30296. }
  30297. // RemovedEdges returns all edge names that were removed in this mutation.
  30298. func (m *UsageDetailMutation) RemovedEdges() []string {
  30299. edges := make([]string, 0, 0)
  30300. return edges
  30301. }
  30302. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30303. // the given name in this mutation.
  30304. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30305. return nil
  30306. }
  30307. // ClearedEdges returns all edge names that were cleared in this mutation.
  30308. func (m *UsageDetailMutation) ClearedEdges() []string {
  30309. edges := make([]string, 0, 0)
  30310. return edges
  30311. }
  30312. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30313. // was cleared in this mutation.
  30314. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30315. return false
  30316. }
  30317. // ClearEdge clears the value of the edge with the given name. It returns an error
  30318. // if that edge is not defined in the schema.
  30319. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30320. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30321. }
  30322. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30323. // It returns an error if the edge is not defined in the schema.
  30324. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30325. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30326. }
  30327. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30328. type UsageStatisticDayMutation struct {
  30329. config
  30330. op Op
  30331. typ string
  30332. id *uint64
  30333. created_at *time.Time
  30334. updated_at *time.Time
  30335. status *uint8
  30336. addstatus *int8
  30337. deleted_at *time.Time
  30338. addtime *uint64
  30339. addaddtime *int64
  30340. _type *int
  30341. add_type *int
  30342. bot_id *string
  30343. organization_id *uint64
  30344. addorganization_id *int64
  30345. ai_response *uint64
  30346. addai_response *int64
  30347. sop_run *uint64
  30348. addsop_run *int64
  30349. total_friend *uint64
  30350. addtotal_friend *int64
  30351. total_group *uint64
  30352. addtotal_group *int64
  30353. account_balance *uint64
  30354. addaccount_balance *int64
  30355. consume_token *uint64
  30356. addconsume_token *int64
  30357. active_user *uint64
  30358. addactive_user *int64
  30359. new_user *int64
  30360. addnew_user *int64
  30361. label_dist *[]custom_types.LabelDist
  30362. appendlabel_dist []custom_types.LabelDist
  30363. clearedFields map[string]struct{}
  30364. done bool
  30365. oldValue func(context.Context) (*UsageStatisticDay, error)
  30366. predicates []predicate.UsageStatisticDay
  30367. }
  30368. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30369. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30370. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30371. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30372. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30373. m := &UsageStatisticDayMutation{
  30374. config: c,
  30375. op: op,
  30376. typ: TypeUsageStatisticDay,
  30377. clearedFields: make(map[string]struct{}),
  30378. }
  30379. for _, opt := range opts {
  30380. opt(m)
  30381. }
  30382. return m
  30383. }
  30384. // withUsageStatisticDayID sets the ID field of the mutation.
  30385. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30386. return func(m *UsageStatisticDayMutation) {
  30387. var (
  30388. err error
  30389. once sync.Once
  30390. value *UsageStatisticDay
  30391. )
  30392. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30393. once.Do(func() {
  30394. if m.done {
  30395. err = errors.New("querying old values post mutation is not allowed")
  30396. } else {
  30397. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30398. }
  30399. })
  30400. return value, err
  30401. }
  30402. m.id = &id
  30403. }
  30404. }
  30405. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30406. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30407. return func(m *UsageStatisticDayMutation) {
  30408. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30409. return node, nil
  30410. }
  30411. m.id = &node.ID
  30412. }
  30413. }
  30414. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30415. // executed in a transaction (ent.Tx), a transactional client is returned.
  30416. func (m UsageStatisticDayMutation) Client() *Client {
  30417. client := &Client{config: m.config}
  30418. client.init()
  30419. return client
  30420. }
  30421. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30422. // it returns an error otherwise.
  30423. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30424. if _, ok := m.driver.(*txDriver); !ok {
  30425. return nil, errors.New("ent: mutation is not running in a transaction")
  30426. }
  30427. tx := &Tx{config: m.config}
  30428. tx.init()
  30429. return tx, nil
  30430. }
  30431. // SetID sets the value of the id field. Note that this
  30432. // operation is only accepted on creation of UsageStatisticDay entities.
  30433. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30434. m.id = &id
  30435. }
  30436. // ID returns the ID value in the mutation. Note that the ID is only available
  30437. // if it was provided to the builder or after it was returned from the database.
  30438. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30439. if m.id == nil {
  30440. return
  30441. }
  30442. return *m.id, true
  30443. }
  30444. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30445. // That means, if the mutation is applied within a transaction with an isolation level such
  30446. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30447. // or updated by the mutation.
  30448. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30449. switch {
  30450. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30451. id, exists := m.ID()
  30452. if exists {
  30453. return []uint64{id}, nil
  30454. }
  30455. fallthrough
  30456. case m.op.Is(OpUpdate | OpDelete):
  30457. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30458. default:
  30459. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30460. }
  30461. }
  30462. // SetCreatedAt sets the "created_at" field.
  30463. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30464. m.created_at = &t
  30465. }
  30466. // CreatedAt returns the value of the "created_at" field in the mutation.
  30467. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30468. v := m.created_at
  30469. if v == nil {
  30470. return
  30471. }
  30472. return *v, true
  30473. }
  30474. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30475. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30477. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30478. if !m.op.Is(OpUpdateOne) {
  30479. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30480. }
  30481. if m.id == nil || m.oldValue == nil {
  30482. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30483. }
  30484. oldValue, err := m.oldValue(ctx)
  30485. if err != nil {
  30486. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30487. }
  30488. return oldValue.CreatedAt, nil
  30489. }
  30490. // ResetCreatedAt resets all changes to the "created_at" field.
  30491. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30492. m.created_at = nil
  30493. }
  30494. // SetUpdatedAt sets the "updated_at" field.
  30495. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30496. m.updated_at = &t
  30497. }
  30498. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30499. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30500. v := m.updated_at
  30501. if v == nil {
  30502. return
  30503. }
  30504. return *v, true
  30505. }
  30506. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30507. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30509. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30510. if !m.op.Is(OpUpdateOne) {
  30511. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30512. }
  30513. if m.id == nil || m.oldValue == nil {
  30514. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30515. }
  30516. oldValue, err := m.oldValue(ctx)
  30517. if err != nil {
  30518. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30519. }
  30520. return oldValue.UpdatedAt, nil
  30521. }
  30522. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30523. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30524. m.updated_at = nil
  30525. }
  30526. // SetStatus sets the "status" field.
  30527. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30528. m.status = &u
  30529. m.addstatus = nil
  30530. }
  30531. // Status returns the value of the "status" field in the mutation.
  30532. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30533. v := m.status
  30534. if v == nil {
  30535. return
  30536. }
  30537. return *v, true
  30538. }
  30539. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30540. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30542. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30543. if !m.op.Is(OpUpdateOne) {
  30544. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30545. }
  30546. if m.id == nil || m.oldValue == nil {
  30547. return v, errors.New("OldStatus requires an ID field in the mutation")
  30548. }
  30549. oldValue, err := m.oldValue(ctx)
  30550. if err != nil {
  30551. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30552. }
  30553. return oldValue.Status, nil
  30554. }
  30555. // AddStatus adds u to the "status" field.
  30556. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30557. if m.addstatus != nil {
  30558. *m.addstatus += u
  30559. } else {
  30560. m.addstatus = &u
  30561. }
  30562. }
  30563. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30564. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30565. v := m.addstatus
  30566. if v == nil {
  30567. return
  30568. }
  30569. return *v, true
  30570. }
  30571. // ClearStatus clears the value of the "status" field.
  30572. func (m *UsageStatisticDayMutation) ClearStatus() {
  30573. m.status = nil
  30574. m.addstatus = nil
  30575. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30576. }
  30577. // StatusCleared returns if the "status" field was cleared in this mutation.
  30578. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30579. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30580. return ok
  30581. }
  30582. // ResetStatus resets all changes to the "status" field.
  30583. func (m *UsageStatisticDayMutation) ResetStatus() {
  30584. m.status = nil
  30585. m.addstatus = nil
  30586. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30587. }
  30588. // SetDeletedAt sets the "deleted_at" field.
  30589. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30590. m.deleted_at = &t
  30591. }
  30592. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30593. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30594. v := m.deleted_at
  30595. if v == nil {
  30596. return
  30597. }
  30598. return *v, true
  30599. }
  30600. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30601. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30603. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30604. if !m.op.Is(OpUpdateOne) {
  30605. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30606. }
  30607. if m.id == nil || m.oldValue == nil {
  30608. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30609. }
  30610. oldValue, err := m.oldValue(ctx)
  30611. if err != nil {
  30612. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30613. }
  30614. return oldValue.DeletedAt, nil
  30615. }
  30616. // ClearDeletedAt clears the value of the "deleted_at" field.
  30617. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30618. m.deleted_at = nil
  30619. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30620. }
  30621. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30622. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30623. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30624. return ok
  30625. }
  30626. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30627. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30628. m.deleted_at = nil
  30629. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30630. }
  30631. // SetAddtime sets the "addtime" field.
  30632. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30633. m.addtime = &u
  30634. m.addaddtime = nil
  30635. }
  30636. // Addtime returns the value of the "addtime" field in the mutation.
  30637. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  30638. v := m.addtime
  30639. if v == nil {
  30640. return
  30641. }
  30642. return *v, true
  30643. }
  30644. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  30645. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30647. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30648. if !m.op.Is(OpUpdateOne) {
  30649. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30650. }
  30651. if m.id == nil || m.oldValue == nil {
  30652. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30653. }
  30654. oldValue, err := m.oldValue(ctx)
  30655. if err != nil {
  30656. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30657. }
  30658. return oldValue.Addtime, nil
  30659. }
  30660. // AddAddtime adds u to the "addtime" field.
  30661. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  30662. if m.addaddtime != nil {
  30663. *m.addaddtime += u
  30664. } else {
  30665. m.addaddtime = &u
  30666. }
  30667. }
  30668. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30669. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  30670. v := m.addaddtime
  30671. if v == nil {
  30672. return
  30673. }
  30674. return *v, true
  30675. }
  30676. // ResetAddtime resets all changes to the "addtime" field.
  30677. func (m *UsageStatisticDayMutation) ResetAddtime() {
  30678. m.addtime = nil
  30679. m.addaddtime = nil
  30680. }
  30681. // SetType sets the "type" field.
  30682. func (m *UsageStatisticDayMutation) SetType(i int) {
  30683. m._type = &i
  30684. m.add_type = nil
  30685. }
  30686. // GetType returns the value of the "type" field in the mutation.
  30687. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  30688. v := m._type
  30689. if v == nil {
  30690. return
  30691. }
  30692. return *v, true
  30693. }
  30694. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  30695. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30697. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  30698. if !m.op.Is(OpUpdateOne) {
  30699. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30700. }
  30701. if m.id == nil || m.oldValue == nil {
  30702. return v, errors.New("OldType requires an ID field in the mutation")
  30703. }
  30704. oldValue, err := m.oldValue(ctx)
  30705. if err != nil {
  30706. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30707. }
  30708. return oldValue.Type, nil
  30709. }
  30710. // AddType adds i to the "type" field.
  30711. func (m *UsageStatisticDayMutation) AddType(i int) {
  30712. if m.add_type != nil {
  30713. *m.add_type += i
  30714. } else {
  30715. m.add_type = &i
  30716. }
  30717. }
  30718. // AddedType returns the value that was added to the "type" field in this mutation.
  30719. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  30720. v := m.add_type
  30721. if v == nil {
  30722. return
  30723. }
  30724. return *v, true
  30725. }
  30726. // ResetType resets all changes to the "type" field.
  30727. func (m *UsageStatisticDayMutation) ResetType() {
  30728. m._type = nil
  30729. m.add_type = nil
  30730. }
  30731. // SetBotID sets the "bot_id" field.
  30732. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  30733. m.bot_id = &s
  30734. }
  30735. // BotID returns the value of the "bot_id" field in the mutation.
  30736. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  30737. v := m.bot_id
  30738. if v == nil {
  30739. return
  30740. }
  30741. return *v, true
  30742. }
  30743. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  30744. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30746. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  30747. if !m.op.Is(OpUpdateOne) {
  30748. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30749. }
  30750. if m.id == nil || m.oldValue == nil {
  30751. return v, errors.New("OldBotID requires an ID field in the mutation")
  30752. }
  30753. oldValue, err := m.oldValue(ctx)
  30754. if err != nil {
  30755. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30756. }
  30757. return oldValue.BotID, nil
  30758. }
  30759. // ClearBotID clears the value of the "bot_id" field.
  30760. func (m *UsageStatisticDayMutation) ClearBotID() {
  30761. m.bot_id = nil
  30762. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  30763. }
  30764. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30765. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  30766. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  30767. return ok
  30768. }
  30769. // ResetBotID resets all changes to the "bot_id" field.
  30770. func (m *UsageStatisticDayMutation) ResetBotID() {
  30771. m.bot_id = nil
  30772. delete(m.clearedFields, usagestatisticday.FieldBotID)
  30773. }
  30774. // SetOrganizationID sets the "organization_id" field.
  30775. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  30776. m.organization_id = &u
  30777. m.addorganization_id = nil
  30778. }
  30779. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30780. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  30781. v := m.organization_id
  30782. if v == nil {
  30783. return
  30784. }
  30785. return *v, true
  30786. }
  30787. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  30788. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30790. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30791. if !m.op.Is(OpUpdateOne) {
  30792. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30793. }
  30794. if m.id == nil || m.oldValue == nil {
  30795. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30796. }
  30797. oldValue, err := m.oldValue(ctx)
  30798. if err != nil {
  30799. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30800. }
  30801. return oldValue.OrganizationID, nil
  30802. }
  30803. // AddOrganizationID adds u to the "organization_id" field.
  30804. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  30805. if m.addorganization_id != nil {
  30806. *m.addorganization_id += u
  30807. } else {
  30808. m.addorganization_id = &u
  30809. }
  30810. }
  30811. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30812. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  30813. v := m.addorganization_id
  30814. if v == nil {
  30815. return
  30816. }
  30817. return *v, true
  30818. }
  30819. // ClearOrganizationID clears the value of the "organization_id" field.
  30820. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  30821. m.organization_id = nil
  30822. m.addorganization_id = nil
  30823. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  30824. }
  30825. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30826. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  30827. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  30828. return ok
  30829. }
  30830. // ResetOrganizationID resets all changes to the "organization_id" field.
  30831. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  30832. m.organization_id = nil
  30833. m.addorganization_id = nil
  30834. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  30835. }
  30836. // SetAiResponse sets the "ai_response" field.
  30837. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  30838. m.ai_response = &u
  30839. m.addai_response = nil
  30840. }
  30841. // AiResponse returns the value of the "ai_response" field in the mutation.
  30842. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  30843. v := m.ai_response
  30844. if v == nil {
  30845. return
  30846. }
  30847. return *v, true
  30848. }
  30849. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  30850. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30852. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30853. if !m.op.Is(OpUpdateOne) {
  30854. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30855. }
  30856. if m.id == nil || m.oldValue == nil {
  30857. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30858. }
  30859. oldValue, err := m.oldValue(ctx)
  30860. if err != nil {
  30861. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30862. }
  30863. return oldValue.AiResponse, nil
  30864. }
  30865. // AddAiResponse adds u to the "ai_response" field.
  30866. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  30867. if m.addai_response != nil {
  30868. *m.addai_response += u
  30869. } else {
  30870. m.addai_response = &u
  30871. }
  30872. }
  30873. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30874. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  30875. v := m.addai_response
  30876. if v == nil {
  30877. return
  30878. }
  30879. return *v, true
  30880. }
  30881. // ResetAiResponse resets all changes to the "ai_response" field.
  30882. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  30883. m.ai_response = nil
  30884. m.addai_response = nil
  30885. }
  30886. // SetSopRun sets the "sop_run" field.
  30887. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  30888. m.sop_run = &u
  30889. m.addsop_run = nil
  30890. }
  30891. // SopRun returns the value of the "sop_run" field in the mutation.
  30892. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  30893. v := m.sop_run
  30894. if v == nil {
  30895. return
  30896. }
  30897. return *v, true
  30898. }
  30899. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  30900. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30902. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30903. if !m.op.Is(OpUpdateOne) {
  30904. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30905. }
  30906. if m.id == nil || m.oldValue == nil {
  30907. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30908. }
  30909. oldValue, err := m.oldValue(ctx)
  30910. if err != nil {
  30911. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30912. }
  30913. return oldValue.SopRun, nil
  30914. }
  30915. // AddSopRun adds u to the "sop_run" field.
  30916. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  30917. if m.addsop_run != nil {
  30918. *m.addsop_run += u
  30919. } else {
  30920. m.addsop_run = &u
  30921. }
  30922. }
  30923. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30924. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  30925. v := m.addsop_run
  30926. if v == nil {
  30927. return
  30928. }
  30929. return *v, true
  30930. }
  30931. // ResetSopRun resets all changes to the "sop_run" field.
  30932. func (m *UsageStatisticDayMutation) ResetSopRun() {
  30933. m.sop_run = nil
  30934. m.addsop_run = nil
  30935. }
  30936. // SetTotalFriend sets the "total_friend" field.
  30937. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  30938. m.total_friend = &u
  30939. m.addtotal_friend = nil
  30940. }
  30941. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30942. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  30943. v := m.total_friend
  30944. if v == nil {
  30945. return
  30946. }
  30947. return *v, true
  30948. }
  30949. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  30950. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30952. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30953. if !m.op.Is(OpUpdateOne) {
  30954. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30955. }
  30956. if m.id == nil || m.oldValue == nil {
  30957. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30958. }
  30959. oldValue, err := m.oldValue(ctx)
  30960. if err != nil {
  30961. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30962. }
  30963. return oldValue.TotalFriend, nil
  30964. }
  30965. // AddTotalFriend adds u to the "total_friend" field.
  30966. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  30967. if m.addtotal_friend != nil {
  30968. *m.addtotal_friend += u
  30969. } else {
  30970. m.addtotal_friend = &u
  30971. }
  30972. }
  30973. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30974. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  30975. v := m.addtotal_friend
  30976. if v == nil {
  30977. return
  30978. }
  30979. return *v, true
  30980. }
  30981. // ResetTotalFriend resets all changes to the "total_friend" field.
  30982. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  30983. m.total_friend = nil
  30984. m.addtotal_friend = nil
  30985. }
  30986. // SetTotalGroup sets the "total_group" field.
  30987. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  30988. m.total_group = &u
  30989. m.addtotal_group = nil
  30990. }
  30991. // TotalGroup returns the value of the "total_group" field in the mutation.
  30992. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  30993. v := m.total_group
  30994. if v == nil {
  30995. return
  30996. }
  30997. return *v, true
  30998. }
  30999. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  31000. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31002. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31003. if !m.op.Is(OpUpdateOne) {
  31004. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31005. }
  31006. if m.id == nil || m.oldValue == nil {
  31007. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31008. }
  31009. oldValue, err := m.oldValue(ctx)
  31010. if err != nil {
  31011. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31012. }
  31013. return oldValue.TotalGroup, nil
  31014. }
  31015. // AddTotalGroup adds u to the "total_group" field.
  31016. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  31017. if m.addtotal_group != nil {
  31018. *m.addtotal_group += u
  31019. } else {
  31020. m.addtotal_group = &u
  31021. }
  31022. }
  31023. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31024. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  31025. v := m.addtotal_group
  31026. if v == nil {
  31027. return
  31028. }
  31029. return *v, true
  31030. }
  31031. // ResetTotalGroup resets all changes to the "total_group" field.
  31032. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  31033. m.total_group = nil
  31034. m.addtotal_group = nil
  31035. }
  31036. // SetAccountBalance sets the "account_balance" field.
  31037. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  31038. m.account_balance = &u
  31039. m.addaccount_balance = nil
  31040. }
  31041. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31042. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  31043. v := m.account_balance
  31044. if v == nil {
  31045. return
  31046. }
  31047. return *v, true
  31048. }
  31049. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  31050. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31052. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31053. if !m.op.Is(OpUpdateOne) {
  31054. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31055. }
  31056. if m.id == nil || m.oldValue == nil {
  31057. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31058. }
  31059. oldValue, err := m.oldValue(ctx)
  31060. if err != nil {
  31061. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31062. }
  31063. return oldValue.AccountBalance, nil
  31064. }
  31065. // AddAccountBalance adds u to the "account_balance" field.
  31066. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  31067. if m.addaccount_balance != nil {
  31068. *m.addaccount_balance += u
  31069. } else {
  31070. m.addaccount_balance = &u
  31071. }
  31072. }
  31073. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31074. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  31075. v := m.addaccount_balance
  31076. if v == nil {
  31077. return
  31078. }
  31079. return *v, true
  31080. }
  31081. // ResetAccountBalance resets all changes to the "account_balance" field.
  31082. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31083. m.account_balance = nil
  31084. m.addaccount_balance = nil
  31085. }
  31086. // SetConsumeToken sets the "consume_token" field.
  31087. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31088. m.consume_token = &u
  31089. m.addconsume_token = nil
  31090. }
  31091. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31092. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31093. v := m.consume_token
  31094. if v == nil {
  31095. return
  31096. }
  31097. return *v, true
  31098. }
  31099. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31100. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31102. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31103. if !m.op.Is(OpUpdateOne) {
  31104. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31105. }
  31106. if m.id == nil || m.oldValue == nil {
  31107. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31108. }
  31109. oldValue, err := m.oldValue(ctx)
  31110. if err != nil {
  31111. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31112. }
  31113. return oldValue.ConsumeToken, nil
  31114. }
  31115. // AddConsumeToken adds u to the "consume_token" field.
  31116. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31117. if m.addconsume_token != nil {
  31118. *m.addconsume_token += u
  31119. } else {
  31120. m.addconsume_token = &u
  31121. }
  31122. }
  31123. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31124. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31125. v := m.addconsume_token
  31126. if v == nil {
  31127. return
  31128. }
  31129. return *v, true
  31130. }
  31131. // ResetConsumeToken resets all changes to the "consume_token" field.
  31132. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31133. m.consume_token = nil
  31134. m.addconsume_token = nil
  31135. }
  31136. // SetActiveUser sets the "active_user" field.
  31137. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31138. m.active_user = &u
  31139. m.addactive_user = nil
  31140. }
  31141. // ActiveUser returns the value of the "active_user" field in the mutation.
  31142. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31143. v := m.active_user
  31144. if v == nil {
  31145. return
  31146. }
  31147. return *v, true
  31148. }
  31149. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31150. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31152. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31153. if !m.op.Is(OpUpdateOne) {
  31154. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31155. }
  31156. if m.id == nil || m.oldValue == nil {
  31157. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31158. }
  31159. oldValue, err := m.oldValue(ctx)
  31160. if err != nil {
  31161. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31162. }
  31163. return oldValue.ActiveUser, nil
  31164. }
  31165. // AddActiveUser adds u to the "active_user" field.
  31166. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31167. if m.addactive_user != nil {
  31168. *m.addactive_user += u
  31169. } else {
  31170. m.addactive_user = &u
  31171. }
  31172. }
  31173. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31174. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31175. v := m.addactive_user
  31176. if v == nil {
  31177. return
  31178. }
  31179. return *v, true
  31180. }
  31181. // ResetActiveUser resets all changes to the "active_user" field.
  31182. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31183. m.active_user = nil
  31184. m.addactive_user = nil
  31185. }
  31186. // SetNewUser sets the "new_user" field.
  31187. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31188. m.new_user = &i
  31189. m.addnew_user = nil
  31190. }
  31191. // NewUser returns the value of the "new_user" field in the mutation.
  31192. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31193. v := m.new_user
  31194. if v == nil {
  31195. return
  31196. }
  31197. return *v, true
  31198. }
  31199. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31200. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31202. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31203. if !m.op.Is(OpUpdateOne) {
  31204. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31205. }
  31206. if m.id == nil || m.oldValue == nil {
  31207. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31208. }
  31209. oldValue, err := m.oldValue(ctx)
  31210. if err != nil {
  31211. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31212. }
  31213. return oldValue.NewUser, nil
  31214. }
  31215. // AddNewUser adds i to the "new_user" field.
  31216. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31217. if m.addnew_user != nil {
  31218. *m.addnew_user += i
  31219. } else {
  31220. m.addnew_user = &i
  31221. }
  31222. }
  31223. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31224. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31225. v := m.addnew_user
  31226. if v == nil {
  31227. return
  31228. }
  31229. return *v, true
  31230. }
  31231. // ResetNewUser resets all changes to the "new_user" field.
  31232. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31233. m.new_user = nil
  31234. m.addnew_user = nil
  31235. }
  31236. // SetLabelDist sets the "label_dist" field.
  31237. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31238. m.label_dist = &ctd
  31239. m.appendlabel_dist = nil
  31240. }
  31241. // LabelDist returns the value of the "label_dist" field in the mutation.
  31242. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31243. v := m.label_dist
  31244. if v == nil {
  31245. return
  31246. }
  31247. return *v, true
  31248. }
  31249. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31250. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31252. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31253. if !m.op.Is(OpUpdateOne) {
  31254. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31255. }
  31256. if m.id == nil || m.oldValue == nil {
  31257. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31258. }
  31259. oldValue, err := m.oldValue(ctx)
  31260. if err != nil {
  31261. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31262. }
  31263. return oldValue.LabelDist, nil
  31264. }
  31265. // AppendLabelDist adds ctd to the "label_dist" field.
  31266. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31267. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31268. }
  31269. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31270. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31271. if len(m.appendlabel_dist) == 0 {
  31272. return nil, false
  31273. }
  31274. return m.appendlabel_dist, true
  31275. }
  31276. // ResetLabelDist resets all changes to the "label_dist" field.
  31277. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31278. m.label_dist = nil
  31279. m.appendlabel_dist = nil
  31280. }
  31281. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31282. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31283. m.predicates = append(m.predicates, ps...)
  31284. }
  31285. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31286. // users can use type-assertion to append predicates that do not depend on any generated package.
  31287. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31288. p := make([]predicate.UsageStatisticDay, len(ps))
  31289. for i := range ps {
  31290. p[i] = ps[i]
  31291. }
  31292. m.Where(p...)
  31293. }
  31294. // Op returns the operation name.
  31295. func (m *UsageStatisticDayMutation) Op() Op {
  31296. return m.op
  31297. }
  31298. // SetOp allows setting the mutation operation.
  31299. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31300. m.op = op
  31301. }
  31302. // Type returns the node type of this mutation (UsageStatisticDay).
  31303. func (m *UsageStatisticDayMutation) Type() string {
  31304. return m.typ
  31305. }
  31306. // Fields returns all fields that were changed during this mutation. Note that in
  31307. // order to get all numeric fields that were incremented/decremented, call
  31308. // AddedFields().
  31309. func (m *UsageStatisticDayMutation) Fields() []string {
  31310. fields := make([]string, 0, 17)
  31311. if m.created_at != nil {
  31312. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31313. }
  31314. if m.updated_at != nil {
  31315. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31316. }
  31317. if m.status != nil {
  31318. fields = append(fields, usagestatisticday.FieldStatus)
  31319. }
  31320. if m.deleted_at != nil {
  31321. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31322. }
  31323. if m.addtime != nil {
  31324. fields = append(fields, usagestatisticday.FieldAddtime)
  31325. }
  31326. if m._type != nil {
  31327. fields = append(fields, usagestatisticday.FieldType)
  31328. }
  31329. if m.bot_id != nil {
  31330. fields = append(fields, usagestatisticday.FieldBotID)
  31331. }
  31332. if m.organization_id != nil {
  31333. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31334. }
  31335. if m.ai_response != nil {
  31336. fields = append(fields, usagestatisticday.FieldAiResponse)
  31337. }
  31338. if m.sop_run != nil {
  31339. fields = append(fields, usagestatisticday.FieldSopRun)
  31340. }
  31341. if m.total_friend != nil {
  31342. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31343. }
  31344. if m.total_group != nil {
  31345. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31346. }
  31347. if m.account_balance != nil {
  31348. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31349. }
  31350. if m.consume_token != nil {
  31351. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31352. }
  31353. if m.active_user != nil {
  31354. fields = append(fields, usagestatisticday.FieldActiveUser)
  31355. }
  31356. if m.new_user != nil {
  31357. fields = append(fields, usagestatisticday.FieldNewUser)
  31358. }
  31359. if m.label_dist != nil {
  31360. fields = append(fields, usagestatisticday.FieldLabelDist)
  31361. }
  31362. return fields
  31363. }
  31364. // Field returns the value of a field with the given name. The second boolean
  31365. // return value indicates that this field was not set, or was not defined in the
  31366. // schema.
  31367. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31368. switch name {
  31369. case usagestatisticday.FieldCreatedAt:
  31370. return m.CreatedAt()
  31371. case usagestatisticday.FieldUpdatedAt:
  31372. return m.UpdatedAt()
  31373. case usagestatisticday.FieldStatus:
  31374. return m.Status()
  31375. case usagestatisticday.FieldDeletedAt:
  31376. return m.DeletedAt()
  31377. case usagestatisticday.FieldAddtime:
  31378. return m.Addtime()
  31379. case usagestatisticday.FieldType:
  31380. return m.GetType()
  31381. case usagestatisticday.FieldBotID:
  31382. return m.BotID()
  31383. case usagestatisticday.FieldOrganizationID:
  31384. return m.OrganizationID()
  31385. case usagestatisticday.FieldAiResponse:
  31386. return m.AiResponse()
  31387. case usagestatisticday.FieldSopRun:
  31388. return m.SopRun()
  31389. case usagestatisticday.FieldTotalFriend:
  31390. return m.TotalFriend()
  31391. case usagestatisticday.FieldTotalGroup:
  31392. return m.TotalGroup()
  31393. case usagestatisticday.FieldAccountBalance:
  31394. return m.AccountBalance()
  31395. case usagestatisticday.FieldConsumeToken:
  31396. return m.ConsumeToken()
  31397. case usagestatisticday.FieldActiveUser:
  31398. return m.ActiveUser()
  31399. case usagestatisticday.FieldNewUser:
  31400. return m.NewUser()
  31401. case usagestatisticday.FieldLabelDist:
  31402. return m.LabelDist()
  31403. }
  31404. return nil, false
  31405. }
  31406. // OldField returns the old value of the field from the database. An error is
  31407. // returned if the mutation operation is not UpdateOne, or the query to the
  31408. // database failed.
  31409. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31410. switch name {
  31411. case usagestatisticday.FieldCreatedAt:
  31412. return m.OldCreatedAt(ctx)
  31413. case usagestatisticday.FieldUpdatedAt:
  31414. return m.OldUpdatedAt(ctx)
  31415. case usagestatisticday.FieldStatus:
  31416. return m.OldStatus(ctx)
  31417. case usagestatisticday.FieldDeletedAt:
  31418. return m.OldDeletedAt(ctx)
  31419. case usagestatisticday.FieldAddtime:
  31420. return m.OldAddtime(ctx)
  31421. case usagestatisticday.FieldType:
  31422. return m.OldType(ctx)
  31423. case usagestatisticday.FieldBotID:
  31424. return m.OldBotID(ctx)
  31425. case usagestatisticday.FieldOrganizationID:
  31426. return m.OldOrganizationID(ctx)
  31427. case usagestatisticday.FieldAiResponse:
  31428. return m.OldAiResponse(ctx)
  31429. case usagestatisticday.FieldSopRun:
  31430. return m.OldSopRun(ctx)
  31431. case usagestatisticday.FieldTotalFriend:
  31432. return m.OldTotalFriend(ctx)
  31433. case usagestatisticday.FieldTotalGroup:
  31434. return m.OldTotalGroup(ctx)
  31435. case usagestatisticday.FieldAccountBalance:
  31436. return m.OldAccountBalance(ctx)
  31437. case usagestatisticday.FieldConsumeToken:
  31438. return m.OldConsumeToken(ctx)
  31439. case usagestatisticday.FieldActiveUser:
  31440. return m.OldActiveUser(ctx)
  31441. case usagestatisticday.FieldNewUser:
  31442. return m.OldNewUser(ctx)
  31443. case usagestatisticday.FieldLabelDist:
  31444. return m.OldLabelDist(ctx)
  31445. }
  31446. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31447. }
  31448. // SetField sets the value of a field with the given name. It returns an error if
  31449. // the field is not defined in the schema, or if the type mismatched the field
  31450. // type.
  31451. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31452. switch name {
  31453. case usagestatisticday.FieldCreatedAt:
  31454. v, ok := value.(time.Time)
  31455. if !ok {
  31456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31457. }
  31458. m.SetCreatedAt(v)
  31459. return nil
  31460. case usagestatisticday.FieldUpdatedAt:
  31461. v, ok := value.(time.Time)
  31462. if !ok {
  31463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31464. }
  31465. m.SetUpdatedAt(v)
  31466. return nil
  31467. case usagestatisticday.FieldStatus:
  31468. v, ok := value.(uint8)
  31469. if !ok {
  31470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31471. }
  31472. m.SetStatus(v)
  31473. return nil
  31474. case usagestatisticday.FieldDeletedAt:
  31475. v, ok := value.(time.Time)
  31476. if !ok {
  31477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31478. }
  31479. m.SetDeletedAt(v)
  31480. return nil
  31481. case usagestatisticday.FieldAddtime:
  31482. v, ok := value.(uint64)
  31483. if !ok {
  31484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31485. }
  31486. m.SetAddtime(v)
  31487. return nil
  31488. case usagestatisticday.FieldType:
  31489. v, ok := value.(int)
  31490. if !ok {
  31491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31492. }
  31493. m.SetType(v)
  31494. return nil
  31495. case usagestatisticday.FieldBotID:
  31496. v, ok := value.(string)
  31497. if !ok {
  31498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31499. }
  31500. m.SetBotID(v)
  31501. return nil
  31502. case usagestatisticday.FieldOrganizationID:
  31503. v, ok := value.(uint64)
  31504. if !ok {
  31505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31506. }
  31507. m.SetOrganizationID(v)
  31508. return nil
  31509. case usagestatisticday.FieldAiResponse:
  31510. v, ok := value.(uint64)
  31511. if !ok {
  31512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31513. }
  31514. m.SetAiResponse(v)
  31515. return nil
  31516. case usagestatisticday.FieldSopRun:
  31517. v, ok := value.(uint64)
  31518. if !ok {
  31519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31520. }
  31521. m.SetSopRun(v)
  31522. return nil
  31523. case usagestatisticday.FieldTotalFriend:
  31524. v, ok := value.(uint64)
  31525. if !ok {
  31526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31527. }
  31528. m.SetTotalFriend(v)
  31529. return nil
  31530. case usagestatisticday.FieldTotalGroup:
  31531. v, ok := value.(uint64)
  31532. if !ok {
  31533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31534. }
  31535. m.SetTotalGroup(v)
  31536. return nil
  31537. case usagestatisticday.FieldAccountBalance:
  31538. v, ok := value.(uint64)
  31539. if !ok {
  31540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31541. }
  31542. m.SetAccountBalance(v)
  31543. return nil
  31544. case usagestatisticday.FieldConsumeToken:
  31545. v, ok := value.(uint64)
  31546. if !ok {
  31547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31548. }
  31549. m.SetConsumeToken(v)
  31550. return nil
  31551. case usagestatisticday.FieldActiveUser:
  31552. v, ok := value.(uint64)
  31553. if !ok {
  31554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31555. }
  31556. m.SetActiveUser(v)
  31557. return nil
  31558. case usagestatisticday.FieldNewUser:
  31559. v, ok := value.(int64)
  31560. if !ok {
  31561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31562. }
  31563. m.SetNewUser(v)
  31564. return nil
  31565. case usagestatisticday.FieldLabelDist:
  31566. v, ok := value.([]custom_types.LabelDist)
  31567. if !ok {
  31568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31569. }
  31570. m.SetLabelDist(v)
  31571. return nil
  31572. }
  31573. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31574. }
  31575. // AddedFields returns all numeric fields that were incremented/decremented during
  31576. // this mutation.
  31577. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31578. var fields []string
  31579. if m.addstatus != nil {
  31580. fields = append(fields, usagestatisticday.FieldStatus)
  31581. }
  31582. if m.addaddtime != nil {
  31583. fields = append(fields, usagestatisticday.FieldAddtime)
  31584. }
  31585. if m.add_type != nil {
  31586. fields = append(fields, usagestatisticday.FieldType)
  31587. }
  31588. if m.addorganization_id != nil {
  31589. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31590. }
  31591. if m.addai_response != nil {
  31592. fields = append(fields, usagestatisticday.FieldAiResponse)
  31593. }
  31594. if m.addsop_run != nil {
  31595. fields = append(fields, usagestatisticday.FieldSopRun)
  31596. }
  31597. if m.addtotal_friend != nil {
  31598. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31599. }
  31600. if m.addtotal_group != nil {
  31601. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31602. }
  31603. if m.addaccount_balance != nil {
  31604. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31605. }
  31606. if m.addconsume_token != nil {
  31607. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31608. }
  31609. if m.addactive_user != nil {
  31610. fields = append(fields, usagestatisticday.FieldActiveUser)
  31611. }
  31612. if m.addnew_user != nil {
  31613. fields = append(fields, usagestatisticday.FieldNewUser)
  31614. }
  31615. return fields
  31616. }
  31617. // AddedField returns the numeric value that was incremented/decremented on a field
  31618. // with the given name. The second boolean return value indicates that this field
  31619. // was not set, or was not defined in the schema.
  31620. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31621. switch name {
  31622. case usagestatisticday.FieldStatus:
  31623. return m.AddedStatus()
  31624. case usagestatisticday.FieldAddtime:
  31625. return m.AddedAddtime()
  31626. case usagestatisticday.FieldType:
  31627. return m.AddedType()
  31628. case usagestatisticday.FieldOrganizationID:
  31629. return m.AddedOrganizationID()
  31630. case usagestatisticday.FieldAiResponse:
  31631. return m.AddedAiResponse()
  31632. case usagestatisticday.FieldSopRun:
  31633. return m.AddedSopRun()
  31634. case usagestatisticday.FieldTotalFriend:
  31635. return m.AddedTotalFriend()
  31636. case usagestatisticday.FieldTotalGroup:
  31637. return m.AddedTotalGroup()
  31638. case usagestatisticday.FieldAccountBalance:
  31639. return m.AddedAccountBalance()
  31640. case usagestatisticday.FieldConsumeToken:
  31641. return m.AddedConsumeToken()
  31642. case usagestatisticday.FieldActiveUser:
  31643. return m.AddedActiveUser()
  31644. case usagestatisticday.FieldNewUser:
  31645. return m.AddedNewUser()
  31646. }
  31647. return nil, false
  31648. }
  31649. // AddField adds the value to the field with the given name. It returns an error if
  31650. // the field is not defined in the schema, or if the type mismatched the field
  31651. // type.
  31652. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  31653. switch name {
  31654. case usagestatisticday.FieldStatus:
  31655. v, ok := value.(int8)
  31656. if !ok {
  31657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31658. }
  31659. m.AddStatus(v)
  31660. return nil
  31661. case usagestatisticday.FieldAddtime:
  31662. v, ok := value.(int64)
  31663. if !ok {
  31664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31665. }
  31666. m.AddAddtime(v)
  31667. return nil
  31668. case usagestatisticday.FieldType:
  31669. v, ok := value.(int)
  31670. if !ok {
  31671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31672. }
  31673. m.AddType(v)
  31674. return nil
  31675. case usagestatisticday.FieldOrganizationID:
  31676. v, ok := value.(int64)
  31677. if !ok {
  31678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31679. }
  31680. m.AddOrganizationID(v)
  31681. return nil
  31682. case usagestatisticday.FieldAiResponse:
  31683. v, ok := value.(int64)
  31684. if !ok {
  31685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31686. }
  31687. m.AddAiResponse(v)
  31688. return nil
  31689. case usagestatisticday.FieldSopRun:
  31690. v, ok := value.(int64)
  31691. if !ok {
  31692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31693. }
  31694. m.AddSopRun(v)
  31695. return nil
  31696. case usagestatisticday.FieldTotalFriend:
  31697. v, ok := value.(int64)
  31698. if !ok {
  31699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31700. }
  31701. m.AddTotalFriend(v)
  31702. return nil
  31703. case usagestatisticday.FieldTotalGroup:
  31704. v, ok := value.(int64)
  31705. if !ok {
  31706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31707. }
  31708. m.AddTotalGroup(v)
  31709. return nil
  31710. case usagestatisticday.FieldAccountBalance:
  31711. v, ok := value.(int64)
  31712. if !ok {
  31713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31714. }
  31715. m.AddAccountBalance(v)
  31716. return nil
  31717. case usagestatisticday.FieldConsumeToken:
  31718. v, ok := value.(int64)
  31719. if !ok {
  31720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31721. }
  31722. m.AddConsumeToken(v)
  31723. return nil
  31724. case usagestatisticday.FieldActiveUser:
  31725. v, ok := value.(int64)
  31726. if !ok {
  31727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31728. }
  31729. m.AddActiveUser(v)
  31730. return nil
  31731. case usagestatisticday.FieldNewUser:
  31732. v, ok := value.(int64)
  31733. if !ok {
  31734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31735. }
  31736. m.AddNewUser(v)
  31737. return nil
  31738. }
  31739. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  31740. }
  31741. // ClearedFields returns all nullable fields that were cleared during this
  31742. // mutation.
  31743. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  31744. var fields []string
  31745. if m.FieldCleared(usagestatisticday.FieldStatus) {
  31746. fields = append(fields, usagestatisticday.FieldStatus)
  31747. }
  31748. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  31749. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31750. }
  31751. if m.FieldCleared(usagestatisticday.FieldBotID) {
  31752. fields = append(fields, usagestatisticday.FieldBotID)
  31753. }
  31754. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  31755. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31756. }
  31757. return fields
  31758. }
  31759. // FieldCleared returns a boolean indicating if a field with the given name was
  31760. // cleared in this mutation.
  31761. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  31762. _, ok := m.clearedFields[name]
  31763. return ok
  31764. }
  31765. // ClearField clears the value of the field with the given name. It returns an
  31766. // error if the field is not defined in the schema.
  31767. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  31768. switch name {
  31769. case usagestatisticday.FieldStatus:
  31770. m.ClearStatus()
  31771. return nil
  31772. case usagestatisticday.FieldDeletedAt:
  31773. m.ClearDeletedAt()
  31774. return nil
  31775. case usagestatisticday.FieldBotID:
  31776. m.ClearBotID()
  31777. return nil
  31778. case usagestatisticday.FieldOrganizationID:
  31779. m.ClearOrganizationID()
  31780. return nil
  31781. }
  31782. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  31783. }
  31784. // ResetField resets all changes in the mutation for the field with the given name.
  31785. // It returns an error if the field is not defined in the schema.
  31786. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  31787. switch name {
  31788. case usagestatisticday.FieldCreatedAt:
  31789. m.ResetCreatedAt()
  31790. return nil
  31791. case usagestatisticday.FieldUpdatedAt:
  31792. m.ResetUpdatedAt()
  31793. return nil
  31794. case usagestatisticday.FieldStatus:
  31795. m.ResetStatus()
  31796. return nil
  31797. case usagestatisticday.FieldDeletedAt:
  31798. m.ResetDeletedAt()
  31799. return nil
  31800. case usagestatisticday.FieldAddtime:
  31801. m.ResetAddtime()
  31802. return nil
  31803. case usagestatisticday.FieldType:
  31804. m.ResetType()
  31805. return nil
  31806. case usagestatisticday.FieldBotID:
  31807. m.ResetBotID()
  31808. return nil
  31809. case usagestatisticday.FieldOrganizationID:
  31810. m.ResetOrganizationID()
  31811. return nil
  31812. case usagestatisticday.FieldAiResponse:
  31813. m.ResetAiResponse()
  31814. return nil
  31815. case usagestatisticday.FieldSopRun:
  31816. m.ResetSopRun()
  31817. return nil
  31818. case usagestatisticday.FieldTotalFriend:
  31819. m.ResetTotalFriend()
  31820. return nil
  31821. case usagestatisticday.FieldTotalGroup:
  31822. m.ResetTotalGroup()
  31823. return nil
  31824. case usagestatisticday.FieldAccountBalance:
  31825. m.ResetAccountBalance()
  31826. return nil
  31827. case usagestatisticday.FieldConsumeToken:
  31828. m.ResetConsumeToken()
  31829. return nil
  31830. case usagestatisticday.FieldActiveUser:
  31831. m.ResetActiveUser()
  31832. return nil
  31833. case usagestatisticday.FieldNewUser:
  31834. m.ResetNewUser()
  31835. return nil
  31836. case usagestatisticday.FieldLabelDist:
  31837. m.ResetLabelDist()
  31838. return nil
  31839. }
  31840. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31841. }
  31842. // AddedEdges returns all edge names that were set/added in this mutation.
  31843. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  31844. edges := make([]string, 0, 0)
  31845. return edges
  31846. }
  31847. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31848. // name in this mutation.
  31849. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  31850. return nil
  31851. }
  31852. // RemovedEdges returns all edge names that were removed in this mutation.
  31853. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  31854. edges := make([]string, 0, 0)
  31855. return edges
  31856. }
  31857. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31858. // the given name in this mutation.
  31859. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  31860. return nil
  31861. }
  31862. // ClearedEdges returns all edge names that were cleared in this mutation.
  31863. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  31864. edges := make([]string, 0, 0)
  31865. return edges
  31866. }
  31867. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31868. // was cleared in this mutation.
  31869. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  31870. return false
  31871. }
  31872. // ClearEdge clears the value of the edge with the given name. It returns an error
  31873. // if that edge is not defined in the schema.
  31874. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  31875. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  31876. }
  31877. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31878. // It returns an error if the edge is not defined in the schema.
  31879. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  31880. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  31881. }
  31882. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  31883. type UsageStatisticHourMutation struct {
  31884. config
  31885. op Op
  31886. typ string
  31887. id *uint64
  31888. created_at *time.Time
  31889. updated_at *time.Time
  31890. status *uint8
  31891. addstatus *int8
  31892. deleted_at *time.Time
  31893. addtime *uint64
  31894. addaddtime *int64
  31895. _type *int
  31896. add_type *int
  31897. bot_id *string
  31898. organization_id *uint64
  31899. addorganization_id *int64
  31900. ai_response *uint64
  31901. addai_response *int64
  31902. sop_run *uint64
  31903. addsop_run *int64
  31904. total_friend *uint64
  31905. addtotal_friend *int64
  31906. total_group *uint64
  31907. addtotal_group *int64
  31908. account_balance *uint64
  31909. addaccount_balance *int64
  31910. consume_token *uint64
  31911. addconsume_token *int64
  31912. active_user *uint64
  31913. addactive_user *int64
  31914. new_user *int64
  31915. addnew_user *int64
  31916. label_dist *[]custom_types.LabelDist
  31917. appendlabel_dist []custom_types.LabelDist
  31918. clearedFields map[string]struct{}
  31919. done bool
  31920. oldValue func(context.Context) (*UsageStatisticHour, error)
  31921. predicates []predicate.UsageStatisticHour
  31922. }
  31923. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  31924. // usagestatistichourOption allows management of the mutation configuration using functional options.
  31925. type usagestatistichourOption func(*UsageStatisticHourMutation)
  31926. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  31927. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  31928. m := &UsageStatisticHourMutation{
  31929. config: c,
  31930. op: op,
  31931. typ: TypeUsageStatisticHour,
  31932. clearedFields: make(map[string]struct{}),
  31933. }
  31934. for _, opt := range opts {
  31935. opt(m)
  31936. }
  31937. return m
  31938. }
  31939. // withUsageStatisticHourID sets the ID field of the mutation.
  31940. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  31941. return func(m *UsageStatisticHourMutation) {
  31942. var (
  31943. err error
  31944. once sync.Once
  31945. value *UsageStatisticHour
  31946. )
  31947. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  31948. once.Do(func() {
  31949. if m.done {
  31950. err = errors.New("querying old values post mutation is not allowed")
  31951. } else {
  31952. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  31953. }
  31954. })
  31955. return value, err
  31956. }
  31957. m.id = &id
  31958. }
  31959. }
  31960. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  31961. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  31962. return func(m *UsageStatisticHourMutation) {
  31963. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  31964. return node, nil
  31965. }
  31966. m.id = &node.ID
  31967. }
  31968. }
  31969. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31970. // executed in a transaction (ent.Tx), a transactional client is returned.
  31971. func (m UsageStatisticHourMutation) Client() *Client {
  31972. client := &Client{config: m.config}
  31973. client.init()
  31974. return client
  31975. }
  31976. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31977. // it returns an error otherwise.
  31978. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  31979. if _, ok := m.driver.(*txDriver); !ok {
  31980. return nil, errors.New("ent: mutation is not running in a transaction")
  31981. }
  31982. tx := &Tx{config: m.config}
  31983. tx.init()
  31984. return tx, nil
  31985. }
  31986. // SetID sets the value of the id field. Note that this
  31987. // operation is only accepted on creation of UsageStatisticHour entities.
  31988. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  31989. m.id = &id
  31990. }
  31991. // ID returns the ID value in the mutation. Note that the ID is only available
  31992. // if it was provided to the builder or after it was returned from the database.
  31993. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  31994. if m.id == nil {
  31995. return
  31996. }
  31997. return *m.id, true
  31998. }
  31999. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32000. // That means, if the mutation is applied within a transaction with an isolation level such
  32001. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32002. // or updated by the mutation.
  32003. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  32004. switch {
  32005. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32006. id, exists := m.ID()
  32007. if exists {
  32008. return []uint64{id}, nil
  32009. }
  32010. fallthrough
  32011. case m.op.Is(OpUpdate | OpDelete):
  32012. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  32013. default:
  32014. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32015. }
  32016. }
  32017. // SetCreatedAt sets the "created_at" field.
  32018. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  32019. m.created_at = &t
  32020. }
  32021. // CreatedAt returns the value of the "created_at" field in the mutation.
  32022. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  32023. v := m.created_at
  32024. if v == nil {
  32025. return
  32026. }
  32027. return *v, true
  32028. }
  32029. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  32030. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32032. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32033. if !m.op.Is(OpUpdateOne) {
  32034. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32035. }
  32036. if m.id == nil || m.oldValue == nil {
  32037. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32038. }
  32039. oldValue, err := m.oldValue(ctx)
  32040. if err != nil {
  32041. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32042. }
  32043. return oldValue.CreatedAt, nil
  32044. }
  32045. // ResetCreatedAt resets all changes to the "created_at" field.
  32046. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  32047. m.created_at = nil
  32048. }
  32049. // SetUpdatedAt sets the "updated_at" field.
  32050. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  32051. m.updated_at = &t
  32052. }
  32053. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32054. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  32055. v := m.updated_at
  32056. if v == nil {
  32057. return
  32058. }
  32059. return *v, true
  32060. }
  32061. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  32062. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32064. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32065. if !m.op.Is(OpUpdateOne) {
  32066. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32067. }
  32068. if m.id == nil || m.oldValue == nil {
  32069. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32070. }
  32071. oldValue, err := m.oldValue(ctx)
  32072. if err != nil {
  32073. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32074. }
  32075. return oldValue.UpdatedAt, nil
  32076. }
  32077. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32078. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  32079. m.updated_at = nil
  32080. }
  32081. // SetStatus sets the "status" field.
  32082. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32083. m.status = &u
  32084. m.addstatus = nil
  32085. }
  32086. // Status returns the value of the "status" field in the mutation.
  32087. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32088. v := m.status
  32089. if v == nil {
  32090. return
  32091. }
  32092. return *v, true
  32093. }
  32094. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32095. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32097. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32098. if !m.op.Is(OpUpdateOne) {
  32099. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32100. }
  32101. if m.id == nil || m.oldValue == nil {
  32102. return v, errors.New("OldStatus requires an ID field in the mutation")
  32103. }
  32104. oldValue, err := m.oldValue(ctx)
  32105. if err != nil {
  32106. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32107. }
  32108. return oldValue.Status, nil
  32109. }
  32110. // AddStatus adds u to the "status" field.
  32111. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32112. if m.addstatus != nil {
  32113. *m.addstatus += u
  32114. } else {
  32115. m.addstatus = &u
  32116. }
  32117. }
  32118. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32119. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32120. v := m.addstatus
  32121. if v == nil {
  32122. return
  32123. }
  32124. return *v, true
  32125. }
  32126. // ClearStatus clears the value of the "status" field.
  32127. func (m *UsageStatisticHourMutation) ClearStatus() {
  32128. m.status = nil
  32129. m.addstatus = nil
  32130. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32131. }
  32132. // StatusCleared returns if the "status" field was cleared in this mutation.
  32133. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32134. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32135. return ok
  32136. }
  32137. // ResetStatus resets all changes to the "status" field.
  32138. func (m *UsageStatisticHourMutation) ResetStatus() {
  32139. m.status = nil
  32140. m.addstatus = nil
  32141. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32142. }
  32143. // SetDeletedAt sets the "deleted_at" field.
  32144. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32145. m.deleted_at = &t
  32146. }
  32147. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32148. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32149. v := m.deleted_at
  32150. if v == nil {
  32151. return
  32152. }
  32153. return *v, true
  32154. }
  32155. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32156. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32158. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32159. if !m.op.Is(OpUpdateOne) {
  32160. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32161. }
  32162. if m.id == nil || m.oldValue == nil {
  32163. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32164. }
  32165. oldValue, err := m.oldValue(ctx)
  32166. if err != nil {
  32167. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32168. }
  32169. return oldValue.DeletedAt, nil
  32170. }
  32171. // ClearDeletedAt clears the value of the "deleted_at" field.
  32172. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32173. m.deleted_at = nil
  32174. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32175. }
  32176. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32177. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32178. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32179. return ok
  32180. }
  32181. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32182. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32183. m.deleted_at = nil
  32184. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32185. }
  32186. // SetAddtime sets the "addtime" field.
  32187. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32188. m.addtime = &u
  32189. m.addaddtime = nil
  32190. }
  32191. // Addtime returns the value of the "addtime" field in the mutation.
  32192. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32193. v := m.addtime
  32194. if v == nil {
  32195. return
  32196. }
  32197. return *v, true
  32198. }
  32199. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32200. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32202. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32203. if !m.op.Is(OpUpdateOne) {
  32204. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32205. }
  32206. if m.id == nil || m.oldValue == nil {
  32207. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32208. }
  32209. oldValue, err := m.oldValue(ctx)
  32210. if err != nil {
  32211. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32212. }
  32213. return oldValue.Addtime, nil
  32214. }
  32215. // AddAddtime adds u to the "addtime" field.
  32216. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32217. if m.addaddtime != nil {
  32218. *m.addaddtime += u
  32219. } else {
  32220. m.addaddtime = &u
  32221. }
  32222. }
  32223. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32224. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32225. v := m.addaddtime
  32226. if v == nil {
  32227. return
  32228. }
  32229. return *v, true
  32230. }
  32231. // ResetAddtime resets all changes to the "addtime" field.
  32232. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32233. m.addtime = nil
  32234. m.addaddtime = nil
  32235. }
  32236. // SetType sets the "type" field.
  32237. func (m *UsageStatisticHourMutation) SetType(i int) {
  32238. m._type = &i
  32239. m.add_type = nil
  32240. }
  32241. // GetType returns the value of the "type" field in the mutation.
  32242. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32243. v := m._type
  32244. if v == nil {
  32245. return
  32246. }
  32247. return *v, true
  32248. }
  32249. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32250. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32252. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32253. if !m.op.Is(OpUpdateOne) {
  32254. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32255. }
  32256. if m.id == nil || m.oldValue == nil {
  32257. return v, errors.New("OldType requires an ID field in the mutation")
  32258. }
  32259. oldValue, err := m.oldValue(ctx)
  32260. if err != nil {
  32261. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32262. }
  32263. return oldValue.Type, nil
  32264. }
  32265. // AddType adds i to the "type" field.
  32266. func (m *UsageStatisticHourMutation) AddType(i int) {
  32267. if m.add_type != nil {
  32268. *m.add_type += i
  32269. } else {
  32270. m.add_type = &i
  32271. }
  32272. }
  32273. // AddedType returns the value that was added to the "type" field in this mutation.
  32274. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32275. v := m.add_type
  32276. if v == nil {
  32277. return
  32278. }
  32279. return *v, true
  32280. }
  32281. // ResetType resets all changes to the "type" field.
  32282. func (m *UsageStatisticHourMutation) ResetType() {
  32283. m._type = nil
  32284. m.add_type = nil
  32285. }
  32286. // SetBotID sets the "bot_id" field.
  32287. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32288. m.bot_id = &s
  32289. }
  32290. // BotID returns the value of the "bot_id" field in the mutation.
  32291. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32292. v := m.bot_id
  32293. if v == nil {
  32294. return
  32295. }
  32296. return *v, true
  32297. }
  32298. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32299. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32301. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32302. if !m.op.Is(OpUpdateOne) {
  32303. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32304. }
  32305. if m.id == nil || m.oldValue == nil {
  32306. return v, errors.New("OldBotID requires an ID field in the mutation")
  32307. }
  32308. oldValue, err := m.oldValue(ctx)
  32309. if err != nil {
  32310. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32311. }
  32312. return oldValue.BotID, nil
  32313. }
  32314. // ClearBotID clears the value of the "bot_id" field.
  32315. func (m *UsageStatisticHourMutation) ClearBotID() {
  32316. m.bot_id = nil
  32317. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32318. }
  32319. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32320. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32321. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32322. return ok
  32323. }
  32324. // ResetBotID resets all changes to the "bot_id" field.
  32325. func (m *UsageStatisticHourMutation) ResetBotID() {
  32326. m.bot_id = nil
  32327. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32328. }
  32329. // SetOrganizationID sets the "organization_id" field.
  32330. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32331. m.organization_id = &u
  32332. m.addorganization_id = nil
  32333. }
  32334. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32335. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32336. v := m.organization_id
  32337. if v == nil {
  32338. return
  32339. }
  32340. return *v, true
  32341. }
  32342. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32343. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32345. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32346. if !m.op.Is(OpUpdateOne) {
  32347. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32348. }
  32349. if m.id == nil || m.oldValue == nil {
  32350. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32351. }
  32352. oldValue, err := m.oldValue(ctx)
  32353. if err != nil {
  32354. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32355. }
  32356. return oldValue.OrganizationID, nil
  32357. }
  32358. // AddOrganizationID adds u to the "organization_id" field.
  32359. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32360. if m.addorganization_id != nil {
  32361. *m.addorganization_id += u
  32362. } else {
  32363. m.addorganization_id = &u
  32364. }
  32365. }
  32366. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32367. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32368. v := m.addorganization_id
  32369. if v == nil {
  32370. return
  32371. }
  32372. return *v, true
  32373. }
  32374. // ClearOrganizationID clears the value of the "organization_id" field.
  32375. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32376. m.organization_id = nil
  32377. m.addorganization_id = nil
  32378. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32379. }
  32380. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32381. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32382. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32383. return ok
  32384. }
  32385. // ResetOrganizationID resets all changes to the "organization_id" field.
  32386. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32387. m.organization_id = nil
  32388. m.addorganization_id = nil
  32389. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32390. }
  32391. // SetAiResponse sets the "ai_response" field.
  32392. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32393. m.ai_response = &u
  32394. m.addai_response = nil
  32395. }
  32396. // AiResponse returns the value of the "ai_response" field in the mutation.
  32397. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32398. v := m.ai_response
  32399. if v == nil {
  32400. return
  32401. }
  32402. return *v, true
  32403. }
  32404. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32405. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32407. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32408. if !m.op.Is(OpUpdateOne) {
  32409. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32410. }
  32411. if m.id == nil || m.oldValue == nil {
  32412. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32413. }
  32414. oldValue, err := m.oldValue(ctx)
  32415. if err != nil {
  32416. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32417. }
  32418. return oldValue.AiResponse, nil
  32419. }
  32420. // AddAiResponse adds u to the "ai_response" field.
  32421. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32422. if m.addai_response != nil {
  32423. *m.addai_response += u
  32424. } else {
  32425. m.addai_response = &u
  32426. }
  32427. }
  32428. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32429. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32430. v := m.addai_response
  32431. if v == nil {
  32432. return
  32433. }
  32434. return *v, true
  32435. }
  32436. // ResetAiResponse resets all changes to the "ai_response" field.
  32437. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32438. m.ai_response = nil
  32439. m.addai_response = nil
  32440. }
  32441. // SetSopRun sets the "sop_run" field.
  32442. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32443. m.sop_run = &u
  32444. m.addsop_run = nil
  32445. }
  32446. // SopRun returns the value of the "sop_run" field in the mutation.
  32447. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32448. v := m.sop_run
  32449. if v == nil {
  32450. return
  32451. }
  32452. return *v, true
  32453. }
  32454. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  32455. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32457. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32458. if !m.op.Is(OpUpdateOne) {
  32459. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32460. }
  32461. if m.id == nil || m.oldValue == nil {
  32462. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32463. }
  32464. oldValue, err := m.oldValue(ctx)
  32465. if err != nil {
  32466. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32467. }
  32468. return oldValue.SopRun, nil
  32469. }
  32470. // AddSopRun adds u to the "sop_run" field.
  32471. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32472. if m.addsop_run != nil {
  32473. *m.addsop_run += u
  32474. } else {
  32475. m.addsop_run = &u
  32476. }
  32477. }
  32478. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32479. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32480. v := m.addsop_run
  32481. if v == nil {
  32482. return
  32483. }
  32484. return *v, true
  32485. }
  32486. // ResetSopRun resets all changes to the "sop_run" field.
  32487. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32488. m.sop_run = nil
  32489. m.addsop_run = nil
  32490. }
  32491. // SetTotalFriend sets the "total_friend" field.
  32492. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32493. m.total_friend = &u
  32494. m.addtotal_friend = nil
  32495. }
  32496. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32497. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32498. v := m.total_friend
  32499. if v == nil {
  32500. return
  32501. }
  32502. return *v, true
  32503. }
  32504. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32505. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32507. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32508. if !m.op.Is(OpUpdateOne) {
  32509. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32510. }
  32511. if m.id == nil || m.oldValue == nil {
  32512. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32513. }
  32514. oldValue, err := m.oldValue(ctx)
  32515. if err != nil {
  32516. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32517. }
  32518. return oldValue.TotalFriend, nil
  32519. }
  32520. // AddTotalFriend adds u to the "total_friend" field.
  32521. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32522. if m.addtotal_friend != nil {
  32523. *m.addtotal_friend += u
  32524. } else {
  32525. m.addtotal_friend = &u
  32526. }
  32527. }
  32528. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32529. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32530. v := m.addtotal_friend
  32531. if v == nil {
  32532. return
  32533. }
  32534. return *v, true
  32535. }
  32536. // ResetTotalFriend resets all changes to the "total_friend" field.
  32537. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32538. m.total_friend = nil
  32539. m.addtotal_friend = nil
  32540. }
  32541. // SetTotalGroup sets the "total_group" field.
  32542. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32543. m.total_group = &u
  32544. m.addtotal_group = nil
  32545. }
  32546. // TotalGroup returns the value of the "total_group" field in the mutation.
  32547. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32548. v := m.total_group
  32549. if v == nil {
  32550. return
  32551. }
  32552. return *v, true
  32553. }
  32554. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32555. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32557. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32558. if !m.op.Is(OpUpdateOne) {
  32559. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32560. }
  32561. if m.id == nil || m.oldValue == nil {
  32562. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32563. }
  32564. oldValue, err := m.oldValue(ctx)
  32565. if err != nil {
  32566. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32567. }
  32568. return oldValue.TotalGroup, nil
  32569. }
  32570. // AddTotalGroup adds u to the "total_group" field.
  32571. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32572. if m.addtotal_group != nil {
  32573. *m.addtotal_group += u
  32574. } else {
  32575. m.addtotal_group = &u
  32576. }
  32577. }
  32578. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32579. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32580. v := m.addtotal_group
  32581. if v == nil {
  32582. return
  32583. }
  32584. return *v, true
  32585. }
  32586. // ResetTotalGroup resets all changes to the "total_group" field.
  32587. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32588. m.total_group = nil
  32589. m.addtotal_group = nil
  32590. }
  32591. // SetAccountBalance sets the "account_balance" field.
  32592. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32593. m.account_balance = &u
  32594. m.addaccount_balance = nil
  32595. }
  32596. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32597. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32598. v := m.account_balance
  32599. if v == nil {
  32600. return
  32601. }
  32602. return *v, true
  32603. }
  32604. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32605. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32607. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32608. if !m.op.Is(OpUpdateOne) {
  32609. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32610. }
  32611. if m.id == nil || m.oldValue == nil {
  32612. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32613. }
  32614. oldValue, err := m.oldValue(ctx)
  32615. if err != nil {
  32616. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32617. }
  32618. return oldValue.AccountBalance, nil
  32619. }
  32620. // AddAccountBalance adds u to the "account_balance" field.
  32621. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32622. if m.addaccount_balance != nil {
  32623. *m.addaccount_balance += u
  32624. } else {
  32625. m.addaccount_balance = &u
  32626. }
  32627. }
  32628. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32629. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32630. v := m.addaccount_balance
  32631. if v == nil {
  32632. return
  32633. }
  32634. return *v, true
  32635. }
  32636. // ResetAccountBalance resets all changes to the "account_balance" field.
  32637. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  32638. m.account_balance = nil
  32639. m.addaccount_balance = nil
  32640. }
  32641. // SetConsumeToken sets the "consume_token" field.
  32642. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  32643. m.consume_token = &u
  32644. m.addconsume_token = nil
  32645. }
  32646. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32647. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  32648. v := m.consume_token
  32649. if v == nil {
  32650. return
  32651. }
  32652. return *v, true
  32653. }
  32654. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  32655. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32657. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32658. if !m.op.Is(OpUpdateOne) {
  32659. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32660. }
  32661. if m.id == nil || m.oldValue == nil {
  32662. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32663. }
  32664. oldValue, err := m.oldValue(ctx)
  32665. if err != nil {
  32666. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32667. }
  32668. return oldValue.ConsumeToken, nil
  32669. }
  32670. // AddConsumeToken adds u to the "consume_token" field.
  32671. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  32672. if m.addconsume_token != nil {
  32673. *m.addconsume_token += u
  32674. } else {
  32675. m.addconsume_token = &u
  32676. }
  32677. }
  32678. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32679. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  32680. v := m.addconsume_token
  32681. if v == nil {
  32682. return
  32683. }
  32684. return *v, true
  32685. }
  32686. // ResetConsumeToken resets all changes to the "consume_token" field.
  32687. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  32688. m.consume_token = nil
  32689. m.addconsume_token = nil
  32690. }
  32691. // SetActiveUser sets the "active_user" field.
  32692. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  32693. m.active_user = &u
  32694. m.addactive_user = nil
  32695. }
  32696. // ActiveUser returns the value of the "active_user" field in the mutation.
  32697. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  32698. v := m.active_user
  32699. if v == nil {
  32700. return
  32701. }
  32702. return *v, true
  32703. }
  32704. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  32705. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32707. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32708. if !m.op.Is(OpUpdateOne) {
  32709. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32710. }
  32711. if m.id == nil || m.oldValue == nil {
  32712. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32713. }
  32714. oldValue, err := m.oldValue(ctx)
  32715. if err != nil {
  32716. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32717. }
  32718. return oldValue.ActiveUser, nil
  32719. }
  32720. // AddActiveUser adds u to the "active_user" field.
  32721. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  32722. if m.addactive_user != nil {
  32723. *m.addactive_user += u
  32724. } else {
  32725. m.addactive_user = &u
  32726. }
  32727. }
  32728. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32729. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  32730. v := m.addactive_user
  32731. if v == nil {
  32732. return
  32733. }
  32734. return *v, true
  32735. }
  32736. // ResetActiveUser resets all changes to the "active_user" field.
  32737. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  32738. m.active_user = nil
  32739. m.addactive_user = nil
  32740. }
  32741. // SetNewUser sets the "new_user" field.
  32742. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  32743. m.new_user = &i
  32744. m.addnew_user = nil
  32745. }
  32746. // NewUser returns the value of the "new_user" field in the mutation.
  32747. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  32748. v := m.new_user
  32749. if v == nil {
  32750. return
  32751. }
  32752. return *v, true
  32753. }
  32754. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  32755. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32757. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32758. if !m.op.Is(OpUpdateOne) {
  32759. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32760. }
  32761. if m.id == nil || m.oldValue == nil {
  32762. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32763. }
  32764. oldValue, err := m.oldValue(ctx)
  32765. if err != nil {
  32766. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32767. }
  32768. return oldValue.NewUser, nil
  32769. }
  32770. // AddNewUser adds i to the "new_user" field.
  32771. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  32772. if m.addnew_user != nil {
  32773. *m.addnew_user += i
  32774. } else {
  32775. m.addnew_user = &i
  32776. }
  32777. }
  32778. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32779. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  32780. v := m.addnew_user
  32781. if v == nil {
  32782. return
  32783. }
  32784. return *v, true
  32785. }
  32786. // ResetNewUser resets all changes to the "new_user" field.
  32787. func (m *UsageStatisticHourMutation) ResetNewUser() {
  32788. m.new_user = nil
  32789. m.addnew_user = nil
  32790. }
  32791. // SetLabelDist sets the "label_dist" field.
  32792. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32793. m.label_dist = &ctd
  32794. m.appendlabel_dist = nil
  32795. }
  32796. // LabelDist returns the value of the "label_dist" field in the mutation.
  32797. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32798. v := m.label_dist
  32799. if v == nil {
  32800. return
  32801. }
  32802. return *v, true
  32803. }
  32804. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  32805. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32807. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32808. if !m.op.Is(OpUpdateOne) {
  32809. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32810. }
  32811. if m.id == nil || m.oldValue == nil {
  32812. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32813. }
  32814. oldValue, err := m.oldValue(ctx)
  32815. if err != nil {
  32816. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32817. }
  32818. return oldValue.LabelDist, nil
  32819. }
  32820. // AppendLabelDist adds ctd to the "label_dist" field.
  32821. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32822. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32823. }
  32824. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32825. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32826. if len(m.appendlabel_dist) == 0 {
  32827. return nil, false
  32828. }
  32829. return m.appendlabel_dist, true
  32830. }
  32831. // ResetLabelDist resets all changes to the "label_dist" field.
  32832. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  32833. m.label_dist = nil
  32834. m.appendlabel_dist = nil
  32835. }
  32836. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  32837. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  32838. m.predicates = append(m.predicates, ps...)
  32839. }
  32840. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  32841. // users can use type-assertion to append predicates that do not depend on any generated package.
  32842. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  32843. p := make([]predicate.UsageStatisticHour, len(ps))
  32844. for i := range ps {
  32845. p[i] = ps[i]
  32846. }
  32847. m.Where(p...)
  32848. }
  32849. // Op returns the operation name.
  32850. func (m *UsageStatisticHourMutation) Op() Op {
  32851. return m.op
  32852. }
  32853. // SetOp allows setting the mutation operation.
  32854. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  32855. m.op = op
  32856. }
  32857. // Type returns the node type of this mutation (UsageStatisticHour).
  32858. func (m *UsageStatisticHourMutation) Type() string {
  32859. return m.typ
  32860. }
  32861. // Fields returns all fields that were changed during this mutation. Note that in
  32862. // order to get all numeric fields that were incremented/decremented, call
  32863. // AddedFields().
  32864. func (m *UsageStatisticHourMutation) Fields() []string {
  32865. fields := make([]string, 0, 17)
  32866. if m.created_at != nil {
  32867. fields = append(fields, usagestatistichour.FieldCreatedAt)
  32868. }
  32869. if m.updated_at != nil {
  32870. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  32871. }
  32872. if m.status != nil {
  32873. fields = append(fields, usagestatistichour.FieldStatus)
  32874. }
  32875. if m.deleted_at != nil {
  32876. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32877. }
  32878. if m.addtime != nil {
  32879. fields = append(fields, usagestatistichour.FieldAddtime)
  32880. }
  32881. if m._type != nil {
  32882. fields = append(fields, usagestatistichour.FieldType)
  32883. }
  32884. if m.bot_id != nil {
  32885. fields = append(fields, usagestatistichour.FieldBotID)
  32886. }
  32887. if m.organization_id != nil {
  32888. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32889. }
  32890. if m.ai_response != nil {
  32891. fields = append(fields, usagestatistichour.FieldAiResponse)
  32892. }
  32893. if m.sop_run != nil {
  32894. fields = append(fields, usagestatistichour.FieldSopRun)
  32895. }
  32896. if m.total_friend != nil {
  32897. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32898. }
  32899. if m.total_group != nil {
  32900. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32901. }
  32902. if m.account_balance != nil {
  32903. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32904. }
  32905. if m.consume_token != nil {
  32906. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32907. }
  32908. if m.active_user != nil {
  32909. fields = append(fields, usagestatistichour.FieldActiveUser)
  32910. }
  32911. if m.new_user != nil {
  32912. fields = append(fields, usagestatistichour.FieldNewUser)
  32913. }
  32914. if m.label_dist != nil {
  32915. fields = append(fields, usagestatistichour.FieldLabelDist)
  32916. }
  32917. return fields
  32918. }
  32919. // Field returns the value of a field with the given name. The second boolean
  32920. // return value indicates that this field was not set, or was not defined in the
  32921. // schema.
  32922. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  32923. switch name {
  32924. case usagestatistichour.FieldCreatedAt:
  32925. return m.CreatedAt()
  32926. case usagestatistichour.FieldUpdatedAt:
  32927. return m.UpdatedAt()
  32928. case usagestatistichour.FieldStatus:
  32929. return m.Status()
  32930. case usagestatistichour.FieldDeletedAt:
  32931. return m.DeletedAt()
  32932. case usagestatistichour.FieldAddtime:
  32933. return m.Addtime()
  32934. case usagestatistichour.FieldType:
  32935. return m.GetType()
  32936. case usagestatistichour.FieldBotID:
  32937. return m.BotID()
  32938. case usagestatistichour.FieldOrganizationID:
  32939. return m.OrganizationID()
  32940. case usagestatistichour.FieldAiResponse:
  32941. return m.AiResponse()
  32942. case usagestatistichour.FieldSopRun:
  32943. return m.SopRun()
  32944. case usagestatistichour.FieldTotalFriend:
  32945. return m.TotalFriend()
  32946. case usagestatistichour.FieldTotalGroup:
  32947. return m.TotalGroup()
  32948. case usagestatistichour.FieldAccountBalance:
  32949. return m.AccountBalance()
  32950. case usagestatistichour.FieldConsumeToken:
  32951. return m.ConsumeToken()
  32952. case usagestatistichour.FieldActiveUser:
  32953. return m.ActiveUser()
  32954. case usagestatistichour.FieldNewUser:
  32955. return m.NewUser()
  32956. case usagestatistichour.FieldLabelDist:
  32957. return m.LabelDist()
  32958. }
  32959. return nil, false
  32960. }
  32961. // OldField returns the old value of the field from the database. An error is
  32962. // returned if the mutation operation is not UpdateOne, or the query to the
  32963. // database failed.
  32964. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32965. switch name {
  32966. case usagestatistichour.FieldCreatedAt:
  32967. return m.OldCreatedAt(ctx)
  32968. case usagestatistichour.FieldUpdatedAt:
  32969. return m.OldUpdatedAt(ctx)
  32970. case usagestatistichour.FieldStatus:
  32971. return m.OldStatus(ctx)
  32972. case usagestatistichour.FieldDeletedAt:
  32973. return m.OldDeletedAt(ctx)
  32974. case usagestatistichour.FieldAddtime:
  32975. return m.OldAddtime(ctx)
  32976. case usagestatistichour.FieldType:
  32977. return m.OldType(ctx)
  32978. case usagestatistichour.FieldBotID:
  32979. return m.OldBotID(ctx)
  32980. case usagestatistichour.FieldOrganizationID:
  32981. return m.OldOrganizationID(ctx)
  32982. case usagestatistichour.FieldAiResponse:
  32983. return m.OldAiResponse(ctx)
  32984. case usagestatistichour.FieldSopRun:
  32985. return m.OldSopRun(ctx)
  32986. case usagestatistichour.FieldTotalFriend:
  32987. return m.OldTotalFriend(ctx)
  32988. case usagestatistichour.FieldTotalGroup:
  32989. return m.OldTotalGroup(ctx)
  32990. case usagestatistichour.FieldAccountBalance:
  32991. return m.OldAccountBalance(ctx)
  32992. case usagestatistichour.FieldConsumeToken:
  32993. return m.OldConsumeToken(ctx)
  32994. case usagestatistichour.FieldActiveUser:
  32995. return m.OldActiveUser(ctx)
  32996. case usagestatistichour.FieldNewUser:
  32997. return m.OldNewUser(ctx)
  32998. case usagestatistichour.FieldLabelDist:
  32999. return m.OldLabelDist(ctx)
  33000. }
  33001. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33002. }
  33003. // SetField sets the value of a field with the given name. It returns an error if
  33004. // the field is not defined in the schema, or if the type mismatched the field
  33005. // type.
  33006. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  33007. switch name {
  33008. case usagestatistichour.FieldCreatedAt:
  33009. v, ok := value.(time.Time)
  33010. if !ok {
  33011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33012. }
  33013. m.SetCreatedAt(v)
  33014. return nil
  33015. case usagestatistichour.FieldUpdatedAt:
  33016. v, ok := value.(time.Time)
  33017. if !ok {
  33018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33019. }
  33020. m.SetUpdatedAt(v)
  33021. return nil
  33022. case usagestatistichour.FieldStatus:
  33023. v, ok := value.(uint8)
  33024. if !ok {
  33025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33026. }
  33027. m.SetStatus(v)
  33028. return nil
  33029. case usagestatistichour.FieldDeletedAt:
  33030. v, ok := value.(time.Time)
  33031. if !ok {
  33032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33033. }
  33034. m.SetDeletedAt(v)
  33035. return nil
  33036. case usagestatistichour.FieldAddtime:
  33037. v, ok := value.(uint64)
  33038. if !ok {
  33039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33040. }
  33041. m.SetAddtime(v)
  33042. return nil
  33043. case usagestatistichour.FieldType:
  33044. v, ok := value.(int)
  33045. if !ok {
  33046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33047. }
  33048. m.SetType(v)
  33049. return nil
  33050. case usagestatistichour.FieldBotID:
  33051. v, ok := value.(string)
  33052. if !ok {
  33053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33054. }
  33055. m.SetBotID(v)
  33056. return nil
  33057. case usagestatistichour.FieldOrganizationID:
  33058. v, ok := value.(uint64)
  33059. if !ok {
  33060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33061. }
  33062. m.SetOrganizationID(v)
  33063. return nil
  33064. case usagestatistichour.FieldAiResponse:
  33065. v, ok := value.(uint64)
  33066. if !ok {
  33067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33068. }
  33069. m.SetAiResponse(v)
  33070. return nil
  33071. case usagestatistichour.FieldSopRun:
  33072. v, ok := value.(uint64)
  33073. if !ok {
  33074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33075. }
  33076. m.SetSopRun(v)
  33077. return nil
  33078. case usagestatistichour.FieldTotalFriend:
  33079. v, ok := value.(uint64)
  33080. if !ok {
  33081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33082. }
  33083. m.SetTotalFriend(v)
  33084. return nil
  33085. case usagestatistichour.FieldTotalGroup:
  33086. v, ok := value.(uint64)
  33087. if !ok {
  33088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33089. }
  33090. m.SetTotalGroup(v)
  33091. return nil
  33092. case usagestatistichour.FieldAccountBalance:
  33093. v, ok := value.(uint64)
  33094. if !ok {
  33095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33096. }
  33097. m.SetAccountBalance(v)
  33098. return nil
  33099. case usagestatistichour.FieldConsumeToken:
  33100. v, ok := value.(uint64)
  33101. if !ok {
  33102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33103. }
  33104. m.SetConsumeToken(v)
  33105. return nil
  33106. case usagestatistichour.FieldActiveUser:
  33107. v, ok := value.(uint64)
  33108. if !ok {
  33109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33110. }
  33111. m.SetActiveUser(v)
  33112. return nil
  33113. case usagestatistichour.FieldNewUser:
  33114. v, ok := value.(int64)
  33115. if !ok {
  33116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33117. }
  33118. m.SetNewUser(v)
  33119. return nil
  33120. case usagestatistichour.FieldLabelDist:
  33121. v, ok := value.([]custom_types.LabelDist)
  33122. if !ok {
  33123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33124. }
  33125. m.SetLabelDist(v)
  33126. return nil
  33127. }
  33128. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33129. }
  33130. // AddedFields returns all numeric fields that were incremented/decremented during
  33131. // this mutation.
  33132. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33133. var fields []string
  33134. if m.addstatus != nil {
  33135. fields = append(fields, usagestatistichour.FieldStatus)
  33136. }
  33137. if m.addaddtime != nil {
  33138. fields = append(fields, usagestatistichour.FieldAddtime)
  33139. }
  33140. if m.add_type != nil {
  33141. fields = append(fields, usagestatistichour.FieldType)
  33142. }
  33143. if m.addorganization_id != nil {
  33144. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33145. }
  33146. if m.addai_response != nil {
  33147. fields = append(fields, usagestatistichour.FieldAiResponse)
  33148. }
  33149. if m.addsop_run != nil {
  33150. fields = append(fields, usagestatistichour.FieldSopRun)
  33151. }
  33152. if m.addtotal_friend != nil {
  33153. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33154. }
  33155. if m.addtotal_group != nil {
  33156. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33157. }
  33158. if m.addaccount_balance != nil {
  33159. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33160. }
  33161. if m.addconsume_token != nil {
  33162. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33163. }
  33164. if m.addactive_user != nil {
  33165. fields = append(fields, usagestatistichour.FieldActiveUser)
  33166. }
  33167. if m.addnew_user != nil {
  33168. fields = append(fields, usagestatistichour.FieldNewUser)
  33169. }
  33170. return fields
  33171. }
  33172. // AddedField returns the numeric value that was incremented/decremented on a field
  33173. // with the given name. The second boolean return value indicates that this field
  33174. // was not set, or was not defined in the schema.
  33175. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33176. switch name {
  33177. case usagestatistichour.FieldStatus:
  33178. return m.AddedStatus()
  33179. case usagestatistichour.FieldAddtime:
  33180. return m.AddedAddtime()
  33181. case usagestatistichour.FieldType:
  33182. return m.AddedType()
  33183. case usagestatistichour.FieldOrganizationID:
  33184. return m.AddedOrganizationID()
  33185. case usagestatistichour.FieldAiResponse:
  33186. return m.AddedAiResponse()
  33187. case usagestatistichour.FieldSopRun:
  33188. return m.AddedSopRun()
  33189. case usagestatistichour.FieldTotalFriend:
  33190. return m.AddedTotalFriend()
  33191. case usagestatistichour.FieldTotalGroup:
  33192. return m.AddedTotalGroup()
  33193. case usagestatistichour.FieldAccountBalance:
  33194. return m.AddedAccountBalance()
  33195. case usagestatistichour.FieldConsumeToken:
  33196. return m.AddedConsumeToken()
  33197. case usagestatistichour.FieldActiveUser:
  33198. return m.AddedActiveUser()
  33199. case usagestatistichour.FieldNewUser:
  33200. return m.AddedNewUser()
  33201. }
  33202. return nil, false
  33203. }
  33204. // AddField adds the value to the field with the given name. It returns an error if
  33205. // the field is not defined in the schema, or if the type mismatched the field
  33206. // type.
  33207. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33208. switch name {
  33209. case usagestatistichour.FieldStatus:
  33210. v, ok := value.(int8)
  33211. if !ok {
  33212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33213. }
  33214. m.AddStatus(v)
  33215. return nil
  33216. case usagestatistichour.FieldAddtime:
  33217. v, ok := value.(int64)
  33218. if !ok {
  33219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33220. }
  33221. m.AddAddtime(v)
  33222. return nil
  33223. case usagestatistichour.FieldType:
  33224. v, ok := value.(int)
  33225. if !ok {
  33226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33227. }
  33228. m.AddType(v)
  33229. return nil
  33230. case usagestatistichour.FieldOrganizationID:
  33231. v, ok := value.(int64)
  33232. if !ok {
  33233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33234. }
  33235. m.AddOrganizationID(v)
  33236. return nil
  33237. case usagestatistichour.FieldAiResponse:
  33238. v, ok := value.(int64)
  33239. if !ok {
  33240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33241. }
  33242. m.AddAiResponse(v)
  33243. return nil
  33244. case usagestatistichour.FieldSopRun:
  33245. v, ok := value.(int64)
  33246. if !ok {
  33247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33248. }
  33249. m.AddSopRun(v)
  33250. return nil
  33251. case usagestatistichour.FieldTotalFriend:
  33252. v, ok := value.(int64)
  33253. if !ok {
  33254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33255. }
  33256. m.AddTotalFriend(v)
  33257. return nil
  33258. case usagestatistichour.FieldTotalGroup:
  33259. v, ok := value.(int64)
  33260. if !ok {
  33261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33262. }
  33263. m.AddTotalGroup(v)
  33264. return nil
  33265. case usagestatistichour.FieldAccountBalance:
  33266. v, ok := value.(int64)
  33267. if !ok {
  33268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33269. }
  33270. m.AddAccountBalance(v)
  33271. return nil
  33272. case usagestatistichour.FieldConsumeToken:
  33273. v, ok := value.(int64)
  33274. if !ok {
  33275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33276. }
  33277. m.AddConsumeToken(v)
  33278. return nil
  33279. case usagestatistichour.FieldActiveUser:
  33280. v, ok := value.(int64)
  33281. if !ok {
  33282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33283. }
  33284. m.AddActiveUser(v)
  33285. return nil
  33286. case usagestatistichour.FieldNewUser:
  33287. v, ok := value.(int64)
  33288. if !ok {
  33289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33290. }
  33291. m.AddNewUser(v)
  33292. return nil
  33293. }
  33294. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33295. }
  33296. // ClearedFields returns all nullable fields that were cleared during this
  33297. // mutation.
  33298. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33299. var fields []string
  33300. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33301. fields = append(fields, usagestatistichour.FieldStatus)
  33302. }
  33303. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33304. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33305. }
  33306. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33307. fields = append(fields, usagestatistichour.FieldBotID)
  33308. }
  33309. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33310. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33311. }
  33312. return fields
  33313. }
  33314. // FieldCleared returns a boolean indicating if a field with the given name was
  33315. // cleared in this mutation.
  33316. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33317. _, ok := m.clearedFields[name]
  33318. return ok
  33319. }
  33320. // ClearField clears the value of the field with the given name. It returns an
  33321. // error if the field is not defined in the schema.
  33322. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33323. switch name {
  33324. case usagestatistichour.FieldStatus:
  33325. m.ClearStatus()
  33326. return nil
  33327. case usagestatistichour.FieldDeletedAt:
  33328. m.ClearDeletedAt()
  33329. return nil
  33330. case usagestatistichour.FieldBotID:
  33331. m.ClearBotID()
  33332. return nil
  33333. case usagestatistichour.FieldOrganizationID:
  33334. m.ClearOrganizationID()
  33335. return nil
  33336. }
  33337. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33338. }
  33339. // ResetField resets all changes in the mutation for the field with the given name.
  33340. // It returns an error if the field is not defined in the schema.
  33341. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33342. switch name {
  33343. case usagestatistichour.FieldCreatedAt:
  33344. m.ResetCreatedAt()
  33345. return nil
  33346. case usagestatistichour.FieldUpdatedAt:
  33347. m.ResetUpdatedAt()
  33348. return nil
  33349. case usagestatistichour.FieldStatus:
  33350. m.ResetStatus()
  33351. return nil
  33352. case usagestatistichour.FieldDeletedAt:
  33353. m.ResetDeletedAt()
  33354. return nil
  33355. case usagestatistichour.FieldAddtime:
  33356. m.ResetAddtime()
  33357. return nil
  33358. case usagestatistichour.FieldType:
  33359. m.ResetType()
  33360. return nil
  33361. case usagestatistichour.FieldBotID:
  33362. m.ResetBotID()
  33363. return nil
  33364. case usagestatistichour.FieldOrganizationID:
  33365. m.ResetOrganizationID()
  33366. return nil
  33367. case usagestatistichour.FieldAiResponse:
  33368. m.ResetAiResponse()
  33369. return nil
  33370. case usagestatistichour.FieldSopRun:
  33371. m.ResetSopRun()
  33372. return nil
  33373. case usagestatistichour.FieldTotalFriend:
  33374. m.ResetTotalFriend()
  33375. return nil
  33376. case usagestatistichour.FieldTotalGroup:
  33377. m.ResetTotalGroup()
  33378. return nil
  33379. case usagestatistichour.FieldAccountBalance:
  33380. m.ResetAccountBalance()
  33381. return nil
  33382. case usagestatistichour.FieldConsumeToken:
  33383. m.ResetConsumeToken()
  33384. return nil
  33385. case usagestatistichour.FieldActiveUser:
  33386. m.ResetActiveUser()
  33387. return nil
  33388. case usagestatistichour.FieldNewUser:
  33389. m.ResetNewUser()
  33390. return nil
  33391. case usagestatistichour.FieldLabelDist:
  33392. m.ResetLabelDist()
  33393. return nil
  33394. }
  33395. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33396. }
  33397. // AddedEdges returns all edge names that were set/added in this mutation.
  33398. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33399. edges := make([]string, 0, 0)
  33400. return edges
  33401. }
  33402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33403. // name in this mutation.
  33404. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33405. return nil
  33406. }
  33407. // RemovedEdges returns all edge names that were removed in this mutation.
  33408. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33409. edges := make([]string, 0, 0)
  33410. return edges
  33411. }
  33412. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33413. // the given name in this mutation.
  33414. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33415. return nil
  33416. }
  33417. // ClearedEdges returns all edge names that were cleared in this mutation.
  33418. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33419. edges := make([]string, 0, 0)
  33420. return edges
  33421. }
  33422. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33423. // was cleared in this mutation.
  33424. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33425. return false
  33426. }
  33427. // ClearEdge clears the value of the edge with the given name. It returns an error
  33428. // if that edge is not defined in the schema.
  33429. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33430. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33431. }
  33432. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33433. // It returns an error if the edge is not defined in the schema.
  33434. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33435. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33436. }
  33437. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33438. type UsageStatisticMonthMutation struct {
  33439. config
  33440. op Op
  33441. typ string
  33442. id *uint64
  33443. created_at *time.Time
  33444. updated_at *time.Time
  33445. status *uint8
  33446. addstatus *int8
  33447. deleted_at *time.Time
  33448. addtime *uint64
  33449. addaddtime *int64
  33450. _type *int
  33451. add_type *int
  33452. bot_id *string
  33453. organization_id *uint64
  33454. addorganization_id *int64
  33455. ai_response *uint64
  33456. addai_response *int64
  33457. sop_run *uint64
  33458. addsop_run *int64
  33459. total_friend *uint64
  33460. addtotal_friend *int64
  33461. total_group *uint64
  33462. addtotal_group *int64
  33463. account_balance *uint64
  33464. addaccount_balance *int64
  33465. consume_token *uint64
  33466. addconsume_token *int64
  33467. active_user *uint64
  33468. addactive_user *int64
  33469. new_user *int64
  33470. addnew_user *int64
  33471. label_dist *[]custom_types.LabelDist
  33472. appendlabel_dist []custom_types.LabelDist
  33473. clearedFields map[string]struct{}
  33474. done bool
  33475. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33476. predicates []predicate.UsageStatisticMonth
  33477. }
  33478. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33479. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33480. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33481. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33482. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33483. m := &UsageStatisticMonthMutation{
  33484. config: c,
  33485. op: op,
  33486. typ: TypeUsageStatisticMonth,
  33487. clearedFields: make(map[string]struct{}),
  33488. }
  33489. for _, opt := range opts {
  33490. opt(m)
  33491. }
  33492. return m
  33493. }
  33494. // withUsageStatisticMonthID sets the ID field of the mutation.
  33495. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33496. return func(m *UsageStatisticMonthMutation) {
  33497. var (
  33498. err error
  33499. once sync.Once
  33500. value *UsageStatisticMonth
  33501. )
  33502. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33503. once.Do(func() {
  33504. if m.done {
  33505. err = errors.New("querying old values post mutation is not allowed")
  33506. } else {
  33507. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33508. }
  33509. })
  33510. return value, err
  33511. }
  33512. m.id = &id
  33513. }
  33514. }
  33515. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33516. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33517. return func(m *UsageStatisticMonthMutation) {
  33518. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33519. return node, nil
  33520. }
  33521. m.id = &node.ID
  33522. }
  33523. }
  33524. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33525. // executed in a transaction (ent.Tx), a transactional client is returned.
  33526. func (m UsageStatisticMonthMutation) Client() *Client {
  33527. client := &Client{config: m.config}
  33528. client.init()
  33529. return client
  33530. }
  33531. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33532. // it returns an error otherwise.
  33533. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33534. if _, ok := m.driver.(*txDriver); !ok {
  33535. return nil, errors.New("ent: mutation is not running in a transaction")
  33536. }
  33537. tx := &Tx{config: m.config}
  33538. tx.init()
  33539. return tx, nil
  33540. }
  33541. // SetID sets the value of the id field. Note that this
  33542. // operation is only accepted on creation of UsageStatisticMonth entities.
  33543. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33544. m.id = &id
  33545. }
  33546. // ID returns the ID value in the mutation. Note that the ID is only available
  33547. // if it was provided to the builder or after it was returned from the database.
  33548. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33549. if m.id == nil {
  33550. return
  33551. }
  33552. return *m.id, true
  33553. }
  33554. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33555. // That means, if the mutation is applied within a transaction with an isolation level such
  33556. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33557. // or updated by the mutation.
  33558. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33559. switch {
  33560. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33561. id, exists := m.ID()
  33562. if exists {
  33563. return []uint64{id}, nil
  33564. }
  33565. fallthrough
  33566. case m.op.Is(OpUpdate | OpDelete):
  33567. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33568. default:
  33569. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33570. }
  33571. }
  33572. // SetCreatedAt sets the "created_at" field.
  33573. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33574. m.created_at = &t
  33575. }
  33576. // CreatedAt returns the value of the "created_at" field in the mutation.
  33577. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33578. v := m.created_at
  33579. if v == nil {
  33580. return
  33581. }
  33582. return *v, true
  33583. }
  33584. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33585. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33587. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33588. if !m.op.Is(OpUpdateOne) {
  33589. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33590. }
  33591. if m.id == nil || m.oldValue == nil {
  33592. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33593. }
  33594. oldValue, err := m.oldValue(ctx)
  33595. if err != nil {
  33596. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33597. }
  33598. return oldValue.CreatedAt, nil
  33599. }
  33600. // ResetCreatedAt resets all changes to the "created_at" field.
  33601. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33602. m.created_at = nil
  33603. }
  33604. // SetUpdatedAt sets the "updated_at" field.
  33605. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33606. m.updated_at = &t
  33607. }
  33608. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33609. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33610. v := m.updated_at
  33611. if v == nil {
  33612. return
  33613. }
  33614. return *v, true
  33615. }
  33616. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33617. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33619. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33620. if !m.op.Is(OpUpdateOne) {
  33621. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33622. }
  33623. if m.id == nil || m.oldValue == nil {
  33624. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33625. }
  33626. oldValue, err := m.oldValue(ctx)
  33627. if err != nil {
  33628. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33629. }
  33630. return oldValue.UpdatedAt, nil
  33631. }
  33632. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33633. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33634. m.updated_at = nil
  33635. }
  33636. // SetStatus sets the "status" field.
  33637. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  33638. m.status = &u
  33639. m.addstatus = nil
  33640. }
  33641. // Status returns the value of the "status" field in the mutation.
  33642. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  33643. v := m.status
  33644. if v == nil {
  33645. return
  33646. }
  33647. return *v, true
  33648. }
  33649. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  33650. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33652. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33653. if !m.op.Is(OpUpdateOne) {
  33654. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33655. }
  33656. if m.id == nil || m.oldValue == nil {
  33657. return v, errors.New("OldStatus requires an ID field in the mutation")
  33658. }
  33659. oldValue, err := m.oldValue(ctx)
  33660. if err != nil {
  33661. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33662. }
  33663. return oldValue.Status, nil
  33664. }
  33665. // AddStatus adds u to the "status" field.
  33666. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  33667. if m.addstatus != nil {
  33668. *m.addstatus += u
  33669. } else {
  33670. m.addstatus = &u
  33671. }
  33672. }
  33673. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33674. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  33675. v := m.addstatus
  33676. if v == nil {
  33677. return
  33678. }
  33679. return *v, true
  33680. }
  33681. // ClearStatus clears the value of the "status" field.
  33682. func (m *UsageStatisticMonthMutation) ClearStatus() {
  33683. m.status = nil
  33684. m.addstatus = nil
  33685. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  33686. }
  33687. // StatusCleared returns if the "status" field was cleared in this mutation.
  33688. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  33689. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  33690. return ok
  33691. }
  33692. // ResetStatus resets all changes to the "status" field.
  33693. func (m *UsageStatisticMonthMutation) ResetStatus() {
  33694. m.status = nil
  33695. m.addstatus = nil
  33696. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  33697. }
  33698. // SetDeletedAt sets the "deleted_at" field.
  33699. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  33700. m.deleted_at = &t
  33701. }
  33702. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33703. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  33704. v := m.deleted_at
  33705. if v == nil {
  33706. return
  33707. }
  33708. return *v, true
  33709. }
  33710. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  33711. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33713. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33714. if !m.op.Is(OpUpdateOne) {
  33715. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33716. }
  33717. if m.id == nil || m.oldValue == nil {
  33718. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33719. }
  33720. oldValue, err := m.oldValue(ctx)
  33721. if err != nil {
  33722. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33723. }
  33724. return oldValue.DeletedAt, nil
  33725. }
  33726. // ClearDeletedAt clears the value of the "deleted_at" field.
  33727. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  33728. m.deleted_at = nil
  33729. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  33730. }
  33731. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33732. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  33733. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  33734. return ok
  33735. }
  33736. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33737. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  33738. m.deleted_at = nil
  33739. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  33740. }
  33741. // SetAddtime sets the "addtime" field.
  33742. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  33743. m.addtime = &u
  33744. m.addaddtime = nil
  33745. }
  33746. // Addtime returns the value of the "addtime" field in the mutation.
  33747. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  33748. v := m.addtime
  33749. if v == nil {
  33750. return
  33751. }
  33752. return *v, true
  33753. }
  33754. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  33755. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33757. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33758. if !m.op.Is(OpUpdateOne) {
  33759. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33760. }
  33761. if m.id == nil || m.oldValue == nil {
  33762. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33763. }
  33764. oldValue, err := m.oldValue(ctx)
  33765. if err != nil {
  33766. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33767. }
  33768. return oldValue.Addtime, nil
  33769. }
  33770. // AddAddtime adds u to the "addtime" field.
  33771. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  33772. if m.addaddtime != nil {
  33773. *m.addaddtime += u
  33774. } else {
  33775. m.addaddtime = &u
  33776. }
  33777. }
  33778. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33779. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  33780. v := m.addaddtime
  33781. if v == nil {
  33782. return
  33783. }
  33784. return *v, true
  33785. }
  33786. // ResetAddtime resets all changes to the "addtime" field.
  33787. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  33788. m.addtime = nil
  33789. m.addaddtime = nil
  33790. }
  33791. // SetType sets the "type" field.
  33792. func (m *UsageStatisticMonthMutation) SetType(i int) {
  33793. m._type = &i
  33794. m.add_type = nil
  33795. }
  33796. // GetType returns the value of the "type" field in the mutation.
  33797. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  33798. v := m._type
  33799. if v == nil {
  33800. return
  33801. }
  33802. return *v, true
  33803. }
  33804. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  33805. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33807. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  33808. if !m.op.Is(OpUpdateOne) {
  33809. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33810. }
  33811. if m.id == nil || m.oldValue == nil {
  33812. return v, errors.New("OldType requires an ID field in the mutation")
  33813. }
  33814. oldValue, err := m.oldValue(ctx)
  33815. if err != nil {
  33816. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33817. }
  33818. return oldValue.Type, nil
  33819. }
  33820. // AddType adds i to the "type" field.
  33821. func (m *UsageStatisticMonthMutation) AddType(i int) {
  33822. if m.add_type != nil {
  33823. *m.add_type += i
  33824. } else {
  33825. m.add_type = &i
  33826. }
  33827. }
  33828. // AddedType returns the value that was added to the "type" field in this mutation.
  33829. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  33830. v := m.add_type
  33831. if v == nil {
  33832. return
  33833. }
  33834. return *v, true
  33835. }
  33836. // ResetType resets all changes to the "type" field.
  33837. func (m *UsageStatisticMonthMutation) ResetType() {
  33838. m._type = nil
  33839. m.add_type = nil
  33840. }
  33841. // SetBotID sets the "bot_id" field.
  33842. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  33843. m.bot_id = &s
  33844. }
  33845. // BotID returns the value of the "bot_id" field in the mutation.
  33846. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  33847. v := m.bot_id
  33848. if v == nil {
  33849. return
  33850. }
  33851. return *v, true
  33852. }
  33853. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  33854. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33856. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  33857. if !m.op.Is(OpUpdateOne) {
  33858. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33859. }
  33860. if m.id == nil || m.oldValue == nil {
  33861. return v, errors.New("OldBotID requires an ID field in the mutation")
  33862. }
  33863. oldValue, err := m.oldValue(ctx)
  33864. if err != nil {
  33865. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33866. }
  33867. return oldValue.BotID, nil
  33868. }
  33869. // ClearBotID clears the value of the "bot_id" field.
  33870. func (m *UsageStatisticMonthMutation) ClearBotID() {
  33871. m.bot_id = nil
  33872. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  33873. }
  33874. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33875. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  33876. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  33877. return ok
  33878. }
  33879. // ResetBotID resets all changes to the "bot_id" field.
  33880. func (m *UsageStatisticMonthMutation) ResetBotID() {
  33881. m.bot_id = nil
  33882. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  33883. }
  33884. // SetOrganizationID sets the "organization_id" field.
  33885. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  33886. m.organization_id = &u
  33887. m.addorganization_id = nil
  33888. }
  33889. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33890. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  33891. v := m.organization_id
  33892. if v == nil {
  33893. return
  33894. }
  33895. return *v, true
  33896. }
  33897. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  33898. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33900. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33901. if !m.op.Is(OpUpdateOne) {
  33902. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33903. }
  33904. if m.id == nil || m.oldValue == nil {
  33905. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33906. }
  33907. oldValue, err := m.oldValue(ctx)
  33908. if err != nil {
  33909. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33910. }
  33911. return oldValue.OrganizationID, nil
  33912. }
  33913. // AddOrganizationID adds u to the "organization_id" field.
  33914. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  33915. if m.addorganization_id != nil {
  33916. *m.addorganization_id += u
  33917. } else {
  33918. m.addorganization_id = &u
  33919. }
  33920. }
  33921. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33922. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  33923. v := m.addorganization_id
  33924. if v == nil {
  33925. return
  33926. }
  33927. return *v, true
  33928. }
  33929. // ClearOrganizationID clears the value of the "organization_id" field.
  33930. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  33931. m.organization_id = nil
  33932. m.addorganization_id = nil
  33933. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  33934. }
  33935. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33936. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  33937. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  33938. return ok
  33939. }
  33940. // ResetOrganizationID resets all changes to the "organization_id" field.
  33941. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  33942. m.organization_id = nil
  33943. m.addorganization_id = nil
  33944. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  33945. }
  33946. // SetAiResponse sets the "ai_response" field.
  33947. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  33948. m.ai_response = &u
  33949. m.addai_response = nil
  33950. }
  33951. // AiResponse returns the value of the "ai_response" field in the mutation.
  33952. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  33953. v := m.ai_response
  33954. if v == nil {
  33955. return
  33956. }
  33957. return *v, true
  33958. }
  33959. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  33960. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33962. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33963. if !m.op.Is(OpUpdateOne) {
  33964. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33965. }
  33966. if m.id == nil || m.oldValue == nil {
  33967. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33968. }
  33969. oldValue, err := m.oldValue(ctx)
  33970. if err != nil {
  33971. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33972. }
  33973. return oldValue.AiResponse, nil
  33974. }
  33975. // AddAiResponse adds u to the "ai_response" field.
  33976. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  33977. if m.addai_response != nil {
  33978. *m.addai_response += u
  33979. } else {
  33980. m.addai_response = &u
  33981. }
  33982. }
  33983. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33984. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  33985. v := m.addai_response
  33986. if v == nil {
  33987. return
  33988. }
  33989. return *v, true
  33990. }
  33991. // ResetAiResponse resets all changes to the "ai_response" field.
  33992. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  33993. m.ai_response = nil
  33994. m.addai_response = nil
  33995. }
  33996. // SetSopRun sets the "sop_run" field.
  33997. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  33998. m.sop_run = &u
  33999. m.addsop_run = nil
  34000. }
  34001. // SopRun returns the value of the "sop_run" field in the mutation.
  34002. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  34003. v := m.sop_run
  34004. if v == nil {
  34005. return
  34006. }
  34007. return *v, true
  34008. }
  34009. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  34010. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34012. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34013. if !m.op.Is(OpUpdateOne) {
  34014. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34015. }
  34016. if m.id == nil || m.oldValue == nil {
  34017. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34018. }
  34019. oldValue, err := m.oldValue(ctx)
  34020. if err != nil {
  34021. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34022. }
  34023. return oldValue.SopRun, nil
  34024. }
  34025. // AddSopRun adds u to the "sop_run" field.
  34026. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  34027. if m.addsop_run != nil {
  34028. *m.addsop_run += u
  34029. } else {
  34030. m.addsop_run = &u
  34031. }
  34032. }
  34033. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34034. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  34035. v := m.addsop_run
  34036. if v == nil {
  34037. return
  34038. }
  34039. return *v, true
  34040. }
  34041. // ResetSopRun resets all changes to the "sop_run" field.
  34042. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  34043. m.sop_run = nil
  34044. m.addsop_run = nil
  34045. }
  34046. // SetTotalFriend sets the "total_friend" field.
  34047. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  34048. m.total_friend = &u
  34049. m.addtotal_friend = nil
  34050. }
  34051. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34052. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  34053. v := m.total_friend
  34054. if v == nil {
  34055. return
  34056. }
  34057. return *v, true
  34058. }
  34059. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  34060. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34062. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34063. if !m.op.Is(OpUpdateOne) {
  34064. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34065. }
  34066. if m.id == nil || m.oldValue == nil {
  34067. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34068. }
  34069. oldValue, err := m.oldValue(ctx)
  34070. if err != nil {
  34071. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34072. }
  34073. return oldValue.TotalFriend, nil
  34074. }
  34075. // AddTotalFriend adds u to the "total_friend" field.
  34076. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  34077. if m.addtotal_friend != nil {
  34078. *m.addtotal_friend += u
  34079. } else {
  34080. m.addtotal_friend = &u
  34081. }
  34082. }
  34083. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34084. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34085. v := m.addtotal_friend
  34086. if v == nil {
  34087. return
  34088. }
  34089. return *v, true
  34090. }
  34091. // ResetTotalFriend resets all changes to the "total_friend" field.
  34092. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34093. m.total_friend = nil
  34094. m.addtotal_friend = nil
  34095. }
  34096. // SetTotalGroup sets the "total_group" field.
  34097. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34098. m.total_group = &u
  34099. m.addtotal_group = nil
  34100. }
  34101. // TotalGroup returns the value of the "total_group" field in the mutation.
  34102. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34103. v := m.total_group
  34104. if v == nil {
  34105. return
  34106. }
  34107. return *v, true
  34108. }
  34109. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34110. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34112. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34113. if !m.op.Is(OpUpdateOne) {
  34114. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34115. }
  34116. if m.id == nil || m.oldValue == nil {
  34117. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34118. }
  34119. oldValue, err := m.oldValue(ctx)
  34120. if err != nil {
  34121. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34122. }
  34123. return oldValue.TotalGroup, nil
  34124. }
  34125. // AddTotalGroup adds u to the "total_group" field.
  34126. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34127. if m.addtotal_group != nil {
  34128. *m.addtotal_group += u
  34129. } else {
  34130. m.addtotal_group = &u
  34131. }
  34132. }
  34133. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34134. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34135. v := m.addtotal_group
  34136. if v == nil {
  34137. return
  34138. }
  34139. return *v, true
  34140. }
  34141. // ResetTotalGroup resets all changes to the "total_group" field.
  34142. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34143. m.total_group = nil
  34144. m.addtotal_group = nil
  34145. }
  34146. // SetAccountBalance sets the "account_balance" field.
  34147. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34148. m.account_balance = &u
  34149. m.addaccount_balance = nil
  34150. }
  34151. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34152. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34153. v := m.account_balance
  34154. if v == nil {
  34155. return
  34156. }
  34157. return *v, true
  34158. }
  34159. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34160. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34162. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34163. if !m.op.Is(OpUpdateOne) {
  34164. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34165. }
  34166. if m.id == nil || m.oldValue == nil {
  34167. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34168. }
  34169. oldValue, err := m.oldValue(ctx)
  34170. if err != nil {
  34171. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34172. }
  34173. return oldValue.AccountBalance, nil
  34174. }
  34175. // AddAccountBalance adds u to the "account_balance" field.
  34176. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34177. if m.addaccount_balance != nil {
  34178. *m.addaccount_balance += u
  34179. } else {
  34180. m.addaccount_balance = &u
  34181. }
  34182. }
  34183. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34184. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34185. v := m.addaccount_balance
  34186. if v == nil {
  34187. return
  34188. }
  34189. return *v, true
  34190. }
  34191. // ResetAccountBalance resets all changes to the "account_balance" field.
  34192. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34193. m.account_balance = nil
  34194. m.addaccount_balance = nil
  34195. }
  34196. // SetConsumeToken sets the "consume_token" field.
  34197. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34198. m.consume_token = &u
  34199. m.addconsume_token = nil
  34200. }
  34201. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34202. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34203. v := m.consume_token
  34204. if v == nil {
  34205. return
  34206. }
  34207. return *v, true
  34208. }
  34209. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34210. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34212. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34213. if !m.op.Is(OpUpdateOne) {
  34214. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34215. }
  34216. if m.id == nil || m.oldValue == nil {
  34217. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34218. }
  34219. oldValue, err := m.oldValue(ctx)
  34220. if err != nil {
  34221. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34222. }
  34223. return oldValue.ConsumeToken, nil
  34224. }
  34225. // AddConsumeToken adds u to the "consume_token" field.
  34226. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34227. if m.addconsume_token != nil {
  34228. *m.addconsume_token += u
  34229. } else {
  34230. m.addconsume_token = &u
  34231. }
  34232. }
  34233. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34234. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34235. v := m.addconsume_token
  34236. if v == nil {
  34237. return
  34238. }
  34239. return *v, true
  34240. }
  34241. // ResetConsumeToken resets all changes to the "consume_token" field.
  34242. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34243. m.consume_token = nil
  34244. m.addconsume_token = nil
  34245. }
  34246. // SetActiveUser sets the "active_user" field.
  34247. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34248. m.active_user = &u
  34249. m.addactive_user = nil
  34250. }
  34251. // ActiveUser returns the value of the "active_user" field in the mutation.
  34252. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34253. v := m.active_user
  34254. if v == nil {
  34255. return
  34256. }
  34257. return *v, true
  34258. }
  34259. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34260. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34262. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34263. if !m.op.Is(OpUpdateOne) {
  34264. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34265. }
  34266. if m.id == nil || m.oldValue == nil {
  34267. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34268. }
  34269. oldValue, err := m.oldValue(ctx)
  34270. if err != nil {
  34271. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34272. }
  34273. return oldValue.ActiveUser, nil
  34274. }
  34275. // AddActiveUser adds u to the "active_user" field.
  34276. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34277. if m.addactive_user != nil {
  34278. *m.addactive_user += u
  34279. } else {
  34280. m.addactive_user = &u
  34281. }
  34282. }
  34283. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34284. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34285. v := m.addactive_user
  34286. if v == nil {
  34287. return
  34288. }
  34289. return *v, true
  34290. }
  34291. // ResetActiveUser resets all changes to the "active_user" field.
  34292. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34293. m.active_user = nil
  34294. m.addactive_user = nil
  34295. }
  34296. // SetNewUser sets the "new_user" field.
  34297. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34298. m.new_user = &i
  34299. m.addnew_user = nil
  34300. }
  34301. // NewUser returns the value of the "new_user" field in the mutation.
  34302. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34303. v := m.new_user
  34304. if v == nil {
  34305. return
  34306. }
  34307. return *v, true
  34308. }
  34309. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34310. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34312. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34313. if !m.op.Is(OpUpdateOne) {
  34314. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34315. }
  34316. if m.id == nil || m.oldValue == nil {
  34317. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34318. }
  34319. oldValue, err := m.oldValue(ctx)
  34320. if err != nil {
  34321. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34322. }
  34323. return oldValue.NewUser, nil
  34324. }
  34325. // AddNewUser adds i to the "new_user" field.
  34326. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34327. if m.addnew_user != nil {
  34328. *m.addnew_user += i
  34329. } else {
  34330. m.addnew_user = &i
  34331. }
  34332. }
  34333. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34334. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34335. v := m.addnew_user
  34336. if v == nil {
  34337. return
  34338. }
  34339. return *v, true
  34340. }
  34341. // ResetNewUser resets all changes to the "new_user" field.
  34342. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34343. m.new_user = nil
  34344. m.addnew_user = nil
  34345. }
  34346. // SetLabelDist sets the "label_dist" field.
  34347. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34348. m.label_dist = &ctd
  34349. m.appendlabel_dist = nil
  34350. }
  34351. // LabelDist returns the value of the "label_dist" field in the mutation.
  34352. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34353. v := m.label_dist
  34354. if v == nil {
  34355. return
  34356. }
  34357. return *v, true
  34358. }
  34359. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34360. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34362. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34363. if !m.op.Is(OpUpdateOne) {
  34364. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34365. }
  34366. if m.id == nil || m.oldValue == nil {
  34367. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34368. }
  34369. oldValue, err := m.oldValue(ctx)
  34370. if err != nil {
  34371. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34372. }
  34373. return oldValue.LabelDist, nil
  34374. }
  34375. // AppendLabelDist adds ctd to the "label_dist" field.
  34376. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34377. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34378. }
  34379. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34380. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34381. if len(m.appendlabel_dist) == 0 {
  34382. return nil, false
  34383. }
  34384. return m.appendlabel_dist, true
  34385. }
  34386. // ResetLabelDist resets all changes to the "label_dist" field.
  34387. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34388. m.label_dist = nil
  34389. m.appendlabel_dist = nil
  34390. }
  34391. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34392. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34393. m.predicates = append(m.predicates, ps...)
  34394. }
  34395. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34396. // users can use type-assertion to append predicates that do not depend on any generated package.
  34397. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34398. p := make([]predicate.UsageStatisticMonth, len(ps))
  34399. for i := range ps {
  34400. p[i] = ps[i]
  34401. }
  34402. m.Where(p...)
  34403. }
  34404. // Op returns the operation name.
  34405. func (m *UsageStatisticMonthMutation) Op() Op {
  34406. return m.op
  34407. }
  34408. // SetOp allows setting the mutation operation.
  34409. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34410. m.op = op
  34411. }
  34412. // Type returns the node type of this mutation (UsageStatisticMonth).
  34413. func (m *UsageStatisticMonthMutation) Type() string {
  34414. return m.typ
  34415. }
  34416. // Fields returns all fields that were changed during this mutation. Note that in
  34417. // order to get all numeric fields that were incremented/decremented, call
  34418. // AddedFields().
  34419. func (m *UsageStatisticMonthMutation) Fields() []string {
  34420. fields := make([]string, 0, 17)
  34421. if m.created_at != nil {
  34422. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34423. }
  34424. if m.updated_at != nil {
  34425. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34426. }
  34427. if m.status != nil {
  34428. fields = append(fields, usagestatisticmonth.FieldStatus)
  34429. }
  34430. if m.deleted_at != nil {
  34431. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34432. }
  34433. if m.addtime != nil {
  34434. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34435. }
  34436. if m._type != nil {
  34437. fields = append(fields, usagestatisticmonth.FieldType)
  34438. }
  34439. if m.bot_id != nil {
  34440. fields = append(fields, usagestatisticmonth.FieldBotID)
  34441. }
  34442. if m.organization_id != nil {
  34443. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34444. }
  34445. if m.ai_response != nil {
  34446. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34447. }
  34448. if m.sop_run != nil {
  34449. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34450. }
  34451. if m.total_friend != nil {
  34452. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34453. }
  34454. if m.total_group != nil {
  34455. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34456. }
  34457. if m.account_balance != nil {
  34458. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34459. }
  34460. if m.consume_token != nil {
  34461. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34462. }
  34463. if m.active_user != nil {
  34464. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34465. }
  34466. if m.new_user != nil {
  34467. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34468. }
  34469. if m.label_dist != nil {
  34470. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34471. }
  34472. return fields
  34473. }
  34474. // Field returns the value of a field with the given name. The second boolean
  34475. // return value indicates that this field was not set, or was not defined in the
  34476. // schema.
  34477. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34478. switch name {
  34479. case usagestatisticmonth.FieldCreatedAt:
  34480. return m.CreatedAt()
  34481. case usagestatisticmonth.FieldUpdatedAt:
  34482. return m.UpdatedAt()
  34483. case usagestatisticmonth.FieldStatus:
  34484. return m.Status()
  34485. case usagestatisticmonth.FieldDeletedAt:
  34486. return m.DeletedAt()
  34487. case usagestatisticmonth.FieldAddtime:
  34488. return m.Addtime()
  34489. case usagestatisticmonth.FieldType:
  34490. return m.GetType()
  34491. case usagestatisticmonth.FieldBotID:
  34492. return m.BotID()
  34493. case usagestatisticmonth.FieldOrganizationID:
  34494. return m.OrganizationID()
  34495. case usagestatisticmonth.FieldAiResponse:
  34496. return m.AiResponse()
  34497. case usagestatisticmonth.FieldSopRun:
  34498. return m.SopRun()
  34499. case usagestatisticmonth.FieldTotalFriend:
  34500. return m.TotalFriend()
  34501. case usagestatisticmonth.FieldTotalGroup:
  34502. return m.TotalGroup()
  34503. case usagestatisticmonth.FieldAccountBalance:
  34504. return m.AccountBalance()
  34505. case usagestatisticmonth.FieldConsumeToken:
  34506. return m.ConsumeToken()
  34507. case usagestatisticmonth.FieldActiveUser:
  34508. return m.ActiveUser()
  34509. case usagestatisticmonth.FieldNewUser:
  34510. return m.NewUser()
  34511. case usagestatisticmonth.FieldLabelDist:
  34512. return m.LabelDist()
  34513. }
  34514. return nil, false
  34515. }
  34516. // OldField returns the old value of the field from the database. An error is
  34517. // returned if the mutation operation is not UpdateOne, or the query to the
  34518. // database failed.
  34519. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34520. switch name {
  34521. case usagestatisticmonth.FieldCreatedAt:
  34522. return m.OldCreatedAt(ctx)
  34523. case usagestatisticmonth.FieldUpdatedAt:
  34524. return m.OldUpdatedAt(ctx)
  34525. case usagestatisticmonth.FieldStatus:
  34526. return m.OldStatus(ctx)
  34527. case usagestatisticmonth.FieldDeletedAt:
  34528. return m.OldDeletedAt(ctx)
  34529. case usagestatisticmonth.FieldAddtime:
  34530. return m.OldAddtime(ctx)
  34531. case usagestatisticmonth.FieldType:
  34532. return m.OldType(ctx)
  34533. case usagestatisticmonth.FieldBotID:
  34534. return m.OldBotID(ctx)
  34535. case usagestatisticmonth.FieldOrganizationID:
  34536. return m.OldOrganizationID(ctx)
  34537. case usagestatisticmonth.FieldAiResponse:
  34538. return m.OldAiResponse(ctx)
  34539. case usagestatisticmonth.FieldSopRun:
  34540. return m.OldSopRun(ctx)
  34541. case usagestatisticmonth.FieldTotalFriend:
  34542. return m.OldTotalFriend(ctx)
  34543. case usagestatisticmonth.FieldTotalGroup:
  34544. return m.OldTotalGroup(ctx)
  34545. case usagestatisticmonth.FieldAccountBalance:
  34546. return m.OldAccountBalance(ctx)
  34547. case usagestatisticmonth.FieldConsumeToken:
  34548. return m.OldConsumeToken(ctx)
  34549. case usagestatisticmonth.FieldActiveUser:
  34550. return m.OldActiveUser(ctx)
  34551. case usagestatisticmonth.FieldNewUser:
  34552. return m.OldNewUser(ctx)
  34553. case usagestatisticmonth.FieldLabelDist:
  34554. return m.OldLabelDist(ctx)
  34555. }
  34556. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34557. }
  34558. // SetField sets the value of a field with the given name. It returns an error if
  34559. // the field is not defined in the schema, or if the type mismatched the field
  34560. // type.
  34561. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34562. switch name {
  34563. case usagestatisticmonth.FieldCreatedAt:
  34564. v, ok := value.(time.Time)
  34565. if !ok {
  34566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34567. }
  34568. m.SetCreatedAt(v)
  34569. return nil
  34570. case usagestatisticmonth.FieldUpdatedAt:
  34571. v, ok := value.(time.Time)
  34572. if !ok {
  34573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34574. }
  34575. m.SetUpdatedAt(v)
  34576. return nil
  34577. case usagestatisticmonth.FieldStatus:
  34578. v, ok := value.(uint8)
  34579. if !ok {
  34580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34581. }
  34582. m.SetStatus(v)
  34583. return nil
  34584. case usagestatisticmonth.FieldDeletedAt:
  34585. v, ok := value.(time.Time)
  34586. if !ok {
  34587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34588. }
  34589. m.SetDeletedAt(v)
  34590. return nil
  34591. case usagestatisticmonth.FieldAddtime:
  34592. v, ok := value.(uint64)
  34593. if !ok {
  34594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34595. }
  34596. m.SetAddtime(v)
  34597. return nil
  34598. case usagestatisticmonth.FieldType:
  34599. v, ok := value.(int)
  34600. if !ok {
  34601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34602. }
  34603. m.SetType(v)
  34604. return nil
  34605. case usagestatisticmonth.FieldBotID:
  34606. v, ok := value.(string)
  34607. if !ok {
  34608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34609. }
  34610. m.SetBotID(v)
  34611. return nil
  34612. case usagestatisticmonth.FieldOrganizationID:
  34613. v, ok := value.(uint64)
  34614. if !ok {
  34615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34616. }
  34617. m.SetOrganizationID(v)
  34618. return nil
  34619. case usagestatisticmonth.FieldAiResponse:
  34620. v, ok := value.(uint64)
  34621. if !ok {
  34622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34623. }
  34624. m.SetAiResponse(v)
  34625. return nil
  34626. case usagestatisticmonth.FieldSopRun:
  34627. v, ok := value.(uint64)
  34628. if !ok {
  34629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34630. }
  34631. m.SetSopRun(v)
  34632. return nil
  34633. case usagestatisticmonth.FieldTotalFriend:
  34634. v, ok := value.(uint64)
  34635. if !ok {
  34636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34637. }
  34638. m.SetTotalFriend(v)
  34639. return nil
  34640. case usagestatisticmonth.FieldTotalGroup:
  34641. v, ok := value.(uint64)
  34642. if !ok {
  34643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34644. }
  34645. m.SetTotalGroup(v)
  34646. return nil
  34647. case usagestatisticmonth.FieldAccountBalance:
  34648. v, ok := value.(uint64)
  34649. if !ok {
  34650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34651. }
  34652. m.SetAccountBalance(v)
  34653. return nil
  34654. case usagestatisticmonth.FieldConsumeToken:
  34655. v, ok := value.(uint64)
  34656. if !ok {
  34657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34658. }
  34659. m.SetConsumeToken(v)
  34660. return nil
  34661. case usagestatisticmonth.FieldActiveUser:
  34662. v, ok := value.(uint64)
  34663. if !ok {
  34664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34665. }
  34666. m.SetActiveUser(v)
  34667. return nil
  34668. case usagestatisticmonth.FieldNewUser:
  34669. v, ok := value.(int64)
  34670. if !ok {
  34671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34672. }
  34673. m.SetNewUser(v)
  34674. return nil
  34675. case usagestatisticmonth.FieldLabelDist:
  34676. v, ok := value.([]custom_types.LabelDist)
  34677. if !ok {
  34678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34679. }
  34680. m.SetLabelDist(v)
  34681. return nil
  34682. }
  34683. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34684. }
  34685. // AddedFields returns all numeric fields that were incremented/decremented during
  34686. // this mutation.
  34687. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  34688. var fields []string
  34689. if m.addstatus != nil {
  34690. fields = append(fields, usagestatisticmonth.FieldStatus)
  34691. }
  34692. if m.addaddtime != nil {
  34693. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34694. }
  34695. if m.add_type != nil {
  34696. fields = append(fields, usagestatisticmonth.FieldType)
  34697. }
  34698. if m.addorganization_id != nil {
  34699. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34700. }
  34701. if m.addai_response != nil {
  34702. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34703. }
  34704. if m.addsop_run != nil {
  34705. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34706. }
  34707. if m.addtotal_friend != nil {
  34708. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34709. }
  34710. if m.addtotal_group != nil {
  34711. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34712. }
  34713. if m.addaccount_balance != nil {
  34714. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34715. }
  34716. if m.addconsume_token != nil {
  34717. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34718. }
  34719. if m.addactive_user != nil {
  34720. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34721. }
  34722. if m.addnew_user != nil {
  34723. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34724. }
  34725. return fields
  34726. }
  34727. // AddedField returns the numeric value that was incremented/decremented on a field
  34728. // with the given name. The second boolean return value indicates that this field
  34729. // was not set, or was not defined in the schema.
  34730. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  34731. switch name {
  34732. case usagestatisticmonth.FieldStatus:
  34733. return m.AddedStatus()
  34734. case usagestatisticmonth.FieldAddtime:
  34735. return m.AddedAddtime()
  34736. case usagestatisticmonth.FieldType:
  34737. return m.AddedType()
  34738. case usagestatisticmonth.FieldOrganizationID:
  34739. return m.AddedOrganizationID()
  34740. case usagestatisticmonth.FieldAiResponse:
  34741. return m.AddedAiResponse()
  34742. case usagestatisticmonth.FieldSopRun:
  34743. return m.AddedSopRun()
  34744. case usagestatisticmonth.FieldTotalFriend:
  34745. return m.AddedTotalFriend()
  34746. case usagestatisticmonth.FieldTotalGroup:
  34747. return m.AddedTotalGroup()
  34748. case usagestatisticmonth.FieldAccountBalance:
  34749. return m.AddedAccountBalance()
  34750. case usagestatisticmonth.FieldConsumeToken:
  34751. return m.AddedConsumeToken()
  34752. case usagestatisticmonth.FieldActiveUser:
  34753. return m.AddedActiveUser()
  34754. case usagestatisticmonth.FieldNewUser:
  34755. return m.AddedNewUser()
  34756. }
  34757. return nil, false
  34758. }
  34759. // AddField adds the value to the field with the given name. It returns an error if
  34760. // the field is not defined in the schema, or if the type mismatched the field
  34761. // type.
  34762. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  34763. switch name {
  34764. case usagestatisticmonth.FieldStatus:
  34765. v, ok := value.(int8)
  34766. if !ok {
  34767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34768. }
  34769. m.AddStatus(v)
  34770. return nil
  34771. case usagestatisticmonth.FieldAddtime:
  34772. v, ok := value.(int64)
  34773. if !ok {
  34774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34775. }
  34776. m.AddAddtime(v)
  34777. return nil
  34778. case usagestatisticmonth.FieldType:
  34779. v, ok := value.(int)
  34780. if !ok {
  34781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34782. }
  34783. m.AddType(v)
  34784. return nil
  34785. case usagestatisticmonth.FieldOrganizationID:
  34786. v, ok := value.(int64)
  34787. if !ok {
  34788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34789. }
  34790. m.AddOrganizationID(v)
  34791. return nil
  34792. case usagestatisticmonth.FieldAiResponse:
  34793. v, ok := value.(int64)
  34794. if !ok {
  34795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34796. }
  34797. m.AddAiResponse(v)
  34798. return nil
  34799. case usagestatisticmonth.FieldSopRun:
  34800. v, ok := value.(int64)
  34801. if !ok {
  34802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34803. }
  34804. m.AddSopRun(v)
  34805. return nil
  34806. case usagestatisticmonth.FieldTotalFriend:
  34807. v, ok := value.(int64)
  34808. if !ok {
  34809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34810. }
  34811. m.AddTotalFriend(v)
  34812. return nil
  34813. case usagestatisticmonth.FieldTotalGroup:
  34814. v, ok := value.(int64)
  34815. if !ok {
  34816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34817. }
  34818. m.AddTotalGroup(v)
  34819. return nil
  34820. case usagestatisticmonth.FieldAccountBalance:
  34821. v, ok := value.(int64)
  34822. if !ok {
  34823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34824. }
  34825. m.AddAccountBalance(v)
  34826. return nil
  34827. case usagestatisticmonth.FieldConsumeToken:
  34828. v, ok := value.(int64)
  34829. if !ok {
  34830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34831. }
  34832. m.AddConsumeToken(v)
  34833. return nil
  34834. case usagestatisticmonth.FieldActiveUser:
  34835. v, ok := value.(int64)
  34836. if !ok {
  34837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34838. }
  34839. m.AddActiveUser(v)
  34840. return nil
  34841. case usagestatisticmonth.FieldNewUser:
  34842. v, ok := value.(int64)
  34843. if !ok {
  34844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34845. }
  34846. m.AddNewUser(v)
  34847. return nil
  34848. }
  34849. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  34850. }
  34851. // ClearedFields returns all nullable fields that were cleared during this
  34852. // mutation.
  34853. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  34854. var fields []string
  34855. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  34856. fields = append(fields, usagestatisticmonth.FieldStatus)
  34857. }
  34858. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  34859. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34860. }
  34861. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  34862. fields = append(fields, usagestatisticmonth.FieldBotID)
  34863. }
  34864. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  34865. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34866. }
  34867. return fields
  34868. }
  34869. // FieldCleared returns a boolean indicating if a field with the given name was
  34870. // cleared in this mutation.
  34871. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  34872. _, ok := m.clearedFields[name]
  34873. return ok
  34874. }
  34875. // ClearField clears the value of the field with the given name. It returns an
  34876. // error if the field is not defined in the schema.
  34877. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  34878. switch name {
  34879. case usagestatisticmonth.FieldStatus:
  34880. m.ClearStatus()
  34881. return nil
  34882. case usagestatisticmonth.FieldDeletedAt:
  34883. m.ClearDeletedAt()
  34884. return nil
  34885. case usagestatisticmonth.FieldBotID:
  34886. m.ClearBotID()
  34887. return nil
  34888. case usagestatisticmonth.FieldOrganizationID:
  34889. m.ClearOrganizationID()
  34890. return nil
  34891. }
  34892. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  34893. }
  34894. // ResetField resets all changes in the mutation for the field with the given name.
  34895. // It returns an error if the field is not defined in the schema.
  34896. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  34897. switch name {
  34898. case usagestatisticmonth.FieldCreatedAt:
  34899. m.ResetCreatedAt()
  34900. return nil
  34901. case usagestatisticmonth.FieldUpdatedAt:
  34902. m.ResetUpdatedAt()
  34903. return nil
  34904. case usagestatisticmonth.FieldStatus:
  34905. m.ResetStatus()
  34906. return nil
  34907. case usagestatisticmonth.FieldDeletedAt:
  34908. m.ResetDeletedAt()
  34909. return nil
  34910. case usagestatisticmonth.FieldAddtime:
  34911. m.ResetAddtime()
  34912. return nil
  34913. case usagestatisticmonth.FieldType:
  34914. m.ResetType()
  34915. return nil
  34916. case usagestatisticmonth.FieldBotID:
  34917. m.ResetBotID()
  34918. return nil
  34919. case usagestatisticmonth.FieldOrganizationID:
  34920. m.ResetOrganizationID()
  34921. return nil
  34922. case usagestatisticmonth.FieldAiResponse:
  34923. m.ResetAiResponse()
  34924. return nil
  34925. case usagestatisticmonth.FieldSopRun:
  34926. m.ResetSopRun()
  34927. return nil
  34928. case usagestatisticmonth.FieldTotalFriend:
  34929. m.ResetTotalFriend()
  34930. return nil
  34931. case usagestatisticmonth.FieldTotalGroup:
  34932. m.ResetTotalGroup()
  34933. return nil
  34934. case usagestatisticmonth.FieldAccountBalance:
  34935. m.ResetAccountBalance()
  34936. return nil
  34937. case usagestatisticmonth.FieldConsumeToken:
  34938. m.ResetConsumeToken()
  34939. return nil
  34940. case usagestatisticmonth.FieldActiveUser:
  34941. m.ResetActiveUser()
  34942. return nil
  34943. case usagestatisticmonth.FieldNewUser:
  34944. m.ResetNewUser()
  34945. return nil
  34946. case usagestatisticmonth.FieldLabelDist:
  34947. m.ResetLabelDist()
  34948. return nil
  34949. }
  34950. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34951. }
  34952. // AddedEdges returns all edge names that were set/added in this mutation.
  34953. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  34954. edges := make([]string, 0, 0)
  34955. return edges
  34956. }
  34957. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34958. // name in this mutation.
  34959. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  34960. return nil
  34961. }
  34962. // RemovedEdges returns all edge names that were removed in this mutation.
  34963. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  34964. edges := make([]string, 0, 0)
  34965. return edges
  34966. }
  34967. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34968. // the given name in this mutation.
  34969. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  34970. return nil
  34971. }
  34972. // ClearedEdges returns all edge names that were cleared in this mutation.
  34973. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  34974. edges := make([]string, 0, 0)
  34975. return edges
  34976. }
  34977. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34978. // was cleared in this mutation.
  34979. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  34980. return false
  34981. }
  34982. // ClearEdge clears the value of the edge with the given name. It returns an error
  34983. // if that edge is not defined in the schema.
  34984. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  34985. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  34986. }
  34987. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34988. // It returns an error if the edge is not defined in the schema.
  34989. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  34990. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  34991. }
  34992. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  34993. type UsageTotalMutation struct {
  34994. config
  34995. op Op
  34996. typ string
  34997. id *uint64
  34998. created_at *time.Time
  34999. updated_at *time.Time
  35000. status *uint8
  35001. addstatus *int8
  35002. _type *int
  35003. add_type *int
  35004. bot_id *string
  35005. total_tokens *uint64
  35006. addtotal_tokens *int64
  35007. start_index *uint64
  35008. addstart_index *int64
  35009. end_index *uint64
  35010. addend_index *int64
  35011. organization_id *uint64
  35012. addorganization_id *int64
  35013. clearedFields map[string]struct{}
  35014. done bool
  35015. oldValue func(context.Context) (*UsageTotal, error)
  35016. predicates []predicate.UsageTotal
  35017. }
  35018. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  35019. // usagetotalOption allows management of the mutation configuration using functional options.
  35020. type usagetotalOption func(*UsageTotalMutation)
  35021. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  35022. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  35023. m := &UsageTotalMutation{
  35024. config: c,
  35025. op: op,
  35026. typ: TypeUsageTotal,
  35027. clearedFields: make(map[string]struct{}),
  35028. }
  35029. for _, opt := range opts {
  35030. opt(m)
  35031. }
  35032. return m
  35033. }
  35034. // withUsageTotalID sets the ID field of the mutation.
  35035. func withUsageTotalID(id uint64) usagetotalOption {
  35036. return func(m *UsageTotalMutation) {
  35037. var (
  35038. err error
  35039. once sync.Once
  35040. value *UsageTotal
  35041. )
  35042. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  35043. once.Do(func() {
  35044. if m.done {
  35045. err = errors.New("querying old values post mutation is not allowed")
  35046. } else {
  35047. value, err = m.Client().UsageTotal.Get(ctx, id)
  35048. }
  35049. })
  35050. return value, err
  35051. }
  35052. m.id = &id
  35053. }
  35054. }
  35055. // withUsageTotal sets the old UsageTotal of the mutation.
  35056. func withUsageTotal(node *UsageTotal) usagetotalOption {
  35057. return func(m *UsageTotalMutation) {
  35058. m.oldValue = func(context.Context) (*UsageTotal, error) {
  35059. return node, nil
  35060. }
  35061. m.id = &node.ID
  35062. }
  35063. }
  35064. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35065. // executed in a transaction (ent.Tx), a transactional client is returned.
  35066. func (m UsageTotalMutation) Client() *Client {
  35067. client := &Client{config: m.config}
  35068. client.init()
  35069. return client
  35070. }
  35071. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35072. // it returns an error otherwise.
  35073. func (m UsageTotalMutation) Tx() (*Tx, error) {
  35074. if _, ok := m.driver.(*txDriver); !ok {
  35075. return nil, errors.New("ent: mutation is not running in a transaction")
  35076. }
  35077. tx := &Tx{config: m.config}
  35078. tx.init()
  35079. return tx, nil
  35080. }
  35081. // SetID sets the value of the id field. Note that this
  35082. // operation is only accepted on creation of UsageTotal entities.
  35083. func (m *UsageTotalMutation) SetID(id uint64) {
  35084. m.id = &id
  35085. }
  35086. // ID returns the ID value in the mutation. Note that the ID is only available
  35087. // if it was provided to the builder or after it was returned from the database.
  35088. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35089. if m.id == nil {
  35090. return
  35091. }
  35092. return *m.id, true
  35093. }
  35094. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35095. // That means, if the mutation is applied within a transaction with an isolation level such
  35096. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35097. // or updated by the mutation.
  35098. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35099. switch {
  35100. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35101. id, exists := m.ID()
  35102. if exists {
  35103. return []uint64{id}, nil
  35104. }
  35105. fallthrough
  35106. case m.op.Is(OpUpdate | OpDelete):
  35107. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35108. default:
  35109. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35110. }
  35111. }
  35112. // SetCreatedAt sets the "created_at" field.
  35113. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35114. m.created_at = &t
  35115. }
  35116. // CreatedAt returns the value of the "created_at" field in the mutation.
  35117. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35118. v := m.created_at
  35119. if v == nil {
  35120. return
  35121. }
  35122. return *v, true
  35123. }
  35124. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35125. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35127. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35128. if !m.op.Is(OpUpdateOne) {
  35129. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35130. }
  35131. if m.id == nil || m.oldValue == nil {
  35132. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35133. }
  35134. oldValue, err := m.oldValue(ctx)
  35135. if err != nil {
  35136. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35137. }
  35138. return oldValue.CreatedAt, nil
  35139. }
  35140. // ResetCreatedAt resets all changes to the "created_at" field.
  35141. func (m *UsageTotalMutation) ResetCreatedAt() {
  35142. m.created_at = nil
  35143. }
  35144. // SetUpdatedAt sets the "updated_at" field.
  35145. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35146. m.updated_at = &t
  35147. }
  35148. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35149. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35150. v := m.updated_at
  35151. if v == nil {
  35152. return
  35153. }
  35154. return *v, true
  35155. }
  35156. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35157. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35159. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35160. if !m.op.Is(OpUpdateOne) {
  35161. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35162. }
  35163. if m.id == nil || m.oldValue == nil {
  35164. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35165. }
  35166. oldValue, err := m.oldValue(ctx)
  35167. if err != nil {
  35168. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35169. }
  35170. return oldValue.UpdatedAt, nil
  35171. }
  35172. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35173. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35174. m.updated_at = nil
  35175. }
  35176. // SetStatus sets the "status" field.
  35177. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35178. m.status = &u
  35179. m.addstatus = nil
  35180. }
  35181. // Status returns the value of the "status" field in the mutation.
  35182. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35183. v := m.status
  35184. if v == nil {
  35185. return
  35186. }
  35187. return *v, true
  35188. }
  35189. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35190. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35192. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35193. if !m.op.Is(OpUpdateOne) {
  35194. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35195. }
  35196. if m.id == nil || m.oldValue == nil {
  35197. return v, errors.New("OldStatus requires an ID field in the mutation")
  35198. }
  35199. oldValue, err := m.oldValue(ctx)
  35200. if err != nil {
  35201. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35202. }
  35203. return oldValue.Status, nil
  35204. }
  35205. // AddStatus adds u to the "status" field.
  35206. func (m *UsageTotalMutation) AddStatus(u int8) {
  35207. if m.addstatus != nil {
  35208. *m.addstatus += u
  35209. } else {
  35210. m.addstatus = &u
  35211. }
  35212. }
  35213. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35214. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35215. v := m.addstatus
  35216. if v == nil {
  35217. return
  35218. }
  35219. return *v, true
  35220. }
  35221. // ClearStatus clears the value of the "status" field.
  35222. func (m *UsageTotalMutation) ClearStatus() {
  35223. m.status = nil
  35224. m.addstatus = nil
  35225. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35226. }
  35227. // StatusCleared returns if the "status" field was cleared in this mutation.
  35228. func (m *UsageTotalMutation) StatusCleared() bool {
  35229. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35230. return ok
  35231. }
  35232. // ResetStatus resets all changes to the "status" field.
  35233. func (m *UsageTotalMutation) ResetStatus() {
  35234. m.status = nil
  35235. m.addstatus = nil
  35236. delete(m.clearedFields, usagetotal.FieldStatus)
  35237. }
  35238. // SetType sets the "type" field.
  35239. func (m *UsageTotalMutation) SetType(i int) {
  35240. m._type = &i
  35241. m.add_type = nil
  35242. }
  35243. // GetType returns the value of the "type" field in the mutation.
  35244. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35245. v := m._type
  35246. if v == nil {
  35247. return
  35248. }
  35249. return *v, true
  35250. }
  35251. // OldType returns the old "type" field's value of the UsageTotal entity.
  35252. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35254. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35255. if !m.op.Is(OpUpdateOne) {
  35256. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35257. }
  35258. if m.id == nil || m.oldValue == nil {
  35259. return v, errors.New("OldType requires an ID field in the mutation")
  35260. }
  35261. oldValue, err := m.oldValue(ctx)
  35262. if err != nil {
  35263. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35264. }
  35265. return oldValue.Type, nil
  35266. }
  35267. // AddType adds i to the "type" field.
  35268. func (m *UsageTotalMutation) AddType(i int) {
  35269. if m.add_type != nil {
  35270. *m.add_type += i
  35271. } else {
  35272. m.add_type = &i
  35273. }
  35274. }
  35275. // AddedType returns the value that was added to the "type" field in this mutation.
  35276. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35277. v := m.add_type
  35278. if v == nil {
  35279. return
  35280. }
  35281. return *v, true
  35282. }
  35283. // ClearType clears the value of the "type" field.
  35284. func (m *UsageTotalMutation) ClearType() {
  35285. m._type = nil
  35286. m.add_type = nil
  35287. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35288. }
  35289. // TypeCleared returns if the "type" field was cleared in this mutation.
  35290. func (m *UsageTotalMutation) TypeCleared() bool {
  35291. _, ok := m.clearedFields[usagetotal.FieldType]
  35292. return ok
  35293. }
  35294. // ResetType resets all changes to the "type" field.
  35295. func (m *UsageTotalMutation) ResetType() {
  35296. m._type = nil
  35297. m.add_type = nil
  35298. delete(m.clearedFields, usagetotal.FieldType)
  35299. }
  35300. // SetBotID sets the "bot_id" field.
  35301. func (m *UsageTotalMutation) SetBotID(s string) {
  35302. m.bot_id = &s
  35303. }
  35304. // BotID returns the value of the "bot_id" field in the mutation.
  35305. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35306. v := m.bot_id
  35307. if v == nil {
  35308. return
  35309. }
  35310. return *v, true
  35311. }
  35312. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  35313. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35315. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  35316. if !m.op.Is(OpUpdateOne) {
  35317. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35318. }
  35319. if m.id == nil || m.oldValue == nil {
  35320. return v, errors.New("OldBotID requires an ID field in the mutation")
  35321. }
  35322. oldValue, err := m.oldValue(ctx)
  35323. if err != nil {
  35324. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35325. }
  35326. return oldValue.BotID, nil
  35327. }
  35328. // ResetBotID resets all changes to the "bot_id" field.
  35329. func (m *UsageTotalMutation) ResetBotID() {
  35330. m.bot_id = nil
  35331. }
  35332. // SetTotalTokens sets the "total_tokens" field.
  35333. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35334. m.total_tokens = &u
  35335. m.addtotal_tokens = nil
  35336. }
  35337. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35338. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35339. v := m.total_tokens
  35340. if v == nil {
  35341. return
  35342. }
  35343. return *v, true
  35344. }
  35345. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  35346. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35348. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35349. if !m.op.Is(OpUpdateOne) {
  35350. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35351. }
  35352. if m.id == nil || m.oldValue == nil {
  35353. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35354. }
  35355. oldValue, err := m.oldValue(ctx)
  35356. if err != nil {
  35357. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35358. }
  35359. return oldValue.TotalTokens, nil
  35360. }
  35361. // AddTotalTokens adds u to the "total_tokens" field.
  35362. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35363. if m.addtotal_tokens != nil {
  35364. *m.addtotal_tokens += u
  35365. } else {
  35366. m.addtotal_tokens = &u
  35367. }
  35368. }
  35369. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35370. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35371. v := m.addtotal_tokens
  35372. if v == nil {
  35373. return
  35374. }
  35375. return *v, true
  35376. }
  35377. // ClearTotalTokens clears the value of the "total_tokens" field.
  35378. func (m *UsageTotalMutation) ClearTotalTokens() {
  35379. m.total_tokens = nil
  35380. m.addtotal_tokens = nil
  35381. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35382. }
  35383. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35384. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35385. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35386. return ok
  35387. }
  35388. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35389. func (m *UsageTotalMutation) ResetTotalTokens() {
  35390. m.total_tokens = nil
  35391. m.addtotal_tokens = nil
  35392. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35393. }
  35394. // SetStartIndex sets the "start_index" field.
  35395. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35396. m.start_index = &u
  35397. m.addstart_index = nil
  35398. }
  35399. // StartIndex returns the value of the "start_index" field in the mutation.
  35400. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35401. v := m.start_index
  35402. if v == nil {
  35403. return
  35404. }
  35405. return *v, true
  35406. }
  35407. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  35408. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35410. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35411. if !m.op.Is(OpUpdateOne) {
  35412. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35413. }
  35414. if m.id == nil || m.oldValue == nil {
  35415. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  35416. }
  35417. oldValue, err := m.oldValue(ctx)
  35418. if err != nil {
  35419. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  35420. }
  35421. return oldValue.StartIndex, nil
  35422. }
  35423. // AddStartIndex adds u to the "start_index" field.
  35424. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35425. if m.addstart_index != nil {
  35426. *m.addstart_index += u
  35427. } else {
  35428. m.addstart_index = &u
  35429. }
  35430. }
  35431. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35432. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35433. v := m.addstart_index
  35434. if v == nil {
  35435. return
  35436. }
  35437. return *v, true
  35438. }
  35439. // ClearStartIndex clears the value of the "start_index" field.
  35440. func (m *UsageTotalMutation) ClearStartIndex() {
  35441. m.start_index = nil
  35442. m.addstart_index = nil
  35443. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35444. }
  35445. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35446. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35447. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35448. return ok
  35449. }
  35450. // ResetStartIndex resets all changes to the "start_index" field.
  35451. func (m *UsageTotalMutation) ResetStartIndex() {
  35452. m.start_index = nil
  35453. m.addstart_index = nil
  35454. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35455. }
  35456. // SetEndIndex sets the "end_index" field.
  35457. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35458. m.end_index = &u
  35459. m.addend_index = nil
  35460. }
  35461. // EndIndex returns the value of the "end_index" field in the mutation.
  35462. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35463. v := m.end_index
  35464. if v == nil {
  35465. return
  35466. }
  35467. return *v, true
  35468. }
  35469. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35470. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35472. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35473. if !m.op.Is(OpUpdateOne) {
  35474. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35475. }
  35476. if m.id == nil || m.oldValue == nil {
  35477. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  35478. }
  35479. oldValue, err := m.oldValue(ctx)
  35480. if err != nil {
  35481. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  35482. }
  35483. return oldValue.EndIndex, nil
  35484. }
  35485. // AddEndIndex adds u to the "end_index" field.
  35486. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35487. if m.addend_index != nil {
  35488. *m.addend_index += u
  35489. } else {
  35490. m.addend_index = &u
  35491. }
  35492. }
  35493. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35494. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35495. v := m.addend_index
  35496. if v == nil {
  35497. return
  35498. }
  35499. return *v, true
  35500. }
  35501. // ClearEndIndex clears the value of the "end_index" field.
  35502. func (m *UsageTotalMutation) ClearEndIndex() {
  35503. m.end_index = nil
  35504. m.addend_index = nil
  35505. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35506. }
  35507. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35508. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35509. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35510. return ok
  35511. }
  35512. // ResetEndIndex resets all changes to the "end_index" field.
  35513. func (m *UsageTotalMutation) ResetEndIndex() {
  35514. m.end_index = nil
  35515. m.addend_index = nil
  35516. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35517. }
  35518. // SetOrganizationID sets the "organization_id" field.
  35519. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35520. m.organization_id = &u
  35521. m.addorganization_id = nil
  35522. }
  35523. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35524. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35525. v := m.organization_id
  35526. if v == nil {
  35527. return
  35528. }
  35529. return *v, true
  35530. }
  35531. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35532. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35534. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35535. if !m.op.Is(OpUpdateOne) {
  35536. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35537. }
  35538. if m.id == nil || m.oldValue == nil {
  35539. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35540. }
  35541. oldValue, err := m.oldValue(ctx)
  35542. if err != nil {
  35543. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35544. }
  35545. return oldValue.OrganizationID, nil
  35546. }
  35547. // AddOrganizationID adds u to the "organization_id" field.
  35548. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35549. if m.addorganization_id != nil {
  35550. *m.addorganization_id += u
  35551. } else {
  35552. m.addorganization_id = &u
  35553. }
  35554. }
  35555. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35556. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35557. v := m.addorganization_id
  35558. if v == nil {
  35559. return
  35560. }
  35561. return *v, true
  35562. }
  35563. // ClearOrganizationID clears the value of the "organization_id" field.
  35564. func (m *UsageTotalMutation) ClearOrganizationID() {
  35565. m.organization_id = nil
  35566. m.addorganization_id = nil
  35567. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35568. }
  35569. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35570. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35571. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35572. return ok
  35573. }
  35574. // ResetOrganizationID resets all changes to the "organization_id" field.
  35575. func (m *UsageTotalMutation) ResetOrganizationID() {
  35576. m.organization_id = nil
  35577. m.addorganization_id = nil
  35578. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35579. }
  35580. // Where appends a list predicates to the UsageTotalMutation builder.
  35581. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35582. m.predicates = append(m.predicates, ps...)
  35583. }
  35584. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35585. // users can use type-assertion to append predicates that do not depend on any generated package.
  35586. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35587. p := make([]predicate.UsageTotal, len(ps))
  35588. for i := range ps {
  35589. p[i] = ps[i]
  35590. }
  35591. m.Where(p...)
  35592. }
  35593. // Op returns the operation name.
  35594. func (m *UsageTotalMutation) Op() Op {
  35595. return m.op
  35596. }
  35597. // SetOp allows setting the mutation operation.
  35598. func (m *UsageTotalMutation) SetOp(op Op) {
  35599. m.op = op
  35600. }
  35601. // Type returns the node type of this mutation (UsageTotal).
  35602. func (m *UsageTotalMutation) Type() string {
  35603. return m.typ
  35604. }
  35605. // Fields returns all fields that were changed during this mutation. Note that in
  35606. // order to get all numeric fields that were incremented/decremented, call
  35607. // AddedFields().
  35608. func (m *UsageTotalMutation) Fields() []string {
  35609. fields := make([]string, 0, 9)
  35610. if m.created_at != nil {
  35611. fields = append(fields, usagetotal.FieldCreatedAt)
  35612. }
  35613. if m.updated_at != nil {
  35614. fields = append(fields, usagetotal.FieldUpdatedAt)
  35615. }
  35616. if m.status != nil {
  35617. fields = append(fields, usagetotal.FieldStatus)
  35618. }
  35619. if m._type != nil {
  35620. fields = append(fields, usagetotal.FieldType)
  35621. }
  35622. if m.bot_id != nil {
  35623. fields = append(fields, usagetotal.FieldBotID)
  35624. }
  35625. if m.total_tokens != nil {
  35626. fields = append(fields, usagetotal.FieldTotalTokens)
  35627. }
  35628. if m.start_index != nil {
  35629. fields = append(fields, usagetotal.FieldStartIndex)
  35630. }
  35631. if m.end_index != nil {
  35632. fields = append(fields, usagetotal.FieldEndIndex)
  35633. }
  35634. if m.organization_id != nil {
  35635. fields = append(fields, usagetotal.FieldOrganizationID)
  35636. }
  35637. return fields
  35638. }
  35639. // Field returns the value of a field with the given name. The second boolean
  35640. // return value indicates that this field was not set, or was not defined in the
  35641. // schema.
  35642. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  35643. switch name {
  35644. case usagetotal.FieldCreatedAt:
  35645. return m.CreatedAt()
  35646. case usagetotal.FieldUpdatedAt:
  35647. return m.UpdatedAt()
  35648. case usagetotal.FieldStatus:
  35649. return m.Status()
  35650. case usagetotal.FieldType:
  35651. return m.GetType()
  35652. case usagetotal.FieldBotID:
  35653. return m.BotID()
  35654. case usagetotal.FieldTotalTokens:
  35655. return m.TotalTokens()
  35656. case usagetotal.FieldStartIndex:
  35657. return m.StartIndex()
  35658. case usagetotal.FieldEndIndex:
  35659. return m.EndIndex()
  35660. case usagetotal.FieldOrganizationID:
  35661. return m.OrganizationID()
  35662. }
  35663. return nil, false
  35664. }
  35665. // OldField returns the old value of the field from the database. An error is
  35666. // returned if the mutation operation is not UpdateOne, or the query to the
  35667. // database failed.
  35668. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35669. switch name {
  35670. case usagetotal.FieldCreatedAt:
  35671. return m.OldCreatedAt(ctx)
  35672. case usagetotal.FieldUpdatedAt:
  35673. return m.OldUpdatedAt(ctx)
  35674. case usagetotal.FieldStatus:
  35675. return m.OldStatus(ctx)
  35676. case usagetotal.FieldType:
  35677. return m.OldType(ctx)
  35678. case usagetotal.FieldBotID:
  35679. return m.OldBotID(ctx)
  35680. case usagetotal.FieldTotalTokens:
  35681. return m.OldTotalTokens(ctx)
  35682. case usagetotal.FieldStartIndex:
  35683. return m.OldStartIndex(ctx)
  35684. case usagetotal.FieldEndIndex:
  35685. return m.OldEndIndex(ctx)
  35686. case usagetotal.FieldOrganizationID:
  35687. return m.OldOrganizationID(ctx)
  35688. }
  35689. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  35690. }
  35691. // SetField sets the value of a field with the given name. It returns an error if
  35692. // the field is not defined in the schema, or if the type mismatched the field
  35693. // type.
  35694. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  35695. switch name {
  35696. case usagetotal.FieldCreatedAt:
  35697. v, ok := value.(time.Time)
  35698. if !ok {
  35699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35700. }
  35701. m.SetCreatedAt(v)
  35702. return nil
  35703. case usagetotal.FieldUpdatedAt:
  35704. v, ok := value.(time.Time)
  35705. if !ok {
  35706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35707. }
  35708. m.SetUpdatedAt(v)
  35709. return nil
  35710. case usagetotal.FieldStatus:
  35711. v, ok := value.(uint8)
  35712. if !ok {
  35713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35714. }
  35715. m.SetStatus(v)
  35716. return nil
  35717. case usagetotal.FieldType:
  35718. v, ok := value.(int)
  35719. if !ok {
  35720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35721. }
  35722. m.SetType(v)
  35723. return nil
  35724. case usagetotal.FieldBotID:
  35725. v, ok := value.(string)
  35726. if !ok {
  35727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35728. }
  35729. m.SetBotID(v)
  35730. return nil
  35731. case usagetotal.FieldTotalTokens:
  35732. v, ok := value.(uint64)
  35733. if !ok {
  35734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35735. }
  35736. m.SetTotalTokens(v)
  35737. return nil
  35738. case usagetotal.FieldStartIndex:
  35739. v, ok := value.(uint64)
  35740. if !ok {
  35741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35742. }
  35743. m.SetStartIndex(v)
  35744. return nil
  35745. case usagetotal.FieldEndIndex:
  35746. v, ok := value.(uint64)
  35747. if !ok {
  35748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35749. }
  35750. m.SetEndIndex(v)
  35751. return nil
  35752. case usagetotal.FieldOrganizationID:
  35753. v, ok := value.(uint64)
  35754. if !ok {
  35755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35756. }
  35757. m.SetOrganizationID(v)
  35758. return nil
  35759. }
  35760. return fmt.Errorf("unknown UsageTotal field %s", name)
  35761. }
  35762. // AddedFields returns all numeric fields that were incremented/decremented during
  35763. // this mutation.
  35764. func (m *UsageTotalMutation) AddedFields() []string {
  35765. var fields []string
  35766. if m.addstatus != nil {
  35767. fields = append(fields, usagetotal.FieldStatus)
  35768. }
  35769. if m.add_type != nil {
  35770. fields = append(fields, usagetotal.FieldType)
  35771. }
  35772. if m.addtotal_tokens != nil {
  35773. fields = append(fields, usagetotal.FieldTotalTokens)
  35774. }
  35775. if m.addstart_index != nil {
  35776. fields = append(fields, usagetotal.FieldStartIndex)
  35777. }
  35778. if m.addend_index != nil {
  35779. fields = append(fields, usagetotal.FieldEndIndex)
  35780. }
  35781. if m.addorganization_id != nil {
  35782. fields = append(fields, usagetotal.FieldOrganizationID)
  35783. }
  35784. return fields
  35785. }
  35786. // AddedField returns the numeric value that was incremented/decremented on a field
  35787. // with the given name. The second boolean return value indicates that this field
  35788. // was not set, or was not defined in the schema.
  35789. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  35790. switch name {
  35791. case usagetotal.FieldStatus:
  35792. return m.AddedStatus()
  35793. case usagetotal.FieldType:
  35794. return m.AddedType()
  35795. case usagetotal.FieldTotalTokens:
  35796. return m.AddedTotalTokens()
  35797. case usagetotal.FieldStartIndex:
  35798. return m.AddedStartIndex()
  35799. case usagetotal.FieldEndIndex:
  35800. return m.AddedEndIndex()
  35801. case usagetotal.FieldOrganizationID:
  35802. return m.AddedOrganizationID()
  35803. }
  35804. return nil, false
  35805. }
  35806. // AddField adds the value to the field with the given name. It returns an error if
  35807. // the field is not defined in the schema, or if the type mismatched the field
  35808. // type.
  35809. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  35810. switch name {
  35811. case usagetotal.FieldStatus:
  35812. v, ok := value.(int8)
  35813. if !ok {
  35814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35815. }
  35816. m.AddStatus(v)
  35817. return nil
  35818. case usagetotal.FieldType:
  35819. v, ok := value.(int)
  35820. if !ok {
  35821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35822. }
  35823. m.AddType(v)
  35824. return nil
  35825. case usagetotal.FieldTotalTokens:
  35826. v, ok := value.(int64)
  35827. if !ok {
  35828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35829. }
  35830. m.AddTotalTokens(v)
  35831. return nil
  35832. case usagetotal.FieldStartIndex:
  35833. v, ok := value.(int64)
  35834. if !ok {
  35835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35836. }
  35837. m.AddStartIndex(v)
  35838. return nil
  35839. case usagetotal.FieldEndIndex:
  35840. v, ok := value.(int64)
  35841. if !ok {
  35842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35843. }
  35844. m.AddEndIndex(v)
  35845. return nil
  35846. case usagetotal.FieldOrganizationID:
  35847. v, ok := value.(int64)
  35848. if !ok {
  35849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35850. }
  35851. m.AddOrganizationID(v)
  35852. return nil
  35853. }
  35854. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  35855. }
  35856. // ClearedFields returns all nullable fields that were cleared during this
  35857. // mutation.
  35858. func (m *UsageTotalMutation) ClearedFields() []string {
  35859. var fields []string
  35860. if m.FieldCleared(usagetotal.FieldStatus) {
  35861. fields = append(fields, usagetotal.FieldStatus)
  35862. }
  35863. if m.FieldCleared(usagetotal.FieldType) {
  35864. fields = append(fields, usagetotal.FieldType)
  35865. }
  35866. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  35867. fields = append(fields, usagetotal.FieldTotalTokens)
  35868. }
  35869. if m.FieldCleared(usagetotal.FieldStartIndex) {
  35870. fields = append(fields, usagetotal.FieldStartIndex)
  35871. }
  35872. if m.FieldCleared(usagetotal.FieldEndIndex) {
  35873. fields = append(fields, usagetotal.FieldEndIndex)
  35874. }
  35875. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  35876. fields = append(fields, usagetotal.FieldOrganizationID)
  35877. }
  35878. return fields
  35879. }
  35880. // FieldCleared returns a boolean indicating if a field with the given name was
  35881. // cleared in this mutation.
  35882. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  35883. _, ok := m.clearedFields[name]
  35884. return ok
  35885. }
  35886. // ClearField clears the value of the field with the given name. It returns an
  35887. // error if the field is not defined in the schema.
  35888. func (m *UsageTotalMutation) ClearField(name string) error {
  35889. switch name {
  35890. case usagetotal.FieldStatus:
  35891. m.ClearStatus()
  35892. return nil
  35893. case usagetotal.FieldType:
  35894. m.ClearType()
  35895. return nil
  35896. case usagetotal.FieldTotalTokens:
  35897. m.ClearTotalTokens()
  35898. return nil
  35899. case usagetotal.FieldStartIndex:
  35900. m.ClearStartIndex()
  35901. return nil
  35902. case usagetotal.FieldEndIndex:
  35903. m.ClearEndIndex()
  35904. return nil
  35905. case usagetotal.FieldOrganizationID:
  35906. m.ClearOrganizationID()
  35907. return nil
  35908. }
  35909. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  35910. }
  35911. // ResetField resets all changes in the mutation for the field with the given name.
  35912. // It returns an error if the field is not defined in the schema.
  35913. func (m *UsageTotalMutation) ResetField(name string) error {
  35914. switch name {
  35915. case usagetotal.FieldCreatedAt:
  35916. m.ResetCreatedAt()
  35917. return nil
  35918. case usagetotal.FieldUpdatedAt:
  35919. m.ResetUpdatedAt()
  35920. return nil
  35921. case usagetotal.FieldStatus:
  35922. m.ResetStatus()
  35923. return nil
  35924. case usagetotal.FieldType:
  35925. m.ResetType()
  35926. return nil
  35927. case usagetotal.FieldBotID:
  35928. m.ResetBotID()
  35929. return nil
  35930. case usagetotal.FieldTotalTokens:
  35931. m.ResetTotalTokens()
  35932. return nil
  35933. case usagetotal.FieldStartIndex:
  35934. m.ResetStartIndex()
  35935. return nil
  35936. case usagetotal.FieldEndIndex:
  35937. m.ResetEndIndex()
  35938. return nil
  35939. case usagetotal.FieldOrganizationID:
  35940. m.ResetOrganizationID()
  35941. return nil
  35942. }
  35943. return fmt.Errorf("unknown UsageTotal field %s", name)
  35944. }
  35945. // AddedEdges returns all edge names that were set/added in this mutation.
  35946. func (m *UsageTotalMutation) AddedEdges() []string {
  35947. edges := make([]string, 0, 0)
  35948. return edges
  35949. }
  35950. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35951. // name in this mutation.
  35952. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  35953. return nil
  35954. }
  35955. // RemovedEdges returns all edge names that were removed in this mutation.
  35956. func (m *UsageTotalMutation) RemovedEdges() []string {
  35957. edges := make([]string, 0, 0)
  35958. return edges
  35959. }
  35960. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35961. // the given name in this mutation.
  35962. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  35963. return nil
  35964. }
  35965. // ClearedEdges returns all edge names that were cleared in this mutation.
  35966. func (m *UsageTotalMutation) ClearedEdges() []string {
  35967. edges := make([]string, 0, 0)
  35968. return edges
  35969. }
  35970. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35971. // was cleared in this mutation.
  35972. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  35973. return false
  35974. }
  35975. // ClearEdge clears the value of the edge with the given name. It returns an error
  35976. // if that edge is not defined in the schema.
  35977. func (m *UsageTotalMutation) ClearEdge(name string) error {
  35978. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  35979. }
  35980. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35981. // It returns an error if the edge is not defined in the schema.
  35982. func (m *UsageTotalMutation) ResetEdge(name string) error {
  35983. return fmt.Errorf("unknown UsageTotal edge %s", name)
  35984. }
  35985. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  35986. type WhatsappMutation struct {
  35987. config
  35988. op Op
  35989. typ string
  35990. id *uint64
  35991. created_at *time.Time
  35992. updated_at *time.Time
  35993. status *uint8
  35994. addstatus *int8
  35995. deleted_at *time.Time
  35996. wa_id *string
  35997. wa_name *string
  35998. callback *string
  35999. account *string
  36000. cc *string
  36001. phone *string
  36002. cc_phone *string
  36003. phone_name *string
  36004. phone_status *int8
  36005. addphone_status *int8
  36006. organization_id *uint64
  36007. addorganization_id *int64
  36008. api_base *string
  36009. api_key *string
  36010. allow_list *[]string
  36011. appendallow_list []string
  36012. group_allow_list *[]string
  36013. appendgroup_allow_list []string
  36014. block_list *[]string
  36015. appendblock_list []string
  36016. group_block_list *[]string
  36017. appendgroup_block_list []string
  36018. clearedFields map[string]struct{}
  36019. agent *uint64
  36020. clearedagent bool
  36021. done bool
  36022. oldValue func(context.Context) (*Whatsapp, error)
  36023. predicates []predicate.Whatsapp
  36024. }
  36025. var _ ent.Mutation = (*WhatsappMutation)(nil)
  36026. // whatsappOption allows management of the mutation configuration using functional options.
  36027. type whatsappOption func(*WhatsappMutation)
  36028. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  36029. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  36030. m := &WhatsappMutation{
  36031. config: c,
  36032. op: op,
  36033. typ: TypeWhatsapp,
  36034. clearedFields: make(map[string]struct{}),
  36035. }
  36036. for _, opt := range opts {
  36037. opt(m)
  36038. }
  36039. return m
  36040. }
  36041. // withWhatsappID sets the ID field of the mutation.
  36042. func withWhatsappID(id uint64) whatsappOption {
  36043. return func(m *WhatsappMutation) {
  36044. var (
  36045. err error
  36046. once sync.Once
  36047. value *Whatsapp
  36048. )
  36049. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  36050. once.Do(func() {
  36051. if m.done {
  36052. err = errors.New("querying old values post mutation is not allowed")
  36053. } else {
  36054. value, err = m.Client().Whatsapp.Get(ctx, id)
  36055. }
  36056. })
  36057. return value, err
  36058. }
  36059. m.id = &id
  36060. }
  36061. }
  36062. // withWhatsapp sets the old Whatsapp of the mutation.
  36063. func withWhatsapp(node *Whatsapp) whatsappOption {
  36064. return func(m *WhatsappMutation) {
  36065. m.oldValue = func(context.Context) (*Whatsapp, error) {
  36066. return node, nil
  36067. }
  36068. m.id = &node.ID
  36069. }
  36070. }
  36071. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36072. // executed in a transaction (ent.Tx), a transactional client is returned.
  36073. func (m WhatsappMutation) Client() *Client {
  36074. client := &Client{config: m.config}
  36075. client.init()
  36076. return client
  36077. }
  36078. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36079. // it returns an error otherwise.
  36080. func (m WhatsappMutation) Tx() (*Tx, error) {
  36081. if _, ok := m.driver.(*txDriver); !ok {
  36082. return nil, errors.New("ent: mutation is not running in a transaction")
  36083. }
  36084. tx := &Tx{config: m.config}
  36085. tx.init()
  36086. return tx, nil
  36087. }
  36088. // SetID sets the value of the id field. Note that this
  36089. // operation is only accepted on creation of Whatsapp entities.
  36090. func (m *WhatsappMutation) SetID(id uint64) {
  36091. m.id = &id
  36092. }
  36093. // ID returns the ID value in the mutation. Note that the ID is only available
  36094. // if it was provided to the builder or after it was returned from the database.
  36095. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36096. if m.id == nil {
  36097. return
  36098. }
  36099. return *m.id, true
  36100. }
  36101. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36102. // That means, if the mutation is applied within a transaction with an isolation level such
  36103. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36104. // or updated by the mutation.
  36105. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36106. switch {
  36107. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36108. id, exists := m.ID()
  36109. if exists {
  36110. return []uint64{id}, nil
  36111. }
  36112. fallthrough
  36113. case m.op.Is(OpUpdate | OpDelete):
  36114. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36115. default:
  36116. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36117. }
  36118. }
  36119. // SetCreatedAt sets the "created_at" field.
  36120. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36121. m.created_at = &t
  36122. }
  36123. // CreatedAt returns the value of the "created_at" field in the mutation.
  36124. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36125. v := m.created_at
  36126. if v == nil {
  36127. return
  36128. }
  36129. return *v, true
  36130. }
  36131. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36132. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36134. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36135. if !m.op.Is(OpUpdateOne) {
  36136. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36137. }
  36138. if m.id == nil || m.oldValue == nil {
  36139. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36140. }
  36141. oldValue, err := m.oldValue(ctx)
  36142. if err != nil {
  36143. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36144. }
  36145. return oldValue.CreatedAt, nil
  36146. }
  36147. // ResetCreatedAt resets all changes to the "created_at" field.
  36148. func (m *WhatsappMutation) ResetCreatedAt() {
  36149. m.created_at = nil
  36150. }
  36151. // SetUpdatedAt sets the "updated_at" field.
  36152. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36153. m.updated_at = &t
  36154. }
  36155. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36156. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36157. v := m.updated_at
  36158. if v == nil {
  36159. return
  36160. }
  36161. return *v, true
  36162. }
  36163. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36164. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36166. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36167. if !m.op.Is(OpUpdateOne) {
  36168. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36169. }
  36170. if m.id == nil || m.oldValue == nil {
  36171. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36172. }
  36173. oldValue, err := m.oldValue(ctx)
  36174. if err != nil {
  36175. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36176. }
  36177. return oldValue.UpdatedAt, nil
  36178. }
  36179. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36180. func (m *WhatsappMutation) ResetUpdatedAt() {
  36181. m.updated_at = nil
  36182. }
  36183. // SetStatus sets the "status" field.
  36184. func (m *WhatsappMutation) SetStatus(u uint8) {
  36185. m.status = &u
  36186. m.addstatus = nil
  36187. }
  36188. // Status returns the value of the "status" field in the mutation.
  36189. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36190. v := m.status
  36191. if v == nil {
  36192. return
  36193. }
  36194. return *v, true
  36195. }
  36196. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36197. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36199. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36200. if !m.op.Is(OpUpdateOne) {
  36201. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36202. }
  36203. if m.id == nil || m.oldValue == nil {
  36204. return v, errors.New("OldStatus requires an ID field in the mutation")
  36205. }
  36206. oldValue, err := m.oldValue(ctx)
  36207. if err != nil {
  36208. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36209. }
  36210. return oldValue.Status, nil
  36211. }
  36212. // AddStatus adds u to the "status" field.
  36213. func (m *WhatsappMutation) AddStatus(u int8) {
  36214. if m.addstatus != nil {
  36215. *m.addstatus += u
  36216. } else {
  36217. m.addstatus = &u
  36218. }
  36219. }
  36220. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36221. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36222. v := m.addstatus
  36223. if v == nil {
  36224. return
  36225. }
  36226. return *v, true
  36227. }
  36228. // ClearStatus clears the value of the "status" field.
  36229. func (m *WhatsappMutation) ClearStatus() {
  36230. m.status = nil
  36231. m.addstatus = nil
  36232. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36233. }
  36234. // StatusCleared returns if the "status" field was cleared in this mutation.
  36235. func (m *WhatsappMutation) StatusCleared() bool {
  36236. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36237. return ok
  36238. }
  36239. // ResetStatus resets all changes to the "status" field.
  36240. func (m *WhatsappMutation) ResetStatus() {
  36241. m.status = nil
  36242. m.addstatus = nil
  36243. delete(m.clearedFields, whatsapp.FieldStatus)
  36244. }
  36245. // SetDeletedAt sets the "deleted_at" field.
  36246. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36247. m.deleted_at = &t
  36248. }
  36249. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36250. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36251. v := m.deleted_at
  36252. if v == nil {
  36253. return
  36254. }
  36255. return *v, true
  36256. }
  36257. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36258. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36260. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36261. if !m.op.Is(OpUpdateOne) {
  36262. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36263. }
  36264. if m.id == nil || m.oldValue == nil {
  36265. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36266. }
  36267. oldValue, err := m.oldValue(ctx)
  36268. if err != nil {
  36269. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36270. }
  36271. return oldValue.DeletedAt, nil
  36272. }
  36273. // ClearDeletedAt clears the value of the "deleted_at" field.
  36274. func (m *WhatsappMutation) ClearDeletedAt() {
  36275. m.deleted_at = nil
  36276. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36277. }
  36278. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36279. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36280. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36281. return ok
  36282. }
  36283. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36284. func (m *WhatsappMutation) ResetDeletedAt() {
  36285. m.deleted_at = nil
  36286. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36287. }
  36288. // SetWaID sets the "wa_id" field.
  36289. func (m *WhatsappMutation) SetWaID(s string) {
  36290. m.wa_id = &s
  36291. }
  36292. // WaID returns the value of the "wa_id" field in the mutation.
  36293. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36294. v := m.wa_id
  36295. if v == nil {
  36296. return
  36297. }
  36298. return *v, true
  36299. }
  36300. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36301. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36303. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36304. if !m.op.Is(OpUpdateOne) {
  36305. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36306. }
  36307. if m.id == nil || m.oldValue == nil {
  36308. return v, errors.New("OldWaID requires an ID field in the mutation")
  36309. }
  36310. oldValue, err := m.oldValue(ctx)
  36311. if err != nil {
  36312. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36313. }
  36314. return oldValue.WaID, nil
  36315. }
  36316. // ClearWaID clears the value of the "wa_id" field.
  36317. func (m *WhatsappMutation) ClearWaID() {
  36318. m.wa_id = nil
  36319. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36320. }
  36321. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36322. func (m *WhatsappMutation) WaIDCleared() bool {
  36323. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36324. return ok
  36325. }
  36326. // ResetWaID resets all changes to the "wa_id" field.
  36327. func (m *WhatsappMutation) ResetWaID() {
  36328. m.wa_id = nil
  36329. delete(m.clearedFields, whatsapp.FieldWaID)
  36330. }
  36331. // SetWaName sets the "wa_name" field.
  36332. func (m *WhatsappMutation) SetWaName(s string) {
  36333. m.wa_name = &s
  36334. }
  36335. // WaName returns the value of the "wa_name" field in the mutation.
  36336. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36337. v := m.wa_name
  36338. if v == nil {
  36339. return
  36340. }
  36341. return *v, true
  36342. }
  36343. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36344. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36346. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36347. if !m.op.Is(OpUpdateOne) {
  36348. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36349. }
  36350. if m.id == nil || m.oldValue == nil {
  36351. return v, errors.New("OldWaName requires an ID field in the mutation")
  36352. }
  36353. oldValue, err := m.oldValue(ctx)
  36354. if err != nil {
  36355. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36356. }
  36357. return oldValue.WaName, nil
  36358. }
  36359. // ClearWaName clears the value of the "wa_name" field.
  36360. func (m *WhatsappMutation) ClearWaName() {
  36361. m.wa_name = nil
  36362. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36363. }
  36364. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36365. func (m *WhatsappMutation) WaNameCleared() bool {
  36366. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36367. return ok
  36368. }
  36369. // ResetWaName resets all changes to the "wa_name" field.
  36370. func (m *WhatsappMutation) ResetWaName() {
  36371. m.wa_name = nil
  36372. delete(m.clearedFields, whatsapp.FieldWaName)
  36373. }
  36374. // SetCallback sets the "callback" field.
  36375. func (m *WhatsappMutation) SetCallback(s string) {
  36376. m.callback = &s
  36377. }
  36378. // Callback returns the value of the "callback" field in the mutation.
  36379. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36380. v := m.callback
  36381. if v == nil {
  36382. return
  36383. }
  36384. return *v, true
  36385. }
  36386. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36387. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36389. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36390. if !m.op.Is(OpUpdateOne) {
  36391. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36392. }
  36393. if m.id == nil || m.oldValue == nil {
  36394. return v, errors.New("OldCallback requires an ID field in the mutation")
  36395. }
  36396. oldValue, err := m.oldValue(ctx)
  36397. if err != nil {
  36398. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36399. }
  36400. return oldValue.Callback, nil
  36401. }
  36402. // ClearCallback clears the value of the "callback" field.
  36403. func (m *WhatsappMutation) ClearCallback() {
  36404. m.callback = nil
  36405. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36406. }
  36407. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36408. func (m *WhatsappMutation) CallbackCleared() bool {
  36409. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36410. return ok
  36411. }
  36412. // ResetCallback resets all changes to the "callback" field.
  36413. func (m *WhatsappMutation) ResetCallback() {
  36414. m.callback = nil
  36415. delete(m.clearedFields, whatsapp.FieldCallback)
  36416. }
  36417. // SetAgentID sets the "agent_id" field.
  36418. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36419. m.agent = &u
  36420. }
  36421. // AgentID returns the value of the "agent_id" field in the mutation.
  36422. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36423. v := m.agent
  36424. if v == nil {
  36425. return
  36426. }
  36427. return *v, true
  36428. }
  36429. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36430. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36432. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36433. if !m.op.Is(OpUpdateOne) {
  36434. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36435. }
  36436. if m.id == nil || m.oldValue == nil {
  36437. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36438. }
  36439. oldValue, err := m.oldValue(ctx)
  36440. if err != nil {
  36441. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36442. }
  36443. return oldValue.AgentID, nil
  36444. }
  36445. // ResetAgentID resets all changes to the "agent_id" field.
  36446. func (m *WhatsappMutation) ResetAgentID() {
  36447. m.agent = nil
  36448. }
  36449. // SetAccount sets the "account" field.
  36450. func (m *WhatsappMutation) SetAccount(s string) {
  36451. m.account = &s
  36452. }
  36453. // Account returns the value of the "account" field in the mutation.
  36454. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36455. v := m.account
  36456. if v == nil {
  36457. return
  36458. }
  36459. return *v, true
  36460. }
  36461. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36462. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36464. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36465. if !m.op.Is(OpUpdateOne) {
  36466. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36467. }
  36468. if m.id == nil || m.oldValue == nil {
  36469. return v, errors.New("OldAccount requires an ID field in the mutation")
  36470. }
  36471. oldValue, err := m.oldValue(ctx)
  36472. if err != nil {
  36473. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36474. }
  36475. return oldValue.Account, nil
  36476. }
  36477. // ClearAccount clears the value of the "account" field.
  36478. func (m *WhatsappMutation) ClearAccount() {
  36479. m.account = nil
  36480. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36481. }
  36482. // AccountCleared returns if the "account" field was cleared in this mutation.
  36483. func (m *WhatsappMutation) AccountCleared() bool {
  36484. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36485. return ok
  36486. }
  36487. // ResetAccount resets all changes to the "account" field.
  36488. func (m *WhatsappMutation) ResetAccount() {
  36489. m.account = nil
  36490. delete(m.clearedFields, whatsapp.FieldAccount)
  36491. }
  36492. // SetCc sets the "cc" field.
  36493. func (m *WhatsappMutation) SetCc(s string) {
  36494. m.cc = &s
  36495. }
  36496. // Cc returns the value of the "cc" field in the mutation.
  36497. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36498. v := m.cc
  36499. if v == nil {
  36500. return
  36501. }
  36502. return *v, true
  36503. }
  36504. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36505. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36507. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36508. if !m.op.Is(OpUpdateOne) {
  36509. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36510. }
  36511. if m.id == nil || m.oldValue == nil {
  36512. return v, errors.New("OldCc requires an ID field in the mutation")
  36513. }
  36514. oldValue, err := m.oldValue(ctx)
  36515. if err != nil {
  36516. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36517. }
  36518. return oldValue.Cc, nil
  36519. }
  36520. // ResetCc resets all changes to the "cc" field.
  36521. func (m *WhatsappMutation) ResetCc() {
  36522. m.cc = nil
  36523. }
  36524. // SetPhone sets the "phone" field.
  36525. func (m *WhatsappMutation) SetPhone(s string) {
  36526. m.phone = &s
  36527. }
  36528. // Phone returns the value of the "phone" field in the mutation.
  36529. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36530. v := m.phone
  36531. if v == nil {
  36532. return
  36533. }
  36534. return *v, true
  36535. }
  36536. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36537. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36539. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36540. if !m.op.Is(OpUpdateOne) {
  36541. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36542. }
  36543. if m.id == nil || m.oldValue == nil {
  36544. return v, errors.New("OldPhone requires an ID field in the mutation")
  36545. }
  36546. oldValue, err := m.oldValue(ctx)
  36547. if err != nil {
  36548. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36549. }
  36550. return oldValue.Phone, nil
  36551. }
  36552. // ResetPhone resets all changes to the "phone" field.
  36553. func (m *WhatsappMutation) ResetPhone() {
  36554. m.phone = nil
  36555. }
  36556. // SetCcPhone sets the "cc_phone" field.
  36557. func (m *WhatsappMutation) SetCcPhone(s string) {
  36558. m.cc_phone = &s
  36559. }
  36560. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36561. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36562. v := m.cc_phone
  36563. if v == nil {
  36564. return
  36565. }
  36566. return *v, true
  36567. }
  36568. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36569. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36571. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36572. if !m.op.Is(OpUpdateOne) {
  36573. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36574. }
  36575. if m.id == nil || m.oldValue == nil {
  36576. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36577. }
  36578. oldValue, err := m.oldValue(ctx)
  36579. if err != nil {
  36580. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36581. }
  36582. return oldValue.CcPhone, nil
  36583. }
  36584. // ResetCcPhone resets all changes to the "cc_phone" field.
  36585. func (m *WhatsappMutation) ResetCcPhone() {
  36586. m.cc_phone = nil
  36587. }
  36588. // SetPhoneName sets the "phone_name" field.
  36589. func (m *WhatsappMutation) SetPhoneName(s string) {
  36590. m.phone_name = &s
  36591. }
  36592. // PhoneName returns the value of the "phone_name" field in the mutation.
  36593. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36594. v := m.phone_name
  36595. if v == nil {
  36596. return
  36597. }
  36598. return *v, true
  36599. }
  36600. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36601. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36603. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36604. if !m.op.Is(OpUpdateOne) {
  36605. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36606. }
  36607. if m.id == nil || m.oldValue == nil {
  36608. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36609. }
  36610. oldValue, err := m.oldValue(ctx)
  36611. if err != nil {
  36612. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36613. }
  36614. return oldValue.PhoneName, nil
  36615. }
  36616. // ResetPhoneName resets all changes to the "phone_name" field.
  36617. func (m *WhatsappMutation) ResetPhoneName() {
  36618. m.phone_name = nil
  36619. }
  36620. // SetPhoneStatus sets the "phone_status" field.
  36621. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36622. m.phone_status = &i
  36623. m.addphone_status = nil
  36624. }
  36625. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36626. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36627. v := m.phone_status
  36628. if v == nil {
  36629. return
  36630. }
  36631. return *v, true
  36632. }
  36633. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36634. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36636. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  36637. if !m.op.Is(OpUpdateOne) {
  36638. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  36639. }
  36640. if m.id == nil || m.oldValue == nil {
  36641. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  36642. }
  36643. oldValue, err := m.oldValue(ctx)
  36644. if err != nil {
  36645. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  36646. }
  36647. return oldValue.PhoneStatus, nil
  36648. }
  36649. // AddPhoneStatus adds i to the "phone_status" field.
  36650. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  36651. if m.addphone_status != nil {
  36652. *m.addphone_status += i
  36653. } else {
  36654. m.addphone_status = &i
  36655. }
  36656. }
  36657. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  36658. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  36659. v := m.addphone_status
  36660. if v == nil {
  36661. return
  36662. }
  36663. return *v, true
  36664. }
  36665. // ResetPhoneStatus resets all changes to the "phone_status" field.
  36666. func (m *WhatsappMutation) ResetPhoneStatus() {
  36667. m.phone_status = nil
  36668. m.addphone_status = nil
  36669. }
  36670. // SetOrganizationID sets the "organization_id" field.
  36671. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  36672. m.organization_id = &u
  36673. m.addorganization_id = nil
  36674. }
  36675. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36676. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  36677. v := m.organization_id
  36678. if v == nil {
  36679. return
  36680. }
  36681. return *v, true
  36682. }
  36683. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  36684. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36686. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36687. if !m.op.Is(OpUpdateOne) {
  36688. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36689. }
  36690. if m.id == nil || m.oldValue == nil {
  36691. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36692. }
  36693. oldValue, err := m.oldValue(ctx)
  36694. if err != nil {
  36695. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36696. }
  36697. return oldValue.OrganizationID, nil
  36698. }
  36699. // AddOrganizationID adds u to the "organization_id" field.
  36700. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  36701. if m.addorganization_id != nil {
  36702. *m.addorganization_id += u
  36703. } else {
  36704. m.addorganization_id = &u
  36705. }
  36706. }
  36707. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36708. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  36709. v := m.addorganization_id
  36710. if v == nil {
  36711. return
  36712. }
  36713. return *v, true
  36714. }
  36715. // ClearOrganizationID clears the value of the "organization_id" field.
  36716. func (m *WhatsappMutation) ClearOrganizationID() {
  36717. m.organization_id = nil
  36718. m.addorganization_id = nil
  36719. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  36720. }
  36721. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36722. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  36723. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  36724. return ok
  36725. }
  36726. // ResetOrganizationID resets all changes to the "organization_id" field.
  36727. func (m *WhatsappMutation) ResetOrganizationID() {
  36728. m.organization_id = nil
  36729. m.addorganization_id = nil
  36730. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  36731. }
  36732. // SetAPIBase sets the "api_base" field.
  36733. func (m *WhatsappMutation) SetAPIBase(s string) {
  36734. m.api_base = &s
  36735. }
  36736. // APIBase returns the value of the "api_base" field in the mutation.
  36737. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  36738. v := m.api_base
  36739. if v == nil {
  36740. return
  36741. }
  36742. return *v, true
  36743. }
  36744. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  36745. // If the Whatsapp 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 *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36748. if !m.op.Is(OpUpdateOne) {
  36749. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36750. }
  36751. if m.id == nil || m.oldValue == nil {
  36752. return v, errors.New("OldAPIBase 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 OldAPIBase: %w", err)
  36757. }
  36758. return oldValue.APIBase, nil
  36759. }
  36760. // ClearAPIBase clears the value of the "api_base" field.
  36761. func (m *WhatsappMutation) ClearAPIBase() {
  36762. m.api_base = nil
  36763. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  36764. }
  36765. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  36766. func (m *WhatsappMutation) APIBaseCleared() bool {
  36767. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  36768. return ok
  36769. }
  36770. // ResetAPIBase resets all changes to the "api_base" field.
  36771. func (m *WhatsappMutation) ResetAPIBase() {
  36772. m.api_base = nil
  36773. delete(m.clearedFields, whatsapp.FieldAPIBase)
  36774. }
  36775. // SetAPIKey sets the "api_key" field.
  36776. func (m *WhatsappMutation) SetAPIKey(s string) {
  36777. m.api_key = &s
  36778. }
  36779. // APIKey returns the value of the "api_key" field in the mutation.
  36780. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  36781. v := m.api_key
  36782. if v == nil {
  36783. return
  36784. }
  36785. return *v, true
  36786. }
  36787. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  36788. // If the Whatsapp 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 *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  36791. if !m.op.Is(OpUpdateOne) {
  36792. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  36793. }
  36794. if m.id == nil || m.oldValue == nil {
  36795. return v, errors.New("OldAPIKey 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 OldAPIKey: %w", err)
  36800. }
  36801. return oldValue.APIKey, nil
  36802. }
  36803. // ClearAPIKey clears the value of the "api_key" field.
  36804. func (m *WhatsappMutation) ClearAPIKey() {
  36805. m.api_key = nil
  36806. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  36807. }
  36808. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  36809. func (m *WhatsappMutation) APIKeyCleared() bool {
  36810. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  36811. return ok
  36812. }
  36813. // ResetAPIKey resets all changes to the "api_key" field.
  36814. func (m *WhatsappMutation) ResetAPIKey() {
  36815. m.api_key = nil
  36816. delete(m.clearedFields, whatsapp.FieldAPIKey)
  36817. }
  36818. // SetAllowList sets the "allow_list" field.
  36819. func (m *WhatsappMutation) SetAllowList(s []string) {
  36820. m.allow_list = &s
  36821. m.appendallow_list = nil
  36822. }
  36823. // AllowList returns the value of the "allow_list" field in the mutation.
  36824. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  36825. v := m.allow_list
  36826. if v == nil {
  36827. return
  36828. }
  36829. return *v, true
  36830. }
  36831. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  36832. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36834. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  36835. if !m.op.Is(OpUpdateOne) {
  36836. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  36837. }
  36838. if m.id == nil || m.oldValue == nil {
  36839. return v, errors.New("OldAllowList requires an ID field in the mutation")
  36840. }
  36841. oldValue, err := m.oldValue(ctx)
  36842. if err != nil {
  36843. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  36844. }
  36845. return oldValue.AllowList, nil
  36846. }
  36847. // AppendAllowList adds s to the "allow_list" field.
  36848. func (m *WhatsappMutation) AppendAllowList(s []string) {
  36849. m.appendallow_list = append(m.appendallow_list, s...)
  36850. }
  36851. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  36852. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  36853. if len(m.appendallow_list) == 0 {
  36854. return nil, false
  36855. }
  36856. return m.appendallow_list, true
  36857. }
  36858. // ClearAllowList clears the value of the "allow_list" field.
  36859. func (m *WhatsappMutation) ClearAllowList() {
  36860. m.allow_list = nil
  36861. m.appendallow_list = nil
  36862. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  36863. }
  36864. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  36865. func (m *WhatsappMutation) AllowListCleared() bool {
  36866. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  36867. return ok
  36868. }
  36869. // ResetAllowList resets all changes to the "allow_list" field.
  36870. func (m *WhatsappMutation) ResetAllowList() {
  36871. m.allow_list = nil
  36872. m.appendallow_list = nil
  36873. delete(m.clearedFields, whatsapp.FieldAllowList)
  36874. }
  36875. // SetGroupAllowList sets the "group_allow_list" field.
  36876. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  36877. m.group_allow_list = &s
  36878. m.appendgroup_allow_list = nil
  36879. }
  36880. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  36881. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  36882. v := m.group_allow_list
  36883. if v == nil {
  36884. return
  36885. }
  36886. return *v, true
  36887. }
  36888. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  36889. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36891. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  36892. if !m.op.Is(OpUpdateOne) {
  36893. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  36894. }
  36895. if m.id == nil || m.oldValue == nil {
  36896. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  36897. }
  36898. oldValue, err := m.oldValue(ctx)
  36899. if err != nil {
  36900. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  36901. }
  36902. return oldValue.GroupAllowList, nil
  36903. }
  36904. // AppendGroupAllowList adds s to the "group_allow_list" field.
  36905. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  36906. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  36907. }
  36908. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  36909. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  36910. if len(m.appendgroup_allow_list) == 0 {
  36911. return nil, false
  36912. }
  36913. return m.appendgroup_allow_list, true
  36914. }
  36915. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  36916. func (m *WhatsappMutation) ClearGroupAllowList() {
  36917. m.group_allow_list = nil
  36918. m.appendgroup_allow_list = nil
  36919. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  36920. }
  36921. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  36922. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  36923. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  36924. return ok
  36925. }
  36926. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  36927. func (m *WhatsappMutation) ResetGroupAllowList() {
  36928. m.group_allow_list = nil
  36929. m.appendgroup_allow_list = nil
  36930. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  36931. }
  36932. // SetBlockList sets the "block_list" field.
  36933. func (m *WhatsappMutation) SetBlockList(s []string) {
  36934. m.block_list = &s
  36935. m.appendblock_list = nil
  36936. }
  36937. // BlockList returns the value of the "block_list" field in the mutation.
  36938. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  36939. v := m.block_list
  36940. if v == nil {
  36941. return
  36942. }
  36943. return *v, true
  36944. }
  36945. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  36946. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36948. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  36949. if !m.op.Is(OpUpdateOne) {
  36950. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  36951. }
  36952. if m.id == nil || m.oldValue == nil {
  36953. return v, errors.New("OldBlockList requires an ID field in the mutation")
  36954. }
  36955. oldValue, err := m.oldValue(ctx)
  36956. if err != nil {
  36957. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  36958. }
  36959. return oldValue.BlockList, nil
  36960. }
  36961. // AppendBlockList adds s to the "block_list" field.
  36962. func (m *WhatsappMutation) AppendBlockList(s []string) {
  36963. m.appendblock_list = append(m.appendblock_list, s...)
  36964. }
  36965. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  36966. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  36967. if len(m.appendblock_list) == 0 {
  36968. return nil, false
  36969. }
  36970. return m.appendblock_list, true
  36971. }
  36972. // ClearBlockList clears the value of the "block_list" field.
  36973. func (m *WhatsappMutation) ClearBlockList() {
  36974. m.block_list = nil
  36975. m.appendblock_list = nil
  36976. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  36977. }
  36978. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  36979. func (m *WhatsappMutation) BlockListCleared() bool {
  36980. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  36981. return ok
  36982. }
  36983. // ResetBlockList resets all changes to the "block_list" field.
  36984. func (m *WhatsappMutation) ResetBlockList() {
  36985. m.block_list = nil
  36986. m.appendblock_list = nil
  36987. delete(m.clearedFields, whatsapp.FieldBlockList)
  36988. }
  36989. // SetGroupBlockList sets the "group_block_list" field.
  36990. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  36991. m.group_block_list = &s
  36992. m.appendgroup_block_list = nil
  36993. }
  36994. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  36995. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  36996. v := m.group_block_list
  36997. if v == nil {
  36998. return
  36999. }
  37000. return *v, true
  37001. }
  37002. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  37003. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37005. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  37006. if !m.op.Is(OpUpdateOne) {
  37007. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  37008. }
  37009. if m.id == nil || m.oldValue == nil {
  37010. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  37011. }
  37012. oldValue, err := m.oldValue(ctx)
  37013. if err != nil {
  37014. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  37015. }
  37016. return oldValue.GroupBlockList, nil
  37017. }
  37018. // AppendGroupBlockList adds s to the "group_block_list" field.
  37019. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  37020. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  37021. }
  37022. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  37023. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  37024. if len(m.appendgroup_block_list) == 0 {
  37025. return nil, false
  37026. }
  37027. return m.appendgroup_block_list, true
  37028. }
  37029. // ClearGroupBlockList clears the value of the "group_block_list" field.
  37030. func (m *WhatsappMutation) ClearGroupBlockList() {
  37031. m.group_block_list = nil
  37032. m.appendgroup_block_list = nil
  37033. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  37034. }
  37035. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  37036. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  37037. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  37038. return ok
  37039. }
  37040. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  37041. func (m *WhatsappMutation) ResetGroupBlockList() {
  37042. m.group_block_list = nil
  37043. m.appendgroup_block_list = nil
  37044. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  37045. }
  37046. // ClearAgent clears the "agent" edge to the Agent entity.
  37047. func (m *WhatsappMutation) ClearAgent() {
  37048. m.clearedagent = true
  37049. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  37050. }
  37051. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  37052. func (m *WhatsappMutation) AgentCleared() bool {
  37053. return m.clearedagent
  37054. }
  37055. // AgentIDs returns the "agent" edge IDs in the mutation.
  37056. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37057. // AgentID instead. It exists only for internal usage by the builders.
  37058. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  37059. if id := m.agent; id != nil {
  37060. ids = append(ids, *id)
  37061. }
  37062. return
  37063. }
  37064. // ResetAgent resets all changes to the "agent" edge.
  37065. func (m *WhatsappMutation) ResetAgent() {
  37066. m.agent = nil
  37067. m.clearedagent = false
  37068. }
  37069. // Where appends a list predicates to the WhatsappMutation builder.
  37070. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  37071. m.predicates = append(m.predicates, ps...)
  37072. }
  37073. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  37074. // users can use type-assertion to append predicates that do not depend on any generated package.
  37075. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  37076. p := make([]predicate.Whatsapp, len(ps))
  37077. for i := range ps {
  37078. p[i] = ps[i]
  37079. }
  37080. m.Where(p...)
  37081. }
  37082. // Op returns the operation name.
  37083. func (m *WhatsappMutation) Op() Op {
  37084. return m.op
  37085. }
  37086. // SetOp allows setting the mutation operation.
  37087. func (m *WhatsappMutation) SetOp(op Op) {
  37088. m.op = op
  37089. }
  37090. // Type returns the node type of this mutation (Whatsapp).
  37091. func (m *WhatsappMutation) Type() string {
  37092. return m.typ
  37093. }
  37094. // Fields returns all fields that were changed during this mutation. Note that in
  37095. // order to get all numeric fields that were incremented/decremented, call
  37096. // AddedFields().
  37097. func (m *WhatsappMutation) Fields() []string {
  37098. fields := make([]string, 0, 21)
  37099. if m.created_at != nil {
  37100. fields = append(fields, whatsapp.FieldCreatedAt)
  37101. }
  37102. if m.updated_at != nil {
  37103. fields = append(fields, whatsapp.FieldUpdatedAt)
  37104. }
  37105. if m.status != nil {
  37106. fields = append(fields, whatsapp.FieldStatus)
  37107. }
  37108. if m.deleted_at != nil {
  37109. fields = append(fields, whatsapp.FieldDeletedAt)
  37110. }
  37111. if m.wa_id != nil {
  37112. fields = append(fields, whatsapp.FieldWaID)
  37113. }
  37114. if m.wa_name != nil {
  37115. fields = append(fields, whatsapp.FieldWaName)
  37116. }
  37117. if m.callback != nil {
  37118. fields = append(fields, whatsapp.FieldCallback)
  37119. }
  37120. if m.agent != nil {
  37121. fields = append(fields, whatsapp.FieldAgentID)
  37122. }
  37123. if m.account != nil {
  37124. fields = append(fields, whatsapp.FieldAccount)
  37125. }
  37126. if m.cc != nil {
  37127. fields = append(fields, whatsapp.FieldCc)
  37128. }
  37129. if m.phone != nil {
  37130. fields = append(fields, whatsapp.FieldPhone)
  37131. }
  37132. if m.cc_phone != nil {
  37133. fields = append(fields, whatsapp.FieldCcPhone)
  37134. }
  37135. if m.phone_name != nil {
  37136. fields = append(fields, whatsapp.FieldPhoneName)
  37137. }
  37138. if m.phone_status != nil {
  37139. fields = append(fields, whatsapp.FieldPhoneStatus)
  37140. }
  37141. if m.organization_id != nil {
  37142. fields = append(fields, whatsapp.FieldOrganizationID)
  37143. }
  37144. if m.api_base != nil {
  37145. fields = append(fields, whatsapp.FieldAPIBase)
  37146. }
  37147. if m.api_key != nil {
  37148. fields = append(fields, whatsapp.FieldAPIKey)
  37149. }
  37150. if m.allow_list != nil {
  37151. fields = append(fields, whatsapp.FieldAllowList)
  37152. }
  37153. if m.group_allow_list != nil {
  37154. fields = append(fields, whatsapp.FieldGroupAllowList)
  37155. }
  37156. if m.block_list != nil {
  37157. fields = append(fields, whatsapp.FieldBlockList)
  37158. }
  37159. if m.group_block_list != nil {
  37160. fields = append(fields, whatsapp.FieldGroupBlockList)
  37161. }
  37162. return fields
  37163. }
  37164. // Field returns the value of a field with the given name. The second boolean
  37165. // return value indicates that this field was not set, or was not defined in the
  37166. // schema.
  37167. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37168. switch name {
  37169. case whatsapp.FieldCreatedAt:
  37170. return m.CreatedAt()
  37171. case whatsapp.FieldUpdatedAt:
  37172. return m.UpdatedAt()
  37173. case whatsapp.FieldStatus:
  37174. return m.Status()
  37175. case whatsapp.FieldDeletedAt:
  37176. return m.DeletedAt()
  37177. case whatsapp.FieldWaID:
  37178. return m.WaID()
  37179. case whatsapp.FieldWaName:
  37180. return m.WaName()
  37181. case whatsapp.FieldCallback:
  37182. return m.Callback()
  37183. case whatsapp.FieldAgentID:
  37184. return m.AgentID()
  37185. case whatsapp.FieldAccount:
  37186. return m.Account()
  37187. case whatsapp.FieldCc:
  37188. return m.Cc()
  37189. case whatsapp.FieldPhone:
  37190. return m.Phone()
  37191. case whatsapp.FieldCcPhone:
  37192. return m.CcPhone()
  37193. case whatsapp.FieldPhoneName:
  37194. return m.PhoneName()
  37195. case whatsapp.FieldPhoneStatus:
  37196. return m.PhoneStatus()
  37197. case whatsapp.FieldOrganizationID:
  37198. return m.OrganizationID()
  37199. case whatsapp.FieldAPIBase:
  37200. return m.APIBase()
  37201. case whatsapp.FieldAPIKey:
  37202. return m.APIKey()
  37203. case whatsapp.FieldAllowList:
  37204. return m.AllowList()
  37205. case whatsapp.FieldGroupAllowList:
  37206. return m.GroupAllowList()
  37207. case whatsapp.FieldBlockList:
  37208. return m.BlockList()
  37209. case whatsapp.FieldGroupBlockList:
  37210. return m.GroupBlockList()
  37211. }
  37212. return nil, false
  37213. }
  37214. // OldField returns the old value of the field from the database. An error is
  37215. // returned if the mutation operation is not UpdateOne, or the query to the
  37216. // database failed.
  37217. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37218. switch name {
  37219. case whatsapp.FieldCreatedAt:
  37220. return m.OldCreatedAt(ctx)
  37221. case whatsapp.FieldUpdatedAt:
  37222. return m.OldUpdatedAt(ctx)
  37223. case whatsapp.FieldStatus:
  37224. return m.OldStatus(ctx)
  37225. case whatsapp.FieldDeletedAt:
  37226. return m.OldDeletedAt(ctx)
  37227. case whatsapp.FieldWaID:
  37228. return m.OldWaID(ctx)
  37229. case whatsapp.FieldWaName:
  37230. return m.OldWaName(ctx)
  37231. case whatsapp.FieldCallback:
  37232. return m.OldCallback(ctx)
  37233. case whatsapp.FieldAgentID:
  37234. return m.OldAgentID(ctx)
  37235. case whatsapp.FieldAccount:
  37236. return m.OldAccount(ctx)
  37237. case whatsapp.FieldCc:
  37238. return m.OldCc(ctx)
  37239. case whatsapp.FieldPhone:
  37240. return m.OldPhone(ctx)
  37241. case whatsapp.FieldCcPhone:
  37242. return m.OldCcPhone(ctx)
  37243. case whatsapp.FieldPhoneName:
  37244. return m.OldPhoneName(ctx)
  37245. case whatsapp.FieldPhoneStatus:
  37246. return m.OldPhoneStatus(ctx)
  37247. case whatsapp.FieldOrganizationID:
  37248. return m.OldOrganizationID(ctx)
  37249. case whatsapp.FieldAPIBase:
  37250. return m.OldAPIBase(ctx)
  37251. case whatsapp.FieldAPIKey:
  37252. return m.OldAPIKey(ctx)
  37253. case whatsapp.FieldAllowList:
  37254. return m.OldAllowList(ctx)
  37255. case whatsapp.FieldGroupAllowList:
  37256. return m.OldGroupAllowList(ctx)
  37257. case whatsapp.FieldBlockList:
  37258. return m.OldBlockList(ctx)
  37259. case whatsapp.FieldGroupBlockList:
  37260. return m.OldGroupBlockList(ctx)
  37261. }
  37262. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37263. }
  37264. // SetField sets the value of a field with the given name. It returns an error if
  37265. // the field is not defined in the schema, or if the type mismatched the field
  37266. // type.
  37267. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37268. switch name {
  37269. case whatsapp.FieldCreatedAt:
  37270. v, ok := value.(time.Time)
  37271. if !ok {
  37272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37273. }
  37274. m.SetCreatedAt(v)
  37275. return nil
  37276. case whatsapp.FieldUpdatedAt:
  37277. v, ok := value.(time.Time)
  37278. if !ok {
  37279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37280. }
  37281. m.SetUpdatedAt(v)
  37282. return nil
  37283. case whatsapp.FieldStatus:
  37284. v, ok := value.(uint8)
  37285. if !ok {
  37286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37287. }
  37288. m.SetStatus(v)
  37289. return nil
  37290. case whatsapp.FieldDeletedAt:
  37291. v, ok := value.(time.Time)
  37292. if !ok {
  37293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37294. }
  37295. m.SetDeletedAt(v)
  37296. return nil
  37297. case whatsapp.FieldWaID:
  37298. v, ok := value.(string)
  37299. if !ok {
  37300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37301. }
  37302. m.SetWaID(v)
  37303. return nil
  37304. case whatsapp.FieldWaName:
  37305. v, ok := value.(string)
  37306. if !ok {
  37307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37308. }
  37309. m.SetWaName(v)
  37310. return nil
  37311. case whatsapp.FieldCallback:
  37312. v, ok := value.(string)
  37313. if !ok {
  37314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37315. }
  37316. m.SetCallback(v)
  37317. return nil
  37318. case whatsapp.FieldAgentID:
  37319. v, ok := value.(uint64)
  37320. if !ok {
  37321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37322. }
  37323. m.SetAgentID(v)
  37324. return nil
  37325. case whatsapp.FieldAccount:
  37326. v, ok := value.(string)
  37327. if !ok {
  37328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37329. }
  37330. m.SetAccount(v)
  37331. return nil
  37332. case whatsapp.FieldCc:
  37333. v, ok := value.(string)
  37334. if !ok {
  37335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37336. }
  37337. m.SetCc(v)
  37338. return nil
  37339. case whatsapp.FieldPhone:
  37340. v, ok := value.(string)
  37341. if !ok {
  37342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37343. }
  37344. m.SetPhone(v)
  37345. return nil
  37346. case whatsapp.FieldCcPhone:
  37347. v, ok := value.(string)
  37348. if !ok {
  37349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37350. }
  37351. m.SetCcPhone(v)
  37352. return nil
  37353. case whatsapp.FieldPhoneName:
  37354. v, ok := value.(string)
  37355. if !ok {
  37356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37357. }
  37358. m.SetPhoneName(v)
  37359. return nil
  37360. case whatsapp.FieldPhoneStatus:
  37361. v, ok := value.(int8)
  37362. if !ok {
  37363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37364. }
  37365. m.SetPhoneStatus(v)
  37366. return nil
  37367. case whatsapp.FieldOrganizationID:
  37368. v, ok := value.(uint64)
  37369. if !ok {
  37370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37371. }
  37372. m.SetOrganizationID(v)
  37373. return nil
  37374. case whatsapp.FieldAPIBase:
  37375. v, ok := value.(string)
  37376. if !ok {
  37377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37378. }
  37379. m.SetAPIBase(v)
  37380. return nil
  37381. case whatsapp.FieldAPIKey:
  37382. v, ok := value.(string)
  37383. if !ok {
  37384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37385. }
  37386. m.SetAPIKey(v)
  37387. return nil
  37388. case whatsapp.FieldAllowList:
  37389. v, ok := value.([]string)
  37390. if !ok {
  37391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37392. }
  37393. m.SetAllowList(v)
  37394. return nil
  37395. case whatsapp.FieldGroupAllowList:
  37396. v, ok := value.([]string)
  37397. if !ok {
  37398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37399. }
  37400. m.SetGroupAllowList(v)
  37401. return nil
  37402. case whatsapp.FieldBlockList:
  37403. v, ok := value.([]string)
  37404. if !ok {
  37405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37406. }
  37407. m.SetBlockList(v)
  37408. return nil
  37409. case whatsapp.FieldGroupBlockList:
  37410. v, ok := value.([]string)
  37411. if !ok {
  37412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37413. }
  37414. m.SetGroupBlockList(v)
  37415. return nil
  37416. }
  37417. return fmt.Errorf("unknown Whatsapp field %s", name)
  37418. }
  37419. // AddedFields returns all numeric fields that were incremented/decremented during
  37420. // this mutation.
  37421. func (m *WhatsappMutation) AddedFields() []string {
  37422. var fields []string
  37423. if m.addstatus != nil {
  37424. fields = append(fields, whatsapp.FieldStatus)
  37425. }
  37426. if m.addphone_status != nil {
  37427. fields = append(fields, whatsapp.FieldPhoneStatus)
  37428. }
  37429. if m.addorganization_id != nil {
  37430. fields = append(fields, whatsapp.FieldOrganizationID)
  37431. }
  37432. return fields
  37433. }
  37434. // AddedField returns the numeric value that was incremented/decremented on a field
  37435. // with the given name. The second boolean return value indicates that this field
  37436. // was not set, or was not defined in the schema.
  37437. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37438. switch name {
  37439. case whatsapp.FieldStatus:
  37440. return m.AddedStatus()
  37441. case whatsapp.FieldPhoneStatus:
  37442. return m.AddedPhoneStatus()
  37443. case whatsapp.FieldOrganizationID:
  37444. return m.AddedOrganizationID()
  37445. }
  37446. return nil, false
  37447. }
  37448. // AddField adds the value to the field with the given name. It returns an error if
  37449. // the field is not defined in the schema, or if the type mismatched the field
  37450. // type.
  37451. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37452. switch name {
  37453. case whatsapp.FieldStatus:
  37454. v, ok := value.(int8)
  37455. if !ok {
  37456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37457. }
  37458. m.AddStatus(v)
  37459. return nil
  37460. case whatsapp.FieldPhoneStatus:
  37461. v, ok := value.(int8)
  37462. if !ok {
  37463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37464. }
  37465. m.AddPhoneStatus(v)
  37466. return nil
  37467. case whatsapp.FieldOrganizationID:
  37468. v, ok := value.(int64)
  37469. if !ok {
  37470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37471. }
  37472. m.AddOrganizationID(v)
  37473. return nil
  37474. }
  37475. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37476. }
  37477. // ClearedFields returns all nullable fields that were cleared during this
  37478. // mutation.
  37479. func (m *WhatsappMutation) ClearedFields() []string {
  37480. var fields []string
  37481. if m.FieldCleared(whatsapp.FieldStatus) {
  37482. fields = append(fields, whatsapp.FieldStatus)
  37483. }
  37484. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37485. fields = append(fields, whatsapp.FieldDeletedAt)
  37486. }
  37487. if m.FieldCleared(whatsapp.FieldWaID) {
  37488. fields = append(fields, whatsapp.FieldWaID)
  37489. }
  37490. if m.FieldCleared(whatsapp.FieldWaName) {
  37491. fields = append(fields, whatsapp.FieldWaName)
  37492. }
  37493. if m.FieldCleared(whatsapp.FieldCallback) {
  37494. fields = append(fields, whatsapp.FieldCallback)
  37495. }
  37496. if m.FieldCleared(whatsapp.FieldAccount) {
  37497. fields = append(fields, whatsapp.FieldAccount)
  37498. }
  37499. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37500. fields = append(fields, whatsapp.FieldOrganizationID)
  37501. }
  37502. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37503. fields = append(fields, whatsapp.FieldAPIBase)
  37504. }
  37505. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37506. fields = append(fields, whatsapp.FieldAPIKey)
  37507. }
  37508. if m.FieldCleared(whatsapp.FieldAllowList) {
  37509. fields = append(fields, whatsapp.FieldAllowList)
  37510. }
  37511. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37512. fields = append(fields, whatsapp.FieldGroupAllowList)
  37513. }
  37514. if m.FieldCleared(whatsapp.FieldBlockList) {
  37515. fields = append(fields, whatsapp.FieldBlockList)
  37516. }
  37517. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37518. fields = append(fields, whatsapp.FieldGroupBlockList)
  37519. }
  37520. return fields
  37521. }
  37522. // FieldCleared returns a boolean indicating if a field with the given name was
  37523. // cleared in this mutation.
  37524. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37525. _, ok := m.clearedFields[name]
  37526. return ok
  37527. }
  37528. // ClearField clears the value of the field with the given name. It returns an
  37529. // error if the field is not defined in the schema.
  37530. func (m *WhatsappMutation) ClearField(name string) error {
  37531. switch name {
  37532. case whatsapp.FieldStatus:
  37533. m.ClearStatus()
  37534. return nil
  37535. case whatsapp.FieldDeletedAt:
  37536. m.ClearDeletedAt()
  37537. return nil
  37538. case whatsapp.FieldWaID:
  37539. m.ClearWaID()
  37540. return nil
  37541. case whatsapp.FieldWaName:
  37542. m.ClearWaName()
  37543. return nil
  37544. case whatsapp.FieldCallback:
  37545. m.ClearCallback()
  37546. return nil
  37547. case whatsapp.FieldAccount:
  37548. m.ClearAccount()
  37549. return nil
  37550. case whatsapp.FieldOrganizationID:
  37551. m.ClearOrganizationID()
  37552. return nil
  37553. case whatsapp.FieldAPIBase:
  37554. m.ClearAPIBase()
  37555. return nil
  37556. case whatsapp.FieldAPIKey:
  37557. m.ClearAPIKey()
  37558. return nil
  37559. case whatsapp.FieldAllowList:
  37560. m.ClearAllowList()
  37561. return nil
  37562. case whatsapp.FieldGroupAllowList:
  37563. m.ClearGroupAllowList()
  37564. return nil
  37565. case whatsapp.FieldBlockList:
  37566. m.ClearBlockList()
  37567. return nil
  37568. case whatsapp.FieldGroupBlockList:
  37569. m.ClearGroupBlockList()
  37570. return nil
  37571. }
  37572. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37573. }
  37574. // ResetField resets all changes in the mutation for the field with the given name.
  37575. // It returns an error if the field is not defined in the schema.
  37576. func (m *WhatsappMutation) ResetField(name string) error {
  37577. switch name {
  37578. case whatsapp.FieldCreatedAt:
  37579. m.ResetCreatedAt()
  37580. return nil
  37581. case whatsapp.FieldUpdatedAt:
  37582. m.ResetUpdatedAt()
  37583. return nil
  37584. case whatsapp.FieldStatus:
  37585. m.ResetStatus()
  37586. return nil
  37587. case whatsapp.FieldDeletedAt:
  37588. m.ResetDeletedAt()
  37589. return nil
  37590. case whatsapp.FieldWaID:
  37591. m.ResetWaID()
  37592. return nil
  37593. case whatsapp.FieldWaName:
  37594. m.ResetWaName()
  37595. return nil
  37596. case whatsapp.FieldCallback:
  37597. m.ResetCallback()
  37598. return nil
  37599. case whatsapp.FieldAgentID:
  37600. m.ResetAgentID()
  37601. return nil
  37602. case whatsapp.FieldAccount:
  37603. m.ResetAccount()
  37604. return nil
  37605. case whatsapp.FieldCc:
  37606. m.ResetCc()
  37607. return nil
  37608. case whatsapp.FieldPhone:
  37609. m.ResetPhone()
  37610. return nil
  37611. case whatsapp.FieldCcPhone:
  37612. m.ResetCcPhone()
  37613. return nil
  37614. case whatsapp.FieldPhoneName:
  37615. m.ResetPhoneName()
  37616. return nil
  37617. case whatsapp.FieldPhoneStatus:
  37618. m.ResetPhoneStatus()
  37619. return nil
  37620. case whatsapp.FieldOrganizationID:
  37621. m.ResetOrganizationID()
  37622. return nil
  37623. case whatsapp.FieldAPIBase:
  37624. m.ResetAPIBase()
  37625. return nil
  37626. case whatsapp.FieldAPIKey:
  37627. m.ResetAPIKey()
  37628. return nil
  37629. case whatsapp.FieldAllowList:
  37630. m.ResetAllowList()
  37631. return nil
  37632. case whatsapp.FieldGroupAllowList:
  37633. m.ResetGroupAllowList()
  37634. return nil
  37635. case whatsapp.FieldBlockList:
  37636. m.ResetBlockList()
  37637. return nil
  37638. case whatsapp.FieldGroupBlockList:
  37639. m.ResetGroupBlockList()
  37640. return nil
  37641. }
  37642. return fmt.Errorf("unknown Whatsapp field %s", name)
  37643. }
  37644. // AddedEdges returns all edge names that were set/added in this mutation.
  37645. func (m *WhatsappMutation) AddedEdges() []string {
  37646. edges := make([]string, 0, 1)
  37647. if m.agent != nil {
  37648. edges = append(edges, whatsapp.EdgeAgent)
  37649. }
  37650. return edges
  37651. }
  37652. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37653. // name in this mutation.
  37654. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  37655. switch name {
  37656. case whatsapp.EdgeAgent:
  37657. if id := m.agent; id != nil {
  37658. return []ent.Value{*id}
  37659. }
  37660. }
  37661. return nil
  37662. }
  37663. // RemovedEdges returns all edge names that were removed in this mutation.
  37664. func (m *WhatsappMutation) RemovedEdges() []string {
  37665. edges := make([]string, 0, 1)
  37666. return edges
  37667. }
  37668. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37669. // the given name in this mutation.
  37670. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  37671. return nil
  37672. }
  37673. // ClearedEdges returns all edge names that were cleared in this mutation.
  37674. func (m *WhatsappMutation) ClearedEdges() []string {
  37675. edges := make([]string, 0, 1)
  37676. if m.clearedagent {
  37677. edges = append(edges, whatsapp.EdgeAgent)
  37678. }
  37679. return edges
  37680. }
  37681. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37682. // was cleared in this mutation.
  37683. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  37684. switch name {
  37685. case whatsapp.EdgeAgent:
  37686. return m.clearedagent
  37687. }
  37688. return false
  37689. }
  37690. // ClearEdge clears the value of the edge with the given name. It returns an error
  37691. // if that edge is not defined in the schema.
  37692. func (m *WhatsappMutation) ClearEdge(name string) error {
  37693. switch name {
  37694. case whatsapp.EdgeAgent:
  37695. m.ClearAgent()
  37696. return nil
  37697. }
  37698. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  37699. }
  37700. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37701. // It returns an error if the edge is not defined in the schema.
  37702. func (m *WhatsappMutation) ResetEdge(name string) error {
  37703. switch name {
  37704. case whatsapp.EdgeAgent:
  37705. m.ResetAgent()
  37706. return nil
  37707. }
  37708. return fmt.Errorf("unknown Whatsapp edge %s", name)
  37709. }
  37710. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  37711. type WhatsappChannelMutation struct {
  37712. config
  37713. op Op
  37714. typ string
  37715. id *uint64
  37716. created_at *time.Time
  37717. updated_at *time.Time
  37718. status *uint8
  37719. addstatus *int8
  37720. deleted_at *time.Time
  37721. ak *string
  37722. sk *string
  37723. wa_id *string
  37724. wa_name *string
  37725. waba_id *uint64
  37726. addwaba_id *int64
  37727. business_id *uint64
  37728. addbusiness_id *int64
  37729. organization_id *uint64
  37730. addorganization_id *int64
  37731. verify_account *string
  37732. clearedFields map[string]struct{}
  37733. done bool
  37734. oldValue func(context.Context) (*WhatsappChannel, error)
  37735. predicates []predicate.WhatsappChannel
  37736. }
  37737. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  37738. // whatsappchannelOption allows management of the mutation configuration using functional options.
  37739. type whatsappchannelOption func(*WhatsappChannelMutation)
  37740. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  37741. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  37742. m := &WhatsappChannelMutation{
  37743. config: c,
  37744. op: op,
  37745. typ: TypeWhatsappChannel,
  37746. clearedFields: make(map[string]struct{}),
  37747. }
  37748. for _, opt := range opts {
  37749. opt(m)
  37750. }
  37751. return m
  37752. }
  37753. // withWhatsappChannelID sets the ID field of the mutation.
  37754. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  37755. return func(m *WhatsappChannelMutation) {
  37756. var (
  37757. err error
  37758. once sync.Once
  37759. value *WhatsappChannel
  37760. )
  37761. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  37762. once.Do(func() {
  37763. if m.done {
  37764. err = errors.New("querying old values post mutation is not allowed")
  37765. } else {
  37766. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  37767. }
  37768. })
  37769. return value, err
  37770. }
  37771. m.id = &id
  37772. }
  37773. }
  37774. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  37775. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  37776. return func(m *WhatsappChannelMutation) {
  37777. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  37778. return node, nil
  37779. }
  37780. m.id = &node.ID
  37781. }
  37782. }
  37783. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37784. // executed in a transaction (ent.Tx), a transactional client is returned.
  37785. func (m WhatsappChannelMutation) Client() *Client {
  37786. client := &Client{config: m.config}
  37787. client.init()
  37788. return client
  37789. }
  37790. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37791. // it returns an error otherwise.
  37792. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  37793. if _, ok := m.driver.(*txDriver); !ok {
  37794. return nil, errors.New("ent: mutation is not running in a transaction")
  37795. }
  37796. tx := &Tx{config: m.config}
  37797. tx.init()
  37798. return tx, nil
  37799. }
  37800. // SetID sets the value of the id field. Note that this
  37801. // operation is only accepted on creation of WhatsappChannel entities.
  37802. func (m *WhatsappChannelMutation) SetID(id uint64) {
  37803. m.id = &id
  37804. }
  37805. // ID returns the ID value in the mutation. Note that the ID is only available
  37806. // if it was provided to the builder or after it was returned from the database.
  37807. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  37808. if m.id == nil {
  37809. return
  37810. }
  37811. return *m.id, true
  37812. }
  37813. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37814. // That means, if the mutation is applied within a transaction with an isolation level such
  37815. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37816. // or updated by the mutation.
  37817. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  37818. switch {
  37819. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37820. id, exists := m.ID()
  37821. if exists {
  37822. return []uint64{id}, nil
  37823. }
  37824. fallthrough
  37825. case m.op.Is(OpUpdate | OpDelete):
  37826. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  37827. default:
  37828. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37829. }
  37830. }
  37831. // SetCreatedAt sets the "created_at" field.
  37832. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  37833. m.created_at = &t
  37834. }
  37835. // CreatedAt returns the value of the "created_at" field in the mutation.
  37836. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  37837. v := m.created_at
  37838. if v == nil {
  37839. return
  37840. }
  37841. return *v, true
  37842. }
  37843. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  37844. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37846. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37847. if !m.op.Is(OpUpdateOne) {
  37848. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37849. }
  37850. if m.id == nil || m.oldValue == nil {
  37851. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37852. }
  37853. oldValue, err := m.oldValue(ctx)
  37854. if err != nil {
  37855. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37856. }
  37857. return oldValue.CreatedAt, nil
  37858. }
  37859. // ResetCreatedAt resets all changes to the "created_at" field.
  37860. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  37861. m.created_at = nil
  37862. }
  37863. // SetUpdatedAt sets the "updated_at" field.
  37864. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  37865. m.updated_at = &t
  37866. }
  37867. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37868. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  37869. v := m.updated_at
  37870. if v == nil {
  37871. return
  37872. }
  37873. return *v, true
  37874. }
  37875. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  37876. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37878. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37879. if !m.op.Is(OpUpdateOne) {
  37880. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37881. }
  37882. if m.id == nil || m.oldValue == nil {
  37883. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37884. }
  37885. oldValue, err := m.oldValue(ctx)
  37886. if err != nil {
  37887. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37888. }
  37889. return oldValue.UpdatedAt, nil
  37890. }
  37891. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37892. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  37893. m.updated_at = nil
  37894. }
  37895. // SetStatus sets the "status" field.
  37896. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  37897. m.status = &u
  37898. m.addstatus = nil
  37899. }
  37900. // Status returns the value of the "status" field in the mutation.
  37901. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  37902. v := m.status
  37903. if v == nil {
  37904. return
  37905. }
  37906. return *v, true
  37907. }
  37908. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  37909. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37911. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37912. if !m.op.Is(OpUpdateOne) {
  37913. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37914. }
  37915. if m.id == nil || m.oldValue == nil {
  37916. return v, errors.New("OldStatus requires an ID field in the mutation")
  37917. }
  37918. oldValue, err := m.oldValue(ctx)
  37919. if err != nil {
  37920. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37921. }
  37922. return oldValue.Status, nil
  37923. }
  37924. // AddStatus adds u to the "status" field.
  37925. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  37926. if m.addstatus != nil {
  37927. *m.addstatus += u
  37928. } else {
  37929. m.addstatus = &u
  37930. }
  37931. }
  37932. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37933. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  37934. v := m.addstatus
  37935. if v == nil {
  37936. return
  37937. }
  37938. return *v, true
  37939. }
  37940. // ClearStatus clears the value of the "status" field.
  37941. func (m *WhatsappChannelMutation) ClearStatus() {
  37942. m.status = nil
  37943. m.addstatus = nil
  37944. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  37945. }
  37946. // StatusCleared returns if the "status" field was cleared in this mutation.
  37947. func (m *WhatsappChannelMutation) StatusCleared() bool {
  37948. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  37949. return ok
  37950. }
  37951. // ResetStatus resets all changes to the "status" field.
  37952. func (m *WhatsappChannelMutation) ResetStatus() {
  37953. m.status = nil
  37954. m.addstatus = nil
  37955. delete(m.clearedFields, whatsappchannel.FieldStatus)
  37956. }
  37957. // SetDeletedAt sets the "deleted_at" field.
  37958. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  37959. m.deleted_at = &t
  37960. }
  37961. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37962. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  37963. v := m.deleted_at
  37964. if v == nil {
  37965. return
  37966. }
  37967. return *v, true
  37968. }
  37969. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  37970. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37972. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37973. if !m.op.Is(OpUpdateOne) {
  37974. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37975. }
  37976. if m.id == nil || m.oldValue == nil {
  37977. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37978. }
  37979. oldValue, err := m.oldValue(ctx)
  37980. if err != nil {
  37981. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37982. }
  37983. return oldValue.DeletedAt, nil
  37984. }
  37985. // ClearDeletedAt clears the value of the "deleted_at" field.
  37986. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  37987. m.deleted_at = nil
  37988. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  37989. }
  37990. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37991. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  37992. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  37993. return ok
  37994. }
  37995. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37996. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  37997. m.deleted_at = nil
  37998. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  37999. }
  38000. // SetAk sets the "ak" field.
  38001. func (m *WhatsappChannelMutation) SetAk(s string) {
  38002. m.ak = &s
  38003. }
  38004. // Ak returns the value of the "ak" field in the mutation.
  38005. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  38006. v := m.ak
  38007. if v == nil {
  38008. return
  38009. }
  38010. return *v, true
  38011. }
  38012. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  38013. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38015. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  38016. if !m.op.Is(OpUpdateOne) {
  38017. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  38018. }
  38019. if m.id == nil || m.oldValue == nil {
  38020. return v, errors.New("OldAk requires an ID field in the mutation")
  38021. }
  38022. oldValue, err := m.oldValue(ctx)
  38023. if err != nil {
  38024. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  38025. }
  38026. return oldValue.Ak, nil
  38027. }
  38028. // ClearAk clears the value of the "ak" field.
  38029. func (m *WhatsappChannelMutation) ClearAk() {
  38030. m.ak = nil
  38031. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  38032. }
  38033. // AkCleared returns if the "ak" field was cleared in this mutation.
  38034. func (m *WhatsappChannelMutation) AkCleared() bool {
  38035. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  38036. return ok
  38037. }
  38038. // ResetAk resets all changes to the "ak" field.
  38039. func (m *WhatsappChannelMutation) ResetAk() {
  38040. m.ak = nil
  38041. delete(m.clearedFields, whatsappchannel.FieldAk)
  38042. }
  38043. // SetSk sets the "sk" field.
  38044. func (m *WhatsappChannelMutation) SetSk(s string) {
  38045. m.sk = &s
  38046. }
  38047. // Sk returns the value of the "sk" field in the mutation.
  38048. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  38049. v := m.sk
  38050. if v == nil {
  38051. return
  38052. }
  38053. return *v, true
  38054. }
  38055. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  38056. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38058. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  38059. if !m.op.Is(OpUpdateOne) {
  38060. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  38061. }
  38062. if m.id == nil || m.oldValue == nil {
  38063. return v, errors.New("OldSk requires an ID field in the mutation")
  38064. }
  38065. oldValue, err := m.oldValue(ctx)
  38066. if err != nil {
  38067. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  38068. }
  38069. return oldValue.Sk, nil
  38070. }
  38071. // ResetSk resets all changes to the "sk" field.
  38072. func (m *WhatsappChannelMutation) ResetSk() {
  38073. m.sk = nil
  38074. }
  38075. // SetWaID sets the "wa_id" field.
  38076. func (m *WhatsappChannelMutation) SetWaID(s string) {
  38077. m.wa_id = &s
  38078. }
  38079. // WaID returns the value of the "wa_id" field in the mutation.
  38080. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38081. v := m.wa_id
  38082. if v == nil {
  38083. return
  38084. }
  38085. return *v, true
  38086. }
  38087. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38088. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38090. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38091. if !m.op.Is(OpUpdateOne) {
  38092. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38093. }
  38094. if m.id == nil || m.oldValue == nil {
  38095. return v, errors.New("OldWaID requires an ID field in the mutation")
  38096. }
  38097. oldValue, err := m.oldValue(ctx)
  38098. if err != nil {
  38099. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38100. }
  38101. return oldValue.WaID, nil
  38102. }
  38103. // ClearWaID clears the value of the "wa_id" field.
  38104. func (m *WhatsappChannelMutation) ClearWaID() {
  38105. m.wa_id = nil
  38106. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38107. }
  38108. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38109. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38110. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38111. return ok
  38112. }
  38113. // ResetWaID resets all changes to the "wa_id" field.
  38114. func (m *WhatsappChannelMutation) ResetWaID() {
  38115. m.wa_id = nil
  38116. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38117. }
  38118. // SetWaName sets the "wa_name" field.
  38119. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38120. m.wa_name = &s
  38121. }
  38122. // WaName returns the value of the "wa_name" field in the mutation.
  38123. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38124. v := m.wa_name
  38125. if v == nil {
  38126. return
  38127. }
  38128. return *v, true
  38129. }
  38130. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38131. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38133. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38134. if !m.op.Is(OpUpdateOne) {
  38135. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38136. }
  38137. if m.id == nil || m.oldValue == nil {
  38138. return v, errors.New("OldWaName requires an ID field in the mutation")
  38139. }
  38140. oldValue, err := m.oldValue(ctx)
  38141. if err != nil {
  38142. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38143. }
  38144. return oldValue.WaName, nil
  38145. }
  38146. // ClearWaName clears the value of the "wa_name" field.
  38147. func (m *WhatsappChannelMutation) ClearWaName() {
  38148. m.wa_name = nil
  38149. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38150. }
  38151. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38152. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38153. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38154. return ok
  38155. }
  38156. // ResetWaName resets all changes to the "wa_name" field.
  38157. func (m *WhatsappChannelMutation) ResetWaName() {
  38158. m.wa_name = nil
  38159. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38160. }
  38161. // SetWabaID sets the "waba_id" field.
  38162. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38163. m.waba_id = &u
  38164. m.addwaba_id = nil
  38165. }
  38166. // WabaID returns the value of the "waba_id" field in the mutation.
  38167. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38168. v := m.waba_id
  38169. if v == nil {
  38170. return
  38171. }
  38172. return *v, true
  38173. }
  38174. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38175. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38177. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38178. if !m.op.Is(OpUpdateOne) {
  38179. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38180. }
  38181. if m.id == nil || m.oldValue == nil {
  38182. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38183. }
  38184. oldValue, err := m.oldValue(ctx)
  38185. if err != nil {
  38186. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38187. }
  38188. return oldValue.WabaID, nil
  38189. }
  38190. // AddWabaID adds u to the "waba_id" field.
  38191. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38192. if m.addwaba_id != nil {
  38193. *m.addwaba_id += u
  38194. } else {
  38195. m.addwaba_id = &u
  38196. }
  38197. }
  38198. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38199. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38200. v := m.addwaba_id
  38201. if v == nil {
  38202. return
  38203. }
  38204. return *v, true
  38205. }
  38206. // ResetWabaID resets all changes to the "waba_id" field.
  38207. func (m *WhatsappChannelMutation) ResetWabaID() {
  38208. m.waba_id = nil
  38209. m.addwaba_id = nil
  38210. }
  38211. // SetBusinessID sets the "business_id" field.
  38212. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38213. m.business_id = &u
  38214. m.addbusiness_id = nil
  38215. }
  38216. // BusinessID returns the value of the "business_id" field in the mutation.
  38217. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38218. v := m.business_id
  38219. if v == nil {
  38220. return
  38221. }
  38222. return *v, true
  38223. }
  38224. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38225. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38227. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38228. if !m.op.Is(OpUpdateOne) {
  38229. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38230. }
  38231. if m.id == nil || m.oldValue == nil {
  38232. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38233. }
  38234. oldValue, err := m.oldValue(ctx)
  38235. if err != nil {
  38236. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38237. }
  38238. return oldValue.BusinessID, nil
  38239. }
  38240. // AddBusinessID adds u to the "business_id" field.
  38241. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38242. if m.addbusiness_id != nil {
  38243. *m.addbusiness_id += u
  38244. } else {
  38245. m.addbusiness_id = &u
  38246. }
  38247. }
  38248. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38249. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38250. v := m.addbusiness_id
  38251. if v == nil {
  38252. return
  38253. }
  38254. return *v, true
  38255. }
  38256. // ResetBusinessID resets all changes to the "business_id" field.
  38257. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38258. m.business_id = nil
  38259. m.addbusiness_id = nil
  38260. }
  38261. // SetOrganizationID sets the "organization_id" field.
  38262. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38263. m.organization_id = &u
  38264. m.addorganization_id = nil
  38265. }
  38266. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38267. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38268. v := m.organization_id
  38269. if v == nil {
  38270. return
  38271. }
  38272. return *v, true
  38273. }
  38274. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38275. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38277. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38278. if !m.op.Is(OpUpdateOne) {
  38279. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38280. }
  38281. if m.id == nil || m.oldValue == nil {
  38282. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38283. }
  38284. oldValue, err := m.oldValue(ctx)
  38285. if err != nil {
  38286. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38287. }
  38288. return oldValue.OrganizationID, nil
  38289. }
  38290. // AddOrganizationID adds u to the "organization_id" field.
  38291. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38292. if m.addorganization_id != nil {
  38293. *m.addorganization_id += u
  38294. } else {
  38295. m.addorganization_id = &u
  38296. }
  38297. }
  38298. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38299. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38300. v := m.addorganization_id
  38301. if v == nil {
  38302. return
  38303. }
  38304. return *v, true
  38305. }
  38306. // ClearOrganizationID clears the value of the "organization_id" field.
  38307. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38308. m.organization_id = nil
  38309. m.addorganization_id = nil
  38310. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38311. }
  38312. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38313. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38314. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38315. return ok
  38316. }
  38317. // ResetOrganizationID resets all changes to the "organization_id" field.
  38318. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38319. m.organization_id = nil
  38320. m.addorganization_id = nil
  38321. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38322. }
  38323. // SetVerifyAccount sets the "verify_account" field.
  38324. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38325. m.verify_account = &s
  38326. }
  38327. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38328. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38329. v := m.verify_account
  38330. if v == nil {
  38331. return
  38332. }
  38333. return *v, true
  38334. }
  38335. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38336. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38338. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38339. if !m.op.Is(OpUpdateOne) {
  38340. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38341. }
  38342. if m.id == nil || m.oldValue == nil {
  38343. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38344. }
  38345. oldValue, err := m.oldValue(ctx)
  38346. if err != nil {
  38347. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38348. }
  38349. return oldValue.VerifyAccount, nil
  38350. }
  38351. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38352. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38353. m.verify_account = nil
  38354. }
  38355. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38356. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38357. m.predicates = append(m.predicates, ps...)
  38358. }
  38359. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38360. // users can use type-assertion to append predicates that do not depend on any generated package.
  38361. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38362. p := make([]predicate.WhatsappChannel, len(ps))
  38363. for i := range ps {
  38364. p[i] = ps[i]
  38365. }
  38366. m.Where(p...)
  38367. }
  38368. // Op returns the operation name.
  38369. func (m *WhatsappChannelMutation) Op() Op {
  38370. return m.op
  38371. }
  38372. // SetOp allows setting the mutation operation.
  38373. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38374. m.op = op
  38375. }
  38376. // Type returns the node type of this mutation (WhatsappChannel).
  38377. func (m *WhatsappChannelMutation) Type() string {
  38378. return m.typ
  38379. }
  38380. // Fields returns all fields that were changed during this mutation. Note that in
  38381. // order to get all numeric fields that were incremented/decremented, call
  38382. // AddedFields().
  38383. func (m *WhatsappChannelMutation) Fields() []string {
  38384. fields := make([]string, 0, 12)
  38385. if m.created_at != nil {
  38386. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38387. }
  38388. if m.updated_at != nil {
  38389. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38390. }
  38391. if m.status != nil {
  38392. fields = append(fields, whatsappchannel.FieldStatus)
  38393. }
  38394. if m.deleted_at != nil {
  38395. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38396. }
  38397. if m.ak != nil {
  38398. fields = append(fields, whatsappchannel.FieldAk)
  38399. }
  38400. if m.sk != nil {
  38401. fields = append(fields, whatsappchannel.FieldSk)
  38402. }
  38403. if m.wa_id != nil {
  38404. fields = append(fields, whatsappchannel.FieldWaID)
  38405. }
  38406. if m.wa_name != nil {
  38407. fields = append(fields, whatsappchannel.FieldWaName)
  38408. }
  38409. if m.waba_id != nil {
  38410. fields = append(fields, whatsappchannel.FieldWabaID)
  38411. }
  38412. if m.business_id != nil {
  38413. fields = append(fields, whatsappchannel.FieldBusinessID)
  38414. }
  38415. if m.organization_id != nil {
  38416. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38417. }
  38418. if m.verify_account != nil {
  38419. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38420. }
  38421. return fields
  38422. }
  38423. // Field returns the value of a field with the given name. The second boolean
  38424. // return value indicates that this field was not set, or was not defined in the
  38425. // schema.
  38426. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38427. switch name {
  38428. case whatsappchannel.FieldCreatedAt:
  38429. return m.CreatedAt()
  38430. case whatsappchannel.FieldUpdatedAt:
  38431. return m.UpdatedAt()
  38432. case whatsappchannel.FieldStatus:
  38433. return m.Status()
  38434. case whatsappchannel.FieldDeletedAt:
  38435. return m.DeletedAt()
  38436. case whatsappchannel.FieldAk:
  38437. return m.Ak()
  38438. case whatsappchannel.FieldSk:
  38439. return m.Sk()
  38440. case whatsappchannel.FieldWaID:
  38441. return m.WaID()
  38442. case whatsappchannel.FieldWaName:
  38443. return m.WaName()
  38444. case whatsappchannel.FieldWabaID:
  38445. return m.WabaID()
  38446. case whatsappchannel.FieldBusinessID:
  38447. return m.BusinessID()
  38448. case whatsappchannel.FieldOrganizationID:
  38449. return m.OrganizationID()
  38450. case whatsappchannel.FieldVerifyAccount:
  38451. return m.VerifyAccount()
  38452. }
  38453. return nil, false
  38454. }
  38455. // OldField returns the old value of the field from the database. An error is
  38456. // returned if the mutation operation is not UpdateOne, or the query to the
  38457. // database failed.
  38458. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38459. switch name {
  38460. case whatsappchannel.FieldCreatedAt:
  38461. return m.OldCreatedAt(ctx)
  38462. case whatsappchannel.FieldUpdatedAt:
  38463. return m.OldUpdatedAt(ctx)
  38464. case whatsappchannel.FieldStatus:
  38465. return m.OldStatus(ctx)
  38466. case whatsappchannel.FieldDeletedAt:
  38467. return m.OldDeletedAt(ctx)
  38468. case whatsappchannel.FieldAk:
  38469. return m.OldAk(ctx)
  38470. case whatsappchannel.FieldSk:
  38471. return m.OldSk(ctx)
  38472. case whatsappchannel.FieldWaID:
  38473. return m.OldWaID(ctx)
  38474. case whatsappchannel.FieldWaName:
  38475. return m.OldWaName(ctx)
  38476. case whatsappchannel.FieldWabaID:
  38477. return m.OldWabaID(ctx)
  38478. case whatsappchannel.FieldBusinessID:
  38479. return m.OldBusinessID(ctx)
  38480. case whatsappchannel.FieldOrganizationID:
  38481. return m.OldOrganizationID(ctx)
  38482. case whatsappchannel.FieldVerifyAccount:
  38483. return m.OldVerifyAccount(ctx)
  38484. }
  38485. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38486. }
  38487. // SetField sets the value of a field with the given name. It returns an error if
  38488. // the field is not defined in the schema, or if the type mismatched the field
  38489. // type.
  38490. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38491. switch name {
  38492. case whatsappchannel.FieldCreatedAt:
  38493. v, ok := value.(time.Time)
  38494. if !ok {
  38495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38496. }
  38497. m.SetCreatedAt(v)
  38498. return nil
  38499. case whatsappchannel.FieldUpdatedAt:
  38500. v, ok := value.(time.Time)
  38501. if !ok {
  38502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38503. }
  38504. m.SetUpdatedAt(v)
  38505. return nil
  38506. case whatsappchannel.FieldStatus:
  38507. v, ok := value.(uint8)
  38508. if !ok {
  38509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38510. }
  38511. m.SetStatus(v)
  38512. return nil
  38513. case whatsappchannel.FieldDeletedAt:
  38514. v, ok := value.(time.Time)
  38515. if !ok {
  38516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38517. }
  38518. m.SetDeletedAt(v)
  38519. return nil
  38520. case whatsappchannel.FieldAk:
  38521. v, ok := value.(string)
  38522. if !ok {
  38523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38524. }
  38525. m.SetAk(v)
  38526. return nil
  38527. case whatsappchannel.FieldSk:
  38528. v, ok := value.(string)
  38529. if !ok {
  38530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38531. }
  38532. m.SetSk(v)
  38533. return nil
  38534. case whatsappchannel.FieldWaID:
  38535. v, ok := value.(string)
  38536. if !ok {
  38537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38538. }
  38539. m.SetWaID(v)
  38540. return nil
  38541. case whatsappchannel.FieldWaName:
  38542. v, ok := value.(string)
  38543. if !ok {
  38544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38545. }
  38546. m.SetWaName(v)
  38547. return nil
  38548. case whatsappchannel.FieldWabaID:
  38549. v, ok := value.(uint64)
  38550. if !ok {
  38551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38552. }
  38553. m.SetWabaID(v)
  38554. return nil
  38555. case whatsappchannel.FieldBusinessID:
  38556. v, ok := value.(uint64)
  38557. if !ok {
  38558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38559. }
  38560. m.SetBusinessID(v)
  38561. return nil
  38562. case whatsappchannel.FieldOrganizationID:
  38563. v, ok := value.(uint64)
  38564. if !ok {
  38565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38566. }
  38567. m.SetOrganizationID(v)
  38568. return nil
  38569. case whatsappchannel.FieldVerifyAccount:
  38570. v, ok := value.(string)
  38571. if !ok {
  38572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38573. }
  38574. m.SetVerifyAccount(v)
  38575. return nil
  38576. }
  38577. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38578. }
  38579. // AddedFields returns all numeric fields that were incremented/decremented during
  38580. // this mutation.
  38581. func (m *WhatsappChannelMutation) AddedFields() []string {
  38582. var fields []string
  38583. if m.addstatus != nil {
  38584. fields = append(fields, whatsappchannel.FieldStatus)
  38585. }
  38586. if m.addwaba_id != nil {
  38587. fields = append(fields, whatsappchannel.FieldWabaID)
  38588. }
  38589. if m.addbusiness_id != nil {
  38590. fields = append(fields, whatsappchannel.FieldBusinessID)
  38591. }
  38592. if m.addorganization_id != nil {
  38593. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38594. }
  38595. return fields
  38596. }
  38597. // AddedField returns the numeric value that was incremented/decremented on a field
  38598. // with the given name. The second boolean return value indicates that this field
  38599. // was not set, or was not defined in the schema.
  38600. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38601. switch name {
  38602. case whatsappchannel.FieldStatus:
  38603. return m.AddedStatus()
  38604. case whatsappchannel.FieldWabaID:
  38605. return m.AddedWabaID()
  38606. case whatsappchannel.FieldBusinessID:
  38607. return m.AddedBusinessID()
  38608. case whatsappchannel.FieldOrganizationID:
  38609. return m.AddedOrganizationID()
  38610. }
  38611. return nil, false
  38612. }
  38613. // AddField adds the value to the field with the given name. It returns an error if
  38614. // the field is not defined in the schema, or if the type mismatched the field
  38615. // type.
  38616. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38617. switch name {
  38618. case whatsappchannel.FieldStatus:
  38619. v, ok := value.(int8)
  38620. if !ok {
  38621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38622. }
  38623. m.AddStatus(v)
  38624. return nil
  38625. case whatsappchannel.FieldWabaID:
  38626. v, ok := value.(int64)
  38627. if !ok {
  38628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38629. }
  38630. m.AddWabaID(v)
  38631. return nil
  38632. case whatsappchannel.FieldBusinessID:
  38633. v, ok := value.(int64)
  38634. if !ok {
  38635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38636. }
  38637. m.AddBusinessID(v)
  38638. return nil
  38639. case whatsappchannel.FieldOrganizationID:
  38640. v, ok := value.(int64)
  38641. if !ok {
  38642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38643. }
  38644. m.AddOrganizationID(v)
  38645. return nil
  38646. }
  38647. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  38648. }
  38649. // ClearedFields returns all nullable fields that were cleared during this
  38650. // mutation.
  38651. func (m *WhatsappChannelMutation) ClearedFields() []string {
  38652. var fields []string
  38653. if m.FieldCleared(whatsappchannel.FieldStatus) {
  38654. fields = append(fields, whatsappchannel.FieldStatus)
  38655. }
  38656. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  38657. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38658. }
  38659. if m.FieldCleared(whatsappchannel.FieldAk) {
  38660. fields = append(fields, whatsappchannel.FieldAk)
  38661. }
  38662. if m.FieldCleared(whatsappchannel.FieldWaID) {
  38663. fields = append(fields, whatsappchannel.FieldWaID)
  38664. }
  38665. if m.FieldCleared(whatsappchannel.FieldWaName) {
  38666. fields = append(fields, whatsappchannel.FieldWaName)
  38667. }
  38668. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  38669. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38670. }
  38671. return fields
  38672. }
  38673. // FieldCleared returns a boolean indicating if a field with the given name was
  38674. // cleared in this mutation.
  38675. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  38676. _, ok := m.clearedFields[name]
  38677. return ok
  38678. }
  38679. // ClearField clears the value of the field with the given name. It returns an
  38680. // error if the field is not defined in the schema.
  38681. func (m *WhatsappChannelMutation) ClearField(name string) error {
  38682. switch name {
  38683. case whatsappchannel.FieldStatus:
  38684. m.ClearStatus()
  38685. return nil
  38686. case whatsappchannel.FieldDeletedAt:
  38687. m.ClearDeletedAt()
  38688. return nil
  38689. case whatsappchannel.FieldAk:
  38690. m.ClearAk()
  38691. return nil
  38692. case whatsappchannel.FieldWaID:
  38693. m.ClearWaID()
  38694. return nil
  38695. case whatsappchannel.FieldWaName:
  38696. m.ClearWaName()
  38697. return nil
  38698. case whatsappchannel.FieldOrganizationID:
  38699. m.ClearOrganizationID()
  38700. return nil
  38701. }
  38702. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  38703. }
  38704. // ResetField resets all changes in the mutation for the field with the given name.
  38705. // It returns an error if the field is not defined in the schema.
  38706. func (m *WhatsappChannelMutation) ResetField(name string) error {
  38707. switch name {
  38708. case whatsappchannel.FieldCreatedAt:
  38709. m.ResetCreatedAt()
  38710. return nil
  38711. case whatsappchannel.FieldUpdatedAt:
  38712. m.ResetUpdatedAt()
  38713. return nil
  38714. case whatsappchannel.FieldStatus:
  38715. m.ResetStatus()
  38716. return nil
  38717. case whatsappchannel.FieldDeletedAt:
  38718. m.ResetDeletedAt()
  38719. return nil
  38720. case whatsappchannel.FieldAk:
  38721. m.ResetAk()
  38722. return nil
  38723. case whatsappchannel.FieldSk:
  38724. m.ResetSk()
  38725. return nil
  38726. case whatsappchannel.FieldWaID:
  38727. m.ResetWaID()
  38728. return nil
  38729. case whatsappchannel.FieldWaName:
  38730. m.ResetWaName()
  38731. return nil
  38732. case whatsappchannel.FieldWabaID:
  38733. m.ResetWabaID()
  38734. return nil
  38735. case whatsappchannel.FieldBusinessID:
  38736. m.ResetBusinessID()
  38737. return nil
  38738. case whatsappchannel.FieldOrganizationID:
  38739. m.ResetOrganizationID()
  38740. return nil
  38741. case whatsappchannel.FieldVerifyAccount:
  38742. m.ResetVerifyAccount()
  38743. return nil
  38744. }
  38745. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38746. }
  38747. // AddedEdges returns all edge names that were set/added in this mutation.
  38748. func (m *WhatsappChannelMutation) AddedEdges() []string {
  38749. edges := make([]string, 0, 0)
  38750. return edges
  38751. }
  38752. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38753. // name in this mutation.
  38754. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  38755. return nil
  38756. }
  38757. // RemovedEdges returns all edge names that were removed in this mutation.
  38758. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  38759. edges := make([]string, 0, 0)
  38760. return edges
  38761. }
  38762. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38763. // the given name in this mutation.
  38764. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  38765. return nil
  38766. }
  38767. // ClearedEdges returns all edge names that were cleared in this mutation.
  38768. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  38769. edges := make([]string, 0, 0)
  38770. return edges
  38771. }
  38772. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38773. // was cleared in this mutation.
  38774. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  38775. return false
  38776. }
  38777. // ClearEdge clears the value of the edge with the given name. It returns an error
  38778. // if that edge is not defined in the schema.
  38779. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  38780. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  38781. }
  38782. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38783. // It returns an error if the edge is not defined in the schema.
  38784. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  38785. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  38786. }
  38787. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  38788. type WorkExperienceMutation struct {
  38789. config
  38790. op Op
  38791. typ string
  38792. id *uint64
  38793. created_at *time.Time
  38794. updated_at *time.Time
  38795. deleted_at *time.Time
  38796. start_date *time.Time
  38797. end_date *time.Time
  38798. company *string
  38799. experience *string
  38800. organization_id *uint64
  38801. addorganization_id *int64
  38802. clearedFields map[string]struct{}
  38803. employee *uint64
  38804. clearedemployee bool
  38805. done bool
  38806. oldValue func(context.Context) (*WorkExperience, error)
  38807. predicates []predicate.WorkExperience
  38808. }
  38809. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  38810. // workexperienceOption allows management of the mutation configuration using functional options.
  38811. type workexperienceOption func(*WorkExperienceMutation)
  38812. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  38813. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  38814. m := &WorkExperienceMutation{
  38815. config: c,
  38816. op: op,
  38817. typ: TypeWorkExperience,
  38818. clearedFields: make(map[string]struct{}),
  38819. }
  38820. for _, opt := range opts {
  38821. opt(m)
  38822. }
  38823. return m
  38824. }
  38825. // withWorkExperienceID sets the ID field of the mutation.
  38826. func withWorkExperienceID(id uint64) workexperienceOption {
  38827. return func(m *WorkExperienceMutation) {
  38828. var (
  38829. err error
  38830. once sync.Once
  38831. value *WorkExperience
  38832. )
  38833. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  38834. once.Do(func() {
  38835. if m.done {
  38836. err = errors.New("querying old values post mutation is not allowed")
  38837. } else {
  38838. value, err = m.Client().WorkExperience.Get(ctx, id)
  38839. }
  38840. })
  38841. return value, err
  38842. }
  38843. m.id = &id
  38844. }
  38845. }
  38846. // withWorkExperience sets the old WorkExperience of the mutation.
  38847. func withWorkExperience(node *WorkExperience) workexperienceOption {
  38848. return func(m *WorkExperienceMutation) {
  38849. m.oldValue = func(context.Context) (*WorkExperience, error) {
  38850. return node, nil
  38851. }
  38852. m.id = &node.ID
  38853. }
  38854. }
  38855. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38856. // executed in a transaction (ent.Tx), a transactional client is returned.
  38857. func (m WorkExperienceMutation) Client() *Client {
  38858. client := &Client{config: m.config}
  38859. client.init()
  38860. return client
  38861. }
  38862. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38863. // it returns an error otherwise.
  38864. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  38865. if _, ok := m.driver.(*txDriver); !ok {
  38866. return nil, errors.New("ent: mutation is not running in a transaction")
  38867. }
  38868. tx := &Tx{config: m.config}
  38869. tx.init()
  38870. return tx, nil
  38871. }
  38872. // SetID sets the value of the id field. Note that this
  38873. // operation is only accepted on creation of WorkExperience entities.
  38874. func (m *WorkExperienceMutation) SetID(id uint64) {
  38875. m.id = &id
  38876. }
  38877. // ID returns the ID value in the mutation. Note that the ID is only available
  38878. // if it was provided to the builder or after it was returned from the database.
  38879. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  38880. if m.id == nil {
  38881. return
  38882. }
  38883. return *m.id, true
  38884. }
  38885. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38886. // That means, if the mutation is applied within a transaction with an isolation level such
  38887. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38888. // or updated by the mutation.
  38889. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  38890. switch {
  38891. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38892. id, exists := m.ID()
  38893. if exists {
  38894. return []uint64{id}, nil
  38895. }
  38896. fallthrough
  38897. case m.op.Is(OpUpdate | OpDelete):
  38898. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  38899. default:
  38900. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38901. }
  38902. }
  38903. // SetCreatedAt sets the "created_at" field.
  38904. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  38905. m.created_at = &t
  38906. }
  38907. // CreatedAt returns the value of the "created_at" field in the mutation.
  38908. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  38909. v := m.created_at
  38910. if v == nil {
  38911. return
  38912. }
  38913. return *v, true
  38914. }
  38915. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  38916. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38918. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38919. if !m.op.Is(OpUpdateOne) {
  38920. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38921. }
  38922. if m.id == nil || m.oldValue == nil {
  38923. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38924. }
  38925. oldValue, err := m.oldValue(ctx)
  38926. if err != nil {
  38927. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38928. }
  38929. return oldValue.CreatedAt, nil
  38930. }
  38931. // ResetCreatedAt resets all changes to the "created_at" field.
  38932. func (m *WorkExperienceMutation) ResetCreatedAt() {
  38933. m.created_at = nil
  38934. }
  38935. // SetUpdatedAt sets the "updated_at" field.
  38936. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  38937. m.updated_at = &t
  38938. }
  38939. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38940. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  38941. v := m.updated_at
  38942. if v == nil {
  38943. return
  38944. }
  38945. return *v, true
  38946. }
  38947. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  38948. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38950. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38951. if !m.op.Is(OpUpdateOne) {
  38952. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38953. }
  38954. if m.id == nil || m.oldValue == nil {
  38955. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38956. }
  38957. oldValue, err := m.oldValue(ctx)
  38958. if err != nil {
  38959. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38960. }
  38961. return oldValue.UpdatedAt, nil
  38962. }
  38963. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38964. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  38965. m.updated_at = nil
  38966. }
  38967. // SetDeletedAt sets the "deleted_at" field.
  38968. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  38969. m.deleted_at = &t
  38970. }
  38971. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38972. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  38973. v := m.deleted_at
  38974. if v == nil {
  38975. return
  38976. }
  38977. return *v, true
  38978. }
  38979. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  38980. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38982. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38983. if !m.op.Is(OpUpdateOne) {
  38984. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38985. }
  38986. if m.id == nil || m.oldValue == nil {
  38987. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38988. }
  38989. oldValue, err := m.oldValue(ctx)
  38990. if err != nil {
  38991. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38992. }
  38993. return oldValue.DeletedAt, nil
  38994. }
  38995. // ClearDeletedAt clears the value of the "deleted_at" field.
  38996. func (m *WorkExperienceMutation) ClearDeletedAt() {
  38997. m.deleted_at = nil
  38998. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  38999. }
  39000. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39001. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  39002. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  39003. return ok
  39004. }
  39005. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39006. func (m *WorkExperienceMutation) ResetDeletedAt() {
  39007. m.deleted_at = nil
  39008. delete(m.clearedFields, workexperience.FieldDeletedAt)
  39009. }
  39010. // SetEmployeeID sets the "employee_id" field.
  39011. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  39012. m.employee = &u
  39013. }
  39014. // EmployeeID returns the value of the "employee_id" field in the mutation.
  39015. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  39016. v := m.employee
  39017. if v == nil {
  39018. return
  39019. }
  39020. return *v, true
  39021. }
  39022. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  39023. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39025. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  39026. if !m.op.Is(OpUpdateOne) {
  39027. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  39028. }
  39029. if m.id == nil || m.oldValue == nil {
  39030. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  39031. }
  39032. oldValue, err := m.oldValue(ctx)
  39033. if err != nil {
  39034. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  39035. }
  39036. return oldValue.EmployeeID, nil
  39037. }
  39038. // ResetEmployeeID resets all changes to the "employee_id" field.
  39039. func (m *WorkExperienceMutation) ResetEmployeeID() {
  39040. m.employee = nil
  39041. }
  39042. // SetStartDate sets the "start_date" field.
  39043. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  39044. m.start_date = &t
  39045. }
  39046. // StartDate returns the value of the "start_date" field in the mutation.
  39047. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  39048. v := m.start_date
  39049. if v == nil {
  39050. return
  39051. }
  39052. return *v, true
  39053. }
  39054. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  39055. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39057. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  39058. if !m.op.Is(OpUpdateOne) {
  39059. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  39060. }
  39061. if m.id == nil || m.oldValue == nil {
  39062. return v, errors.New("OldStartDate requires an ID field in the mutation")
  39063. }
  39064. oldValue, err := m.oldValue(ctx)
  39065. if err != nil {
  39066. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  39067. }
  39068. return oldValue.StartDate, nil
  39069. }
  39070. // ResetStartDate resets all changes to the "start_date" field.
  39071. func (m *WorkExperienceMutation) ResetStartDate() {
  39072. m.start_date = nil
  39073. }
  39074. // SetEndDate sets the "end_date" field.
  39075. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  39076. m.end_date = &t
  39077. }
  39078. // EndDate returns the value of the "end_date" field in the mutation.
  39079. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39080. v := m.end_date
  39081. if v == nil {
  39082. return
  39083. }
  39084. return *v, true
  39085. }
  39086. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39087. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39089. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39090. if !m.op.Is(OpUpdateOne) {
  39091. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39092. }
  39093. if m.id == nil || m.oldValue == nil {
  39094. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39095. }
  39096. oldValue, err := m.oldValue(ctx)
  39097. if err != nil {
  39098. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39099. }
  39100. return oldValue.EndDate, nil
  39101. }
  39102. // ResetEndDate resets all changes to the "end_date" field.
  39103. func (m *WorkExperienceMutation) ResetEndDate() {
  39104. m.end_date = nil
  39105. }
  39106. // SetCompany sets the "company" field.
  39107. func (m *WorkExperienceMutation) SetCompany(s string) {
  39108. m.company = &s
  39109. }
  39110. // Company returns the value of the "company" field in the mutation.
  39111. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39112. v := m.company
  39113. if v == nil {
  39114. return
  39115. }
  39116. return *v, true
  39117. }
  39118. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39119. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39121. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39122. if !m.op.Is(OpUpdateOne) {
  39123. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39124. }
  39125. if m.id == nil || m.oldValue == nil {
  39126. return v, errors.New("OldCompany requires an ID field in the mutation")
  39127. }
  39128. oldValue, err := m.oldValue(ctx)
  39129. if err != nil {
  39130. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39131. }
  39132. return oldValue.Company, nil
  39133. }
  39134. // ResetCompany resets all changes to the "company" field.
  39135. func (m *WorkExperienceMutation) ResetCompany() {
  39136. m.company = nil
  39137. }
  39138. // SetExperience sets the "experience" field.
  39139. func (m *WorkExperienceMutation) SetExperience(s string) {
  39140. m.experience = &s
  39141. }
  39142. // Experience returns the value of the "experience" field in the mutation.
  39143. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39144. v := m.experience
  39145. if v == nil {
  39146. return
  39147. }
  39148. return *v, true
  39149. }
  39150. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39151. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39153. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39154. if !m.op.Is(OpUpdateOne) {
  39155. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39156. }
  39157. if m.id == nil || m.oldValue == nil {
  39158. return v, errors.New("OldExperience requires an ID field in the mutation")
  39159. }
  39160. oldValue, err := m.oldValue(ctx)
  39161. if err != nil {
  39162. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39163. }
  39164. return oldValue.Experience, nil
  39165. }
  39166. // ResetExperience resets all changes to the "experience" field.
  39167. func (m *WorkExperienceMutation) ResetExperience() {
  39168. m.experience = nil
  39169. }
  39170. // SetOrganizationID sets the "organization_id" field.
  39171. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39172. m.organization_id = &u
  39173. m.addorganization_id = nil
  39174. }
  39175. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39176. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39177. v := m.organization_id
  39178. if v == nil {
  39179. return
  39180. }
  39181. return *v, true
  39182. }
  39183. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39184. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39186. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39187. if !m.op.Is(OpUpdateOne) {
  39188. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39189. }
  39190. if m.id == nil || m.oldValue == nil {
  39191. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39192. }
  39193. oldValue, err := m.oldValue(ctx)
  39194. if err != nil {
  39195. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39196. }
  39197. return oldValue.OrganizationID, nil
  39198. }
  39199. // AddOrganizationID adds u to the "organization_id" field.
  39200. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39201. if m.addorganization_id != nil {
  39202. *m.addorganization_id += u
  39203. } else {
  39204. m.addorganization_id = &u
  39205. }
  39206. }
  39207. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39208. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39209. v := m.addorganization_id
  39210. if v == nil {
  39211. return
  39212. }
  39213. return *v, true
  39214. }
  39215. // ResetOrganizationID resets all changes to the "organization_id" field.
  39216. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39217. m.organization_id = nil
  39218. m.addorganization_id = nil
  39219. }
  39220. // ClearEmployee clears the "employee" edge to the Employee entity.
  39221. func (m *WorkExperienceMutation) ClearEmployee() {
  39222. m.clearedemployee = true
  39223. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39224. }
  39225. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39226. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39227. return m.clearedemployee
  39228. }
  39229. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39230. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39231. // EmployeeID instead. It exists only for internal usage by the builders.
  39232. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39233. if id := m.employee; id != nil {
  39234. ids = append(ids, *id)
  39235. }
  39236. return
  39237. }
  39238. // ResetEmployee resets all changes to the "employee" edge.
  39239. func (m *WorkExperienceMutation) ResetEmployee() {
  39240. m.employee = nil
  39241. m.clearedemployee = false
  39242. }
  39243. // Where appends a list predicates to the WorkExperienceMutation builder.
  39244. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39245. m.predicates = append(m.predicates, ps...)
  39246. }
  39247. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39248. // users can use type-assertion to append predicates that do not depend on any generated package.
  39249. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39250. p := make([]predicate.WorkExperience, len(ps))
  39251. for i := range ps {
  39252. p[i] = ps[i]
  39253. }
  39254. m.Where(p...)
  39255. }
  39256. // Op returns the operation name.
  39257. func (m *WorkExperienceMutation) Op() Op {
  39258. return m.op
  39259. }
  39260. // SetOp allows setting the mutation operation.
  39261. func (m *WorkExperienceMutation) SetOp(op Op) {
  39262. m.op = op
  39263. }
  39264. // Type returns the node type of this mutation (WorkExperience).
  39265. func (m *WorkExperienceMutation) Type() string {
  39266. return m.typ
  39267. }
  39268. // Fields returns all fields that were changed during this mutation. Note that in
  39269. // order to get all numeric fields that were incremented/decremented, call
  39270. // AddedFields().
  39271. func (m *WorkExperienceMutation) Fields() []string {
  39272. fields := make([]string, 0, 9)
  39273. if m.created_at != nil {
  39274. fields = append(fields, workexperience.FieldCreatedAt)
  39275. }
  39276. if m.updated_at != nil {
  39277. fields = append(fields, workexperience.FieldUpdatedAt)
  39278. }
  39279. if m.deleted_at != nil {
  39280. fields = append(fields, workexperience.FieldDeletedAt)
  39281. }
  39282. if m.employee != nil {
  39283. fields = append(fields, workexperience.FieldEmployeeID)
  39284. }
  39285. if m.start_date != nil {
  39286. fields = append(fields, workexperience.FieldStartDate)
  39287. }
  39288. if m.end_date != nil {
  39289. fields = append(fields, workexperience.FieldEndDate)
  39290. }
  39291. if m.company != nil {
  39292. fields = append(fields, workexperience.FieldCompany)
  39293. }
  39294. if m.experience != nil {
  39295. fields = append(fields, workexperience.FieldExperience)
  39296. }
  39297. if m.organization_id != nil {
  39298. fields = append(fields, workexperience.FieldOrganizationID)
  39299. }
  39300. return fields
  39301. }
  39302. // Field returns the value of a field with the given name. The second boolean
  39303. // return value indicates that this field was not set, or was not defined in the
  39304. // schema.
  39305. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39306. switch name {
  39307. case workexperience.FieldCreatedAt:
  39308. return m.CreatedAt()
  39309. case workexperience.FieldUpdatedAt:
  39310. return m.UpdatedAt()
  39311. case workexperience.FieldDeletedAt:
  39312. return m.DeletedAt()
  39313. case workexperience.FieldEmployeeID:
  39314. return m.EmployeeID()
  39315. case workexperience.FieldStartDate:
  39316. return m.StartDate()
  39317. case workexperience.FieldEndDate:
  39318. return m.EndDate()
  39319. case workexperience.FieldCompany:
  39320. return m.Company()
  39321. case workexperience.FieldExperience:
  39322. return m.Experience()
  39323. case workexperience.FieldOrganizationID:
  39324. return m.OrganizationID()
  39325. }
  39326. return nil, false
  39327. }
  39328. // OldField returns the old value of the field from the database. An error is
  39329. // returned if the mutation operation is not UpdateOne, or the query to the
  39330. // database failed.
  39331. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39332. switch name {
  39333. case workexperience.FieldCreatedAt:
  39334. return m.OldCreatedAt(ctx)
  39335. case workexperience.FieldUpdatedAt:
  39336. return m.OldUpdatedAt(ctx)
  39337. case workexperience.FieldDeletedAt:
  39338. return m.OldDeletedAt(ctx)
  39339. case workexperience.FieldEmployeeID:
  39340. return m.OldEmployeeID(ctx)
  39341. case workexperience.FieldStartDate:
  39342. return m.OldStartDate(ctx)
  39343. case workexperience.FieldEndDate:
  39344. return m.OldEndDate(ctx)
  39345. case workexperience.FieldCompany:
  39346. return m.OldCompany(ctx)
  39347. case workexperience.FieldExperience:
  39348. return m.OldExperience(ctx)
  39349. case workexperience.FieldOrganizationID:
  39350. return m.OldOrganizationID(ctx)
  39351. }
  39352. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39353. }
  39354. // SetField sets the value of a field with the given name. It returns an error if
  39355. // the field is not defined in the schema, or if the type mismatched the field
  39356. // type.
  39357. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39358. switch name {
  39359. case workexperience.FieldCreatedAt:
  39360. v, ok := value.(time.Time)
  39361. if !ok {
  39362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39363. }
  39364. m.SetCreatedAt(v)
  39365. return nil
  39366. case workexperience.FieldUpdatedAt:
  39367. v, ok := value.(time.Time)
  39368. if !ok {
  39369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39370. }
  39371. m.SetUpdatedAt(v)
  39372. return nil
  39373. case workexperience.FieldDeletedAt:
  39374. v, ok := value.(time.Time)
  39375. if !ok {
  39376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39377. }
  39378. m.SetDeletedAt(v)
  39379. return nil
  39380. case workexperience.FieldEmployeeID:
  39381. v, ok := value.(uint64)
  39382. if !ok {
  39383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39384. }
  39385. m.SetEmployeeID(v)
  39386. return nil
  39387. case workexperience.FieldStartDate:
  39388. v, ok := value.(time.Time)
  39389. if !ok {
  39390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39391. }
  39392. m.SetStartDate(v)
  39393. return nil
  39394. case workexperience.FieldEndDate:
  39395. v, ok := value.(time.Time)
  39396. if !ok {
  39397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39398. }
  39399. m.SetEndDate(v)
  39400. return nil
  39401. case workexperience.FieldCompany:
  39402. v, ok := value.(string)
  39403. if !ok {
  39404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39405. }
  39406. m.SetCompany(v)
  39407. return nil
  39408. case workexperience.FieldExperience:
  39409. v, ok := value.(string)
  39410. if !ok {
  39411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39412. }
  39413. m.SetExperience(v)
  39414. return nil
  39415. case workexperience.FieldOrganizationID:
  39416. v, ok := value.(uint64)
  39417. if !ok {
  39418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39419. }
  39420. m.SetOrganizationID(v)
  39421. return nil
  39422. }
  39423. return fmt.Errorf("unknown WorkExperience field %s", name)
  39424. }
  39425. // AddedFields returns all numeric fields that were incremented/decremented during
  39426. // this mutation.
  39427. func (m *WorkExperienceMutation) AddedFields() []string {
  39428. var fields []string
  39429. if m.addorganization_id != nil {
  39430. fields = append(fields, workexperience.FieldOrganizationID)
  39431. }
  39432. return fields
  39433. }
  39434. // AddedField returns the numeric value that was incremented/decremented on a field
  39435. // with the given name. The second boolean return value indicates that this field
  39436. // was not set, or was not defined in the schema.
  39437. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39438. switch name {
  39439. case workexperience.FieldOrganizationID:
  39440. return m.AddedOrganizationID()
  39441. }
  39442. return nil, false
  39443. }
  39444. // AddField adds the value to the field with the given name. It returns an error if
  39445. // the field is not defined in the schema, or if the type mismatched the field
  39446. // type.
  39447. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39448. switch name {
  39449. case workexperience.FieldOrganizationID:
  39450. v, ok := value.(int64)
  39451. if !ok {
  39452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39453. }
  39454. m.AddOrganizationID(v)
  39455. return nil
  39456. }
  39457. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39458. }
  39459. // ClearedFields returns all nullable fields that were cleared during this
  39460. // mutation.
  39461. func (m *WorkExperienceMutation) ClearedFields() []string {
  39462. var fields []string
  39463. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39464. fields = append(fields, workexperience.FieldDeletedAt)
  39465. }
  39466. return fields
  39467. }
  39468. // FieldCleared returns a boolean indicating if a field with the given name was
  39469. // cleared in this mutation.
  39470. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39471. _, ok := m.clearedFields[name]
  39472. return ok
  39473. }
  39474. // ClearField clears the value of the field with the given name. It returns an
  39475. // error if the field is not defined in the schema.
  39476. func (m *WorkExperienceMutation) ClearField(name string) error {
  39477. switch name {
  39478. case workexperience.FieldDeletedAt:
  39479. m.ClearDeletedAt()
  39480. return nil
  39481. }
  39482. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39483. }
  39484. // ResetField resets all changes in the mutation for the field with the given name.
  39485. // It returns an error if the field is not defined in the schema.
  39486. func (m *WorkExperienceMutation) ResetField(name string) error {
  39487. switch name {
  39488. case workexperience.FieldCreatedAt:
  39489. m.ResetCreatedAt()
  39490. return nil
  39491. case workexperience.FieldUpdatedAt:
  39492. m.ResetUpdatedAt()
  39493. return nil
  39494. case workexperience.FieldDeletedAt:
  39495. m.ResetDeletedAt()
  39496. return nil
  39497. case workexperience.FieldEmployeeID:
  39498. m.ResetEmployeeID()
  39499. return nil
  39500. case workexperience.FieldStartDate:
  39501. m.ResetStartDate()
  39502. return nil
  39503. case workexperience.FieldEndDate:
  39504. m.ResetEndDate()
  39505. return nil
  39506. case workexperience.FieldCompany:
  39507. m.ResetCompany()
  39508. return nil
  39509. case workexperience.FieldExperience:
  39510. m.ResetExperience()
  39511. return nil
  39512. case workexperience.FieldOrganizationID:
  39513. m.ResetOrganizationID()
  39514. return nil
  39515. }
  39516. return fmt.Errorf("unknown WorkExperience field %s", name)
  39517. }
  39518. // AddedEdges returns all edge names that were set/added in this mutation.
  39519. func (m *WorkExperienceMutation) AddedEdges() []string {
  39520. edges := make([]string, 0, 1)
  39521. if m.employee != nil {
  39522. edges = append(edges, workexperience.EdgeEmployee)
  39523. }
  39524. return edges
  39525. }
  39526. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39527. // name in this mutation.
  39528. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39529. switch name {
  39530. case workexperience.EdgeEmployee:
  39531. if id := m.employee; id != nil {
  39532. return []ent.Value{*id}
  39533. }
  39534. }
  39535. return nil
  39536. }
  39537. // RemovedEdges returns all edge names that were removed in this mutation.
  39538. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39539. edges := make([]string, 0, 1)
  39540. return edges
  39541. }
  39542. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39543. // the given name in this mutation.
  39544. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39545. return nil
  39546. }
  39547. // ClearedEdges returns all edge names that were cleared in this mutation.
  39548. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39549. edges := make([]string, 0, 1)
  39550. if m.clearedemployee {
  39551. edges = append(edges, workexperience.EdgeEmployee)
  39552. }
  39553. return edges
  39554. }
  39555. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39556. // was cleared in this mutation.
  39557. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39558. switch name {
  39559. case workexperience.EdgeEmployee:
  39560. return m.clearedemployee
  39561. }
  39562. return false
  39563. }
  39564. // ClearEdge clears the value of the edge with the given name. It returns an error
  39565. // if that edge is not defined in the schema.
  39566. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39567. switch name {
  39568. case workexperience.EdgeEmployee:
  39569. m.ClearEmployee()
  39570. return nil
  39571. }
  39572. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39573. }
  39574. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39575. // It returns an error if the edge is not defined in the schema.
  39576. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39577. switch name {
  39578. case workexperience.EdgeEmployee:
  39579. m.ResetEmployee()
  39580. return nil
  39581. }
  39582. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39583. }
  39584. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39585. type WpChatroomMutation struct {
  39586. config
  39587. op Op
  39588. typ string
  39589. id *uint64
  39590. created_at *time.Time
  39591. updated_at *time.Time
  39592. status *uint8
  39593. addstatus *int8
  39594. wx_wxid *string
  39595. chatroom_id *string
  39596. nickname *string
  39597. owner *string
  39598. avatar *string
  39599. member_list *[]string
  39600. appendmember_list []string
  39601. clearedFields map[string]struct{}
  39602. done bool
  39603. oldValue func(context.Context) (*WpChatroom, error)
  39604. predicates []predicate.WpChatroom
  39605. }
  39606. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39607. // wpchatroomOption allows management of the mutation configuration using functional options.
  39608. type wpchatroomOption func(*WpChatroomMutation)
  39609. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39610. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39611. m := &WpChatroomMutation{
  39612. config: c,
  39613. op: op,
  39614. typ: TypeWpChatroom,
  39615. clearedFields: make(map[string]struct{}),
  39616. }
  39617. for _, opt := range opts {
  39618. opt(m)
  39619. }
  39620. return m
  39621. }
  39622. // withWpChatroomID sets the ID field of the mutation.
  39623. func withWpChatroomID(id uint64) wpchatroomOption {
  39624. return func(m *WpChatroomMutation) {
  39625. var (
  39626. err error
  39627. once sync.Once
  39628. value *WpChatroom
  39629. )
  39630. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39631. once.Do(func() {
  39632. if m.done {
  39633. err = errors.New("querying old values post mutation is not allowed")
  39634. } else {
  39635. value, err = m.Client().WpChatroom.Get(ctx, id)
  39636. }
  39637. })
  39638. return value, err
  39639. }
  39640. m.id = &id
  39641. }
  39642. }
  39643. // withWpChatroom sets the old WpChatroom of the mutation.
  39644. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  39645. return func(m *WpChatroomMutation) {
  39646. m.oldValue = func(context.Context) (*WpChatroom, error) {
  39647. return node, nil
  39648. }
  39649. m.id = &node.ID
  39650. }
  39651. }
  39652. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39653. // executed in a transaction (ent.Tx), a transactional client is returned.
  39654. func (m WpChatroomMutation) Client() *Client {
  39655. client := &Client{config: m.config}
  39656. client.init()
  39657. return client
  39658. }
  39659. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39660. // it returns an error otherwise.
  39661. func (m WpChatroomMutation) Tx() (*Tx, error) {
  39662. if _, ok := m.driver.(*txDriver); !ok {
  39663. return nil, errors.New("ent: mutation is not running in a transaction")
  39664. }
  39665. tx := &Tx{config: m.config}
  39666. tx.init()
  39667. return tx, nil
  39668. }
  39669. // SetID sets the value of the id field. Note that this
  39670. // operation is only accepted on creation of WpChatroom entities.
  39671. func (m *WpChatroomMutation) SetID(id uint64) {
  39672. m.id = &id
  39673. }
  39674. // ID returns the ID value in the mutation. Note that the ID is only available
  39675. // if it was provided to the builder or after it was returned from the database.
  39676. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  39677. if m.id == nil {
  39678. return
  39679. }
  39680. return *m.id, true
  39681. }
  39682. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39683. // That means, if the mutation is applied within a transaction with an isolation level such
  39684. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39685. // or updated by the mutation.
  39686. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  39687. switch {
  39688. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39689. id, exists := m.ID()
  39690. if exists {
  39691. return []uint64{id}, nil
  39692. }
  39693. fallthrough
  39694. case m.op.Is(OpUpdate | OpDelete):
  39695. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  39696. default:
  39697. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39698. }
  39699. }
  39700. // SetCreatedAt sets the "created_at" field.
  39701. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  39702. m.created_at = &t
  39703. }
  39704. // CreatedAt returns the value of the "created_at" field in the mutation.
  39705. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  39706. v := m.created_at
  39707. if v == nil {
  39708. return
  39709. }
  39710. return *v, true
  39711. }
  39712. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  39713. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39715. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39716. if !m.op.Is(OpUpdateOne) {
  39717. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39718. }
  39719. if m.id == nil || m.oldValue == nil {
  39720. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39721. }
  39722. oldValue, err := m.oldValue(ctx)
  39723. if err != nil {
  39724. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39725. }
  39726. return oldValue.CreatedAt, nil
  39727. }
  39728. // ResetCreatedAt resets all changes to the "created_at" field.
  39729. func (m *WpChatroomMutation) ResetCreatedAt() {
  39730. m.created_at = nil
  39731. }
  39732. // SetUpdatedAt sets the "updated_at" field.
  39733. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  39734. m.updated_at = &t
  39735. }
  39736. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39737. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  39738. v := m.updated_at
  39739. if v == nil {
  39740. return
  39741. }
  39742. return *v, true
  39743. }
  39744. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  39745. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39747. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39748. if !m.op.Is(OpUpdateOne) {
  39749. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39750. }
  39751. if m.id == nil || m.oldValue == nil {
  39752. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39753. }
  39754. oldValue, err := m.oldValue(ctx)
  39755. if err != nil {
  39756. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39757. }
  39758. return oldValue.UpdatedAt, nil
  39759. }
  39760. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39761. func (m *WpChatroomMutation) ResetUpdatedAt() {
  39762. m.updated_at = nil
  39763. }
  39764. // SetStatus sets the "status" field.
  39765. func (m *WpChatroomMutation) SetStatus(u uint8) {
  39766. m.status = &u
  39767. m.addstatus = nil
  39768. }
  39769. // Status returns the value of the "status" field in the mutation.
  39770. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  39771. v := m.status
  39772. if v == nil {
  39773. return
  39774. }
  39775. return *v, true
  39776. }
  39777. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  39778. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39780. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39781. if !m.op.Is(OpUpdateOne) {
  39782. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39783. }
  39784. if m.id == nil || m.oldValue == nil {
  39785. return v, errors.New("OldStatus requires an ID field in the mutation")
  39786. }
  39787. oldValue, err := m.oldValue(ctx)
  39788. if err != nil {
  39789. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39790. }
  39791. return oldValue.Status, nil
  39792. }
  39793. // AddStatus adds u to the "status" field.
  39794. func (m *WpChatroomMutation) AddStatus(u int8) {
  39795. if m.addstatus != nil {
  39796. *m.addstatus += u
  39797. } else {
  39798. m.addstatus = &u
  39799. }
  39800. }
  39801. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39802. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  39803. v := m.addstatus
  39804. if v == nil {
  39805. return
  39806. }
  39807. return *v, true
  39808. }
  39809. // ClearStatus clears the value of the "status" field.
  39810. func (m *WpChatroomMutation) ClearStatus() {
  39811. m.status = nil
  39812. m.addstatus = nil
  39813. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  39814. }
  39815. // StatusCleared returns if the "status" field was cleared in this mutation.
  39816. func (m *WpChatroomMutation) StatusCleared() bool {
  39817. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  39818. return ok
  39819. }
  39820. // ResetStatus resets all changes to the "status" field.
  39821. func (m *WpChatroomMutation) ResetStatus() {
  39822. m.status = nil
  39823. m.addstatus = nil
  39824. delete(m.clearedFields, wpchatroom.FieldStatus)
  39825. }
  39826. // SetWxWxid sets the "wx_wxid" field.
  39827. func (m *WpChatroomMutation) SetWxWxid(s string) {
  39828. m.wx_wxid = &s
  39829. }
  39830. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39831. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  39832. v := m.wx_wxid
  39833. if v == nil {
  39834. return
  39835. }
  39836. return *v, true
  39837. }
  39838. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  39839. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39841. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39842. if !m.op.Is(OpUpdateOne) {
  39843. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39844. }
  39845. if m.id == nil || m.oldValue == nil {
  39846. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39847. }
  39848. oldValue, err := m.oldValue(ctx)
  39849. if err != nil {
  39850. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39851. }
  39852. return oldValue.WxWxid, nil
  39853. }
  39854. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39855. func (m *WpChatroomMutation) ResetWxWxid() {
  39856. m.wx_wxid = nil
  39857. }
  39858. // SetChatroomID sets the "chatroom_id" field.
  39859. func (m *WpChatroomMutation) SetChatroomID(s string) {
  39860. m.chatroom_id = &s
  39861. }
  39862. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  39863. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  39864. v := m.chatroom_id
  39865. if v == nil {
  39866. return
  39867. }
  39868. return *v, true
  39869. }
  39870. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  39871. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39873. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  39874. if !m.op.Is(OpUpdateOne) {
  39875. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  39876. }
  39877. if m.id == nil || m.oldValue == nil {
  39878. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  39879. }
  39880. oldValue, err := m.oldValue(ctx)
  39881. if err != nil {
  39882. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  39883. }
  39884. return oldValue.ChatroomID, nil
  39885. }
  39886. // ResetChatroomID resets all changes to the "chatroom_id" field.
  39887. func (m *WpChatroomMutation) ResetChatroomID() {
  39888. m.chatroom_id = nil
  39889. }
  39890. // SetNickname sets the "nickname" field.
  39891. func (m *WpChatroomMutation) SetNickname(s string) {
  39892. m.nickname = &s
  39893. }
  39894. // Nickname returns the value of the "nickname" field in the mutation.
  39895. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  39896. v := m.nickname
  39897. if v == nil {
  39898. return
  39899. }
  39900. return *v, true
  39901. }
  39902. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  39903. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39905. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  39906. if !m.op.Is(OpUpdateOne) {
  39907. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39908. }
  39909. if m.id == nil || m.oldValue == nil {
  39910. return v, errors.New("OldNickname requires an ID field in the mutation")
  39911. }
  39912. oldValue, err := m.oldValue(ctx)
  39913. if err != nil {
  39914. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39915. }
  39916. return oldValue.Nickname, nil
  39917. }
  39918. // ResetNickname resets all changes to the "nickname" field.
  39919. func (m *WpChatroomMutation) ResetNickname() {
  39920. m.nickname = nil
  39921. }
  39922. // SetOwner sets the "owner" field.
  39923. func (m *WpChatroomMutation) SetOwner(s string) {
  39924. m.owner = &s
  39925. }
  39926. // Owner returns the value of the "owner" field in the mutation.
  39927. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  39928. v := m.owner
  39929. if v == nil {
  39930. return
  39931. }
  39932. return *v, true
  39933. }
  39934. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  39935. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39937. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  39938. if !m.op.Is(OpUpdateOne) {
  39939. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  39940. }
  39941. if m.id == nil || m.oldValue == nil {
  39942. return v, errors.New("OldOwner requires an ID field in the mutation")
  39943. }
  39944. oldValue, err := m.oldValue(ctx)
  39945. if err != nil {
  39946. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  39947. }
  39948. return oldValue.Owner, nil
  39949. }
  39950. // ResetOwner resets all changes to the "owner" field.
  39951. func (m *WpChatroomMutation) ResetOwner() {
  39952. m.owner = nil
  39953. }
  39954. // SetAvatar sets the "avatar" field.
  39955. func (m *WpChatroomMutation) SetAvatar(s string) {
  39956. m.avatar = &s
  39957. }
  39958. // Avatar returns the value of the "avatar" field in the mutation.
  39959. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  39960. v := m.avatar
  39961. if v == nil {
  39962. return
  39963. }
  39964. return *v, true
  39965. }
  39966. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  39967. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39969. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39970. if !m.op.Is(OpUpdateOne) {
  39971. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39972. }
  39973. if m.id == nil || m.oldValue == nil {
  39974. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39975. }
  39976. oldValue, err := m.oldValue(ctx)
  39977. if err != nil {
  39978. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39979. }
  39980. return oldValue.Avatar, nil
  39981. }
  39982. // ResetAvatar resets all changes to the "avatar" field.
  39983. func (m *WpChatroomMutation) ResetAvatar() {
  39984. m.avatar = nil
  39985. }
  39986. // SetMemberList sets the "member_list" field.
  39987. func (m *WpChatroomMutation) SetMemberList(s []string) {
  39988. m.member_list = &s
  39989. m.appendmember_list = nil
  39990. }
  39991. // MemberList returns the value of the "member_list" field in the mutation.
  39992. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  39993. v := m.member_list
  39994. if v == nil {
  39995. return
  39996. }
  39997. return *v, true
  39998. }
  39999. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  40000. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40002. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  40003. if !m.op.Is(OpUpdateOne) {
  40004. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  40005. }
  40006. if m.id == nil || m.oldValue == nil {
  40007. return v, errors.New("OldMemberList requires an ID field in the mutation")
  40008. }
  40009. oldValue, err := m.oldValue(ctx)
  40010. if err != nil {
  40011. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  40012. }
  40013. return oldValue.MemberList, nil
  40014. }
  40015. // AppendMemberList adds s to the "member_list" field.
  40016. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  40017. m.appendmember_list = append(m.appendmember_list, s...)
  40018. }
  40019. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  40020. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  40021. if len(m.appendmember_list) == 0 {
  40022. return nil, false
  40023. }
  40024. return m.appendmember_list, true
  40025. }
  40026. // ResetMemberList resets all changes to the "member_list" field.
  40027. func (m *WpChatroomMutation) ResetMemberList() {
  40028. m.member_list = nil
  40029. m.appendmember_list = nil
  40030. }
  40031. // Where appends a list predicates to the WpChatroomMutation builder.
  40032. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  40033. m.predicates = append(m.predicates, ps...)
  40034. }
  40035. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  40036. // users can use type-assertion to append predicates that do not depend on any generated package.
  40037. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  40038. p := make([]predicate.WpChatroom, len(ps))
  40039. for i := range ps {
  40040. p[i] = ps[i]
  40041. }
  40042. m.Where(p...)
  40043. }
  40044. // Op returns the operation name.
  40045. func (m *WpChatroomMutation) Op() Op {
  40046. return m.op
  40047. }
  40048. // SetOp allows setting the mutation operation.
  40049. func (m *WpChatroomMutation) SetOp(op Op) {
  40050. m.op = op
  40051. }
  40052. // Type returns the node type of this mutation (WpChatroom).
  40053. func (m *WpChatroomMutation) Type() string {
  40054. return m.typ
  40055. }
  40056. // Fields returns all fields that were changed during this mutation. Note that in
  40057. // order to get all numeric fields that were incremented/decremented, call
  40058. // AddedFields().
  40059. func (m *WpChatroomMutation) Fields() []string {
  40060. fields := make([]string, 0, 9)
  40061. if m.created_at != nil {
  40062. fields = append(fields, wpchatroom.FieldCreatedAt)
  40063. }
  40064. if m.updated_at != nil {
  40065. fields = append(fields, wpchatroom.FieldUpdatedAt)
  40066. }
  40067. if m.status != nil {
  40068. fields = append(fields, wpchatroom.FieldStatus)
  40069. }
  40070. if m.wx_wxid != nil {
  40071. fields = append(fields, wpchatroom.FieldWxWxid)
  40072. }
  40073. if m.chatroom_id != nil {
  40074. fields = append(fields, wpchatroom.FieldChatroomID)
  40075. }
  40076. if m.nickname != nil {
  40077. fields = append(fields, wpchatroom.FieldNickname)
  40078. }
  40079. if m.owner != nil {
  40080. fields = append(fields, wpchatroom.FieldOwner)
  40081. }
  40082. if m.avatar != nil {
  40083. fields = append(fields, wpchatroom.FieldAvatar)
  40084. }
  40085. if m.member_list != nil {
  40086. fields = append(fields, wpchatroom.FieldMemberList)
  40087. }
  40088. return fields
  40089. }
  40090. // Field returns the value of a field with the given name. The second boolean
  40091. // return value indicates that this field was not set, or was not defined in the
  40092. // schema.
  40093. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40094. switch name {
  40095. case wpchatroom.FieldCreatedAt:
  40096. return m.CreatedAt()
  40097. case wpchatroom.FieldUpdatedAt:
  40098. return m.UpdatedAt()
  40099. case wpchatroom.FieldStatus:
  40100. return m.Status()
  40101. case wpchatroom.FieldWxWxid:
  40102. return m.WxWxid()
  40103. case wpchatroom.FieldChatroomID:
  40104. return m.ChatroomID()
  40105. case wpchatroom.FieldNickname:
  40106. return m.Nickname()
  40107. case wpchatroom.FieldOwner:
  40108. return m.Owner()
  40109. case wpchatroom.FieldAvatar:
  40110. return m.Avatar()
  40111. case wpchatroom.FieldMemberList:
  40112. return m.MemberList()
  40113. }
  40114. return nil, false
  40115. }
  40116. // OldField returns the old value of the field from the database. An error is
  40117. // returned if the mutation operation is not UpdateOne, or the query to the
  40118. // database failed.
  40119. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40120. switch name {
  40121. case wpchatroom.FieldCreatedAt:
  40122. return m.OldCreatedAt(ctx)
  40123. case wpchatroom.FieldUpdatedAt:
  40124. return m.OldUpdatedAt(ctx)
  40125. case wpchatroom.FieldStatus:
  40126. return m.OldStatus(ctx)
  40127. case wpchatroom.FieldWxWxid:
  40128. return m.OldWxWxid(ctx)
  40129. case wpchatroom.FieldChatroomID:
  40130. return m.OldChatroomID(ctx)
  40131. case wpchatroom.FieldNickname:
  40132. return m.OldNickname(ctx)
  40133. case wpchatroom.FieldOwner:
  40134. return m.OldOwner(ctx)
  40135. case wpchatroom.FieldAvatar:
  40136. return m.OldAvatar(ctx)
  40137. case wpchatroom.FieldMemberList:
  40138. return m.OldMemberList(ctx)
  40139. }
  40140. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40141. }
  40142. // SetField sets the value of a field with the given name. It returns an error if
  40143. // the field is not defined in the schema, or if the type mismatched the field
  40144. // type.
  40145. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40146. switch name {
  40147. case wpchatroom.FieldCreatedAt:
  40148. v, ok := value.(time.Time)
  40149. if !ok {
  40150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40151. }
  40152. m.SetCreatedAt(v)
  40153. return nil
  40154. case wpchatroom.FieldUpdatedAt:
  40155. v, ok := value.(time.Time)
  40156. if !ok {
  40157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40158. }
  40159. m.SetUpdatedAt(v)
  40160. return nil
  40161. case wpchatroom.FieldStatus:
  40162. v, ok := value.(uint8)
  40163. if !ok {
  40164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40165. }
  40166. m.SetStatus(v)
  40167. return nil
  40168. case wpchatroom.FieldWxWxid:
  40169. v, ok := value.(string)
  40170. if !ok {
  40171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40172. }
  40173. m.SetWxWxid(v)
  40174. return nil
  40175. case wpchatroom.FieldChatroomID:
  40176. v, ok := value.(string)
  40177. if !ok {
  40178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40179. }
  40180. m.SetChatroomID(v)
  40181. return nil
  40182. case wpchatroom.FieldNickname:
  40183. v, ok := value.(string)
  40184. if !ok {
  40185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40186. }
  40187. m.SetNickname(v)
  40188. return nil
  40189. case wpchatroom.FieldOwner:
  40190. v, ok := value.(string)
  40191. if !ok {
  40192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40193. }
  40194. m.SetOwner(v)
  40195. return nil
  40196. case wpchatroom.FieldAvatar:
  40197. v, ok := value.(string)
  40198. if !ok {
  40199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40200. }
  40201. m.SetAvatar(v)
  40202. return nil
  40203. case wpchatroom.FieldMemberList:
  40204. v, ok := value.([]string)
  40205. if !ok {
  40206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40207. }
  40208. m.SetMemberList(v)
  40209. return nil
  40210. }
  40211. return fmt.Errorf("unknown WpChatroom field %s", name)
  40212. }
  40213. // AddedFields returns all numeric fields that were incremented/decremented during
  40214. // this mutation.
  40215. func (m *WpChatroomMutation) AddedFields() []string {
  40216. var fields []string
  40217. if m.addstatus != nil {
  40218. fields = append(fields, wpchatroom.FieldStatus)
  40219. }
  40220. return fields
  40221. }
  40222. // AddedField returns the numeric value that was incremented/decremented on a field
  40223. // with the given name. The second boolean return value indicates that this field
  40224. // was not set, or was not defined in the schema.
  40225. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40226. switch name {
  40227. case wpchatroom.FieldStatus:
  40228. return m.AddedStatus()
  40229. }
  40230. return nil, false
  40231. }
  40232. // AddField adds the value to the field with the given name. It returns an error if
  40233. // the field is not defined in the schema, or if the type mismatched the field
  40234. // type.
  40235. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40236. switch name {
  40237. case wpchatroom.FieldStatus:
  40238. v, ok := value.(int8)
  40239. if !ok {
  40240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40241. }
  40242. m.AddStatus(v)
  40243. return nil
  40244. }
  40245. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40246. }
  40247. // ClearedFields returns all nullable fields that were cleared during this
  40248. // mutation.
  40249. func (m *WpChatroomMutation) ClearedFields() []string {
  40250. var fields []string
  40251. if m.FieldCleared(wpchatroom.FieldStatus) {
  40252. fields = append(fields, wpchatroom.FieldStatus)
  40253. }
  40254. return fields
  40255. }
  40256. // FieldCleared returns a boolean indicating if a field with the given name was
  40257. // cleared in this mutation.
  40258. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40259. _, ok := m.clearedFields[name]
  40260. return ok
  40261. }
  40262. // ClearField clears the value of the field with the given name. It returns an
  40263. // error if the field is not defined in the schema.
  40264. func (m *WpChatroomMutation) ClearField(name string) error {
  40265. switch name {
  40266. case wpchatroom.FieldStatus:
  40267. m.ClearStatus()
  40268. return nil
  40269. }
  40270. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40271. }
  40272. // ResetField resets all changes in the mutation for the field with the given name.
  40273. // It returns an error if the field is not defined in the schema.
  40274. func (m *WpChatroomMutation) ResetField(name string) error {
  40275. switch name {
  40276. case wpchatroom.FieldCreatedAt:
  40277. m.ResetCreatedAt()
  40278. return nil
  40279. case wpchatroom.FieldUpdatedAt:
  40280. m.ResetUpdatedAt()
  40281. return nil
  40282. case wpchatroom.FieldStatus:
  40283. m.ResetStatus()
  40284. return nil
  40285. case wpchatroom.FieldWxWxid:
  40286. m.ResetWxWxid()
  40287. return nil
  40288. case wpchatroom.FieldChatroomID:
  40289. m.ResetChatroomID()
  40290. return nil
  40291. case wpchatroom.FieldNickname:
  40292. m.ResetNickname()
  40293. return nil
  40294. case wpchatroom.FieldOwner:
  40295. m.ResetOwner()
  40296. return nil
  40297. case wpchatroom.FieldAvatar:
  40298. m.ResetAvatar()
  40299. return nil
  40300. case wpchatroom.FieldMemberList:
  40301. m.ResetMemberList()
  40302. return nil
  40303. }
  40304. return fmt.Errorf("unknown WpChatroom field %s", name)
  40305. }
  40306. // AddedEdges returns all edge names that were set/added in this mutation.
  40307. func (m *WpChatroomMutation) AddedEdges() []string {
  40308. edges := make([]string, 0, 0)
  40309. return edges
  40310. }
  40311. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40312. // name in this mutation.
  40313. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40314. return nil
  40315. }
  40316. // RemovedEdges returns all edge names that were removed in this mutation.
  40317. func (m *WpChatroomMutation) RemovedEdges() []string {
  40318. edges := make([]string, 0, 0)
  40319. return edges
  40320. }
  40321. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40322. // the given name in this mutation.
  40323. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40324. return nil
  40325. }
  40326. // ClearedEdges returns all edge names that were cleared in this mutation.
  40327. func (m *WpChatroomMutation) ClearedEdges() []string {
  40328. edges := make([]string, 0, 0)
  40329. return edges
  40330. }
  40331. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40332. // was cleared in this mutation.
  40333. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40334. return false
  40335. }
  40336. // ClearEdge clears the value of the edge with the given name. It returns an error
  40337. // if that edge is not defined in the schema.
  40338. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40339. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40340. }
  40341. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40342. // It returns an error if the edge is not defined in the schema.
  40343. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40344. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40345. }
  40346. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40347. type WpChatroomMemberMutation struct {
  40348. config
  40349. op Op
  40350. typ string
  40351. id *uint64
  40352. created_at *time.Time
  40353. updated_at *time.Time
  40354. status *uint8
  40355. addstatus *int8
  40356. wx_wxid *string
  40357. wxid *string
  40358. nickname *string
  40359. avatar *string
  40360. clearedFields map[string]struct{}
  40361. done bool
  40362. oldValue func(context.Context) (*WpChatroomMember, error)
  40363. predicates []predicate.WpChatroomMember
  40364. }
  40365. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40366. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40367. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40368. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40369. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40370. m := &WpChatroomMemberMutation{
  40371. config: c,
  40372. op: op,
  40373. typ: TypeWpChatroomMember,
  40374. clearedFields: make(map[string]struct{}),
  40375. }
  40376. for _, opt := range opts {
  40377. opt(m)
  40378. }
  40379. return m
  40380. }
  40381. // withWpChatroomMemberID sets the ID field of the mutation.
  40382. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40383. return func(m *WpChatroomMemberMutation) {
  40384. var (
  40385. err error
  40386. once sync.Once
  40387. value *WpChatroomMember
  40388. )
  40389. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40390. once.Do(func() {
  40391. if m.done {
  40392. err = errors.New("querying old values post mutation is not allowed")
  40393. } else {
  40394. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40395. }
  40396. })
  40397. return value, err
  40398. }
  40399. m.id = &id
  40400. }
  40401. }
  40402. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40403. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40404. return func(m *WpChatroomMemberMutation) {
  40405. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40406. return node, nil
  40407. }
  40408. m.id = &node.ID
  40409. }
  40410. }
  40411. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40412. // executed in a transaction (ent.Tx), a transactional client is returned.
  40413. func (m WpChatroomMemberMutation) Client() *Client {
  40414. client := &Client{config: m.config}
  40415. client.init()
  40416. return client
  40417. }
  40418. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40419. // it returns an error otherwise.
  40420. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40421. if _, ok := m.driver.(*txDriver); !ok {
  40422. return nil, errors.New("ent: mutation is not running in a transaction")
  40423. }
  40424. tx := &Tx{config: m.config}
  40425. tx.init()
  40426. return tx, nil
  40427. }
  40428. // SetID sets the value of the id field. Note that this
  40429. // operation is only accepted on creation of WpChatroomMember entities.
  40430. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40431. m.id = &id
  40432. }
  40433. // ID returns the ID value in the mutation. Note that the ID is only available
  40434. // if it was provided to the builder or after it was returned from the database.
  40435. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40436. if m.id == nil {
  40437. return
  40438. }
  40439. return *m.id, true
  40440. }
  40441. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40442. // That means, if the mutation is applied within a transaction with an isolation level such
  40443. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40444. // or updated by the mutation.
  40445. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40446. switch {
  40447. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40448. id, exists := m.ID()
  40449. if exists {
  40450. return []uint64{id}, nil
  40451. }
  40452. fallthrough
  40453. case m.op.Is(OpUpdate | OpDelete):
  40454. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40455. default:
  40456. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40457. }
  40458. }
  40459. // SetCreatedAt sets the "created_at" field.
  40460. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40461. m.created_at = &t
  40462. }
  40463. // CreatedAt returns the value of the "created_at" field in the mutation.
  40464. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40465. v := m.created_at
  40466. if v == nil {
  40467. return
  40468. }
  40469. return *v, true
  40470. }
  40471. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40472. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40474. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40475. if !m.op.Is(OpUpdateOne) {
  40476. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40477. }
  40478. if m.id == nil || m.oldValue == nil {
  40479. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40480. }
  40481. oldValue, err := m.oldValue(ctx)
  40482. if err != nil {
  40483. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40484. }
  40485. return oldValue.CreatedAt, nil
  40486. }
  40487. // ResetCreatedAt resets all changes to the "created_at" field.
  40488. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40489. m.created_at = nil
  40490. }
  40491. // SetUpdatedAt sets the "updated_at" field.
  40492. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40493. m.updated_at = &t
  40494. }
  40495. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40496. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40497. v := m.updated_at
  40498. if v == nil {
  40499. return
  40500. }
  40501. return *v, true
  40502. }
  40503. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40504. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40506. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40507. if !m.op.Is(OpUpdateOne) {
  40508. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40509. }
  40510. if m.id == nil || m.oldValue == nil {
  40511. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40512. }
  40513. oldValue, err := m.oldValue(ctx)
  40514. if err != nil {
  40515. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40516. }
  40517. return oldValue.UpdatedAt, nil
  40518. }
  40519. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40520. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40521. m.updated_at = nil
  40522. }
  40523. // SetStatus sets the "status" field.
  40524. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40525. m.status = &u
  40526. m.addstatus = nil
  40527. }
  40528. // Status returns the value of the "status" field in the mutation.
  40529. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40530. v := m.status
  40531. if v == nil {
  40532. return
  40533. }
  40534. return *v, true
  40535. }
  40536. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40537. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40539. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40540. if !m.op.Is(OpUpdateOne) {
  40541. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40542. }
  40543. if m.id == nil || m.oldValue == nil {
  40544. return v, errors.New("OldStatus requires an ID field in the mutation")
  40545. }
  40546. oldValue, err := m.oldValue(ctx)
  40547. if err != nil {
  40548. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40549. }
  40550. return oldValue.Status, nil
  40551. }
  40552. // AddStatus adds u to the "status" field.
  40553. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40554. if m.addstatus != nil {
  40555. *m.addstatus += u
  40556. } else {
  40557. m.addstatus = &u
  40558. }
  40559. }
  40560. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40561. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40562. v := m.addstatus
  40563. if v == nil {
  40564. return
  40565. }
  40566. return *v, true
  40567. }
  40568. // ClearStatus clears the value of the "status" field.
  40569. func (m *WpChatroomMemberMutation) ClearStatus() {
  40570. m.status = nil
  40571. m.addstatus = nil
  40572. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40573. }
  40574. // StatusCleared returns if the "status" field was cleared in this mutation.
  40575. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40576. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40577. return ok
  40578. }
  40579. // ResetStatus resets all changes to the "status" field.
  40580. func (m *WpChatroomMemberMutation) ResetStatus() {
  40581. m.status = nil
  40582. m.addstatus = nil
  40583. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40584. }
  40585. // SetWxWxid sets the "wx_wxid" field.
  40586. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40587. m.wx_wxid = &s
  40588. }
  40589. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40590. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40591. v := m.wx_wxid
  40592. if v == nil {
  40593. return
  40594. }
  40595. return *v, true
  40596. }
  40597. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40598. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40600. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40601. if !m.op.Is(OpUpdateOne) {
  40602. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40603. }
  40604. if m.id == nil || m.oldValue == nil {
  40605. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40606. }
  40607. oldValue, err := m.oldValue(ctx)
  40608. if err != nil {
  40609. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40610. }
  40611. return oldValue.WxWxid, nil
  40612. }
  40613. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40614. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40615. m.wx_wxid = nil
  40616. }
  40617. // SetWxid sets the "wxid" field.
  40618. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40619. m.wxid = &s
  40620. }
  40621. // Wxid returns the value of the "wxid" field in the mutation.
  40622. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40623. v := m.wxid
  40624. if v == nil {
  40625. return
  40626. }
  40627. return *v, true
  40628. }
  40629. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40630. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40632. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40633. if !m.op.Is(OpUpdateOne) {
  40634. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40635. }
  40636. if m.id == nil || m.oldValue == nil {
  40637. return v, errors.New("OldWxid requires an ID field in the mutation")
  40638. }
  40639. oldValue, err := m.oldValue(ctx)
  40640. if err != nil {
  40641. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40642. }
  40643. return oldValue.Wxid, nil
  40644. }
  40645. // ResetWxid resets all changes to the "wxid" field.
  40646. func (m *WpChatroomMemberMutation) ResetWxid() {
  40647. m.wxid = nil
  40648. }
  40649. // SetNickname sets the "nickname" field.
  40650. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  40651. m.nickname = &s
  40652. }
  40653. // Nickname returns the value of the "nickname" field in the mutation.
  40654. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  40655. v := m.nickname
  40656. if v == nil {
  40657. return
  40658. }
  40659. return *v, true
  40660. }
  40661. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  40662. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40664. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  40665. if !m.op.Is(OpUpdateOne) {
  40666. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40667. }
  40668. if m.id == nil || m.oldValue == nil {
  40669. return v, errors.New("OldNickname requires an ID field in the mutation")
  40670. }
  40671. oldValue, err := m.oldValue(ctx)
  40672. if err != nil {
  40673. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40674. }
  40675. return oldValue.Nickname, nil
  40676. }
  40677. // ResetNickname resets all changes to the "nickname" field.
  40678. func (m *WpChatroomMemberMutation) ResetNickname() {
  40679. m.nickname = nil
  40680. }
  40681. // SetAvatar sets the "avatar" field.
  40682. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  40683. m.avatar = &s
  40684. }
  40685. // Avatar returns the value of the "avatar" field in the mutation.
  40686. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  40687. v := m.avatar
  40688. if v == nil {
  40689. return
  40690. }
  40691. return *v, true
  40692. }
  40693. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  40694. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40696. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40697. if !m.op.Is(OpUpdateOne) {
  40698. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40699. }
  40700. if m.id == nil || m.oldValue == nil {
  40701. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40702. }
  40703. oldValue, err := m.oldValue(ctx)
  40704. if err != nil {
  40705. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40706. }
  40707. return oldValue.Avatar, nil
  40708. }
  40709. // ResetAvatar resets all changes to the "avatar" field.
  40710. func (m *WpChatroomMemberMutation) ResetAvatar() {
  40711. m.avatar = nil
  40712. }
  40713. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  40714. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  40715. m.predicates = append(m.predicates, ps...)
  40716. }
  40717. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  40718. // users can use type-assertion to append predicates that do not depend on any generated package.
  40719. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  40720. p := make([]predicate.WpChatroomMember, len(ps))
  40721. for i := range ps {
  40722. p[i] = ps[i]
  40723. }
  40724. m.Where(p...)
  40725. }
  40726. // Op returns the operation name.
  40727. func (m *WpChatroomMemberMutation) Op() Op {
  40728. return m.op
  40729. }
  40730. // SetOp allows setting the mutation operation.
  40731. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  40732. m.op = op
  40733. }
  40734. // Type returns the node type of this mutation (WpChatroomMember).
  40735. func (m *WpChatroomMemberMutation) Type() string {
  40736. return m.typ
  40737. }
  40738. // Fields returns all fields that were changed during this mutation. Note that in
  40739. // order to get all numeric fields that were incremented/decremented, call
  40740. // AddedFields().
  40741. func (m *WpChatroomMemberMutation) Fields() []string {
  40742. fields := make([]string, 0, 7)
  40743. if m.created_at != nil {
  40744. fields = append(fields, wpchatroommember.FieldCreatedAt)
  40745. }
  40746. if m.updated_at != nil {
  40747. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  40748. }
  40749. if m.status != nil {
  40750. fields = append(fields, wpchatroommember.FieldStatus)
  40751. }
  40752. if m.wx_wxid != nil {
  40753. fields = append(fields, wpchatroommember.FieldWxWxid)
  40754. }
  40755. if m.wxid != nil {
  40756. fields = append(fields, wpchatroommember.FieldWxid)
  40757. }
  40758. if m.nickname != nil {
  40759. fields = append(fields, wpchatroommember.FieldNickname)
  40760. }
  40761. if m.avatar != nil {
  40762. fields = append(fields, wpchatroommember.FieldAvatar)
  40763. }
  40764. return fields
  40765. }
  40766. // Field returns the value of a field with the given name. The second boolean
  40767. // return value indicates that this field was not set, or was not defined in the
  40768. // schema.
  40769. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  40770. switch name {
  40771. case wpchatroommember.FieldCreatedAt:
  40772. return m.CreatedAt()
  40773. case wpchatroommember.FieldUpdatedAt:
  40774. return m.UpdatedAt()
  40775. case wpchatroommember.FieldStatus:
  40776. return m.Status()
  40777. case wpchatroommember.FieldWxWxid:
  40778. return m.WxWxid()
  40779. case wpchatroommember.FieldWxid:
  40780. return m.Wxid()
  40781. case wpchatroommember.FieldNickname:
  40782. return m.Nickname()
  40783. case wpchatroommember.FieldAvatar:
  40784. return m.Avatar()
  40785. }
  40786. return nil, false
  40787. }
  40788. // OldField returns the old value of the field from the database. An error is
  40789. // returned if the mutation operation is not UpdateOne, or the query to the
  40790. // database failed.
  40791. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40792. switch name {
  40793. case wpchatroommember.FieldCreatedAt:
  40794. return m.OldCreatedAt(ctx)
  40795. case wpchatroommember.FieldUpdatedAt:
  40796. return m.OldUpdatedAt(ctx)
  40797. case wpchatroommember.FieldStatus:
  40798. return m.OldStatus(ctx)
  40799. case wpchatroommember.FieldWxWxid:
  40800. return m.OldWxWxid(ctx)
  40801. case wpchatroommember.FieldWxid:
  40802. return m.OldWxid(ctx)
  40803. case wpchatroommember.FieldNickname:
  40804. return m.OldNickname(ctx)
  40805. case wpchatroommember.FieldAvatar:
  40806. return m.OldAvatar(ctx)
  40807. }
  40808. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  40809. }
  40810. // SetField sets the value of a field with the given name. It returns an error if
  40811. // the field is not defined in the schema, or if the type mismatched the field
  40812. // type.
  40813. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  40814. switch name {
  40815. case wpchatroommember.FieldCreatedAt:
  40816. v, ok := value.(time.Time)
  40817. if !ok {
  40818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40819. }
  40820. m.SetCreatedAt(v)
  40821. return nil
  40822. case wpchatroommember.FieldUpdatedAt:
  40823. v, ok := value.(time.Time)
  40824. if !ok {
  40825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40826. }
  40827. m.SetUpdatedAt(v)
  40828. return nil
  40829. case wpchatroommember.FieldStatus:
  40830. v, ok := value.(uint8)
  40831. if !ok {
  40832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40833. }
  40834. m.SetStatus(v)
  40835. return nil
  40836. case wpchatroommember.FieldWxWxid:
  40837. v, ok := value.(string)
  40838. if !ok {
  40839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40840. }
  40841. m.SetWxWxid(v)
  40842. return nil
  40843. case wpchatroommember.FieldWxid:
  40844. v, ok := value.(string)
  40845. if !ok {
  40846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40847. }
  40848. m.SetWxid(v)
  40849. return nil
  40850. case wpchatroommember.FieldNickname:
  40851. v, ok := value.(string)
  40852. if !ok {
  40853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40854. }
  40855. m.SetNickname(v)
  40856. return nil
  40857. case wpchatroommember.FieldAvatar:
  40858. v, ok := value.(string)
  40859. if !ok {
  40860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40861. }
  40862. m.SetAvatar(v)
  40863. return nil
  40864. }
  40865. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40866. }
  40867. // AddedFields returns all numeric fields that were incremented/decremented during
  40868. // this mutation.
  40869. func (m *WpChatroomMemberMutation) AddedFields() []string {
  40870. var fields []string
  40871. if m.addstatus != nil {
  40872. fields = append(fields, wpchatroommember.FieldStatus)
  40873. }
  40874. return fields
  40875. }
  40876. // AddedField returns the numeric value that was incremented/decremented on a field
  40877. // with the given name. The second boolean return value indicates that this field
  40878. // was not set, or was not defined in the schema.
  40879. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  40880. switch name {
  40881. case wpchatroommember.FieldStatus:
  40882. return m.AddedStatus()
  40883. }
  40884. return nil, false
  40885. }
  40886. // AddField adds the value to the field with the given name. It returns an error if
  40887. // the field is not defined in the schema, or if the type mismatched the field
  40888. // type.
  40889. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  40890. switch name {
  40891. case wpchatroommember.FieldStatus:
  40892. v, ok := value.(int8)
  40893. if !ok {
  40894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40895. }
  40896. m.AddStatus(v)
  40897. return nil
  40898. }
  40899. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  40900. }
  40901. // ClearedFields returns all nullable fields that were cleared during this
  40902. // mutation.
  40903. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  40904. var fields []string
  40905. if m.FieldCleared(wpchatroommember.FieldStatus) {
  40906. fields = append(fields, wpchatroommember.FieldStatus)
  40907. }
  40908. return fields
  40909. }
  40910. // FieldCleared returns a boolean indicating if a field with the given name was
  40911. // cleared in this mutation.
  40912. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  40913. _, ok := m.clearedFields[name]
  40914. return ok
  40915. }
  40916. // ClearField clears the value of the field with the given name. It returns an
  40917. // error if the field is not defined in the schema.
  40918. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  40919. switch name {
  40920. case wpchatroommember.FieldStatus:
  40921. m.ClearStatus()
  40922. return nil
  40923. }
  40924. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  40925. }
  40926. // ResetField resets all changes in the mutation for the field with the given name.
  40927. // It returns an error if the field is not defined in the schema.
  40928. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  40929. switch name {
  40930. case wpchatroommember.FieldCreatedAt:
  40931. m.ResetCreatedAt()
  40932. return nil
  40933. case wpchatroommember.FieldUpdatedAt:
  40934. m.ResetUpdatedAt()
  40935. return nil
  40936. case wpchatroommember.FieldStatus:
  40937. m.ResetStatus()
  40938. return nil
  40939. case wpchatroommember.FieldWxWxid:
  40940. m.ResetWxWxid()
  40941. return nil
  40942. case wpchatroommember.FieldWxid:
  40943. m.ResetWxid()
  40944. return nil
  40945. case wpchatroommember.FieldNickname:
  40946. m.ResetNickname()
  40947. return nil
  40948. case wpchatroommember.FieldAvatar:
  40949. m.ResetAvatar()
  40950. return nil
  40951. }
  40952. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40953. }
  40954. // AddedEdges returns all edge names that were set/added in this mutation.
  40955. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  40956. edges := make([]string, 0, 0)
  40957. return edges
  40958. }
  40959. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40960. // name in this mutation.
  40961. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  40962. return nil
  40963. }
  40964. // RemovedEdges returns all edge names that were removed in this mutation.
  40965. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  40966. edges := make([]string, 0, 0)
  40967. return edges
  40968. }
  40969. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40970. // the given name in this mutation.
  40971. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  40972. return nil
  40973. }
  40974. // ClearedEdges returns all edge names that were cleared in this mutation.
  40975. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  40976. edges := make([]string, 0, 0)
  40977. return edges
  40978. }
  40979. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40980. // was cleared in this mutation.
  40981. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  40982. return false
  40983. }
  40984. // ClearEdge clears the value of the edge with the given name. It returns an error
  40985. // if that edge is not defined in the schema.
  40986. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  40987. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  40988. }
  40989. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40990. // It returns an error if the edge is not defined in the schema.
  40991. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  40992. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  40993. }
  40994. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  40995. type WxMutation struct {
  40996. config
  40997. op Op
  40998. typ string
  40999. id *uint64
  41000. created_at *time.Time
  41001. updated_at *time.Time
  41002. status *uint8
  41003. addstatus *int8
  41004. deleted_at *time.Time
  41005. port *string
  41006. process_id *string
  41007. callback *string
  41008. wxid *string
  41009. account *string
  41010. nickname *string
  41011. tel *string
  41012. head_big *string
  41013. organization_id *uint64
  41014. addorganization_id *int64
  41015. api_base *string
  41016. api_key *string
  41017. allow_list *[]string
  41018. appendallow_list []string
  41019. group_allow_list *[]string
  41020. appendgroup_allow_list []string
  41021. block_list *[]string
  41022. appendblock_list []string
  41023. group_block_list *[]string
  41024. appendgroup_block_list []string
  41025. ctype *uint64
  41026. addctype *int64
  41027. clearedFields map[string]struct{}
  41028. server *uint64
  41029. clearedserver bool
  41030. agent *uint64
  41031. clearedagent bool
  41032. done bool
  41033. oldValue func(context.Context) (*Wx, error)
  41034. predicates []predicate.Wx
  41035. }
  41036. var _ ent.Mutation = (*WxMutation)(nil)
  41037. // wxOption allows management of the mutation configuration using functional options.
  41038. type wxOption func(*WxMutation)
  41039. // newWxMutation creates new mutation for the Wx entity.
  41040. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  41041. m := &WxMutation{
  41042. config: c,
  41043. op: op,
  41044. typ: TypeWx,
  41045. clearedFields: make(map[string]struct{}),
  41046. }
  41047. for _, opt := range opts {
  41048. opt(m)
  41049. }
  41050. return m
  41051. }
  41052. // withWxID sets the ID field of the mutation.
  41053. func withWxID(id uint64) wxOption {
  41054. return func(m *WxMutation) {
  41055. var (
  41056. err error
  41057. once sync.Once
  41058. value *Wx
  41059. )
  41060. m.oldValue = func(ctx context.Context) (*Wx, error) {
  41061. once.Do(func() {
  41062. if m.done {
  41063. err = errors.New("querying old values post mutation is not allowed")
  41064. } else {
  41065. value, err = m.Client().Wx.Get(ctx, id)
  41066. }
  41067. })
  41068. return value, err
  41069. }
  41070. m.id = &id
  41071. }
  41072. }
  41073. // withWx sets the old Wx of the mutation.
  41074. func withWx(node *Wx) wxOption {
  41075. return func(m *WxMutation) {
  41076. m.oldValue = func(context.Context) (*Wx, error) {
  41077. return node, nil
  41078. }
  41079. m.id = &node.ID
  41080. }
  41081. }
  41082. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41083. // executed in a transaction (ent.Tx), a transactional client is returned.
  41084. func (m WxMutation) Client() *Client {
  41085. client := &Client{config: m.config}
  41086. client.init()
  41087. return client
  41088. }
  41089. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41090. // it returns an error otherwise.
  41091. func (m WxMutation) Tx() (*Tx, error) {
  41092. if _, ok := m.driver.(*txDriver); !ok {
  41093. return nil, errors.New("ent: mutation is not running in a transaction")
  41094. }
  41095. tx := &Tx{config: m.config}
  41096. tx.init()
  41097. return tx, nil
  41098. }
  41099. // SetID sets the value of the id field. Note that this
  41100. // operation is only accepted on creation of Wx entities.
  41101. func (m *WxMutation) SetID(id uint64) {
  41102. m.id = &id
  41103. }
  41104. // ID returns the ID value in the mutation. Note that the ID is only available
  41105. // if it was provided to the builder or after it was returned from the database.
  41106. func (m *WxMutation) ID() (id uint64, exists bool) {
  41107. if m.id == nil {
  41108. return
  41109. }
  41110. return *m.id, true
  41111. }
  41112. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41113. // That means, if the mutation is applied within a transaction with an isolation level such
  41114. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41115. // or updated by the mutation.
  41116. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41117. switch {
  41118. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41119. id, exists := m.ID()
  41120. if exists {
  41121. return []uint64{id}, nil
  41122. }
  41123. fallthrough
  41124. case m.op.Is(OpUpdate | OpDelete):
  41125. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41126. default:
  41127. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41128. }
  41129. }
  41130. // SetCreatedAt sets the "created_at" field.
  41131. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41132. m.created_at = &t
  41133. }
  41134. // CreatedAt returns the value of the "created_at" field in the mutation.
  41135. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41136. v := m.created_at
  41137. if v == nil {
  41138. return
  41139. }
  41140. return *v, true
  41141. }
  41142. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41143. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41145. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41146. if !m.op.Is(OpUpdateOne) {
  41147. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41148. }
  41149. if m.id == nil || m.oldValue == nil {
  41150. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41151. }
  41152. oldValue, err := m.oldValue(ctx)
  41153. if err != nil {
  41154. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41155. }
  41156. return oldValue.CreatedAt, nil
  41157. }
  41158. // ResetCreatedAt resets all changes to the "created_at" field.
  41159. func (m *WxMutation) ResetCreatedAt() {
  41160. m.created_at = nil
  41161. }
  41162. // SetUpdatedAt sets the "updated_at" field.
  41163. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41164. m.updated_at = &t
  41165. }
  41166. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41167. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41168. v := m.updated_at
  41169. if v == nil {
  41170. return
  41171. }
  41172. return *v, true
  41173. }
  41174. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41175. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41177. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41178. if !m.op.Is(OpUpdateOne) {
  41179. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41180. }
  41181. if m.id == nil || m.oldValue == nil {
  41182. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41183. }
  41184. oldValue, err := m.oldValue(ctx)
  41185. if err != nil {
  41186. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41187. }
  41188. return oldValue.UpdatedAt, nil
  41189. }
  41190. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41191. func (m *WxMutation) ResetUpdatedAt() {
  41192. m.updated_at = nil
  41193. }
  41194. // SetStatus sets the "status" field.
  41195. func (m *WxMutation) SetStatus(u uint8) {
  41196. m.status = &u
  41197. m.addstatus = nil
  41198. }
  41199. // Status returns the value of the "status" field in the mutation.
  41200. func (m *WxMutation) Status() (r uint8, exists bool) {
  41201. v := m.status
  41202. if v == nil {
  41203. return
  41204. }
  41205. return *v, true
  41206. }
  41207. // OldStatus returns the old "status" field's value of the Wx entity.
  41208. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41210. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41211. if !m.op.Is(OpUpdateOne) {
  41212. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41213. }
  41214. if m.id == nil || m.oldValue == nil {
  41215. return v, errors.New("OldStatus requires an ID field in the mutation")
  41216. }
  41217. oldValue, err := m.oldValue(ctx)
  41218. if err != nil {
  41219. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41220. }
  41221. return oldValue.Status, nil
  41222. }
  41223. // AddStatus adds u to the "status" field.
  41224. func (m *WxMutation) AddStatus(u int8) {
  41225. if m.addstatus != nil {
  41226. *m.addstatus += u
  41227. } else {
  41228. m.addstatus = &u
  41229. }
  41230. }
  41231. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41232. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41233. v := m.addstatus
  41234. if v == nil {
  41235. return
  41236. }
  41237. return *v, true
  41238. }
  41239. // ClearStatus clears the value of the "status" field.
  41240. func (m *WxMutation) ClearStatus() {
  41241. m.status = nil
  41242. m.addstatus = nil
  41243. m.clearedFields[wx.FieldStatus] = struct{}{}
  41244. }
  41245. // StatusCleared returns if the "status" field was cleared in this mutation.
  41246. func (m *WxMutation) StatusCleared() bool {
  41247. _, ok := m.clearedFields[wx.FieldStatus]
  41248. return ok
  41249. }
  41250. // ResetStatus resets all changes to the "status" field.
  41251. func (m *WxMutation) ResetStatus() {
  41252. m.status = nil
  41253. m.addstatus = nil
  41254. delete(m.clearedFields, wx.FieldStatus)
  41255. }
  41256. // SetDeletedAt sets the "deleted_at" field.
  41257. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41258. m.deleted_at = &t
  41259. }
  41260. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41261. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41262. v := m.deleted_at
  41263. if v == nil {
  41264. return
  41265. }
  41266. return *v, true
  41267. }
  41268. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41269. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41271. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41272. if !m.op.Is(OpUpdateOne) {
  41273. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41274. }
  41275. if m.id == nil || m.oldValue == nil {
  41276. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41277. }
  41278. oldValue, err := m.oldValue(ctx)
  41279. if err != nil {
  41280. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41281. }
  41282. return oldValue.DeletedAt, nil
  41283. }
  41284. // ClearDeletedAt clears the value of the "deleted_at" field.
  41285. func (m *WxMutation) ClearDeletedAt() {
  41286. m.deleted_at = nil
  41287. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41288. }
  41289. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41290. func (m *WxMutation) DeletedAtCleared() bool {
  41291. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41292. return ok
  41293. }
  41294. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41295. func (m *WxMutation) ResetDeletedAt() {
  41296. m.deleted_at = nil
  41297. delete(m.clearedFields, wx.FieldDeletedAt)
  41298. }
  41299. // SetServerID sets the "server_id" field.
  41300. func (m *WxMutation) SetServerID(u uint64) {
  41301. m.server = &u
  41302. }
  41303. // ServerID returns the value of the "server_id" field in the mutation.
  41304. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41305. v := m.server
  41306. if v == nil {
  41307. return
  41308. }
  41309. return *v, true
  41310. }
  41311. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41312. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41314. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41315. if !m.op.Is(OpUpdateOne) {
  41316. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41317. }
  41318. if m.id == nil || m.oldValue == nil {
  41319. return v, errors.New("OldServerID requires an ID field in the mutation")
  41320. }
  41321. oldValue, err := m.oldValue(ctx)
  41322. if err != nil {
  41323. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41324. }
  41325. return oldValue.ServerID, nil
  41326. }
  41327. // ClearServerID clears the value of the "server_id" field.
  41328. func (m *WxMutation) ClearServerID() {
  41329. m.server = nil
  41330. m.clearedFields[wx.FieldServerID] = struct{}{}
  41331. }
  41332. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41333. func (m *WxMutation) ServerIDCleared() bool {
  41334. _, ok := m.clearedFields[wx.FieldServerID]
  41335. return ok
  41336. }
  41337. // ResetServerID resets all changes to the "server_id" field.
  41338. func (m *WxMutation) ResetServerID() {
  41339. m.server = nil
  41340. delete(m.clearedFields, wx.FieldServerID)
  41341. }
  41342. // SetPort sets the "port" field.
  41343. func (m *WxMutation) SetPort(s string) {
  41344. m.port = &s
  41345. }
  41346. // Port returns the value of the "port" field in the mutation.
  41347. func (m *WxMutation) Port() (r string, exists bool) {
  41348. v := m.port
  41349. if v == nil {
  41350. return
  41351. }
  41352. return *v, true
  41353. }
  41354. // OldPort returns the old "port" field's value of the Wx entity.
  41355. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41357. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41358. if !m.op.Is(OpUpdateOne) {
  41359. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41360. }
  41361. if m.id == nil || m.oldValue == nil {
  41362. return v, errors.New("OldPort requires an ID field in the mutation")
  41363. }
  41364. oldValue, err := m.oldValue(ctx)
  41365. if err != nil {
  41366. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41367. }
  41368. return oldValue.Port, nil
  41369. }
  41370. // ResetPort resets all changes to the "port" field.
  41371. func (m *WxMutation) ResetPort() {
  41372. m.port = nil
  41373. }
  41374. // SetProcessID sets the "process_id" field.
  41375. func (m *WxMutation) SetProcessID(s string) {
  41376. m.process_id = &s
  41377. }
  41378. // ProcessID returns the value of the "process_id" field in the mutation.
  41379. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41380. v := m.process_id
  41381. if v == nil {
  41382. return
  41383. }
  41384. return *v, true
  41385. }
  41386. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41387. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41389. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41390. if !m.op.Is(OpUpdateOne) {
  41391. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41392. }
  41393. if m.id == nil || m.oldValue == nil {
  41394. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41395. }
  41396. oldValue, err := m.oldValue(ctx)
  41397. if err != nil {
  41398. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41399. }
  41400. return oldValue.ProcessID, nil
  41401. }
  41402. // ResetProcessID resets all changes to the "process_id" field.
  41403. func (m *WxMutation) ResetProcessID() {
  41404. m.process_id = nil
  41405. }
  41406. // SetCallback sets the "callback" field.
  41407. func (m *WxMutation) SetCallback(s string) {
  41408. m.callback = &s
  41409. }
  41410. // Callback returns the value of the "callback" field in the mutation.
  41411. func (m *WxMutation) Callback() (r string, exists bool) {
  41412. v := m.callback
  41413. if v == nil {
  41414. return
  41415. }
  41416. return *v, true
  41417. }
  41418. // OldCallback returns the old "callback" field's value of the Wx entity.
  41419. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41421. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41422. if !m.op.Is(OpUpdateOne) {
  41423. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41424. }
  41425. if m.id == nil || m.oldValue == nil {
  41426. return v, errors.New("OldCallback requires an ID field in the mutation")
  41427. }
  41428. oldValue, err := m.oldValue(ctx)
  41429. if err != nil {
  41430. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41431. }
  41432. return oldValue.Callback, nil
  41433. }
  41434. // ResetCallback resets all changes to the "callback" field.
  41435. func (m *WxMutation) ResetCallback() {
  41436. m.callback = nil
  41437. }
  41438. // SetWxid sets the "wxid" field.
  41439. func (m *WxMutation) SetWxid(s string) {
  41440. m.wxid = &s
  41441. }
  41442. // Wxid returns the value of the "wxid" field in the mutation.
  41443. func (m *WxMutation) Wxid() (r string, exists bool) {
  41444. v := m.wxid
  41445. if v == nil {
  41446. return
  41447. }
  41448. return *v, true
  41449. }
  41450. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41451. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41453. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41454. if !m.op.Is(OpUpdateOne) {
  41455. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41456. }
  41457. if m.id == nil || m.oldValue == nil {
  41458. return v, errors.New("OldWxid requires an ID field in the mutation")
  41459. }
  41460. oldValue, err := m.oldValue(ctx)
  41461. if err != nil {
  41462. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41463. }
  41464. return oldValue.Wxid, nil
  41465. }
  41466. // ResetWxid resets all changes to the "wxid" field.
  41467. func (m *WxMutation) ResetWxid() {
  41468. m.wxid = nil
  41469. }
  41470. // SetAccount sets the "account" field.
  41471. func (m *WxMutation) SetAccount(s string) {
  41472. m.account = &s
  41473. }
  41474. // Account returns the value of the "account" field in the mutation.
  41475. func (m *WxMutation) Account() (r string, exists bool) {
  41476. v := m.account
  41477. if v == nil {
  41478. return
  41479. }
  41480. return *v, true
  41481. }
  41482. // OldAccount returns the old "account" field's value of the Wx entity.
  41483. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41485. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41486. if !m.op.Is(OpUpdateOne) {
  41487. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41488. }
  41489. if m.id == nil || m.oldValue == nil {
  41490. return v, errors.New("OldAccount requires an ID field in the mutation")
  41491. }
  41492. oldValue, err := m.oldValue(ctx)
  41493. if err != nil {
  41494. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41495. }
  41496. return oldValue.Account, nil
  41497. }
  41498. // ResetAccount resets all changes to the "account" field.
  41499. func (m *WxMutation) ResetAccount() {
  41500. m.account = nil
  41501. }
  41502. // SetNickname sets the "nickname" field.
  41503. func (m *WxMutation) SetNickname(s string) {
  41504. m.nickname = &s
  41505. }
  41506. // Nickname returns the value of the "nickname" field in the mutation.
  41507. func (m *WxMutation) Nickname() (r string, exists bool) {
  41508. v := m.nickname
  41509. if v == nil {
  41510. return
  41511. }
  41512. return *v, true
  41513. }
  41514. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41515. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41517. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41518. if !m.op.Is(OpUpdateOne) {
  41519. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41520. }
  41521. if m.id == nil || m.oldValue == nil {
  41522. return v, errors.New("OldNickname requires an ID field in the mutation")
  41523. }
  41524. oldValue, err := m.oldValue(ctx)
  41525. if err != nil {
  41526. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41527. }
  41528. return oldValue.Nickname, nil
  41529. }
  41530. // ResetNickname resets all changes to the "nickname" field.
  41531. func (m *WxMutation) ResetNickname() {
  41532. m.nickname = nil
  41533. }
  41534. // SetTel sets the "tel" field.
  41535. func (m *WxMutation) SetTel(s string) {
  41536. m.tel = &s
  41537. }
  41538. // Tel returns the value of the "tel" field in the mutation.
  41539. func (m *WxMutation) Tel() (r string, exists bool) {
  41540. v := m.tel
  41541. if v == nil {
  41542. return
  41543. }
  41544. return *v, true
  41545. }
  41546. // OldTel returns the old "tel" field's value of the Wx entity.
  41547. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41549. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41550. if !m.op.Is(OpUpdateOne) {
  41551. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41552. }
  41553. if m.id == nil || m.oldValue == nil {
  41554. return v, errors.New("OldTel requires an ID field in the mutation")
  41555. }
  41556. oldValue, err := m.oldValue(ctx)
  41557. if err != nil {
  41558. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41559. }
  41560. return oldValue.Tel, nil
  41561. }
  41562. // ResetTel resets all changes to the "tel" field.
  41563. func (m *WxMutation) ResetTel() {
  41564. m.tel = nil
  41565. }
  41566. // SetHeadBig sets the "head_big" field.
  41567. func (m *WxMutation) SetHeadBig(s string) {
  41568. m.head_big = &s
  41569. }
  41570. // HeadBig returns the value of the "head_big" field in the mutation.
  41571. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41572. v := m.head_big
  41573. if v == nil {
  41574. return
  41575. }
  41576. return *v, true
  41577. }
  41578. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41579. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41581. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41582. if !m.op.Is(OpUpdateOne) {
  41583. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41584. }
  41585. if m.id == nil || m.oldValue == nil {
  41586. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41587. }
  41588. oldValue, err := m.oldValue(ctx)
  41589. if err != nil {
  41590. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41591. }
  41592. return oldValue.HeadBig, nil
  41593. }
  41594. // ResetHeadBig resets all changes to the "head_big" field.
  41595. func (m *WxMutation) ResetHeadBig() {
  41596. m.head_big = nil
  41597. }
  41598. // SetOrganizationID sets the "organization_id" field.
  41599. func (m *WxMutation) SetOrganizationID(u uint64) {
  41600. m.organization_id = &u
  41601. m.addorganization_id = nil
  41602. }
  41603. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41604. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41605. v := m.organization_id
  41606. if v == nil {
  41607. return
  41608. }
  41609. return *v, true
  41610. }
  41611. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41612. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41614. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41615. if !m.op.Is(OpUpdateOne) {
  41616. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41617. }
  41618. if m.id == nil || m.oldValue == nil {
  41619. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41620. }
  41621. oldValue, err := m.oldValue(ctx)
  41622. if err != nil {
  41623. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41624. }
  41625. return oldValue.OrganizationID, nil
  41626. }
  41627. // AddOrganizationID adds u to the "organization_id" field.
  41628. func (m *WxMutation) AddOrganizationID(u int64) {
  41629. if m.addorganization_id != nil {
  41630. *m.addorganization_id += u
  41631. } else {
  41632. m.addorganization_id = &u
  41633. }
  41634. }
  41635. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41636. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  41637. v := m.addorganization_id
  41638. if v == nil {
  41639. return
  41640. }
  41641. return *v, true
  41642. }
  41643. // ClearOrganizationID clears the value of the "organization_id" field.
  41644. func (m *WxMutation) ClearOrganizationID() {
  41645. m.organization_id = nil
  41646. m.addorganization_id = nil
  41647. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  41648. }
  41649. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41650. func (m *WxMutation) OrganizationIDCleared() bool {
  41651. _, ok := m.clearedFields[wx.FieldOrganizationID]
  41652. return ok
  41653. }
  41654. // ResetOrganizationID resets all changes to the "organization_id" field.
  41655. func (m *WxMutation) ResetOrganizationID() {
  41656. m.organization_id = nil
  41657. m.addorganization_id = nil
  41658. delete(m.clearedFields, wx.FieldOrganizationID)
  41659. }
  41660. // SetAgentID sets the "agent_id" field.
  41661. func (m *WxMutation) SetAgentID(u uint64) {
  41662. m.agent = &u
  41663. }
  41664. // AgentID returns the value of the "agent_id" field in the mutation.
  41665. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  41666. v := m.agent
  41667. if v == nil {
  41668. return
  41669. }
  41670. return *v, true
  41671. }
  41672. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  41673. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41675. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41676. if !m.op.Is(OpUpdateOne) {
  41677. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41678. }
  41679. if m.id == nil || m.oldValue == nil {
  41680. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41681. }
  41682. oldValue, err := m.oldValue(ctx)
  41683. if err != nil {
  41684. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41685. }
  41686. return oldValue.AgentID, nil
  41687. }
  41688. // ResetAgentID resets all changes to the "agent_id" field.
  41689. func (m *WxMutation) ResetAgentID() {
  41690. m.agent = nil
  41691. }
  41692. // SetAPIBase sets the "api_base" field.
  41693. func (m *WxMutation) SetAPIBase(s string) {
  41694. m.api_base = &s
  41695. }
  41696. // APIBase returns the value of the "api_base" field in the mutation.
  41697. func (m *WxMutation) APIBase() (r string, exists bool) {
  41698. v := m.api_base
  41699. if v == nil {
  41700. return
  41701. }
  41702. return *v, true
  41703. }
  41704. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  41705. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41707. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41708. if !m.op.Is(OpUpdateOne) {
  41709. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41710. }
  41711. if m.id == nil || m.oldValue == nil {
  41712. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41713. }
  41714. oldValue, err := m.oldValue(ctx)
  41715. if err != nil {
  41716. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41717. }
  41718. return oldValue.APIBase, nil
  41719. }
  41720. // ClearAPIBase clears the value of the "api_base" field.
  41721. func (m *WxMutation) ClearAPIBase() {
  41722. m.api_base = nil
  41723. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  41724. }
  41725. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41726. func (m *WxMutation) APIBaseCleared() bool {
  41727. _, ok := m.clearedFields[wx.FieldAPIBase]
  41728. return ok
  41729. }
  41730. // ResetAPIBase resets all changes to the "api_base" field.
  41731. func (m *WxMutation) ResetAPIBase() {
  41732. m.api_base = nil
  41733. delete(m.clearedFields, wx.FieldAPIBase)
  41734. }
  41735. // SetAPIKey sets the "api_key" field.
  41736. func (m *WxMutation) SetAPIKey(s string) {
  41737. m.api_key = &s
  41738. }
  41739. // APIKey returns the value of the "api_key" field in the mutation.
  41740. func (m *WxMutation) APIKey() (r string, exists bool) {
  41741. v := m.api_key
  41742. if v == nil {
  41743. return
  41744. }
  41745. return *v, true
  41746. }
  41747. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  41748. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41750. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41751. if !m.op.Is(OpUpdateOne) {
  41752. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41753. }
  41754. if m.id == nil || m.oldValue == nil {
  41755. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41756. }
  41757. oldValue, err := m.oldValue(ctx)
  41758. if err != nil {
  41759. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41760. }
  41761. return oldValue.APIKey, nil
  41762. }
  41763. // ClearAPIKey clears the value of the "api_key" field.
  41764. func (m *WxMutation) ClearAPIKey() {
  41765. m.api_key = nil
  41766. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  41767. }
  41768. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41769. func (m *WxMutation) APIKeyCleared() bool {
  41770. _, ok := m.clearedFields[wx.FieldAPIKey]
  41771. return ok
  41772. }
  41773. // ResetAPIKey resets all changes to the "api_key" field.
  41774. func (m *WxMutation) ResetAPIKey() {
  41775. m.api_key = nil
  41776. delete(m.clearedFields, wx.FieldAPIKey)
  41777. }
  41778. // SetAllowList sets the "allow_list" field.
  41779. func (m *WxMutation) SetAllowList(s []string) {
  41780. m.allow_list = &s
  41781. m.appendallow_list = nil
  41782. }
  41783. // AllowList returns the value of the "allow_list" field in the mutation.
  41784. func (m *WxMutation) AllowList() (r []string, exists bool) {
  41785. v := m.allow_list
  41786. if v == nil {
  41787. return
  41788. }
  41789. return *v, true
  41790. }
  41791. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  41792. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41794. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41795. if !m.op.Is(OpUpdateOne) {
  41796. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41797. }
  41798. if m.id == nil || m.oldValue == nil {
  41799. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41800. }
  41801. oldValue, err := m.oldValue(ctx)
  41802. if err != nil {
  41803. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41804. }
  41805. return oldValue.AllowList, nil
  41806. }
  41807. // AppendAllowList adds s to the "allow_list" field.
  41808. func (m *WxMutation) AppendAllowList(s []string) {
  41809. m.appendallow_list = append(m.appendallow_list, s...)
  41810. }
  41811. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41812. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  41813. if len(m.appendallow_list) == 0 {
  41814. return nil, false
  41815. }
  41816. return m.appendallow_list, true
  41817. }
  41818. // ResetAllowList resets all changes to the "allow_list" field.
  41819. func (m *WxMutation) ResetAllowList() {
  41820. m.allow_list = nil
  41821. m.appendallow_list = nil
  41822. }
  41823. // SetGroupAllowList sets the "group_allow_list" field.
  41824. func (m *WxMutation) SetGroupAllowList(s []string) {
  41825. m.group_allow_list = &s
  41826. m.appendgroup_allow_list = nil
  41827. }
  41828. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41829. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  41830. v := m.group_allow_list
  41831. if v == nil {
  41832. return
  41833. }
  41834. return *v, true
  41835. }
  41836. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  41837. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41839. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41840. if !m.op.Is(OpUpdateOne) {
  41841. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41842. }
  41843. if m.id == nil || m.oldValue == nil {
  41844. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41845. }
  41846. oldValue, err := m.oldValue(ctx)
  41847. if err != nil {
  41848. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41849. }
  41850. return oldValue.GroupAllowList, nil
  41851. }
  41852. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41853. func (m *WxMutation) AppendGroupAllowList(s []string) {
  41854. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41855. }
  41856. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41857. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  41858. if len(m.appendgroup_allow_list) == 0 {
  41859. return nil, false
  41860. }
  41861. return m.appendgroup_allow_list, true
  41862. }
  41863. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41864. func (m *WxMutation) ResetGroupAllowList() {
  41865. m.group_allow_list = nil
  41866. m.appendgroup_allow_list = nil
  41867. }
  41868. // SetBlockList sets the "block_list" field.
  41869. func (m *WxMutation) SetBlockList(s []string) {
  41870. m.block_list = &s
  41871. m.appendblock_list = nil
  41872. }
  41873. // BlockList returns the value of the "block_list" field in the mutation.
  41874. func (m *WxMutation) BlockList() (r []string, exists bool) {
  41875. v := m.block_list
  41876. if v == nil {
  41877. return
  41878. }
  41879. return *v, true
  41880. }
  41881. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  41882. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41884. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41885. if !m.op.Is(OpUpdateOne) {
  41886. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41887. }
  41888. if m.id == nil || m.oldValue == nil {
  41889. return v, errors.New("OldBlockList requires an ID field in the mutation")
  41890. }
  41891. oldValue, err := m.oldValue(ctx)
  41892. if err != nil {
  41893. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  41894. }
  41895. return oldValue.BlockList, nil
  41896. }
  41897. // AppendBlockList adds s to the "block_list" field.
  41898. func (m *WxMutation) AppendBlockList(s []string) {
  41899. m.appendblock_list = append(m.appendblock_list, s...)
  41900. }
  41901. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41902. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  41903. if len(m.appendblock_list) == 0 {
  41904. return nil, false
  41905. }
  41906. return m.appendblock_list, true
  41907. }
  41908. // ResetBlockList resets all changes to the "block_list" field.
  41909. func (m *WxMutation) ResetBlockList() {
  41910. m.block_list = nil
  41911. m.appendblock_list = nil
  41912. }
  41913. // SetGroupBlockList sets the "group_block_list" field.
  41914. func (m *WxMutation) SetGroupBlockList(s []string) {
  41915. m.group_block_list = &s
  41916. m.appendgroup_block_list = nil
  41917. }
  41918. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41919. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  41920. v := m.group_block_list
  41921. if v == nil {
  41922. return
  41923. }
  41924. return *v, true
  41925. }
  41926. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  41927. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41929. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  41930. if !m.op.Is(OpUpdateOne) {
  41931. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  41932. }
  41933. if m.id == nil || m.oldValue == nil {
  41934. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  41935. }
  41936. oldValue, err := m.oldValue(ctx)
  41937. if err != nil {
  41938. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  41939. }
  41940. return oldValue.GroupBlockList, nil
  41941. }
  41942. // AppendGroupBlockList adds s to the "group_block_list" field.
  41943. func (m *WxMutation) AppendGroupBlockList(s []string) {
  41944. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  41945. }
  41946. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  41947. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  41948. if len(m.appendgroup_block_list) == 0 {
  41949. return nil, false
  41950. }
  41951. return m.appendgroup_block_list, true
  41952. }
  41953. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  41954. func (m *WxMutation) ResetGroupBlockList() {
  41955. m.group_block_list = nil
  41956. m.appendgroup_block_list = nil
  41957. }
  41958. // SetCtype sets the "ctype" field.
  41959. func (m *WxMutation) SetCtype(u uint64) {
  41960. m.ctype = &u
  41961. m.addctype = nil
  41962. }
  41963. // Ctype returns the value of the "ctype" field in the mutation.
  41964. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  41965. v := m.ctype
  41966. if v == nil {
  41967. return
  41968. }
  41969. return *v, true
  41970. }
  41971. // OldCtype returns the old "ctype" field's value of the Wx entity.
  41972. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41974. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  41975. if !m.op.Is(OpUpdateOne) {
  41976. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  41977. }
  41978. if m.id == nil || m.oldValue == nil {
  41979. return v, errors.New("OldCtype requires an ID field in the mutation")
  41980. }
  41981. oldValue, err := m.oldValue(ctx)
  41982. if err != nil {
  41983. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  41984. }
  41985. return oldValue.Ctype, nil
  41986. }
  41987. // AddCtype adds u to the "ctype" field.
  41988. func (m *WxMutation) AddCtype(u int64) {
  41989. if m.addctype != nil {
  41990. *m.addctype += u
  41991. } else {
  41992. m.addctype = &u
  41993. }
  41994. }
  41995. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  41996. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  41997. v := m.addctype
  41998. if v == nil {
  41999. return
  42000. }
  42001. return *v, true
  42002. }
  42003. // ClearCtype clears the value of the "ctype" field.
  42004. func (m *WxMutation) ClearCtype() {
  42005. m.ctype = nil
  42006. m.addctype = nil
  42007. m.clearedFields[wx.FieldCtype] = struct{}{}
  42008. }
  42009. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  42010. func (m *WxMutation) CtypeCleared() bool {
  42011. _, ok := m.clearedFields[wx.FieldCtype]
  42012. return ok
  42013. }
  42014. // ResetCtype resets all changes to the "ctype" field.
  42015. func (m *WxMutation) ResetCtype() {
  42016. m.ctype = nil
  42017. m.addctype = nil
  42018. delete(m.clearedFields, wx.FieldCtype)
  42019. }
  42020. // ClearServer clears the "server" edge to the Server entity.
  42021. func (m *WxMutation) ClearServer() {
  42022. m.clearedserver = true
  42023. m.clearedFields[wx.FieldServerID] = struct{}{}
  42024. }
  42025. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  42026. func (m *WxMutation) ServerCleared() bool {
  42027. return m.ServerIDCleared() || m.clearedserver
  42028. }
  42029. // ServerIDs returns the "server" edge IDs in the mutation.
  42030. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42031. // ServerID instead. It exists only for internal usage by the builders.
  42032. func (m *WxMutation) ServerIDs() (ids []uint64) {
  42033. if id := m.server; id != nil {
  42034. ids = append(ids, *id)
  42035. }
  42036. return
  42037. }
  42038. // ResetServer resets all changes to the "server" edge.
  42039. func (m *WxMutation) ResetServer() {
  42040. m.server = nil
  42041. m.clearedserver = false
  42042. }
  42043. // ClearAgent clears the "agent" edge to the Agent entity.
  42044. func (m *WxMutation) ClearAgent() {
  42045. m.clearedagent = true
  42046. m.clearedFields[wx.FieldAgentID] = struct{}{}
  42047. }
  42048. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42049. func (m *WxMutation) AgentCleared() bool {
  42050. return m.clearedagent
  42051. }
  42052. // AgentIDs returns the "agent" edge IDs in the mutation.
  42053. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42054. // AgentID instead. It exists only for internal usage by the builders.
  42055. func (m *WxMutation) AgentIDs() (ids []uint64) {
  42056. if id := m.agent; id != nil {
  42057. ids = append(ids, *id)
  42058. }
  42059. return
  42060. }
  42061. // ResetAgent resets all changes to the "agent" edge.
  42062. func (m *WxMutation) ResetAgent() {
  42063. m.agent = nil
  42064. m.clearedagent = false
  42065. }
  42066. // Where appends a list predicates to the WxMutation builder.
  42067. func (m *WxMutation) Where(ps ...predicate.Wx) {
  42068. m.predicates = append(m.predicates, ps...)
  42069. }
  42070. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  42071. // users can use type-assertion to append predicates that do not depend on any generated package.
  42072. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  42073. p := make([]predicate.Wx, len(ps))
  42074. for i := range ps {
  42075. p[i] = ps[i]
  42076. }
  42077. m.Where(p...)
  42078. }
  42079. // Op returns the operation name.
  42080. func (m *WxMutation) Op() Op {
  42081. return m.op
  42082. }
  42083. // SetOp allows setting the mutation operation.
  42084. func (m *WxMutation) SetOp(op Op) {
  42085. m.op = op
  42086. }
  42087. // Type returns the node type of this mutation (Wx).
  42088. func (m *WxMutation) Type() string {
  42089. return m.typ
  42090. }
  42091. // Fields returns all fields that were changed during this mutation. Note that in
  42092. // order to get all numeric fields that were incremented/decremented, call
  42093. // AddedFields().
  42094. func (m *WxMutation) Fields() []string {
  42095. fields := make([]string, 0, 22)
  42096. if m.created_at != nil {
  42097. fields = append(fields, wx.FieldCreatedAt)
  42098. }
  42099. if m.updated_at != nil {
  42100. fields = append(fields, wx.FieldUpdatedAt)
  42101. }
  42102. if m.status != nil {
  42103. fields = append(fields, wx.FieldStatus)
  42104. }
  42105. if m.deleted_at != nil {
  42106. fields = append(fields, wx.FieldDeletedAt)
  42107. }
  42108. if m.server != nil {
  42109. fields = append(fields, wx.FieldServerID)
  42110. }
  42111. if m.port != nil {
  42112. fields = append(fields, wx.FieldPort)
  42113. }
  42114. if m.process_id != nil {
  42115. fields = append(fields, wx.FieldProcessID)
  42116. }
  42117. if m.callback != nil {
  42118. fields = append(fields, wx.FieldCallback)
  42119. }
  42120. if m.wxid != nil {
  42121. fields = append(fields, wx.FieldWxid)
  42122. }
  42123. if m.account != nil {
  42124. fields = append(fields, wx.FieldAccount)
  42125. }
  42126. if m.nickname != nil {
  42127. fields = append(fields, wx.FieldNickname)
  42128. }
  42129. if m.tel != nil {
  42130. fields = append(fields, wx.FieldTel)
  42131. }
  42132. if m.head_big != nil {
  42133. fields = append(fields, wx.FieldHeadBig)
  42134. }
  42135. if m.organization_id != nil {
  42136. fields = append(fields, wx.FieldOrganizationID)
  42137. }
  42138. if m.agent != nil {
  42139. fields = append(fields, wx.FieldAgentID)
  42140. }
  42141. if m.api_base != nil {
  42142. fields = append(fields, wx.FieldAPIBase)
  42143. }
  42144. if m.api_key != nil {
  42145. fields = append(fields, wx.FieldAPIKey)
  42146. }
  42147. if m.allow_list != nil {
  42148. fields = append(fields, wx.FieldAllowList)
  42149. }
  42150. if m.group_allow_list != nil {
  42151. fields = append(fields, wx.FieldGroupAllowList)
  42152. }
  42153. if m.block_list != nil {
  42154. fields = append(fields, wx.FieldBlockList)
  42155. }
  42156. if m.group_block_list != nil {
  42157. fields = append(fields, wx.FieldGroupBlockList)
  42158. }
  42159. if m.ctype != nil {
  42160. fields = append(fields, wx.FieldCtype)
  42161. }
  42162. return fields
  42163. }
  42164. // Field returns the value of a field with the given name. The second boolean
  42165. // return value indicates that this field was not set, or was not defined in the
  42166. // schema.
  42167. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42168. switch name {
  42169. case wx.FieldCreatedAt:
  42170. return m.CreatedAt()
  42171. case wx.FieldUpdatedAt:
  42172. return m.UpdatedAt()
  42173. case wx.FieldStatus:
  42174. return m.Status()
  42175. case wx.FieldDeletedAt:
  42176. return m.DeletedAt()
  42177. case wx.FieldServerID:
  42178. return m.ServerID()
  42179. case wx.FieldPort:
  42180. return m.Port()
  42181. case wx.FieldProcessID:
  42182. return m.ProcessID()
  42183. case wx.FieldCallback:
  42184. return m.Callback()
  42185. case wx.FieldWxid:
  42186. return m.Wxid()
  42187. case wx.FieldAccount:
  42188. return m.Account()
  42189. case wx.FieldNickname:
  42190. return m.Nickname()
  42191. case wx.FieldTel:
  42192. return m.Tel()
  42193. case wx.FieldHeadBig:
  42194. return m.HeadBig()
  42195. case wx.FieldOrganizationID:
  42196. return m.OrganizationID()
  42197. case wx.FieldAgentID:
  42198. return m.AgentID()
  42199. case wx.FieldAPIBase:
  42200. return m.APIBase()
  42201. case wx.FieldAPIKey:
  42202. return m.APIKey()
  42203. case wx.FieldAllowList:
  42204. return m.AllowList()
  42205. case wx.FieldGroupAllowList:
  42206. return m.GroupAllowList()
  42207. case wx.FieldBlockList:
  42208. return m.BlockList()
  42209. case wx.FieldGroupBlockList:
  42210. return m.GroupBlockList()
  42211. case wx.FieldCtype:
  42212. return m.Ctype()
  42213. }
  42214. return nil, false
  42215. }
  42216. // OldField returns the old value of the field from the database. An error is
  42217. // returned if the mutation operation is not UpdateOne, or the query to the
  42218. // database failed.
  42219. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42220. switch name {
  42221. case wx.FieldCreatedAt:
  42222. return m.OldCreatedAt(ctx)
  42223. case wx.FieldUpdatedAt:
  42224. return m.OldUpdatedAt(ctx)
  42225. case wx.FieldStatus:
  42226. return m.OldStatus(ctx)
  42227. case wx.FieldDeletedAt:
  42228. return m.OldDeletedAt(ctx)
  42229. case wx.FieldServerID:
  42230. return m.OldServerID(ctx)
  42231. case wx.FieldPort:
  42232. return m.OldPort(ctx)
  42233. case wx.FieldProcessID:
  42234. return m.OldProcessID(ctx)
  42235. case wx.FieldCallback:
  42236. return m.OldCallback(ctx)
  42237. case wx.FieldWxid:
  42238. return m.OldWxid(ctx)
  42239. case wx.FieldAccount:
  42240. return m.OldAccount(ctx)
  42241. case wx.FieldNickname:
  42242. return m.OldNickname(ctx)
  42243. case wx.FieldTel:
  42244. return m.OldTel(ctx)
  42245. case wx.FieldHeadBig:
  42246. return m.OldHeadBig(ctx)
  42247. case wx.FieldOrganizationID:
  42248. return m.OldOrganizationID(ctx)
  42249. case wx.FieldAgentID:
  42250. return m.OldAgentID(ctx)
  42251. case wx.FieldAPIBase:
  42252. return m.OldAPIBase(ctx)
  42253. case wx.FieldAPIKey:
  42254. return m.OldAPIKey(ctx)
  42255. case wx.FieldAllowList:
  42256. return m.OldAllowList(ctx)
  42257. case wx.FieldGroupAllowList:
  42258. return m.OldGroupAllowList(ctx)
  42259. case wx.FieldBlockList:
  42260. return m.OldBlockList(ctx)
  42261. case wx.FieldGroupBlockList:
  42262. return m.OldGroupBlockList(ctx)
  42263. case wx.FieldCtype:
  42264. return m.OldCtype(ctx)
  42265. }
  42266. return nil, fmt.Errorf("unknown Wx field %s", name)
  42267. }
  42268. // SetField sets the value of a field with the given name. It returns an error if
  42269. // the field is not defined in the schema, or if the type mismatched the field
  42270. // type.
  42271. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42272. switch name {
  42273. case wx.FieldCreatedAt:
  42274. v, ok := value.(time.Time)
  42275. if !ok {
  42276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42277. }
  42278. m.SetCreatedAt(v)
  42279. return nil
  42280. case wx.FieldUpdatedAt:
  42281. v, ok := value.(time.Time)
  42282. if !ok {
  42283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42284. }
  42285. m.SetUpdatedAt(v)
  42286. return nil
  42287. case wx.FieldStatus:
  42288. v, ok := value.(uint8)
  42289. if !ok {
  42290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42291. }
  42292. m.SetStatus(v)
  42293. return nil
  42294. case wx.FieldDeletedAt:
  42295. v, ok := value.(time.Time)
  42296. if !ok {
  42297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42298. }
  42299. m.SetDeletedAt(v)
  42300. return nil
  42301. case wx.FieldServerID:
  42302. v, ok := value.(uint64)
  42303. if !ok {
  42304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42305. }
  42306. m.SetServerID(v)
  42307. return nil
  42308. case wx.FieldPort:
  42309. v, ok := value.(string)
  42310. if !ok {
  42311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42312. }
  42313. m.SetPort(v)
  42314. return nil
  42315. case wx.FieldProcessID:
  42316. v, ok := value.(string)
  42317. if !ok {
  42318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42319. }
  42320. m.SetProcessID(v)
  42321. return nil
  42322. case wx.FieldCallback:
  42323. v, ok := value.(string)
  42324. if !ok {
  42325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42326. }
  42327. m.SetCallback(v)
  42328. return nil
  42329. case wx.FieldWxid:
  42330. v, ok := value.(string)
  42331. if !ok {
  42332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42333. }
  42334. m.SetWxid(v)
  42335. return nil
  42336. case wx.FieldAccount:
  42337. v, ok := value.(string)
  42338. if !ok {
  42339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42340. }
  42341. m.SetAccount(v)
  42342. return nil
  42343. case wx.FieldNickname:
  42344. v, ok := value.(string)
  42345. if !ok {
  42346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42347. }
  42348. m.SetNickname(v)
  42349. return nil
  42350. case wx.FieldTel:
  42351. v, ok := value.(string)
  42352. if !ok {
  42353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42354. }
  42355. m.SetTel(v)
  42356. return nil
  42357. case wx.FieldHeadBig:
  42358. v, ok := value.(string)
  42359. if !ok {
  42360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42361. }
  42362. m.SetHeadBig(v)
  42363. return nil
  42364. case wx.FieldOrganizationID:
  42365. v, ok := value.(uint64)
  42366. if !ok {
  42367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42368. }
  42369. m.SetOrganizationID(v)
  42370. return nil
  42371. case wx.FieldAgentID:
  42372. v, ok := value.(uint64)
  42373. if !ok {
  42374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42375. }
  42376. m.SetAgentID(v)
  42377. return nil
  42378. case wx.FieldAPIBase:
  42379. v, ok := value.(string)
  42380. if !ok {
  42381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42382. }
  42383. m.SetAPIBase(v)
  42384. return nil
  42385. case wx.FieldAPIKey:
  42386. v, ok := value.(string)
  42387. if !ok {
  42388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42389. }
  42390. m.SetAPIKey(v)
  42391. return nil
  42392. case wx.FieldAllowList:
  42393. v, ok := value.([]string)
  42394. if !ok {
  42395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42396. }
  42397. m.SetAllowList(v)
  42398. return nil
  42399. case wx.FieldGroupAllowList:
  42400. v, ok := value.([]string)
  42401. if !ok {
  42402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42403. }
  42404. m.SetGroupAllowList(v)
  42405. return nil
  42406. case wx.FieldBlockList:
  42407. v, ok := value.([]string)
  42408. if !ok {
  42409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42410. }
  42411. m.SetBlockList(v)
  42412. return nil
  42413. case wx.FieldGroupBlockList:
  42414. v, ok := value.([]string)
  42415. if !ok {
  42416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42417. }
  42418. m.SetGroupBlockList(v)
  42419. return nil
  42420. case wx.FieldCtype:
  42421. v, ok := value.(uint64)
  42422. if !ok {
  42423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42424. }
  42425. m.SetCtype(v)
  42426. return nil
  42427. }
  42428. return fmt.Errorf("unknown Wx field %s", name)
  42429. }
  42430. // AddedFields returns all numeric fields that were incremented/decremented during
  42431. // this mutation.
  42432. func (m *WxMutation) AddedFields() []string {
  42433. var fields []string
  42434. if m.addstatus != nil {
  42435. fields = append(fields, wx.FieldStatus)
  42436. }
  42437. if m.addorganization_id != nil {
  42438. fields = append(fields, wx.FieldOrganizationID)
  42439. }
  42440. if m.addctype != nil {
  42441. fields = append(fields, wx.FieldCtype)
  42442. }
  42443. return fields
  42444. }
  42445. // AddedField returns the numeric value that was incremented/decremented on a field
  42446. // with the given name. The second boolean return value indicates that this field
  42447. // was not set, or was not defined in the schema.
  42448. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42449. switch name {
  42450. case wx.FieldStatus:
  42451. return m.AddedStatus()
  42452. case wx.FieldOrganizationID:
  42453. return m.AddedOrganizationID()
  42454. case wx.FieldCtype:
  42455. return m.AddedCtype()
  42456. }
  42457. return nil, false
  42458. }
  42459. // AddField adds the value to the field with the given name. It returns an error if
  42460. // the field is not defined in the schema, or if the type mismatched the field
  42461. // type.
  42462. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42463. switch name {
  42464. case wx.FieldStatus:
  42465. v, ok := value.(int8)
  42466. if !ok {
  42467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42468. }
  42469. m.AddStatus(v)
  42470. return nil
  42471. case wx.FieldOrganizationID:
  42472. v, ok := value.(int64)
  42473. if !ok {
  42474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42475. }
  42476. m.AddOrganizationID(v)
  42477. return nil
  42478. case wx.FieldCtype:
  42479. v, ok := value.(int64)
  42480. if !ok {
  42481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42482. }
  42483. m.AddCtype(v)
  42484. return nil
  42485. }
  42486. return fmt.Errorf("unknown Wx numeric field %s", name)
  42487. }
  42488. // ClearedFields returns all nullable fields that were cleared during this
  42489. // mutation.
  42490. func (m *WxMutation) ClearedFields() []string {
  42491. var fields []string
  42492. if m.FieldCleared(wx.FieldStatus) {
  42493. fields = append(fields, wx.FieldStatus)
  42494. }
  42495. if m.FieldCleared(wx.FieldDeletedAt) {
  42496. fields = append(fields, wx.FieldDeletedAt)
  42497. }
  42498. if m.FieldCleared(wx.FieldServerID) {
  42499. fields = append(fields, wx.FieldServerID)
  42500. }
  42501. if m.FieldCleared(wx.FieldOrganizationID) {
  42502. fields = append(fields, wx.FieldOrganizationID)
  42503. }
  42504. if m.FieldCleared(wx.FieldAPIBase) {
  42505. fields = append(fields, wx.FieldAPIBase)
  42506. }
  42507. if m.FieldCleared(wx.FieldAPIKey) {
  42508. fields = append(fields, wx.FieldAPIKey)
  42509. }
  42510. if m.FieldCleared(wx.FieldCtype) {
  42511. fields = append(fields, wx.FieldCtype)
  42512. }
  42513. return fields
  42514. }
  42515. // FieldCleared returns a boolean indicating if a field with the given name was
  42516. // cleared in this mutation.
  42517. func (m *WxMutation) FieldCleared(name string) bool {
  42518. _, ok := m.clearedFields[name]
  42519. return ok
  42520. }
  42521. // ClearField clears the value of the field with the given name. It returns an
  42522. // error if the field is not defined in the schema.
  42523. func (m *WxMutation) ClearField(name string) error {
  42524. switch name {
  42525. case wx.FieldStatus:
  42526. m.ClearStatus()
  42527. return nil
  42528. case wx.FieldDeletedAt:
  42529. m.ClearDeletedAt()
  42530. return nil
  42531. case wx.FieldServerID:
  42532. m.ClearServerID()
  42533. return nil
  42534. case wx.FieldOrganizationID:
  42535. m.ClearOrganizationID()
  42536. return nil
  42537. case wx.FieldAPIBase:
  42538. m.ClearAPIBase()
  42539. return nil
  42540. case wx.FieldAPIKey:
  42541. m.ClearAPIKey()
  42542. return nil
  42543. case wx.FieldCtype:
  42544. m.ClearCtype()
  42545. return nil
  42546. }
  42547. return fmt.Errorf("unknown Wx nullable field %s", name)
  42548. }
  42549. // ResetField resets all changes in the mutation for the field with the given name.
  42550. // It returns an error if the field is not defined in the schema.
  42551. func (m *WxMutation) ResetField(name string) error {
  42552. switch name {
  42553. case wx.FieldCreatedAt:
  42554. m.ResetCreatedAt()
  42555. return nil
  42556. case wx.FieldUpdatedAt:
  42557. m.ResetUpdatedAt()
  42558. return nil
  42559. case wx.FieldStatus:
  42560. m.ResetStatus()
  42561. return nil
  42562. case wx.FieldDeletedAt:
  42563. m.ResetDeletedAt()
  42564. return nil
  42565. case wx.FieldServerID:
  42566. m.ResetServerID()
  42567. return nil
  42568. case wx.FieldPort:
  42569. m.ResetPort()
  42570. return nil
  42571. case wx.FieldProcessID:
  42572. m.ResetProcessID()
  42573. return nil
  42574. case wx.FieldCallback:
  42575. m.ResetCallback()
  42576. return nil
  42577. case wx.FieldWxid:
  42578. m.ResetWxid()
  42579. return nil
  42580. case wx.FieldAccount:
  42581. m.ResetAccount()
  42582. return nil
  42583. case wx.FieldNickname:
  42584. m.ResetNickname()
  42585. return nil
  42586. case wx.FieldTel:
  42587. m.ResetTel()
  42588. return nil
  42589. case wx.FieldHeadBig:
  42590. m.ResetHeadBig()
  42591. return nil
  42592. case wx.FieldOrganizationID:
  42593. m.ResetOrganizationID()
  42594. return nil
  42595. case wx.FieldAgentID:
  42596. m.ResetAgentID()
  42597. return nil
  42598. case wx.FieldAPIBase:
  42599. m.ResetAPIBase()
  42600. return nil
  42601. case wx.FieldAPIKey:
  42602. m.ResetAPIKey()
  42603. return nil
  42604. case wx.FieldAllowList:
  42605. m.ResetAllowList()
  42606. return nil
  42607. case wx.FieldGroupAllowList:
  42608. m.ResetGroupAllowList()
  42609. return nil
  42610. case wx.FieldBlockList:
  42611. m.ResetBlockList()
  42612. return nil
  42613. case wx.FieldGroupBlockList:
  42614. m.ResetGroupBlockList()
  42615. return nil
  42616. case wx.FieldCtype:
  42617. m.ResetCtype()
  42618. return nil
  42619. }
  42620. return fmt.Errorf("unknown Wx field %s", name)
  42621. }
  42622. // AddedEdges returns all edge names that were set/added in this mutation.
  42623. func (m *WxMutation) AddedEdges() []string {
  42624. edges := make([]string, 0, 2)
  42625. if m.server != nil {
  42626. edges = append(edges, wx.EdgeServer)
  42627. }
  42628. if m.agent != nil {
  42629. edges = append(edges, wx.EdgeAgent)
  42630. }
  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 *WxMutation) AddedIDs(name string) []ent.Value {
  42636. switch name {
  42637. case wx.EdgeServer:
  42638. if id := m.server; id != nil {
  42639. return []ent.Value{*id}
  42640. }
  42641. case wx.EdgeAgent:
  42642. if id := m.agent; id != nil {
  42643. return []ent.Value{*id}
  42644. }
  42645. }
  42646. return nil
  42647. }
  42648. // RemovedEdges returns all edge names that were removed in this mutation.
  42649. func (m *WxMutation) RemovedEdges() []string {
  42650. edges := make([]string, 0, 2)
  42651. return edges
  42652. }
  42653. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42654. // the given name in this mutation.
  42655. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  42656. return nil
  42657. }
  42658. // ClearedEdges returns all edge names that were cleared in this mutation.
  42659. func (m *WxMutation) ClearedEdges() []string {
  42660. edges := make([]string, 0, 2)
  42661. if m.clearedserver {
  42662. edges = append(edges, wx.EdgeServer)
  42663. }
  42664. if m.clearedagent {
  42665. edges = append(edges, wx.EdgeAgent)
  42666. }
  42667. return edges
  42668. }
  42669. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42670. // was cleared in this mutation.
  42671. func (m *WxMutation) EdgeCleared(name string) bool {
  42672. switch name {
  42673. case wx.EdgeServer:
  42674. return m.clearedserver
  42675. case wx.EdgeAgent:
  42676. return m.clearedagent
  42677. }
  42678. return false
  42679. }
  42680. // ClearEdge clears the value of the edge with the given name. It returns an error
  42681. // if that edge is not defined in the schema.
  42682. func (m *WxMutation) ClearEdge(name string) error {
  42683. switch name {
  42684. case wx.EdgeServer:
  42685. m.ClearServer()
  42686. return nil
  42687. case wx.EdgeAgent:
  42688. m.ClearAgent()
  42689. return nil
  42690. }
  42691. return fmt.Errorf("unknown Wx unique edge %s", name)
  42692. }
  42693. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42694. // It returns an error if the edge is not defined in the schema.
  42695. func (m *WxMutation) ResetEdge(name string) error {
  42696. switch name {
  42697. case wx.EdgeServer:
  42698. m.ResetServer()
  42699. return nil
  42700. case wx.EdgeAgent:
  42701. m.ResetAgent()
  42702. return nil
  42703. }
  42704. return fmt.Errorf("unknown Wx edge %s", name)
  42705. }
  42706. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  42707. type WxCardMutation struct {
  42708. config
  42709. op Op
  42710. typ string
  42711. id *uint64
  42712. created_at *time.Time
  42713. updated_at *time.Time
  42714. deleted_at *time.Time
  42715. user_id *uint64
  42716. adduser_id *int64
  42717. wx_user_id *uint64
  42718. addwx_user_id *int64
  42719. avatar *string
  42720. logo *string
  42721. name *string
  42722. company *string
  42723. address *string
  42724. phone *string
  42725. official_account *string
  42726. wechat_account *string
  42727. email *string
  42728. api_base *string
  42729. api_key *string
  42730. ai_info *string
  42731. intro *string
  42732. clearedFields map[string]struct{}
  42733. done bool
  42734. oldValue func(context.Context) (*WxCard, error)
  42735. predicates []predicate.WxCard
  42736. }
  42737. var _ ent.Mutation = (*WxCardMutation)(nil)
  42738. // wxcardOption allows management of the mutation configuration using functional options.
  42739. type wxcardOption func(*WxCardMutation)
  42740. // newWxCardMutation creates new mutation for the WxCard entity.
  42741. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  42742. m := &WxCardMutation{
  42743. config: c,
  42744. op: op,
  42745. typ: TypeWxCard,
  42746. clearedFields: make(map[string]struct{}),
  42747. }
  42748. for _, opt := range opts {
  42749. opt(m)
  42750. }
  42751. return m
  42752. }
  42753. // withWxCardID sets the ID field of the mutation.
  42754. func withWxCardID(id uint64) wxcardOption {
  42755. return func(m *WxCardMutation) {
  42756. var (
  42757. err error
  42758. once sync.Once
  42759. value *WxCard
  42760. )
  42761. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  42762. once.Do(func() {
  42763. if m.done {
  42764. err = errors.New("querying old values post mutation is not allowed")
  42765. } else {
  42766. value, err = m.Client().WxCard.Get(ctx, id)
  42767. }
  42768. })
  42769. return value, err
  42770. }
  42771. m.id = &id
  42772. }
  42773. }
  42774. // withWxCard sets the old WxCard of the mutation.
  42775. func withWxCard(node *WxCard) wxcardOption {
  42776. return func(m *WxCardMutation) {
  42777. m.oldValue = func(context.Context) (*WxCard, error) {
  42778. return node, nil
  42779. }
  42780. m.id = &node.ID
  42781. }
  42782. }
  42783. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42784. // executed in a transaction (ent.Tx), a transactional client is returned.
  42785. func (m WxCardMutation) Client() *Client {
  42786. client := &Client{config: m.config}
  42787. client.init()
  42788. return client
  42789. }
  42790. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42791. // it returns an error otherwise.
  42792. func (m WxCardMutation) Tx() (*Tx, error) {
  42793. if _, ok := m.driver.(*txDriver); !ok {
  42794. return nil, errors.New("ent: mutation is not running in a transaction")
  42795. }
  42796. tx := &Tx{config: m.config}
  42797. tx.init()
  42798. return tx, nil
  42799. }
  42800. // SetID sets the value of the id field. Note that this
  42801. // operation is only accepted on creation of WxCard entities.
  42802. func (m *WxCardMutation) SetID(id uint64) {
  42803. m.id = &id
  42804. }
  42805. // ID returns the ID value in the mutation. Note that the ID is only available
  42806. // if it was provided to the builder or after it was returned from the database.
  42807. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  42808. if m.id == nil {
  42809. return
  42810. }
  42811. return *m.id, true
  42812. }
  42813. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42814. // That means, if the mutation is applied within a transaction with an isolation level such
  42815. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42816. // or updated by the mutation.
  42817. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  42818. switch {
  42819. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42820. id, exists := m.ID()
  42821. if exists {
  42822. return []uint64{id}, nil
  42823. }
  42824. fallthrough
  42825. case m.op.Is(OpUpdate | OpDelete):
  42826. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  42827. default:
  42828. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42829. }
  42830. }
  42831. // SetCreatedAt sets the "created_at" field.
  42832. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  42833. m.created_at = &t
  42834. }
  42835. // CreatedAt returns the value of the "created_at" field in the mutation.
  42836. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  42837. v := m.created_at
  42838. if v == nil {
  42839. return
  42840. }
  42841. return *v, true
  42842. }
  42843. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  42844. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42846. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42847. if !m.op.Is(OpUpdateOne) {
  42848. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42849. }
  42850. if m.id == nil || m.oldValue == nil {
  42851. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42852. }
  42853. oldValue, err := m.oldValue(ctx)
  42854. if err != nil {
  42855. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42856. }
  42857. return oldValue.CreatedAt, nil
  42858. }
  42859. // ResetCreatedAt resets all changes to the "created_at" field.
  42860. func (m *WxCardMutation) ResetCreatedAt() {
  42861. m.created_at = nil
  42862. }
  42863. // SetUpdatedAt sets the "updated_at" field.
  42864. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  42865. m.updated_at = &t
  42866. }
  42867. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42868. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  42869. v := m.updated_at
  42870. if v == nil {
  42871. return
  42872. }
  42873. return *v, true
  42874. }
  42875. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  42876. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42878. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42879. if !m.op.Is(OpUpdateOne) {
  42880. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42881. }
  42882. if m.id == nil || m.oldValue == nil {
  42883. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42884. }
  42885. oldValue, err := m.oldValue(ctx)
  42886. if err != nil {
  42887. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42888. }
  42889. return oldValue.UpdatedAt, nil
  42890. }
  42891. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42892. func (m *WxCardMutation) ResetUpdatedAt() {
  42893. m.updated_at = nil
  42894. }
  42895. // SetDeletedAt sets the "deleted_at" field.
  42896. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  42897. m.deleted_at = &t
  42898. }
  42899. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42900. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  42901. v := m.deleted_at
  42902. if v == nil {
  42903. return
  42904. }
  42905. return *v, true
  42906. }
  42907. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  42908. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42910. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42911. if !m.op.Is(OpUpdateOne) {
  42912. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42913. }
  42914. if m.id == nil || m.oldValue == nil {
  42915. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42916. }
  42917. oldValue, err := m.oldValue(ctx)
  42918. if err != nil {
  42919. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42920. }
  42921. return oldValue.DeletedAt, nil
  42922. }
  42923. // ClearDeletedAt clears the value of the "deleted_at" field.
  42924. func (m *WxCardMutation) ClearDeletedAt() {
  42925. m.deleted_at = nil
  42926. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  42927. }
  42928. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42929. func (m *WxCardMutation) DeletedAtCleared() bool {
  42930. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  42931. return ok
  42932. }
  42933. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42934. func (m *WxCardMutation) ResetDeletedAt() {
  42935. m.deleted_at = nil
  42936. delete(m.clearedFields, wxcard.FieldDeletedAt)
  42937. }
  42938. // SetUserID sets the "user_id" field.
  42939. func (m *WxCardMutation) SetUserID(u uint64) {
  42940. m.user_id = &u
  42941. m.adduser_id = nil
  42942. }
  42943. // UserID returns the value of the "user_id" field in the mutation.
  42944. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  42945. v := m.user_id
  42946. if v == nil {
  42947. return
  42948. }
  42949. return *v, true
  42950. }
  42951. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  42952. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42954. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42955. if !m.op.Is(OpUpdateOne) {
  42956. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42957. }
  42958. if m.id == nil || m.oldValue == nil {
  42959. return v, errors.New("OldUserID requires an ID field in the mutation")
  42960. }
  42961. oldValue, err := m.oldValue(ctx)
  42962. if err != nil {
  42963. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42964. }
  42965. return oldValue.UserID, nil
  42966. }
  42967. // AddUserID adds u to the "user_id" field.
  42968. func (m *WxCardMutation) AddUserID(u int64) {
  42969. if m.adduser_id != nil {
  42970. *m.adduser_id += u
  42971. } else {
  42972. m.adduser_id = &u
  42973. }
  42974. }
  42975. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42976. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  42977. v := m.adduser_id
  42978. if v == nil {
  42979. return
  42980. }
  42981. return *v, true
  42982. }
  42983. // ClearUserID clears the value of the "user_id" field.
  42984. func (m *WxCardMutation) ClearUserID() {
  42985. m.user_id = nil
  42986. m.adduser_id = nil
  42987. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  42988. }
  42989. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42990. func (m *WxCardMutation) UserIDCleared() bool {
  42991. _, ok := m.clearedFields[wxcard.FieldUserID]
  42992. return ok
  42993. }
  42994. // ResetUserID resets all changes to the "user_id" field.
  42995. func (m *WxCardMutation) ResetUserID() {
  42996. m.user_id = nil
  42997. m.adduser_id = nil
  42998. delete(m.clearedFields, wxcard.FieldUserID)
  42999. }
  43000. // SetWxUserID sets the "wx_user_id" field.
  43001. func (m *WxCardMutation) SetWxUserID(u uint64) {
  43002. m.wx_user_id = &u
  43003. m.addwx_user_id = nil
  43004. }
  43005. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  43006. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  43007. v := m.wx_user_id
  43008. if v == nil {
  43009. return
  43010. }
  43011. return *v, true
  43012. }
  43013. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  43014. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43016. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  43017. if !m.op.Is(OpUpdateOne) {
  43018. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  43019. }
  43020. if m.id == nil || m.oldValue == nil {
  43021. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  43022. }
  43023. oldValue, err := m.oldValue(ctx)
  43024. if err != nil {
  43025. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  43026. }
  43027. return oldValue.WxUserID, nil
  43028. }
  43029. // AddWxUserID adds u to the "wx_user_id" field.
  43030. func (m *WxCardMutation) AddWxUserID(u int64) {
  43031. if m.addwx_user_id != nil {
  43032. *m.addwx_user_id += u
  43033. } else {
  43034. m.addwx_user_id = &u
  43035. }
  43036. }
  43037. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  43038. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  43039. v := m.addwx_user_id
  43040. if v == nil {
  43041. return
  43042. }
  43043. return *v, true
  43044. }
  43045. // ClearWxUserID clears the value of the "wx_user_id" field.
  43046. func (m *WxCardMutation) ClearWxUserID() {
  43047. m.wx_user_id = nil
  43048. m.addwx_user_id = nil
  43049. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  43050. }
  43051. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  43052. func (m *WxCardMutation) WxUserIDCleared() bool {
  43053. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  43054. return ok
  43055. }
  43056. // ResetWxUserID resets all changes to the "wx_user_id" field.
  43057. func (m *WxCardMutation) ResetWxUserID() {
  43058. m.wx_user_id = nil
  43059. m.addwx_user_id = nil
  43060. delete(m.clearedFields, wxcard.FieldWxUserID)
  43061. }
  43062. // SetAvatar sets the "avatar" field.
  43063. func (m *WxCardMutation) SetAvatar(s string) {
  43064. m.avatar = &s
  43065. }
  43066. // Avatar returns the value of the "avatar" field in the mutation.
  43067. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  43068. v := m.avatar
  43069. if v == nil {
  43070. return
  43071. }
  43072. return *v, true
  43073. }
  43074. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  43075. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43077. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43078. if !m.op.Is(OpUpdateOne) {
  43079. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43080. }
  43081. if m.id == nil || m.oldValue == nil {
  43082. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43083. }
  43084. oldValue, err := m.oldValue(ctx)
  43085. if err != nil {
  43086. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43087. }
  43088. return oldValue.Avatar, nil
  43089. }
  43090. // ResetAvatar resets all changes to the "avatar" field.
  43091. func (m *WxCardMutation) ResetAvatar() {
  43092. m.avatar = nil
  43093. }
  43094. // SetLogo sets the "logo" field.
  43095. func (m *WxCardMutation) SetLogo(s string) {
  43096. m.logo = &s
  43097. }
  43098. // Logo returns the value of the "logo" field in the mutation.
  43099. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43100. v := m.logo
  43101. if v == nil {
  43102. return
  43103. }
  43104. return *v, true
  43105. }
  43106. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43107. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43109. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43110. if !m.op.Is(OpUpdateOne) {
  43111. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43112. }
  43113. if m.id == nil || m.oldValue == nil {
  43114. return v, errors.New("OldLogo requires an ID field in the mutation")
  43115. }
  43116. oldValue, err := m.oldValue(ctx)
  43117. if err != nil {
  43118. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43119. }
  43120. return oldValue.Logo, nil
  43121. }
  43122. // ResetLogo resets all changes to the "logo" field.
  43123. func (m *WxCardMutation) ResetLogo() {
  43124. m.logo = nil
  43125. }
  43126. // SetName sets the "name" field.
  43127. func (m *WxCardMutation) SetName(s string) {
  43128. m.name = &s
  43129. }
  43130. // Name returns the value of the "name" field in the mutation.
  43131. func (m *WxCardMutation) Name() (r string, exists bool) {
  43132. v := m.name
  43133. if v == nil {
  43134. return
  43135. }
  43136. return *v, true
  43137. }
  43138. // OldName returns the old "name" field's value of the WxCard entity.
  43139. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43141. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43142. if !m.op.Is(OpUpdateOne) {
  43143. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43144. }
  43145. if m.id == nil || m.oldValue == nil {
  43146. return v, errors.New("OldName requires an ID field in the mutation")
  43147. }
  43148. oldValue, err := m.oldValue(ctx)
  43149. if err != nil {
  43150. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43151. }
  43152. return oldValue.Name, nil
  43153. }
  43154. // ResetName resets all changes to the "name" field.
  43155. func (m *WxCardMutation) ResetName() {
  43156. m.name = nil
  43157. }
  43158. // SetCompany sets the "company" field.
  43159. func (m *WxCardMutation) SetCompany(s string) {
  43160. m.company = &s
  43161. }
  43162. // Company returns the value of the "company" field in the mutation.
  43163. func (m *WxCardMutation) Company() (r string, exists bool) {
  43164. v := m.company
  43165. if v == nil {
  43166. return
  43167. }
  43168. return *v, true
  43169. }
  43170. // OldCompany returns the old "company" field's value of the WxCard entity.
  43171. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43173. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43174. if !m.op.Is(OpUpdateOne) {
  43175. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43176. }
  43177. if m.id == nil || m.oldValue == nil {
  43178. return v, errors.New("OldCompany requires an ID field in the mutation")
  43179. }
  43180. oldValue, err := m.oldValue(ctx)
  43181. if err != nil {
  43182. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43183. }
  43184. return oldValue.Company, nil
  43185. }
  43186. // ResetCompany resets all changes to the "company" field.
  43187. func (m *WxCardMutation) ResetCompany() {
  43188. m.company = nil
  43189. }
  43190. // SetAddress sets the "address" field.
  43191. func (m *WxCardMutation) SetAddress(s string) {
  43192. m.address = &s
  43193. }
  43194. // Address returns the value of the "address" field in the mutation.
  43195. func (m *WxCardMutation) Address() (r string, exists bool) {
  43196. v := m.address
  43197. if v == nil {
  43198. return
  43199. }
  43200. return *v, true
  43201. }
  43202. // OldAddress returns the old "address" field's value of the WxCard entity.
  43203. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43205. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43206. if !m.op.Is(OpUpdateOne) {
  43207. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43208. }
  43209. if m.id == nil || m.oldValue == nil {
  43210. return v, errors.New("OldAddress requires an ID field in the mutation")
  43211. }
  43212. oldValue, err := m.oldValue(ctx)
  43213. if err != nil {
  43214. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43215. }
  43216. return oldValue.Address, nil
  43217. }
  43218. // ResetAddress resets all changes to the "address" field.
  43219. func (m *WxCardMutation) ResetAddress() {
  43220. m.address = nil
  43221. }
  43222. // SetPhone sets the "phone" field.
  43223. func (m *WxCardMutation) SetPhone(s string) {
  43224. m.phone = &s
  43225. }
  43226. // Phone returns the value of the "phone" field in the mutation.
  43227. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43228. v := m.phone
  43229. if v == nil {
  43230. return
  43231. }
  43232. return *v, true
  43233. }
  43234. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43235. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43237. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43238. if !m.op.Is(OpUpdateOne) {
  43239. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43240. }
  43241. if m.id == nil || m.oldValue == nil {
  43242. return v, errors.New("OldPhone requires an ID field in the mutation")
  43243. }
  43244. oldValue, err := m.oldValue(ctx)
  43245. if err != nil {
  43246. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43247. }
  43248. return oldValue.Phone, nil
  43249. }
  43250. // ResetPhone resets all changes to the "phone" field.
  43251. func (m *WxCardMutation) ResetPhone() {
  43252. m.phone = nil
  43253. }
  43254. // SetOfficialAccount sets the "official_account" field.
  43255. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43256. m.official_account = &s
  43257. }
  43258. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43259. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43260. v := m.official_account
  43261. if v == nil {
  43262. return
  43263. }
  43264. return *v, true
  43265. }
  43266. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43267. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43269. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43270. if !m.op.Is(OpUpdateOne) {
  43271. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43272. }
  43273. if m.id == nil || m.oldValue == nil {
  43274. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43275. }
  43276. oldValue, err := m.oldValue(ctx)
  43277. if err != nil {
  43278. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43279. }
  43280. return oldValue.OfficialAccount, nil
  43281. }
  43282. // ResetOfficialAccount resets all changes to the "official_account" field.
  43283. func (m *WxCardMutation) ResetOfficialAccount() {
  43284. m.official_account = nil
  43285. }
  43286. // SetWechatAccount sets the "wechat_account" field.
  43287. func (m *WxCardMutation) SetWechatAccount(s string) {
  43288. m.wechat_account = &s
  43289. }
  43290. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43291. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43292. v := m.wechat_account
  43293. if v == nil {
  43294. return
  43295. }
  43296. return *v, true
  43297. }
  43298. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43299. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43301. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43302. if !m.op.Is(OpUpdateOne) {
  43303. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43304. }
  43305. if m.id == nil || m.oldValue == nil {
  43306. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43307. }
  43308. oldValue, err := m.oldValue(ctx)
  43309. if err != nil {
  43310. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43311. }
  43312. return oldValue.WechatAccount, nil
  43313. }
  43314. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43315. func (m *WxCardMutation) ResetWechatAccount() {
  43316. m.wechat_account = nil
  43317. }
  43318. // SetEmail sets the "email" field.
  43319. func (m *WxCardMutation) SetEmail(s string) {
  43320. m.email = &s
  43321. }
  43322. // Email returns the value of the "email" field in the mutation.
  43323. func (m *WxCardMutation) Email() (r string, exists bool) {
  43324. v := m.email
  43325. if v == nil {
  43326. return
  43327. }
  43328. return *v, true
  43329. }
  43330. // OldEmail returns the old "email" field's value of the WxCard entity.
  43331. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43333. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43334. if !m.op.Is(OpUpdateOne) {
  43335. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43336. }
  43337. if m.id == nil || m.oldValue == nil {
  43338. return v, errors.New("OldEmail requires an ID field in the mutation")
  43339. }
  43340. oldValue, err := m.oldValue(ctx)
  43341. if err != nil {
  43342. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43343. }
  43344. return oldValue.Email, nil
  43345. }
  43346. // ClearEmail clears the value of the "email" field.
  43347. func (m *WxCardMutation) ClearEmail() {
  43348. m.email = nil
  43349. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43350. }
  43351. // EmailCleared returns if the "email" field was cleared in this mutation.
  43352. func (m *WxCardMutation) EmailCleared() bool {
  43353. _, ok := m.clearedFields[wxcard.FieldEmail]
  43354. return ok
  43355. }
  43356. // ResetEmail resets all changes to the "email" field.
  43357. func (m *WxCardMutation) ResetEmail() {
  43358. m.email = nil
  43359. delete(m.clearedFields, wxcard.FieldEmail)
  43360. }
  43361. // SetAPIBase sets the "api_base" field.
  43362. func (m *WxCardMutation) SetAPIBase(s string) {
  43363. m.api_base = &s
  43364. }
  43365. // APIBase returns the value of the "api_base" field in the mutation.
  43366. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43367. v := m.api_base
  43368. if v == nil {
  43369. return
  43370. }
  43371. return *v, true
  43372. }
  43373. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43374. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43376. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43377. if !m.op.Is(OpUpdateOne) {
  43378. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43379. }
  43380. if m.id == nil || m.oldValue == nil {
  43381. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43382. }
  43383. oldValue, err := m.oldValue(ctx)
  43384. if err != nil {
  43385. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43386. }
  43387. return oldValue.APIBase, nil
  43388. }
  43389. // ClearAPIBase clears the value of the "api_base" field.
  43390. func (m *WxCardMutation) ClearAPIBase() {
  43391. m.api_base = nil
  43392. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43393. }
  43394. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43395. func (m *WxCardMutation) APIBaseCleared() bool {
  43396. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43397. return ok
  43398. }
  43399. // ResetAPIBase resets all changes to the "api_base" field.
  43400. func (m *WxCardMutation) ResetAPIBase() {
  43401. m.api_base = nil
  43402. delete(m.clearedFields, wxcard.FieldAPIBase)
  43403. }
  43404. // SetAPIKey sets the "api_key" field.
  43405. func (m *WxCardMutation) SetAPIKey(s string) {
  43406. m.api_key = &s
  43407. }
  43408. // APIKey returns the value of the "api_key" field in the mutation.
  43409. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43410. v := m.api_key
  43411. if v == nil {
  43412. return
  43413. }
  43414. return *v, true
  43415. }
  43416. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43417. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43419. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43420. if !m.op.Is(OpUpdateOne) {
  43421. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43422. }
  43423. if m.id == nil || m.oldValue == nil {
  43424. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43425. }
  43426. oldValue, err := m.oldValue(ctx)
  43427. if err != nil {
  43428. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43429. }
  43430. return oldValue.APIKey, nil
  43431. }
  43432. // ClearAPIKey clears the value of the "api_key" field.
  43433. func (m *WxCardMutation) ClearAPIKey() {
  43434. m.api_key = nil
  43435. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43436. }
  43437. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43438. func (m *WxCardMutation) APIKeyCleared() bool {
  43439. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43440. return ok
  43441. }
  43442. // ResetAPIKey resets all changes to the "api_key" field.
  43443. func (m *WxCardMutation) ResetAPIKey() {
  43444. m.api_key = nil
  43445. delete(m.clearedFields, wxcard.FieldAPIKey)
  43446. }
  43447. // SetAiInfo sets the "ai_info" field.
  43448. func (m *WxCardMutation) SetAiInfo(s string) {
  43449. m.ai_info = &s
  43450. }
  43451. // AiInfo returns the value of the "ai_info" field in the mutation.
  43452. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43453. v := m.ai_info
  43454. if v == nil {
  43455. return
  43456. }
  43457. return *v, true
  43458. }
  43459. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43460. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43462. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43463. if !m.op.Is(OpUpdateOne) {
  43464. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43465. }
  43466. if m.id == nil || m.oldValue == nil {
  43467. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43468. }
  43469. oldValue, err := m.oldValue(ctx)
  43470. if err != nil {
  43471. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43472. }
  43473. return oldValue.AiInfo, nil
  43474. }
  43475. // ClearAiInfo clears the value of the "ai_info" field.
  43476. func (m *WxCardMutation) ClearAiInfo() {
  43477. m.ai_info = nil
  43478. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43479. }
  43480. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43481. func (m *WxCardMutation) AiInfoCleared() bool {
  43482. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43483. return ok
  43484. }
  43485. // ResetAiInfo resets all changes to the "ai_info" field.
  43486. func (m *WxCardMutation) ResetAiInfo() {
  43487. m.ai_info = nil
  43488. delete(m.clearedFields, wxcard.FieldAiInfo)
  43489. }
  43490. // SetIntro sets the "intro" field.
  43491. func (m *WxCardMutation) SetIntro(s string) {
  43492. m.intro = &s
  43493. }
  43494. // Intro returns the value of the "intro" field in the mutation.
  43495. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43496. v := m.intro
  43497. if v == nil {
  43498. return
  43499. }
  43500. return *v, true
  43501. }
  43502. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43503. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43505. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43506. if !m.op.Is(OpUpdateOne) {
  43507. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43508. }
  43509. if m.id == nil || m.oldValue == nil {
  43510. return v, errors.New("OldIntro requires an ID field in the mutation")
  43511. }
  43512. oldValue, err := m.oldValue(ctx)
  43513. if err != nil {
  43514. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43515. }
  43516. return oldValue.Intro, nil
  43517. }
  43518. // ClearIntro clears the value of the "intro" field.
  43519. func (m *WxCardMutation) ClearIntro() {
  43520. m.intro = nil
  43521. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43522. }
  43523. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43524. func (m *WxCardMutation) IntroCleared() bool {
  43525. _, ok := m.clearedFields[wxcard.FieldIntro]
  43526. return ok
  43527. }
  43528. // ResetIntro resets all changes to the "intro" field.
  43529. func (m *WxCardMutation) ResetIntro() {
  43530. m.intro = nil
  43531. delete(m.clearedFields, wxcard.FieldIntro)
  43532. }
  43533. // Where appends a list predicates to the WxCardMutation builder.
  43534. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43535. m.predicates = append(m.predicates, ps...)
  43536. }
  43537. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43538. // users can use type-assertion to append predicates that do not depend on any generated package.
  43539. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43540. p := make([]predicate.WxCard, len(ps))
  43541. for i := range ps {
  43542. p[i] = ps[i]
  43543. }
  43544. m.Where(p...)
  43545. }
  43546. // Op returns the operation name.
  43547. func (m *WxCardMutation) Op() Op {
  43548. return m.op
  43549. }
  43550. // SetOp allows setting the mutation operation.
  43551. func (m *WxCardMutation) SetOp(op Op) {
  43552. m.op = op
  43553. }
  43554. // Type returns the node type of this mutation (WxCard).
  43555. func (m *WxCardMutation) Type() string {
  43556. return m.typ
  43557. }
  43558. // Fields returns all fields that were changed during this mutation. Note that in
  43559. // order to get all numeric fields that were incremented/decremented, call
  43560. // AddedFields().
  43561. func (m *WxCardMutation) Fields() []string {
  43562. fields := make([]string, 0, 18)
  43563. if m.created_at != nil {
  43564. fields = append(fields, wxcard.FieldCreatedAt)
  43565. }
  43566. if m.updated_at != nil {
  43567. fields = append(fields, wxcard.FieldUpdatedAt)
  43568. }
  43569. if m.deleted_at != nil {
  43570. fields = append(fields, wxcard.FieldDeletedAt)
  43571. }
  43572. if m.user_id != nil {
  43573. fields = append(fields, wxcard.FieldUserID)
  43574. }
  43575. if m.wx_user_id != nil {
  43576. fields = append(fields, wxcard.FieldWxUserID)
  43577. }
  43578. if m.avatar != nil {
  43579. fields = append(fields, wxcard.FieldAvatar)
  43580. }
  43581. if m.logo != nil {
  43582. fields = append(fields, wxcard.FieldLogo)
  43583. }
  43584. if m.name != nil {
  43585. fields = append(fields, wxcard.FieldName)
  43586. }
  43587. if m.company != nil {
  43588. fields = append(fields, wxcard.FieldCompany)
  43589. }
  43590. if m.address != nil {
  43591. fields = append(fields, wxcard.FieldAddress)
  43592. }
  43593. if m.phone != nil {
  43594. fields = append(fields, wxcard.FieldPhone)
  43595. }
  43596. if m.official_account != nil {
  43597. fields = append(fields, wxcard.FieldOfficialAccount)
  43598. }
  43599. if m.wechat_account != nil {
  43600. fields = append(fields, wxcard.FieldWechatAccount)
  43601. }
  43602. if m.email != nil {
  43603. fields = append(fields, wxcard.FieldEmail)
  43604. }
  43605. if m.api_base != nil {
  43606. fields = append(fields, wxcard.FieldAPIBase)
  43607. }
  43608. if m.api_key != nil {
  43609. fields = append(fields, wxcard.FieldAPIKey)
  43610. }
  43611. if m.ai_info != nil {
  43612. fields = append(fields, wxcard.FieldAiInfo)
  43613. }
  43614. if m.intro != nil {
  43615. fields = append(fields, wxcard.FieldIntro)
  43616. }
  43617. return fields
  43618. }
  43619. // Field returns the value of a field with the given name. The second boolean
  43620. // return value indicates that this field was not set, or was not defined in the
  43621. // schema.
  43622. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43623. switch name {
  43624. case wxcard.FieldCreatedAt:
  43625. return m.CreatedAt()
  43626. case wxcard.FieldUpdatedAt:
  43627. return m.UpdatedAt()
  43628. case wxcard.FieldDeletedAt:
  43629. return m.DeletedAt()
  43630. case wxcard.FieldUserID:
  43631. return m.UserID()
  43632. case wxcard.FieldWxUserID:
  43633. return m.WxUserID()
  43634. case wxcard.FieldAvatar:
  43635. return m.Avatar()
  43636. case wxcard.FieldLogo:
  43637. return m.Logo()
  43638. case wxcard.FieldName:
  43639. return m.Name()
  43640. case wxcard.FieldCompany:
  43641. return m.Company()
  43642. case wxcard.FieldAddress:
  43643. return m.Address()
  43644. case wxcard.FieldPhone:
  43645. return m.Phone()
  43646. case wxcard.FieldOfficialAccount:
  43647. return m.OfficialAccount()
  43648. case wxcard.FieldWechatAccount:
  43649. return m.WechatAccount()
  43650. case wxcard.FieldEmail:
  43651. return m.Email()
  43652. case wxcard.FieldAPIBase:
  43653. return m.APIBase()
  43654. case wxcard.FieldAPIKey:
  43655. return m.APIKey()
  43656. case wxcard.FieldAiInfo:
  43657. return m.AiInfo()
  43658. case wxcard.FieldIntro:
  43659. return m.Intro()
  43660. }
  43661. return nil, false
  43662. }
  43663. // OldField returns the old value of the field from the database. An error is
  43664. // returned if the mutation operation is not UpdateOne, or the query to the
  43665. // database failed.
  43666. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43667. switch name {
  43668. case wxcard.FieldCreatedAt:
  43669. return m.OldCreatedAt(ctx)
  43670. case wxcard.FieldUpdatedAt:
  43671. return m.OldUpdatedAt(ctx)
  43672. case wxcard.FieldDeletedAt:
  43673. return m.OldDeletedAt(ctx)
  43674. case wxcard.FieldUserID:
  43675. return m.OldUserID(ctx)
  43676. case wxcard.FieldWxUserID:
  43677. return m.OldWxUserID(ctx)
  43678. case wxcard.FieldAvatar:
  43679. return m.OldAvatar(ctx)
  43680. case wxcard.FieldLogo:
  43681. return m.OldLogo(ctx)
  43682. case wxcard.FieldName:
  43683. return m.OldName(ctx)
  43684. case wxcard.FieldCompany:
  43685. return m.OldCompany(ctx)
  43686. case wxcard.FieldAddress:
  43687. return m.OldAddress(ctx)
  43688. case wxcard.FieldPhone:
  43689. return m.OldPhone(ctx)
  43690. case wxcard.FieldOfficialAccount:
  43691. return m.OldOfficialAccount(ctx)
  43692. case wxcard.FieldWechatAccount:
  43693. return m.OldWechatAccount(ctx)
  43694. case wxcard.FieldEmail:
  43695. return m.OldEmail(ctx)
  43696. case wxcard.FieldAPIBase:
  43697. return m.OldAPIBase(ctx)
  43698. case wxcard.FieldAPIKey:
  43699. return m.OldAPIKey(ctx)
  43700. case wxcard.FieldAiInfo:
  43701. return m.OldAiInfo(ctx)
  43702. case wxcard.FieldIntro:
  43703. return m.OldIntro(ctx)
  43704. }
  43705. return nil, fmt.Errorf("unknown WxCard field %s", name)
  43706. }
  43707. // SetField sets the value of a field with the given name. It returns an error if
  43708. // the field is not defined in the schema, or if the type mismatched the field
  43709. // type.
  43710. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  43711. switch name {
  43712. case wxcard.FieldCreatedAt:
  43713. v, ok := value.(time.Time)
  43714. if !ok {
  43715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43716. }
  43717. m.SetCreatedAt(v)
  43718. return nil
  43719. case wxcard.FieldUpdatedAt:
  43720. v, ok := value.(time.Time)
  43721. if !ok {
  43722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43723. }
  43724. m.SetUpdatedAt(v)
  43725. return nil
  43726. case wxcard.FieldDeletedAt:
  43727. v, ok := value.(time.Time)
  43728. if !ok {
  43729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43730. }
  43731. m.SetDeletedAt(v)
  43732. return nil
  43733. case wxcard.FieldUserID:
  43734. v, ok := value.(uint64)
  43735. if !ok {
  43736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43737. }
  43738. m.SetUserID(v)
  43739. return nil
  43740. case wxcard.FieldWxUserID:
  43741. v, ok := value.(uint64)
  43742. if !ok {
  43743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43744. }
  43745. m.SetWxUserID(v)
  43746. return nil
  43747. case wxcard.FieldAvatar:
  43748. v, ok := value.(string)
  43749. if !ok {
  43750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43751. }
  43752. m.SetAvatar(v)
  43753. return nil
  43754. case wxcard.FieldLogo:
  43755. v, ok := value.(string)
  43756. if !ok {
  43757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43758. }
  43759. m.SetLogo(v)
  43760. return nil
  43761. case wxcard.FieldName:
  43762. v, ok := value.(string)
  43763. if !ok {
  43764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43765. }
  43766. m.SetName(v)
  43767. return nil
  43768. case wxcard.FieldCompany:
  43769. v, ok := value.(string)
  43770. if !ok {
  43771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43772. }
  43773. m.SetCompany(v)
  43774. return nil
  43775. case wxcard.FieldAddress:
  43776. v, ok := value.(string)
  43777. if !ok {
  43778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43779. }
  43780. m.SetAddress(v)
  43781. return nil
  43782. case wxcard.FieldPhone:
  43783. v, ok := value.(string)
  43784. if !ok {
  43785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43786. }
  43787. m.SetPhone(v)
  43788. return nil
  43789. case wxcard.FieldOfficialAccount:
  43790. v, ok := value.(string)
  43791. if !ok {
  43792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43793. }
  43794. m.SetOfficialAccount(v)
  43795. return nil
  43796. case wxcard.FieldWechatAccount:
  43797. v, ok := value.(string)
  43798. if !ok {
  43799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43800. }
  43801. m.SetWechatAccount(v)
  43802. return nil
  43803. case wxcard.FieldEmail:
  43804. v, ok := value.(string)
  43805. if !ok {
  43806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43807. }
  43808. m.SetEmail(v)
  43809. return nil
  43810. case wxcard.FieldAPIBase:
  43811. v, ok := value.(string)
  43812. if !ok {
  43813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43814. }
  43815. m.SetAPIBase(v)
  43816. return nil
  43817. case wxcard.FieldAPIKey:
  43818. v, ok := value.(string)
  43819. if !ok {
  43820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43821. }
  43822. m.SetAPIKey(v)
  43823. return nil
  43824. case wxcard.FieldAiInfo:
  43825. v, ok := value.(string)
  43826. if !ok {
  43827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43828. }
  43829. m.SetAiInfo(v)
  43830. return nil
  43831. case wxcard.FieldIntro:
  43832. v, ok := value.(string)
  43833. if !ok {
  43834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43835. }
  43836. m.SetIntro(v)
  43837. return nil
  43838. }
  43839. return fmt.Errorf("unknown WxCard field %s", name)
  43840. }
  43841. // AddedFields returns all numeric fields that were incremented/decremented during
  43842. // this mutation.
  43843. func (m *WxCardMutation) AddedFields() []string {
  43844. var fields []string
  43845. if m.adduser_id != nil {
  43846. fields = append(fields, wxcard.FieldUserID)
  43847. }
  43848. if m.addwx_user_id != nil {
  43849. fields = append(fields, wxcard.FieldWxUserID)
  43850. }
  43851. return fields
  43852. }
  43853. // AddedField returns the numeric value that was incremented/decremented on a field
  43854. // with the given name. The second boolean return value indicates that this field
  43855. // was not set, or was not defined in the schema.
  43856. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  43857. switch name {
  43858. case wxcard.FieldUserID:
  43859. return m.AddedUserID()
  43860. case wxcard.FieldWxUserID:
  43861. return m.AddedWxUserID()
  43862. }
  43863. return nil, false
  43864. }
  43865. // AddField adds the value to the field with the given name. It returns an error if
  43866. // the field is not defined in the schema, or if the type mismatched the field
  43867. // type.
  43868. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  43869. switch name {
  43870. case wxcard.FieldUserID:
  43871. v, ok := value.(int64)
  43872. if !ok {
  43873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43874. }
  43875. m.AddUserID(v)
  43876. return nil
  43877. case wxcard.FieldWxUserID:
  43878. v, ok := value.(int64)
  43879. if !ok {
  43880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43881. }
  43882. m.AddWxUserID(v)
  43883. return nil
  43884. }
  43885. return fmt.Errorf("unknown WxCard numeric field %s", name)
  43886. }
  43887. // ClearedFields returns all nullable fields that were cleared during this
  43888. // mutation.
  43889. func (m *WxCardMutation) ClearedFields() []string {
  43890. var fields []string
  43891. if m.FieldCleared(wxcard.FieldDeletedAt) {
  43892. fields = append(fields, wxcard.FieldDeletedAt)
  43893. }
  43894. if m.FieldCleared(wxcard.FieldUserID) {
  43895. fields = append(fields, wxcard.FieldUserID)
  43896. }
  43897. if m.FieldCleared(wxcard.FieldWxUserID) {
  43898. fields = append(fields, wxcard.FieldWxUserID)
  43899. }
  43900. if m.FieldCleared(wxcard.FieldEmail) {
  43901. fields = append(fields, wxcard.FieldEmail)
  43902. }
  43903. if m.FieldCleared(wxcard.FieldAPIBase) {
  43904. fields = append(fields, wxcard.FieldAPIBase)
  43905. }
  43906. if m.FieldCleared(wxcard.FieldAPIKey) {
  43907. fields = append(fields, wxcard.FieldAPIKey)
  43908. }
  43909. if m.FieldCleared(wxcard.FieldAiInfo) {
  43910. fields = append(fields, wxcard.FieldAiInfo)
  43911. }
  43912. if m.FieldCleared(wxcard.FieldIntro) {
  43913. fields = append(fields, wxcard.FieldIntro)
  43914. }
  43915. return fields
  43916. }
  43917. // FieldCleared returns a boolean indicating if a field with the given name was
  43918. // cleared in this mutation.
  43919. func (m *WxCardMutation) FieldCleared(name string) bool {
  43920. _, ok := m.clearedFields[name]
  43921. return ok
  43922. }
  43923. // ClearField clears the value of the field with the given name. It returns an
  43924. // error if the field is not defined in the schema.
  43925. func (m *WxCardMutation) ClearField(name string) error {
  43926. switch name {
  43927. case wxcard.FieldDeletedAt:
  43928. m.ClearDeletedAt()
  43929. return nil
  43930. case wxcard.FieldUserID:
  43931. m.ClearUserID()
  43932. return nil
  43933. case wxcard.FieldWxUserID:
  43934. m.ClearWxUserID()
  43935. return nil
  43936. case wxcard.FieldEmail:
  43937. m.ClearEmail()
  43938. return nil
  43939. case wxcard.FieldAPIBase:
  43940. m.ClearAPIBase()
  43941. return nil
  43942. case wxcard.FieldAPIKey:
  43943. m.ClearAPIKey()
  43944. return nil
  43945. case wxcard.FieldAiInfo:
  43946. m.ClearAiInfo()
  43947. return nil
  43948. case wxcard.FieldIntro:
  43949. m.ClearIntro()
  43950. return nil
  43951. }
  43952. return fmt.Errorf("unknown WxCard nullable field %s", name)
  43953. }
  43954. // ResetField resets all changes in the mutation for the field with the given name.
  43955. // It returns an error if the field is not defined in the schema.
  43956. func (m *WxCardMutation) ResetField(name string) error {
  43957. switch name {
  43958. case wxcard.FieldCreatedAt:
  43959. m.ResetCreatedAt()
  43960. return nil
  43961. case wxcard.FieldUpdatedAt:
  43962. m.ResetUpdatedAt()
  43963. return nil
  43964. case wxcard.FieldDeletedAt:
  43965. m.ResetDeletedAt()
  43966. return nil
  43967. case wxcard.FieldUserID:
  43968. m.ResetUserID()
  43969. return nil
  43970. case wxcard.FieldWxUserID:
  43971. m.ResetWxUserID()
  43972. return nil
  43973. case wxcard.FieldAvatar:
  43974. m.ResetAvatar()
  43975. return nil
  43976. case wxcard.FieldLogo:
  43977. m.ResetLogo()
  43978. return nil
  43979. case wxcard.FieldName:
  43980. m.ResetName()
  43981. return nil
  43982. case wxcard.FieldCompany:
  43983. m.ResetCompany()
  43984. return nil
  43985. case wxcard.FieldAddress:
  43986. m.ResetAddress()
  43987. return nil
  43988. case wxcard.FieldPhone:
  43989. m.ResetPhone()
  43990. return nil
  43991. case wxcard.FieldOfficialAccount:
  43992. m.ResetOfficialAccount()
  43993. return nil
  43994. case wxcard.FieldWechatAccount:
  43995. m.ResetWechatAccount()
  43996. return nil
  43997. case wxcard.FieldEmail:
  43998. m.ResetEmail()
  43999. return nil
  44000. case wxcard.FieldAPIBase:
  44001. m.ResetAPIBase()
  44002. return nil
  44003. case wxcard.FieldAPIKey:
  44004. m.ResetAPIKey()
  44005. return nil
  44006. case wxcard.FieldAiInfo:
  44007. m.ResetAiInfo()
  44008. return nil
  44009. case wxcard.FieldIntro:
  44010. m.ResetIntro()
  44011. return nil
  44012. }
  44013. return fmt.Errorf("unknown WxCard field %s", name)
  44014. }
  44015. // AddedEdges returns all edge names that were set/added in this mutation.
  44016. func (m *WxCardMutation) AddedEdges() []string {
  44017. edges := make([]string, 0, 0)
  44018. return edges
  44019. }
  44020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44021. // name in this mutation.
  44022. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  44023. return nil
  44024. }
  44025. // RemovedEdges returns all edge names that were removed in this mutation.
  44026. func (m *WxCardMutation) RemovedEdges() []string {
  44027. edges := make([]string, 0, 0)
  44028. return edges
  44029. }
  44030. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44031. // the given name in this mutation.
  44032. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  44033. return nil
  44034. }
  44035. // ClearedEdges returns all edge names that were cleared in this mutation.
  44036. func (m *WxCardMutation) ClearedEdges() []string {
  44037. edges := make([]string, 0, 0)
  44038. return edges
  44039. }
  44040. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44041. // was cleared in this mutation.
  44042. func (m *WxCardMutation) EdgeCleared(name string) bool {
  44043. return false
  44044. }
  44045. // ClearEdge clears the value of the edge with the given name. It returns an error
  44046. // if that edge is not defined in the schema.
  44047. func (m *WxCardMutation) ClearEdge(name string) error {
  44048. return fmt.Errorf("unknown WxCard unique edge %s", name)
  44049. }
  44050. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44051. // It returns an error if the edge is not defined in the schema.
  44052. func (m *WxCardMutation) ResetEdge(name string) error {
  44053. return fmt.Errorf("unknown WxCard edge %s", name)
  44054. }
  44055. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  44056. type WxCardUserMutation struct {
  44057. config
  44058. op Op
  44059. typ string
  44060. id *uint64
  44061. created_at *time.Time
  44062. updated_at *time.Time
  44063. deleted_at *time.Time
  44064. wxid *string
  44065. account *string
  44066. avatar *string
  44067. nickname *string
  44068. remark *string
  44069. phone *string
  44070. open_id *string
  44071. union_id *string
  44072. session_key *string
  44073. is_vip *int
  44074. addis_vip *int
  44075. clearedFields map[string]struct{}
  44076. done bool
  44077. oldValue func(context.Context) (*WxCardUser, error)
  44078. predicates []predicate.WxCardUser
  44079. }
  44080. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44081. // wxcarduserOption allows management of the mutation configuration using functional options.
  44082. type wxcarduserOption func(*WxCardUserMutation)
  44083. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44084. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44085. m := &WxCardUserMutation{
  44086. config: c,
  44087. op: op,
  44088. typ: TypeWxCardUser,
  44089. clearedFields: make(map[string]struct{}),
  44090. }
  44091. for _, opt := range opts {
  44092. opt(m)
  44093. }
  44094. return m
  44095. }
  44096. // withWxCardUserID sets the ID field of the mutation.
  44097. func withWxCardUserID(id uint64) wxcarduserOption {
  44098. return func(m *WxCardUserMutation) {
  44099. var (
  44100. err error
  44101. once sync.Once
  44102. value *WxCardUser
  44103. )
  44104. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44105. once.Do(func() {
  44106. if m.done {
  44107. err = errors.New("querying old values post mutation is not allowed")
  44108. } else {
  44109. value, err = m.Client().WxCardUser.Get(ctx, id)
  44110. }
  44111. })
  44112. return value, err
  44113. }
  44114. m.id = &id
  44115. }
  44116. }
  44117. // withWxCardUser sets the old WxCardUser of the mutation.
  44118. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44119. return func(m *WxCardUserMutation) {
  44120. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44121. return node, nil
  44122. }
  44123. m.id = &node.ID
  44124. }
  44125. }
  44126. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44127. // executed in a transaction (ent.Tx), a transactional client is returned.
  44128. func (m WxCardUserMutation) Client() *Client {
  44129. client := &Client{config: m.config}
  44130. client.init()
  44131. return client
  44132. }
  44133. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44134. // it returns an error otherwise.
  44135. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44136. if _, ok := m.driver.(*txDriver); !ok {
  44137. return nil, errors.New("ent: mutation is not running in a transaction")
  44138. }
  44139. tx := &Tx{config: m.config}
  44140. tx.init()
  44141. return tx, nil
  44142. }
  44143. // SetID sets the value of the id field. Note that this
  44144. // operation is only accepted on creation of WxCardUser entities.
  44145. func (m *WxCardUserMutation) SetID(id uint64) {
  44146. m.id = &id
  44147. }
  44148. // ID returns the ID value in the mutation. Note that the ID is only available
  44149. // if it was provided to the builder or after it was returned from the database.
  44150. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44151. if m.id == nil {
  44152. return
  44153. }
  44154. return *m.id, true
  44155. }
  44156. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44157. // That means, if the mutation is applied within a transaction with an isolation level such
  44158. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44159. // or updated by the mutation.
  44160. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44161. switch {
  44162. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44163. id, exists := m.ID()
  44164. if exists {
  44165. return []uint64{id}, nil
  44166. }
  44167. fallthrough
  44168. case m.op.Is(OpUpdate | OpDelete):
  44169. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44170. default:
  44171. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44172. }
  44173. }
  44174. // SetCreatedAt sets the "created_at" field.
  44175. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44176. m.created_at = &t
  44177. }
  44178. // CreatedAt returns the value of the "created_at" field in the mutation.
  44179. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44180. v := m.created_at
  44181. if v == nil {
  44182. return
  44183. }
  44184. return *v, true
  44185. }
  44186. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44187. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44189. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44190. if !m.op.Is(OpUpdateOne) {
  44191. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44192. }
  44193. if m.id == nil || m.oldValue == nil {
  44194. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44195. }
  44196. oldValue, err := m.oldValue(ctx)
  44197. if err != nil {
  44198. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44199. }
  44200. return oldValue.CreatedAt, nil
  44201. }
  44202. // ResetCreatedAt resets all changes to the "created_at" field.
  44203. func (m *WxCardUserMutation) ResetCreatedAt() {
  44204. m.created_at = nil
  44205. }
  44206. // SetUpdatedAt sets the "updated_at" field.
  44207. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44208. m.updated_at = &t
  44209. }
  44210. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44211. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44212. v := m.updated_at
  44213. if v == nil {
  44214. return
  44215. }
  44216. return *v, true
  44217. }
  44218. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44219. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44221. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44222. if !m.op.Is(OpUpdateOne) {
  44223. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44224. }
  44225. if m.id == nil || m.oldValue == nil {
  44226. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44227. }
  44228. oldValue, err := m.oldValue(ctx)
  44229. if err != nil {
  44230. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44231. }
  44232. return oldValue.UpdatedAt, nil
  44233. }
  44234. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44235. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44236. m.updated_at = nil
  44237. }
  44238. // SetDeletedAt sets the "deleted_at" field.
  44239. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44240. m.deleted_at = &t
  44241. }
  44242. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44243. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44244. v := m.deleted_at
  44245. if v == nil {
  44246. return
  44247. }
  44248. return *v, true
  44249. }
  44250. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44251. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44253. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44254. if !m.op.Is(OpUpdateOne) {
  44255. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44256. }
  44257. if m.id == nil || m.oldValue == nil {
  44258. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44259. }
  44260. oldValue, err := m.oldValue(ctx)
  44261. if err != nil {
  44262. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44263. }
  44264. return oldValue.DeletedAt, nil
  44265. }
  44266. // ClearDeletedAt clears the value of the "deleted_at" field.
  44267. func (m *WxCardUserMutation) ClearDeletedAt() {
  44268. m.deleted_at = nil
  44269. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44270. }
  44271. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44272. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44273. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44274. return ok
  44275. }
  44276. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44277. func (m *WxCardUserMutation) ResetDeletedAt() {
  44278. m.deleted_at = nil
  44279. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44280. }
  44281. // SetWxid sets the "wxid" field.
  44282. func (m *WxCardUserMutation) SetWxid(s string) {
  44283. m.wxid = &s
  44284. }
  44285. // Wxid returns the value of the "wxid" field in the mutation.
  44286. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44287. v := m.wxid
  44288. if v == nil {
  44289. return
  44290. }
  44291. return *v, true
  44292. }
  44293. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44294. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44296. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44297. if !m.op.Is(OpUpdateOne) {
  44298. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44299. }
  44300. if m.id == nil || m.oldValue == nil {
  44301. return v, errors.New("OldWxid requires an ID field in the mutation")
  44302. }
  44303. oldValue, err := m.oldValue(ctx)
  44304. if err != nil {
  44305. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44306. }
  44307. return oldValue.Wxid, nil
  44308. }
  44309. // ResetWxid resets all changes to the "wxid" field.
  44310. func (m *WxCardUserMutation) ResetWxid() {
  44311. m.wxid = nil
  44312. }
  44313. // SetAccount sets the "account" field.
  44314. func (m *WxCardUserMutation) SetAccount(s string) {
  44315. m.account = &s
  44316. }
  44317. // Account returns the value of the "account" field in the mutation.
  44318. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44319. v := m.account
  44320. if v == nil {
  44321. return
  44322. }
  44323. return *v, true
  44324. }
  44325. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44326. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44328. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44329. if !m.op.Is(OpUpdateOne) {
  44330. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44331. }
  44332. if m.id == nil || m.oldValue == nil {
  44333. return v, errors.New("OldAccount requires an ID field in the mutation")
  44334. }
  44335. oldValue, err := m.oldValue(ctx)
  44336. if err != nil {
  44337. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44338. }
  44339. return oldValue.Account, nil
  44340. }
  44341. // ResetAccount resets all changes to the "account" field.
  44342. func (m *WxCardUserMutation) ResetAccount() {
  44343. m.account = nil
  44344. }
  44345. // SetAvatar sets the "avatar" field.
  44346. func (m *WxCardUserMutation) SetAvatar(s string) {
  44347. m.avatar = &s
  44348. }
  44349. // Avatar returns the value of the "avatar" field in the mutation.
  44350. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44351. v := m.avatar
  44352. if v == nil {
  44353. return
  44354. }
  44355. return *v, true
  44356. }
  44357. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44358. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44360. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44361. if !m.op.Is(OpUpdateOne) {
  44362. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44363. }
  44364. if m.id == nil || m.oldValue == nil {
  44365. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44366. }
  44367. oldValue, err := m.oldValue(ctx)
  44368. if err != nil {
  44369. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44370. }
  44371. return oldValue.Avatar, nil
  44372. }
  44373. // ResetAvatar resets all changes to the "avatar" field.
  44374. func (m *WxCardUserMutation) ResetAvatar() {
  44375. m.avatar = nil
  44376. }
  44377. // SetNickname sets the "nickname" field.
  44378. func (m *WxCardUserMutation) SetNickname(s string) {
  44379. m.nickname = &s
  44380. }
  44381. // Nickname returns the value of the "nickname" field in the mutation.
  44382. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44383. v := m.nickname
  44384. if v == nil {
  44385. return
  44386. }
  44387. return *v, true
  44388. }
  44389. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44390. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44392. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44393. if !m.op.Is(OpUpdateOne) {
  44394. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44395. }
  44396. if m.id == nil || m.oldValue == nil {
  44397. return v, errors.New("OldNickname requires an ID field in the mutation")
  44398. }
  44399. oldValue, err := m.oldValue(ctx)
  44400. if err != nil {
  44401. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44402. }
  44403. return oldValue.Nickname, nil
  44404. }
  44405. // ResetNickname resets all changes to the "nickname" field.
  44406. func (m *WxCardUserMutation) ResetNickname() {
  44407. m.nickname = nil
  44408. }
  44409. // SetRemark sets the "remark" field.
  44410. func (m *WxCardUserMutation) SetRemark(s string) {
  44411. m.remark = &s
  44412. }
  44413. // Remark returns the value of the "remark" field in the mutation.
  44414. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44415. v := m.remark
  44416. if v == nil {
  44417. return
  44418. }
  44419. return *v, true
  44420. }
  44421. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44422. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44424. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44425. if !m.op.Is(OpUpdateOne) {
  44426. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44427. }
  44428. if m.id == nil || m.oldValue == nil {
  44429. return v, errors.New("OldRemark requires an ID field in the mutation")
  44430. }
  44431. oldValue, err := m.oldValue(ctx)
  44432. if err != nil {
  44433. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44434. }
  44435. return oldValue.Remark, nil
  44436. }
  44437. // ResetRemark resets all changes to the "remark" field.
  44438. func (m *WxCardUserMutation) ResetRemark() {
  44439. m.remark = nil
  44440. }
  44441. // SetPhone sets the "phone" field.
  44442. func (m *WxCardUserMutation) SetPhone(s string) {
  44443. m.phone = &s
  44444. }
  44445. // Phone returns the value of the "phone" field in the mutation.
  44446. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44447. v := m.phone
  44448. if v == nil {
  44449. return
  44450. }
  44451. return *v, true
  44452. }
  44453. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44454. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44456. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44457. if !m.op.Is(OpUpdateOne) {
  44458. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44459. }
  44460. if m.id == nil || m.oldValue == nil {
  44461. return v, errors.New("OldPhone requires an ID field in the mutation")
  44462. }
  44463. oldValue, err := m.oldValue(ctx)
  44464. if err != nil {
  44465. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44466. }
  44467. return oldValue.Phone, nil
  44468. }
  44469. // ResetPhone resets all changes to the "phone" field.
  44470. func (m *WxCardUserMutation) ResetPhone() {
  44471. m.phone = nil
  44472. }
  44473. // SetOpenID sets the "open_id" field.
  44474. func (m *WxCardUserMutation) SetOpenID(s string) {
  44475. m.open_id = &s
  44476. }
  44477. // OpenID returns the value of the "open_id" field in the mutation.
  44478. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44479. v := m.open_id
  44480. if v == nil {
  44481. return
  44482. }
  44483. return *v, true
  44484. }
  44485. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44486. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44488. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44489. if !m.op.Is(OpUpdateOne) {
  44490. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44491. }
  44492. if m.id == nil || m.oldValue == nil {
  44493. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44494. }
  44495. oldValue, err := m.oldValue(ctx)
  44496. if err != nil {
  44497. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44498. }
  44499. return oldValue.OpenID, nil
  44500. }
  44501. // ResetOpenID resets all changes to the "open_id" field.
  44502. func (m *WxCardUserMutation) ResetOpenID() {
  44503. m.open_id = nil
  44504. }
  44505. // SetUnionID sets the "union_id" field.
  44506. func (m *WxCardUserMutation) SetUnionID(s string) {
  44507. m.union_id = &s
  44508. }
  44509. // UnionID returns the value of the "union_id" field in the mutation.
  44510. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44511. v := m.union_id
  44512. if v == nil {
  44513. return
  44514. }
  44515. return *v, true
  44516. }
  44517. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44518. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44520. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44521. if !m.op.Is(OpUpdateOne) {
  44522. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44523. }
  44524. if m.id == nil || m.oldValue == nil {
  44525. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44526. }
  44527. oldValue, err := m.oldValue(ctx)
  44528. if err != nil {
  44529. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44530. }
  44531. return oldValue.UnionID, nil
  44532. }
  44533. // ResetUnionID resets all changes to the "union_id" field.
  44534. func (m *WxCardUserMutation) ResetUnionID() {
  44535. m.union_id = nil
  44536. }
  44537. // SetSessionKey sets the "session_key" field.
  44538. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44539. m.session_key = &s
  44540. }
  44541. // SessionKey returns the value of the "session_key" field in the mutation.
  44542. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44543. v := m.session_key
  44544. if v == nil {
  44545. return
  44546. }
  44547. return *v, true
  44548. }
  44549. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44550. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44552. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44553. if !m.op.Is(OpUpdateOne) {
  44554. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44555. }
  44556. if m.id == nil || m.oldValue == nil {
  44557. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44558. }
  44559. oldValue, err := m.oldValue(ctx)
  44560. if err != nil {
  44561. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44562. }
  44563. return oldValue.SessionKey, nil
  44564. }
  44565. // ResetSessionKey resets all changes to the "session_key" field.
  44566. func (m *WxCardUserMutation) ResetSessionKey() {
  44567. m.session_key = nil
  44568. }
  44569. // SetIsVip sets the "is_vip" field.
  44570. func (m *WxCardUserMutation) SetIsVip(i int) {
  44571. m.is_vip = &i
  44572. m.addis_vip = nil
  44573. }
  44574. // IsVip returns the value of the "is_vip" field in the mutation.
  44575. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44576. v := m.is_vip
  44577. if v == nil {
  44578. return
  44579. }
  44580. return *v, true
  44581. }
  44582. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44583. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44585. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44586. if !m.op.Is(OpUpdateOne) {
  44587. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44588. }
  44589. if m.id == nil || m.oldValue == nil {
  44590. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44591. }
  44592. oldValue, err := m.oldValue(ctx)
  44593. if err != nil {
  44594. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44595. }
  44596. return oldValue.IsVip, nil
  44597. }
  44598. // AddIsVip adds i to the "is_vip" field.
  44599. func (m *WxCardUserMutation) AddIsVip(i int) {
  44600. if m.addis_vip != nil {
  44601. *m.addis_vip += i
  44602. } else {
  44603. m.addis_vip = &i
  44604. }
  44605. }
  44606. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44607. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44608. v := m.addis_vip
  44609. if v == nil {
  44610. return
  44611. }
  44612. return *v, true
  44613. }
  44614. // ResetIsVip resets all changes to the "is_vip" field.
  44615. func (m *WxCardUserMutation) ResetIsVip() {
  44616. m.is_vip = nil
  44617. m.addis_vip = nil
  44618. }
  44619. // Where appends a list predicates to the WxCardUserMutation builder.
  44620. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44621. m.predicates = append(m.predicates, ps...)
  44622. }
  44623. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44624. // users can use type-assertion to append predicates that do not depend on any generated package.
  44625. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44626. p := make([]predicate.WxCardUser, len(ps))
  44627. for i := range ps {
  44628. p[i] = ps[i]
  44629. }
  44630. m.Where(p...)
  44631. }
  44632. // Op returns the operation name.
  44633. func (m *WxCardUserMutation) Op() Op {
  44634. return m.op
  44635. }
  44636. // SetOp allows setting the mutation operation.
  44637. func (m *WxCardUserMutation) SetOp(op Op) {
  44638. m.op = op
  44639. }
  44640. // Type returns the node type of this mutation (WxCardUser).
  44641. func (m *WxCardUserMutation) Type() string {
  44642. return m.typ
  44643. }
  44644. // Fields returns all fields that were changed during this mutation. Note that in
  44645. // order to get all numeric fields that were incremented/decremented, call
  44646. // AddedFields().
  44647. func (m *WxCardUserMutation) Fields() []string {
  44648. fields := make([]string, 0, 13)
  44649. if m.created_at != nil {
  44650. fields = append(fields, wxcarduser.FieldCreatedAt)
  44651. }
  44652. if m.updated_at != nil {
  44653. fields = append(fields, wxcarduser.FieldUpdatedAt)
  44654. }
  44655. if m.deleted_at != nil {
  44656. fields = append(fields, wxcarduser.FieldDeletedAt)
  44657. }
  44658. if m.wxid != nil {
  44659. fields = append(fields, wxcarduser.FieldWxid)
  44660. }
  44661. if m.account != nil {
  44662. fields = append(fields, wxcarduser.FieldAccount)
  44663. }
  44664. if m.avatar != nil {
  44665. fields = append(fields, wxcarduser.FieldAvatar)
  44666. }
  44667. if m.nickname != nil {
  44668. fields = append(fields, wxcarduser.FieldNickname)
  44669. }
  44670. if m.remark != nil {
  44671. fields = append(fields, wxcarduser.FieldRemark)
  44672. }
  44673. if m.phone != nil {
  44674. fields = append(fields, wxcarduser.FieldPhone)
  44675. }
  44676. if m.open_id != nil {
  44677. fields = append(fields, wxcarduser.FieldOpenID)
  44678. }
  44679. if m.union_id != nil {
  44680. fields = append(fields, wxcarduser.FieldUnionID)
  44681. }
  44682. if m.session_key != nil {
  44683. fields = append(fields, wxcarduser.FieldSessionKey)
  44684. }
  44685. if m.is_vip != nil {
  44686. fields = append(fields, wxcarduser.FieldIsVip)
  44687. }
  44688. return fields
  44689. }
  44690. // Field returns the value of a field with the given name. The second boolean
  44691. // return value indicates that this field was not set, or was not defined in the
  44692. // schema.
  44693. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  44694. switch name {
  44695. case wxcarduser.FieldCreatedAt:
  44696. return m.CreatedAt()
  44697. case wxcarduser.FieldUpdatedAt:
  44698. return m.UpdatedAt()
  44699. case wxcarduser.FieldDeletedAt:
  44700. return m.DeletedAt()
  44701. case wxcarduser.FieldWxid:
  44702. return m.Wxid()
  44703. case wxcarduser.FieldAccount:
  44704. return m.Account()
  44705. case wxcarduser.FieldAvatar:
  44706. return m.Avatar()
  44707. case wxcarduser.FieldNickname:
  44708. return m.Nickname()
  44709. case wxcarduser.FieldRemark:
  44710. return m.Remark()
  44711. case wxcarduser.FieldPhone:
  44712. return m.Phone()
  44713. case wxcarduser.FieldOpenID:
  44714. return m.OpenID()
  44715. case wxcarduser.FieldUnionID:
  44716. return m.UnionID()
  44717. case wxcarduser.FieldSessionKey:
  44718. return m.SessionKey()
  44719. case wxcarduser.FieldIsVip:
  44720. return m.IsVip()
  44721. }
  44722. return nil, false
  44723. }
  44724. // OldField returns the old value of the field from the database. An error is
  44725. // returned if the mutation operation is not UpdateOne, or the query to the
  44726. // database failed.
  44727. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44728. switch name {
  44729. case wxcarduser.FieldCreatedAt:
  44730. return m.OldCreatedAt(ctx)
  44731. case wxcarduser.FieldUpdatedAt:
  44732. return m.OldUpdatedAt(ctx)
  44733. case wxcarduser.FieldDeletedAt:
  44734. return m.OldDeletedAt(ctx)
  44735. case wxcarduser.FieldWxid:
  44736. return m.OldWxid(ctx)
  44737. case wxcarduser.FieldAccount:
  44738. return m.OldAccount(ctx)
  44739. case wxcarduser.FieldAvatar:
  44740. return m.OldAvatar(ctx)
  44741. case wxcarduser.FieldNickname:
  44742. return m.OldNickname(ctx)
  44743. case wxcarduser.FieldRemark:
  44744. return m.OldRemark(ctx)
  44745. case wxcarduser.FieldPhone:
  44746. return m.OldPhone(ctx)
  44747. case wxcarduser.FieldOpenID:
  44748. return m.OldOpenID(ctx)
  44749. case wxcarduser.FieldUnionID:
  44750. return m.OldUnionID(ctx)
  44751. case wxcarduser.FieldSessionKey:
  44752. return m.OldSessionKey(ctx)
  44753. case wxcarduser.FieldIsVip:
  44754. return m.OldIsVip(ctx)
  44755. }
  44756. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  44757. }
  44758. // SetField sets the value of a field with the given name. It returns an error if
  44759. // the field is not defined in the schema, or if the type mismatched the field
  44760. // type.
  44761. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  44762. switch name {
  44763. case wxcarduser.FieldCreatedAt:
  44764. v, ok := value.(time.Time)
  44765. if !ok {
  44766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44767. }
  44768. m.SetCreatedAt(v)
  44769. return nil
  44770. case wxcarduser.FieldUpdatedAt:
  44771. v, ok := value.(time.Time)
  44772. if !ok {
  44773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44774. }
  44775. m.SetUpdatedAt(v)
  44776. return nil
  44777. case wxcarduser.FieldDeletedAt:
  44778. v, ok := value.(time.Time)
  44779. if !ok {
  44780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44781. }
  44782. m.SetDeletedAt(v)
  44783. return nil
  44784. case wxcarduser.FieldWxid:
  44785. v, ok := value.(string)
  44786. if !ok {
  44787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44788. }
  44789. m.SetWxid(v)
  44790. return nil
  44791. case wxcarduser.FieldAccount:
  44792. v, ok := value.(string)
  44793. if !ok {
  44794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44795. }
  44796. m.SetAccount(v)
  44797. return nil
  44798. case wxcarduser.FieldAvatar:
  44799. v, ok := value.(string)
  44800. if !ok {
  44801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44802. }
  44803. m.SetAvatar(v)
  44804. return nil
  44805. case wxcarduser.FieldNickname:
  44806. v, ok := value.(string)
  44807. if !ok {
  44808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44809. }
  44810. m.SetNickname(v)
  44811. return nil
  44812. case wxcarduser.FieldRemark:
  44813. v, ok := value.(string)
  44814. if !ok {
  44815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44816. }
  44817. m.SetRemark(v)
  44818. return nil
  44819. case wxcarduser.FieldPhone:
  44820. v, ok := value.(string)
  44821. if !ok {
  44822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44823. }
  44824. m.SetPhone(v)
  44825. return nil
  44826. case wxcarduser.FieldOpenID:
  44827. v, ok := value.(string)
  44828. if !ok {
  44829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44830. }
  44831. m.SetOpenID(v)
  44832. return nil
  44833. case wxcarduser.FieldUnionID:
  44834. v, ok := value.(string)
  44835. if !ok {
  44836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44837. }
  44838. m.SetUnionID(v)
  44839. return nil
  44840. case wxcarduser.FieldSessionKey:
  44841. v, ok := value.(string)
  44842. if !ok {
  44843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44844. }
  44845. m.SetSessionKey(v)
  44846. return nil
  44847. case wxcarduser.FieldIsVip:
  44848. v, ok := value.(int)
  44849. if !ok {
  44850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44851. }
  44852. m.SetIsVip(v)
  44853. return nil
  44854. }
  44855. return fmt.Errorf("unknown WxCardUser field %s", name)
  44856. }
  44857. // AddedFields returns all numeric fields that were incremented/decremented during
  44858. // this mutation.
  44859. func (m *WxCardUserMutation) AddedFields() []string {
  44860. var fields []string
  44861. if m.addis_vip != nil {
  44862. fields = append(fields, wxcarduser.FieldIsVip)
  44863. }
  44864. return fields
  44865. }
  44866. // AddedField returns the numeric value that was incremented/decremented on a field
  44867. // with the given name. The second boolean return value indicates that this field
  44868. // was not set, or was not defined in the schema.
  44869. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  44870. switch name {
  44871. case wxcarduser.FieldIsVip:
  44872. return m.AddedIsVip()
  44873. }
  44874. return nil, false
  44875. }
  44876. // AddField adds the value to the field with the given name. It returns an error if
  44877. // the field is not defined in the schema, or if the type mismatched the field
  44878. // type.
  44879. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  44880. switch name {
  44881. case wxcarduser.FieldIsVip:
  44882. v, ok := value.(int)
  44883. if !ok {
  44884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44885. }
  44886. m.AddIsVip(v)
  44887. return nil
  44888. }
  44889. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  44890. }
  44891. // ClearedFields returns all nullable fields that were cleared during this
  44892. // mutation.
  44893. func (m *WxCardUserMutation) ClearedFields() []string {
  44894. var fields []string
  44895. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  44896. fields = append(fields, wxcarduser.FieldDeletedAt)
  44897. }
  44898. return fields
  44899. }
  44900. // FieldCleared returns a boolean indicating if a field with the given name was
  44901. // cleared in this mutation.
  44902. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  44903. _, ok := m.clearedFields[name]
  44904. return ok
  44905. }
  44906. // ClearField clears the value of the field with the given name. It returns an
  44907. // error if the field is not defined in the schema.
  44908. func (m *WxCardUserMutation) ClearField(name string) error {
  44909. switch name {
  44910. case wxcarduser.FieldDeletedAt:
  44911. m.ClearDeletedAt()
  44912. return nil
  44913. }
  44914. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  44915. }
  44916. // ResetField resets all changes in the mutation for the field with the given name.
  44917. // It returns an error if the field is not defined in the schema.
  44918. func (m *WxCardUserMutation) ResetField(name string) error {
  44919. switch name {
  44920. case wxcarduser.FieldCreatedAt:
  44921. m.ResetCreatedAt()
  44922. return nil
  44923. case wxcarduser.FieldUpdatedAt:
  44924. m.ResetUpdatedAt()
  44925. return nil
  44926. case wxcarduser.FieldDeletedAt:
  44927. m.ResetDeletedAt()
  44928. return nil
  44929. case wxcarduser.FieldWxid:
  44930. m.ResetWxid()
  44931. return nil
  44932. case wxcarduser.FieldAccount:
  44933. m.ResetAccount()
  44934. return nil
  44935. case wxcarduser.FieldAvatar:
  44936. m.ResetAvatar()
  44937. return nil
  44938. case wxcarduser.FieldNickname:
  44939. m.ResetNickname()
  44940. return nil
  44941. case wxcarduser.FieldRemark:
  44942. m.ResetRemark()
  44943. return nil
  44944. case wxcarduser.FieldPhone:
  44945. m.ResetPhone()
  44946. return nil
  44947. case wxcarduser.FieldOpenID:
  44948. m.ResetOpenID()
  44949. return nil
  44950. case wxcarduser.FieldUnionID:
  44951. m.ResetUnionID()
  44952. return nil
  44953. case wxcarduser.FieldSessionKey:
  44954. m.ResetSessionKey()
  44955. return nil
  44956. case wxcarduser.FieldIsVip:
  44957. m.ResetIsVip()
  44958. return nil
  44959. }
  44960. return fmt.Errorf("unknown WxCardUser field %s", name)
  44961. }
  44962. // AddedEdges returns all edge names that were set/added in this mutation.
  44963. func (m *WxCardUserMutation) AddedEdges() []string {
  44964. edges := make([]string, 0, 0)
  44965. return edges
  44966. }
  44967. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44968. // name in this mutation.
  44969. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  44970. return nil
  44971. }
  44972. // RemovedEdges returns all edge names that were removed in this mutation.
  44973. func (m *WxCardUserMutation) RemovedEdges() []string {
  44974. edges := make([]string, 0, 0)
  44975. return edges
  44976. }
  44977. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44978. // the given name in this mutation.
  44979. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  44980. return nil
  44981. }
  44982. // ClearedEdges returns all edge names that were cleared in this mutation.
  44983. func (m *WxCardUserMutation) ClearedEdges() []string {
  44984. edges := make([]string, 0, 0)
  44985. return edges
  44986. }
  44987. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44988. // was cleared in this mutation.
  44989. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  44990. return false
  44991. }
  44992. // ClearEdge clears the value of the edge with the given name. It returns an error
  44993. // if that edge is not defined in the schema.
  44994. func (m *WxCardUserMutation) ClearEdge(name string) error {
  44995. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  44996. }
  44997. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44998. // It returns an error if the edge is not defined in the schema.
  44999. func (m *WxCardUserMutation) ResetEdge(name string) error {
  45000. return fmt.Errorf("unknown WxCardUser edge %s", name)
  45001. }
  45002. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  45003. type WxCardVisitMutation struct {
  45004. config
  45005. op Op
  45006. typ string
  45007. id *uint64
  45008. created_at *time.Time
  45009. updated_at *time.Time
  45010. deleted_at *time.Time
  45011. user_id *uint64
  45012. adduser_id *int64
  45013. bot_id *uint64
  45014. addbot_id *int64
  45015. bot_type *uint8
  45016. addbot_type *int8
  45017. clearedFields map[string]struct{}
  45018. done bool
  45019. oldValue func(context.Context) (*WxCardVisit, error)
  45020. predicates []predicate.WxCardVisit
  45021. }
  45022. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  45023. // wxcardvisitOption allows management of the mutation configuration using functional options.
  45024. type wxcardvisitOption func(*WxCardVisitMutation)
  45025. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  45026. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  45027. m := &WxCardVisitMutation{
  45028. config: c,
  45029. op: op,
  45030. typ: TypeWxCardVisit,
  45031. clearedFields: make(map[string]struct{}),
  45032. }
  45033. for _, opt := range opts {
  45034. opt(m)
  45035. }
  45036. return m
  45037. }
  45038. // withWxCardVisitID sets the ID field of the mutation.
  45039. func withWxCardVisitID(id uint64) wxcardvisitOption {
  45040. return func(m *WxCardVisitMutation) {
  45041. var (
  45042. err error
  45043. once sync.Once
  45044. value *WxCardVisit
  45045. )
  45046. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  45047. once.Do(func() {
  45048. if m.done {
  45049. err = errors.New("querying old values post mutation is not allowed")
  45050. } else {
  45051. value, err = m.Client().WxCardVisit.Get(ctx, id)
  45052. }
  45053. })
  45054. return value, err
  45055. }
  45056. m.id = &id
  45057. }
  45058. }
  45059. // withWxCardVisit sets the old WxCardVisit of the mutation.
  45060. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  45061. return func(m *WxCardVisitMutation) {
  45062. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  45063. return node, nil
  45064. }
  45065. m.id = &node.ID
  45066. }
  45067. }
  45068. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45069. // executed in a transaction (ent.Tx), a transactional client is returned.
  45070. func (m WxCardVisitMutation) Client() *Client {
  45071. client := &Client{config: m.config}
  45072. client.init()
  45073. return client
  45074. }
  45075. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45076. // it returns an error otherwise.
  45077. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  45078. if _, ok := m.driver.(*txDriver); !ok {
  45079. return nil, errors.New("ent: mutation is not running in a transaction")
  45080. }
  45081. tx := &Tx{config: m.config}
  45082. tx.init()
  45083. return tx, nil
  45084. }
  45085. // SetID sets the value of the id field. Note that this
  45086. // operation is only accepted on creation of WxCardVisit entities.
  45087. func (m *WxCardVisitMutation) SetID(id uint64) {
  45088. m.id = &id
  45089. }
  45090. // ID returns the ID value in the mutation. Note that the ID is only available
  45091. // if it was provided to the builder or after it was returned from the database.
  45092. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45093. if m.id == nil {
  45094. return
  45095. }
  45096. return *m.id, true
  45097. }
  45098. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45099. // That means, if the mutation is applied within a transaction with an isolation level such
  45100. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45101. // or updated by the mutation.
  45102. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45103. switch {
  45104. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45105. id, exists := m.ID()
  45106. if exists {
  45107. return []uint64{id}, nil
  45108. }
  45109. fallthrough
  45110. case m.op.Is(OpUpdate | OpDelete):
  45111. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45112. default:
  45113. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45114. }
  45115. }
  45116. // SetCreatedAt sets the "created_at" field.
  45117. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45118. m.created_at = &t
  45119. }
  45120. // CreatedAt returns the value of the "created_at" field in the mutation.
  45121. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45122. v := m.created_at
  45123. if v == nil {
  45124. return
  45125. }
  45126. return *v, true
  45127. }
  45128. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45129. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45131. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45132. if !m.op.Is(OpUpdateOne) {
  45133. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45134. }
  45135. if m.id == nil || m.oldValue == nil {
  45136. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45137. }
  45138. oldValue, err := m.oldValue(ctx)
  45139. if err != nil {
  45140. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45141. }
  45142. return oldValue.CreatedAt, nil
  45143. }
  45144. // ResetCreatedAt resets all changes to the "created_at" field.
  45145. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45146. m.created_at = nil
  45147. }
  45148. // SetUpdatedAt sets the "updated_at" field.
  45149. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45150. m.updated_at = &t
  45151. }
  45152. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45153. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45154. v := m.updated_at
  45155. if v == nil {
  45156. return
  45157. }
  45158. return *v, true
  45159. }
  45160. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45161. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45163. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45164. if !m.op.Is(OpUpdateOne) {
  45165. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45166. }
  45167. if m.id == nil || m.oldValue == nil {
  45168. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45169. }
  45170. oldValue, err := m.oldValue(ctx)
  45171. if err != nil {
  45172. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45173. }
  45174. return oldValue.UpdatedAt, nil
  45175. }
  45176. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45177. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45178. m.updated_at = nil
  45179. }
  45180. // SetDeletedAt sets the "deleted_at" field.
  45181. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45182. m.deleted_at = &t
  45183. }
  45184. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45185. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45186. v := m.deleted_at
  45187. if v == nil {
  45188. return
  45189. }
  45190. return *v, true
  45191. }
  45192. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45193. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45195. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45196. if !m.op.Is(OpUpdateOne) {
  45197. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45198. }
  45199. if m.id == nil || m.oldValue == nil {
  45200. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45201. }
  45202. oldValue, err := m.oldValue(ctx)
  45203. if err != nil {
  45204. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45205. }
  45206. return oldValue.DeletedAt, nil
  45207. }
  45208. // ClearDeletedAt clears the value of the "deleted_at" field.
  45209. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45210. m.deleted_at = nil
  45211. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45212. }
  45213. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45214. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45215. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45216. return ok
  45217. }
  45218. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45219. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45220. m.deleted_at = nil
  45221. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45222. }
  45223. // SetUserID sets the "user_id" field.
  45224. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45225. m.user_id = &u
  45226. m.adduser_id = nil
  45227. }
  45228. // UserID returns the value of the "user_id" field in the mutation.
  45229. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45230. v := m.user_id
  45231. if v == nil {
  45232. return
  45233. }
  45234. return *v, true
  45235. }
  45236. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45237. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45239. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45240. if !m.op.Is(OpUpdateOne) {
  45241. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45242. }
  45243. if m.id == nil || m.oldValue == nil {
  45244. return v, errors.New("OldUserID requires an ID field in the mutation")
  45245. }
  45246. oldValue, err := m.oldValue(ctx)
  45247. if err != nil {
  45248. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45249. }
  45250. return oldValue.UserID, nil
  45251. }
  45252. // AddUserID adds u to the "user_id" field.
  45253. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45254. if m.adduser_id != nil {
  45255. *m.adduser_id += u
  45256. } else {
  45257. m.adduser_id = &u
  45258. }
  45259. }
  45260. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45261. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45262. v := m.adduser_id
  45263. if v == nil {
  45264. return
  45265. }
  45266. return *v, true
  45267. }
  45268. // ClearUserID clears the value of the "user_id" field.
  45269. func (m *WxCardVisitMutation) ClearUserID() {
  45270. m.user_id = nil
  45271. m.adduser_id = nil
  45272. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45273. }
  45274. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45275. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45276. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45277. return ok
  45278. }
  45279. // ResetUserID resets all changes to the "user_id" field.
  45280. func (m *WxCardVisitMutation) ResetUserID() {
  45281. m.user_id = nil
  45282. m.adduser_id = nil
  45283. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45284. }
  45285. // SetBotID sets the "bot_id" field.
  45286. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45287. m.bot_id = &u
  45288. m.addbot_id = nil
  45289. }
  45290. // BotID returns the value of the "bot_id" field in the mutation.
  45291. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45292. v := m.bot_id
  45293. if v == nil {
  45294. return
  45295. }
  45296. return *v, true
  45297. }
  45298. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45299. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45301. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45302. if !m.op.Is(OpUpdateOne) {
  45303. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45304. }
  45305. if m.id == nil || m.oldValue == nil {
  45306. return v, errors.New("OldBotID requires an ID field in the mutation")
  45307. }
  45308. oldValue, err := m.oldValue(ctx)
  45309. if err != nil {
  45310. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45311. }
  45312. return oldValue.BotID, nil
  45313. }
  45314. // AddBotID adds u to the "bot_id" field.
  45315. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45316. if m.addbot_id != nil {
  45317. *m.addbot_id += u
  45318. } else {
  45319. m.addbot_id = &u
  45320. }
  45321. }
  45322. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45323. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45324. v := m.addbot_id
  45325. if v == nil {
  45326. return
  45327. }
  45328. return *v, true
  45329. }
  45330. // ResetBotID resets all changes to the "bot_id" field.
  45331. func (m *WxCardVisitMutation) ResetBotID() {
  45332. m.bot_id = nil
  45333. m.addbot_id = nil
  45334. }
  45335. // SetBotType sets the "bot_type" field.
  45336. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45337. m.bot_type = &u
  45338. m.addbot_type = nil
  45339. }
  45340. // BotType returns the value of the "bot_type" field in the mutation.
  45341. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45342. v := m.bot_type
  45343. if v == nil {
  45344. return
  45345. }
  45346. return *v, true
  45347. }
  45348. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  45349. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45351. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  45352. if !m.op.Is(OpUpdateOne) {
  45353. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45354. }
  45355. if m.id == nil || m.oldValue == nil {
  45356. return v, errors.New("OldBotType requires an ID field in the mutation")
  45357. }
  45358. oldValue, err := m.oldValue(ctx)
  45359. if err != nil {
  45360. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  45361. }
  45362. return oldValue.BotType, nil
  45363. }
  45364. // AddBotType adds u to the "bot_type" field.
  45365. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45366. if m.addbot_type != nil {
  45367. *m.addbot_type += u
  45368. } else {
  45369. m.addbot_type = &u
  45370. }
  45371. }
  45372. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45373. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45374. v := m.addbot_type
  45375. if v == nil {
  45376. return
  45377. }
  45378. return *v, true
  45379. }
  45380. // ResetBotType resets all changes to the "bot_type" field.
  45381. func (m *WxCardVisitMutation) ResetBotType() {
  45382. m.bot_type = nil
  45383. m.addbot_type = nil
  45384. }
  45385. // Where appends a list predicates to the WxCardVisitMutation builder.
  45386. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45387. m.predicates = append(m.predicates, ps...)
  45388. }
  45389. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45390. // users can use type-assertion to append predicates that do not depend on any generated package.
  45391. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45392. p := make([]predicate.WxCardVisit, len(ps))
  45393. for i := range ps {
  45394. p[i] = ps[i]
  45395. }
  45396. m.Where(p...)
  45397. }
  45398. // Op returns the operation name.
  45399. func (m *WxCardVisitMutation) Op() Op {
  45400. return m.op
  45401. }
  45402. // SetOp allows setting the mutation operation.
  45403. func (m *WxCardVisitMutation) SetOp(op Op) {
  45404. m.op = op
  45405. }
  45406. // Type returns the node type of this mutation (WxCardVisit).
  45407. func (m *WxCardVisitMutation) Type() string {
  45408. return m.typ
  45409. }
  45410. // Fields returns all fields that were changed during this mutation. Note that in
  45411. // order to get all numeric fields that were incremented/decremented, call
  45412. // AddedFields().
  45413. func (m *WxCardVisitMutation) Fields() []string {
  45414. fields := make([]string, 0, 6)
  45415. if m.created_at != nil {
  45416. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45417. }
  45418. if m.updated_at != nil {
  45419. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45420. }
  45421. if m.deleted_at != nil {
  45422. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45423. }
  45424. if m.user_id != nil {
  45425. fields = append(fields, wxcardvisit.FieldUserID)
  45426. }
  45427. if m.bot_id != nil {
  45428. fields = append(fields, wxcardvisit.FieldBotID)
  45429. }
  45430. if m.bot_type != nil {
  45431. fields = append(fields, wxcardvisit.FieldBotType)
  45432. }
  45433. return fields
  45434. }
  45435. // Field returns the value of a field with the given name. The second boolean
  45436. // return value indicates that this field was not set, or was not defined in the
  45437. // schema.
  45438. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45439. switch name {
  45440. case wxcardvisit.FieldCreatedAt:
  45441. return m.CreatedAt()
  45442. case wxcardvisit.FieldUpdatedAt:
  45443. return m.UpdatedAt()
  45444. case wxcardvisit.FieldDeletedAt:
  45445. return m.DeletedAt()
  45446. case wxcardvisit.FieldUserID:
  45447. return m.UserID()
  45448. case wxcardvisit.FieldBotID:
  45449. return m.BotID()
  45450. case wxcardvisit.FieldBotType:
  45451. return m.BotType()
  45452. }
  45453. return nil, false
  45454. }
  45455. // OldField returns the old value of the field from the database. An error is
  45456. // returned if the mutation operation is not UpdateOne, or the query to the
  45457. // database failed.
  45458. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45459. switch name {
  45460. case wxcardvisit.FieldCreatedAt:
  45461. return m.OldCreatedAt(ctx)
  45462. case wxcardvisit.FieldUpdatedAt:
  45463. return m.OldUpdatedAt(ctx)
  45464. case wxcardvisit.FieldDeletedAt:
  45465. return m.OldDeletedAt(ctx)
  45466. case wxcardvisit.FieldUserID:
  45467. return m.OldUserID(ctx)
  45468. case wxcardvisit.FieldBotID:
  45469. return m.OldBotID(ctx)
  45470. case wxcardvisit.FieldBotType:
  45471. return m.OldBotType(ctx)
  45472. }
  45473. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45474. }
  45475. // SetField sets the value of a field with the given name. It returns an error if
  45476. // the field is not defined in the schema, or if the type mismatched the field
  45477. // type.
  45478. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45479. switch name {
  45480. case wxcardvisit.FieldCreatedAt:
  45481. v, ok := value.(time.Time)
  45482. if !ok {
  45483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45484. }
  45485. m.SetCreatedAt(v)
  45486. return nil
  45487. case wxcardvisit.FieldUpdatedAt:
  45488. v, ok := value.(time.Time)
  45489. if !ok {
  45490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45491. }
  45492. m.SetUpdatedAt(v)
  45493. return nil
  45494. case wxcardvisit.FieldDeletedAt:
  45495. v, ok := value.(time.Time)
  45496. if !ok {
  45497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45498. }
  45499. m.SetDeletedAt(v)
  45500. return nil
  45501. case wxcardvisit.FieldUserID:
  45502. v, ok := value.(uint64)
  45503. if !ok {
  45504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45505. }
  45506. m.SetUserID(v)
  45507. return nil
  45508. case wxcardvisit.FieldBotID:
  45509. v, ok := value.(uint64)
  45510. if !ok {
  45511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45512. }
  45513. m.SetBotID(v)
  45514. return nil
  45515. case wxcardvisit.FieldBotType:
  45516. v, ok := value.(uint8)
  45517. if !ok {
  45518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45519. }
  45520. m.SetBotType(v)
  45521. return nil
  45522. }
  45523. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45524. }
  45525. // AddedFields returns all numeric fields that were incremented/decremented during
  45526. // this mutation.
  45527. func (m *WxCardVisitMutation) AddedFields() []string {
  45528. var fields []string
  45529. if m.adduser_id != nil {
  45530. fields = append(fields, wxcardvisit.FieldUserID)
  45531. }
  45532. if m.addbot_id != nil {
  45533. fields = append(fields, wxcardvisit.FieldBotID)
  45534. }
  45535. if m.addbot_type != nil {
  45536. fields = append(fields, wxcardvisit.FieldBotType)
  45537. }
  45538. return fields
  45539. }
  45540. // AddedField returns the numeric value that was incremented/decremented on a field
  45541. // with the given name. The second boolean return value indicates that this field
  45542. // was not set, or was not defined in the schema.
  45543. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45544. switch name {
  45545. case wxcardvisit.FieldUserID:
  45546. return m.AddedUserID()
  45547. case wxcardvisit.FieldBotID:
  45548. return m.AddedBotID()
  45549. case wxcardvisit.FieldBotType:
  45550. return m.AddedBotType()
  45551. }
  45552. return nil, false
  45553. }
  45554. // AddField adds the value to the field with the given name. It returns an error if
  45555. // the field is not defined in the schema, or if the type mismatched the field
  45556. // type.
  45557. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45558. switch name {
  45559. case wxcardvisit.FieldUserID:
  45560. v, ok := value.(int64)
  45561. if !ok {
  45562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45563. }
  45564. m.AddUserID(v)
  45565. return nil
  45566. case wxcardvisit.FieldBotID:
  45567. v, ok := value.(int64)
  45568. if !ok {
  45569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45570. }
  45571. m.AddBotID(v)
  45572. return nil
  45573. case wxcardvisit.FieldBotType:
  45574. v, ok := value.(int8)
  45575. if !ok {
  45576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45577. }
  45578. m.AddBotType(v)
  45579. return nil
  45580. }
  45581. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45582. }
  45583. // ClearedFields returns all nullable fields that were cleared during this
  45584. // mutation.
  45585. func (m *WxCardVisitMutation) ClearedFields() []string {
  45586. var fields []string
  45587. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45588. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45589. }
  45590. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45591. fields = append(fields, wxcardvisit.FieldUserID)
  45592. }
  45593. return fields
  45594. }
  45595. // FieldCleared returns a boolean indicating if a field with the given name was
  45596. // cleared in this mutation.
  45597. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45598. _, ok := m.clearedFields[name]
  45599. return ok
  45600. }
  45601. // ClearField clears the value of the field with the given name. It returns an
  45602. // error if the field is not defined in the schema.
  45603. func (m *WxCardVisitMutation) ClearField(name string) error {
  45604. switch name {
  45605. case wxcardvisit.FieldDeletedAt:
  45606. m.ClearDeletedAt()
  45607. return nil
  45608. case wxcardvisit.FieldUserID:
  45609. m.ClearUserID()
  45610. return nil
  45611. }
  45612. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45613. }
  45614. // ResetField resets all changes in the mutation for the field with the given name.
  45615. // It returns an error if the field is not defined in the schema.
  45616. func (m *WxCardVisitMutation) ResetField(name string) error {
  45617. switch name {
  45618. case wxcardvisit.FieldCreatedAt:
  45619. m.ResetCreatedAt()
  45620. return nil
  45621. case wxcardvisit.FieldUpdatedAt:
  45622. m.ResetUpdatedAt()
  45623. return nil
  45624. case wxcardvisit.FieldDeletedAt:
  45625. m.ResetDeletedAt()
  45626. return nil
  45627. case wxcardvisit.FieldUserID:
  45628. m.ResetUserID()
  45629. return nil
  45630. case wxcardvisit.FieldBotID:
  45631. m.ResetBotID()
  45632. return nil
  45633. case wxcardvisit.FieldBotType:
  45634. m.ResetBotType()
  45635. return nil
  45636. }
  45637. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45638. }
  45639. // AddedEdges returns all edge names that were set/added in this mutation.
  45640. func (m *WxCardVisitMutation) AddedEdges() []string {
  45641. edges := make([]string, 0, 0)
  45642. return edges
  45643. }
  45644. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45645. // name in this mutation.
  45646. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  45647. return nil
  45648. }
  45649. // RemovedEdges returns all edge names that were removed in this mutation.
  45650. func (m *WxCardVisitMutation) RemovedEdges() []string {
  45651. edges := make([]string, 0, 0)
  45652. return edges
  45653. }
  45654. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45655. // the given name in this mutation.
  45656. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  45657. return nil
  45658. }
  45659. // ClearedEdges returns all edge names that were cleared in this mutation.
  45660. func (m *WxCardVisitMutation) ClearedEdges() []string {
  45661. edges := make([]string, 0, 0)
  45662. return edges
  45663. }
  45664. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45665. // was cleared in this mutation.
  45666. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  45667. return false
  45668. }
  45669. // ClearEdge clears the value of the edge with the given name. It returns an error
  45670. // if that edge is not defined in the schema.
  45671. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  45672. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  45673. }
  45674. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45675. // It returns an error if the edge is not defined in the schema.
  45676. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  45677. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  45678. }
  45679. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  45680. type XunjiMutation struct {
  45681. config
  45682. op Op
  45683. typ string
  45684. id *uint64
  45685. created_at *time.Time
  45686. updated_at *time.Time
  45687. status *uint8
  45688. addstatus *int8
  45689. deleted_at *time.Time
  45690. app_key *string
  45691. app_secret *string
  45692. token *string
  45693. encoding_key *string
  45694. organization_id *uint64
  45695. addorganization_id *int64
  45696. clearedFields map[string]struct{}
  45697. done bool
  45698. oldValue func(context.Context) (*Xunji, error)
  45699. predicates []predicate.Xunji
  45700. }
  45701. var _ ent.Mutation = (*XunjiMutation)(nil)
  45702. // xunjiOption allows management of the mutation configuration using functional options.
  45703. type xunjiOption func(*XunjiMutation)
  45704. // newXunjiMutation creates new mutation for the Xunji entity.
  45705. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  45706. m := &XunjiMutation{
  45707. config: c,
  45708. op: op,
  45709. typ: TypeXunji,
  45710. clearedFields: make(map[string]struct{}),
  45711. }
  45712. for _, opt := range opts {
  45713. opt(m)
  45714. }
  45715. return m
  45716. }
  45717. // withXunjiID sets the ID field of the mutation.
  45718. func withXunjiID(id uint64) xunjiOption {
  45719. return func(m *XunjiMutation) {
  45720. var (
  45721. err error
  45722. once sync.Once
  45723. value *Xunji
  45724. )
  45725. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  45726. once.Do(func() {
  45727. if m.done {
  45728. err = errors.New("querying old values post mutation is not allowed")
  45729. } else {
  45730. value, err = m.Client().Xunji.Get(ctx, id)
  45731. }
  45732. })
  45733. return value, err
  45734. }
  45735. m.id = &id
  45736. }
  45737. }
  45738. // withXunji sets the old Xunji of the mutation.
  45739. func withXunji(node *Xunji) xunjiOption {
  45740. return func(m *XunjiMutation) {
  45741. m.oldValue = func(context.Context) (*Xunji, error) {
  45742. return node, nil
  45743. }
  45744. m.id = &node.ID
  45745. }
  45746. }
  45747. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45748. // executed in a transaction (ent.Tx), a transactional client is returned.
  45749. func (m XunjiMutation) Client() *Client {
  45750. client := &Client{config: m.config}
  45751. client.init()
  45752. return client
  45753. }
  45754. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45755. // it returns an error otherwise.
  45756. func (m XunjiMutation) Tx() (*Tx, error) {
  45757. if _, ok := m.driver.(*txDriver); !ok {
  45758. return nil, errors.New("ent: mutation is not running in a transaction")
  45759. }
  45760. tx := &Tx{config: m.config}
  45761. tx.init()
  45762. return tx, nil
  45763. }
  45764. // SetID sets the value of the id field. Note that this
  45765. // operation is only accepted on creation of Xunji entities.
  45766. func (m *XunjiMutation) SetID(id uint64) {
  45767. m.id = &id
  45768. }
  45769. // ID returns the ID value in the mutation. Note that the ID is only available
  45770. // if it was provided to the builder or after it was returned from the database.
  45771. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  45772. if m.id == nil {
  45773. return
  45774. }
  45775. return *m.id, true
  45776. }
  45777. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45778. // That means, if the mutation is applied within a transaction with an isolation level such
  45779. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45780. // or updated by the mutation.
  45781. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  45782. switch {
  45783. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45784. id, exists := m.ID()
  45785. if exists {
  45786. return []uint64{id}, nil
  45787. }
  45788. fallthrough
  45789. case m.op.Is(OpUpdate | OpDelete):
  45790. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  45791. default:
  45792. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45793. }
  45794. }
  45795. // SetCreatedAt sets the "created_at" field.
  45796. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  45797. m.created_at = &t
  45798. }
  45799. // CreatedAt returns the value of the "created_at" field in the mutation.
  45800. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  45801. v := m.created_at
  45802. if v == nil {
  45803. return
  45804. }
  45805. return *v, true
  45806. }
  45807. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  45808. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45810. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45811. if !m.op.Is(OpUpdateOne) {
  45812. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45813. }
  45814. if m.id == nil || m.oldValue == nil {
  45815. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45816. }
  45817. oldValue, err := m.oldValue(ctx)
  45818. if err != nil {
  45819. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45820. }
  45821. return oldValue.CreatedAt, nil
  45822. }
  45823. // ResetCreatedAt resets all changes to the "created_at" field.
  45824. func (m *XunjiMutation) ResetCreatedAt() {
  45825. m.created_at = nil
  45826. }
  45827. // SetUpdatedAt sets the "updated_at" field.
  45828. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  45829. m.updated_at = &t
  45830. }
  45831. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45832. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  45833. v := m.updated_at
  45834. if v == nil {
  45835. return
  45836. }
  45837. return *v, true
  45838. }
  45839. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  45840. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45842. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45843. if !m.op.Is(OpUpdateOne) {
  45844. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45845. }
  45846. if m.id == nil || m.oldValue == nil {
  45847. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45848. }
  45849. oldValue, err := m.oldValue(ctx)
  45850. if err != nil {
  45851. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45852. }
  45853. return oldValue.UpdatedAt, nil
  45854. }
  45855. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45856. func (m *XunjiMutation) ResetUpdatedAt() {
  45857. m.updated_at = nil
  45858. }
  45859. // SetStatus sets the "status" field.
  45860. func (m *XunjiMutation) SetStatus(u uint8) {
  45861. m.status = &u
  45862. m.addstatus = nil
  45863. }
  45864. // Status returns the value of the "status" field in the mutation.
  45865. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  45866. v := m.status
  45867. if v == nil {
  45868. return
  45869. }
  45870. return *v, true
  45871. }
  45872. // OldStatus returns the old "status" field's value of the Xunji entity.
  45873. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45875. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45876. if !m.op.Is(OpUpdateOne) {
  45877. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45878. }
  45879. if m.id == nil || m.oldValue == nil {
  45880. return v, errors.New("OldStatus requires an ID field in the mutation")
  45881. }
  45882. oldValue, err := m.oldValue(ctx)
  45883. if err != nil {
  45884. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45885. }
  45886. return oldValue.Status, nil
  45887. }
  45888. // AddStatus adds u to the "status" field.
  45889. func (m *XunjiMutation) AddStatus(u int8) {
  45890. if m.addstatus != nil {
  45891. *m.addstatus += u
  45892. } else {
  45893. m.addstatus = &u
  45894. }
  45895. }
  45896. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45897. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  45898. v := m.addstatus
  45899. if v == nil {
  45900. return
  45901. }
  45902. return *v, true
  45903. }
  45904. // ClearStatus clears the value of the "status" field.
  45905. func (m *XunjiMutation) ClearStatus() {
  45906. m.status = nil
  45907. m.addstatus = nil
  45908. m.clearedFields[xunji.FieldStatus] = struct{}{}
  45909. }
  45910. // StatusCleared returns if the "status" field was cleared in this mutation.
  45911. func (m *XunjiMutation) StatusCleared() bool {
  45912. _, ok := m.clearedFields[xunji.FieldStatus]
  45913. return ok
  45914. }
  45915. // ResetStatus resets all changes to the "status" field.
  45916. func (m *XunjiMutation) ResetStatus() {
  45917. m.status = nil
  45918. m.addstatus = nil
  45919. delete(m.clearedFields, xunji.FieldStatus)
  45920. }
  45921. // SetDeletedAt sets the "deleted_at" field.
  45922. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  45923. m.deleted_at = &t
  45924. }
  45925. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45926. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  45927. v := m.deleted_at
  45928. if v == nil {
  45929. return
  45930. }
  45931. return *v, true
  45932. }
  45933. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  45934. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45936. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45937. if !m.op.Is(OpUpdateOne) {
  45938. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45939. }
  45940. if m.id == nil || m.oldValue == nil {
  45941. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45942. }
  45943. oldValue, err := m.oldValue(ctx)
  45944. if err != nil {
  45945. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45946. }
  45947. return oldValue.DeletedAt, nil
  45948. }
  45949. // ClearDeletedAt clears the value of the "deleted_at" field.
  45950. func (m *XunjiMutation) ClearDeletedAt() {
  45951. m.deleted_at = nil
  45952. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  45953. }
  45954. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45955. func (m *XunjiMutation) DeletedAtCleared() bool {
  45956. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  45957. return ok
  45958. }
  45959. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45960. func (m *XunjiMutation) ResetDeletedAt() {
  45961. m.deleted_at = nil
  45962. delete(m.clearedFields, xunji.FieldDeletedAt)
  45963. }
  45964. // SetAppKey sets the "app_key" field.
  45965. func (m *XunjiMutation) SetAppKey(s string) {
  45966. m.app_key = &s
  45967. }
  45968. // AppKey returns the value of the "app_key" field in the mutation.
  45969. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  45970. v := m.app_key
  45971. if v == nil {
  45972. return
  45973. }
  45974. return *v, true
  45975. }
  45976. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  45977. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45979. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  45980. if !m.op.Is(OpUpdateOne) {
  45981. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  45982. }
  45983. if m.id == nil || m.oldValue == nil {
  45984. return v, errors.New("OldAppKey requires an ID field in the mutation")
  45985. }
  45986. oldValue, err := m.oldValue(ctx)
  45987. if err != nil {
  45988. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  45989. }
  45990. return oldValue.AppKey, nil
  45991. }
  45992. // ClearAppKey clears the value of the "app_key" field.
  45993. func (m *XunjiMutation) ClearAppKey() {
  45994. m.app_key = nil
  45995. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  45996. }
  45997. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  45998. func (m *XunjiMutation) AppKeyCleared() bool {
  45999. _, ok := m.clearedFields[xunji.FieldAppKey]
  46000. return ok
  46001. }
  46002. // ResetAppKey resets all changes to the "app_key" field.
  46003. func (m *XunjiMutation) ResetAppKey() {
  46004. m.app_key = nil
  46005. delete(m.clearedFields, xunji.FieldAppKey)
  46006. }
  46007. // SetAppSecret sets the "app_secret" field.
  46008. func (m *XunjiMutation) SetAppSecret(s string) {
  46009. m.app_secret = &s
  46010. }
  46011. // AppSecret returns the value of the "app_secret" field in the mutation.
  46012. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  46013. v := m.app_secret
  46014. if v == nil {
  46015. return
  46016. }
  46017. return *v, true
  46018. }
  46019. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  46020. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46022. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  46023. if !m.op.Is(OpUpdateOne) {
  46024. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  46025. }
  46026. if m.id == nil || m.oldValue == nil {
  46027. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  46028. }
  46029. oldValue, err := m.oldValue(ctx)
  46030. if err != nil {
  46031. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  46032. }
  46033. return oldValue.AppSecret, nil
  46034. }
  46035. // ClearAppSecret clears the value of the "app_secret" field.
  46036. func (m *XunjiMutation) ClearAppSecret() {
  46037. m.app_secret = nil
  46038. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  46039. }
  46040. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  46041. func (m *XunjiMutation) AppSecretCleared() bool {
  46042. _, ok := m.clearedFields[xunji.FieldAppSecret]
  46043. return ok
  46044. }
  46045. // ResetAppSecret resets all changes to the "app_secret" field.
  46046. func (m *XunjiMutation) ResetAppSecret() {
  46047. m.app_secret = nil
  46048. delete(m.clearedFields, xunji.FieldAppSecret)
  46049. }
  46050. // SetToken sets the "token" field.
  46051. func (m *XunjiMutation) SetToken(s string) {
  46052. m.token = &s
  46053. }
  46054. // Token returns the value of the "token" field in the mutation.
  46055. func (m *XunjiMutation) Token() (r string, exists bool) {
  46056. v := m.token
  46057. if v == nil {
  46058. return
  46059. }
  46060. return *v, true
  46061. }
  46062. // OldToken returns the old "token" field's value of the Xunji entity.
  46063. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46065. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  46066. if !m.op.Is(OpUpdateOne) {
  46067. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  46068. }
  46069. if m.id == nil || m.oldValue == nil {
  46070. return v, errors.New("OldToken requires an ID field in the mutation")
  46071. }
  46072. oldValue, err := m.oldValue(ctx)
  46073. if err != nil {
  46074. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  46075. }
  46076. return oldValue.Token, nil
  46077. }
  46078. // ClearToken clears the value of the "token" field.
  46079. func (m *XunjiMutation) ClearToken() {
  46080. m.token = nil
  46081. m.clearedFields[xunji.FieldToken] = struct{}{}
  46082. }
  46083. // TokenCleared returns if the "token" field was cleared in this mutation.
  46084. func (m *XunjiMutation) TokenCleared() bool {
  46085. _, ok := m.clearedFields[xunji.FieldToken]
  46086. return ok
  46087. }
  46088. // ResetToken resets all changes to the "token" field.
  46089. func (m *XunjiMutation) ResetToken() {
  46090. m.token = nil
  46091. delete(m.clearedFields, xunji.FieldToken)
  46092. }
  46093. // SetEncodingKey sets the "encoding_key" field.
  46094. func (m *XunjiMutation) SetEncodingKey(s string) {
  46095. m.encoding_key = &s
  46096. }
  46097. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  46098. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  46099. v := m.encoding_key
  46100. if v == nil {
  46101. return
  46102. }
  46103. return *v, true
  46104. }
  46105. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  46106. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46108. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  46109. if !m.op.Is(OpUpdateOne) {
  46110. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  46111. }
  46112. if m.id == nil || m.oldValue == nil {
  46113. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  46114. }
  46115. oldValue, err := m.oldValue(ctx)
  46116. if err != nil {
  46117. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  46118. }
  46119. return oldValue.EncodingKey, nil
  46120. }
  46121. // ClearEncodingKey clears the value of the "encoding_key" field.
  46122. func (m *XunjiMutation) ClearEncodingKey() {
  46123. m.encoding_key = nil
  46124. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  46125. }
  46126. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  46127. func (m *XunjiMutation) EncodingKeyCleared() bool {
  46128. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  46129. return ok
  46130. }
  46131. // ResetEncodingKey resets all changes to the "encoding_key" field.
  46132. func (m *XunjiMutation) ResetEncodingKey() {
  46133. m.encoding_key = nil
  46134. delete(m.clearedFields, xunji.FieldEncodingKey)
  46135. }
  46136. // SetOrganizationID sets the "organization_id" field.
  46137. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  46138. m.organization_id = &u
  46139. m.addorganization_id = nil
  46140. }
  46141. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46142. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  46143. v := m.organization_id
  46144. if v == nil {
  46145. return
  46146. }
  46147. return *v, true
  46148. }
  46149. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  46150. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46152. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46153. if !m.op.Is(OpUpdateOne) {
  46154. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46155. }
  46156. if m.id == nil || m.oldValue == nil {
  46157. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46158. }
  46159. oldValue, err := m.oldValue(ctx)
  46160. if err != nil {
  46161. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46162. }
  46163. return oldValue.OrganizationID, nil
  46164. }
  46165. // AddOrganizationID adds u to the "organization_id" field.
  46166. func (m *XunjiMutation) AddOrganizationID(u int64) {
  46167. if m.addorganization_id != nil {
  46168. *m.addorganization_id += u
  46169. } else {
  46170. m.addorganization_id = &u
  46171. }
  46172. }
  46173. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46174. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  46175. v := m.addorganization_id
  46176. if v == nil {
  46177. return
  46178. }
  46179. return *v, true
  46180. }
  46181. // ResetOrganizationID resets all changes to the "organization_id" field.
  46182. func (m *XunjiMutation) ResetOrganizationID() {
  46183. m.organization_id = nil
  46184. m.addorganization_id = nil
  46185. }
  46186. // Where appends a list predicates to the XunjiMutation builder.
  46187. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  46188. m.predicates = append(m.predicates, ps...)
  46189. }
  46190. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  46191. // users can use type-assertion to append predicates that do not depend on any generated package.
  46192. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  46193. p := make([]predicate.Xunji, len(ps))
  46194. for i := range ps {
  46195. p[i] = ps[i]
  46196. }
  46197. m.Where(p...)
  46198. }
  46199. // Op returns the operation name.
  46200. func (m *XunjiMutation) Op() Op {
  46201. return m.op
  46202. }
  46203. // SetOp allows setting the mutation operation.
  46204. func (m *XunjiMutation) SetOp(op Op) {
  46205. m.op = op
  46206. }
  46207. // Type returns the node type of this mutation (Xunji).
  46208. func (m *XunjiMutation) Type() string {
  46209. return m.typ
  46210. }
  46211. // Fields returns all fields that were changed during this mutation. Note that in
  46212. // order to get all numeric fields that were incremented/decremented, call
  46213. // AddedFields().
  46214. func (m *XunjiMutation) Fields() []string {
  46215. fields := make([]string, 0, 9)
  46216. if m.created_at != nil {
  46217. fields = append(fields, xunji.FieldCreatedAt)
  46218. }
  46219. if m.updated_at != nil {
  46220. fields = append(fields, xunji.FieldUpdatedAt)
  46221. }
  46222. if m.status != nil {
  46223. fields = append(fields, xunji.FieldStatus)
  46224. }
  46225. if m.deleted_at != nil {
  46226. fields = append(fields, xunji.FieldDeletedAt)
  46227. }
  46228. if m.app_key != nil {
  46229. fields = append(fields, xunji.FieldAppKey)
  46230. }
  46231. if m.app_secret != nil {
  46232. fields = append(fields, xunji.FieldAppSecret)
  46233. }
  46234. if m.token != nil {
  46235. fields = append(fields, xunji.FieldToken)
  46236. }
  46237. if m.encoding_key != nil {
  46238. fields = append(fields, xunji.FieldEncodingKey)
  46239. }
  46240. if m.organization_id != nil {
  46241. fields = append(fields, xunji.FieldOrganizationID)
  46242. }
  46243. return fields
  46244. }
  46245. // Field returns the value of a field with the given name. The second boolean
  46246. // return value indicates that this field was not set, or was not defined in the
  46247. // schema.
  46248. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  46249. switch name {
  46250. case xunji.FieldCreatedAt:
  46251. return m.CreatedAt()
  46252. case xunji.FieldUpdatedAt:
  46253. return m.UpdatedAt()
  46254. case xunji.FieldStatus:
  46255. return m.Status()
  46256. case xunji.FieldDeletedAt:
  46257. return m.DeletedAt()
  46258. case xunji.FieldAppKey:
  46259. return m.AppKey()
  46260. case xunji.FieldAppSecret:
  46261. return m.AppSecret()
  46262. case xunji.FieldToken:
  46263. return m.Token()
  46264. case xunji.FieldEncodingKey:
  46265. return m.EncodingKey()
  46266. case xunji.FieldOrganizationID:
  46267. return m.OrganizationID()
  46268. }
  46269. return nil, false
  46270. }
  46271. // OldField returns the old value of the field from the database. An error is
  46272. // returned if the mutation operation is not UpdateOne, or the query to the
  46273. // database failed.
  46274. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46275. switch name {
  46276. case xunji.FieldCreatedAt:
  46277. return m.OldCreatedAt(ctx)
  46278. case xunji.FieldUpdatedAt:
  46279. return m.OldUpdatedAt(ctx)
  46280. case xunji.FieldStatus:
  46281. return m.OldStatus(ctx)
  46282. case xunji.FieldDeletedAt:
  46283. return m.OldDeletedAt(ctx)
  46284. case xunji.FieldAppKey:
  46285. return m.OldAppKey(ctx)
  46286. case xunji.FieldAppSecret:
  46287. return m.OldAppSecret(ctx)
  46288. case xunji.FieldToken:
  46289. return m.OldToken(ctx)
  46290. case xunji.FieldEncodingKey:
  46291. return m.OldEncodingKey(ctx)
  46292. case xunji.FieldOrganizationID:
  46293. return m.OldOrganizationID(ctx)
  46294. }
  46295. return nil, fmt.Errorf("unknown Xunji field %s", name)
  46296. }
  46297. // SetField sets the value of a field with the given name. It returns an error if
  46298. // the field is not defined in the schema, or if the type mismatched the field
  46299. // type.
  46300. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  46301. switch name {
  46302. case xunji.FieldCreatedAt:
  46303. v, ok := value.(time.Time)
  46304. if !ok {
  46305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46306. }
  46307. m.SetCreatedAt(v)
  46308. return nil
  46309. case xunji.FieldUpdatedAt:
  46310. v, ok := value.(time.Time)
  46311. if !ok {
  46312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46313. }
  46314. m.SetUpdatedAt(v)
  46315. return nil
  46316. case xunji.FieldStatus:
  46317. v, ok := value.(uint8)
  46318. if !ok {
  46319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46320. }
  46321. m.SetStatus(v)
  46322. return nil
  46323. case xunji.FieldDeletedAt:
  46324. v, ok := value.(time.Time)
  46325. if !ok {
  46326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46327. }
  46328. m.SetDeletedAt(v)
  46329. return nil
  46330. case xunji.FieldAppKey:
  46331. v, ok := value.(string)
  46332. if !ok {
  46333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46334. }
  46335. m.SetAppKey(v)
  46336. return nil
  46337. case xunji.FieldAppSecret:
  46338. v, ok := value.(string)
  46339. if !ok {
  46340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46341. }
  46342. m.SetAppSecret(v)
  46343. return nil
  46344. case xunji.FieldToken:
  46345. v, ok := value.(string)
  46346. if !ok {
  46347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46348. }
  46349. m.SetToken(v)
  46350. return nil
  46351. case xunji.FieldEncodingKey:
  46352. v, ok := value.(string)
  46353. if !ok {
  46354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46355. }
  46356. m.SetEncodingKey(v)
  46357. return nil
  46358. case xunji.FieldOrganizationID:
  46359. v, ok := value.(uint64)
  46360. if !ok {
  46361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46362. }
  46363. m.SetOrganizationID(v)
  46364. return nil
  46365. }
  46366. return fmt.Errorf("unknown Xunji field %s", name)
  46367. }
  46368. // AddedFields returns all numeric fields that were incremented/decremented during
  46369. // this mutation.
  46370. func (m *XunjiMutation) AddedFields() []string {
  46371. var fields []string
  46372. if m.addstatus != nil {
  46373. fields = append(fields, xunji.FieldStatus)
  46374. }
  46375. if m.addorganization_id != nil {
  46376. fields = append(fields, xunji.FieldOrganizationID)
  46377. }
  46378. return fields
  46379. }
  46380. // AddedField returns the numeric value that was incremented/decremented on a field
  46381. // with the given name. The second boolean return value indicates that this field
  46382. // was not set, or was not defined in the schema.
  46383. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  46384. switch name {
  46385. case xunji.FieldStatus:
  46386. return m.AddedStatus()
  46387. case xunji.FieldOrganizationID:
  46388. return m.AddedOrganizationID()
  46389. }
  46390. return nil, false
  46391. }
  46392. // AddField adds the value to the field with the given name. It returns an error if
  46393. // the field is not defined in the schema, or if the type mismatched the field
  46394. // type.
  46395. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  46396. switch name {
  46397. case xunji.FieldStatus:
  46398. v, ok := value.(int8)
  46399. if !ok {
  46400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46401. }
  46402. m.AddStatus(v)
  46403. return nil
  46404. case xunji.FieldOrganizationID:
  46405. v, ok := value.(int64)
  46406. if !ok {
  46407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46408. }
  46409. m.AddOrganizationID(v)
  46410. return nil
  46411. }
  46412. return fmt.Errorf("unknown Xunji numeric field %s", name)
  46413. }
  46414. // ClearedFields returns all nullable fields that were cleared during this
  46415. // mutation.
  46416. func (m *XunjiMutation) ClearedFields() []string {
  46417. var fields []string
  46418. if m.FieldCleared(xunji.FieldStatus) {
  46419. fields = append(fields, xunji.FieldStatus)
  46420. }
  46421. if m.FieldCleared(xunji.FieldDeletedAt) {
  46422. fields = append(fields, xunji.FieldDeletedAt)
  46423. }
  46424. if m.FieldCleared(xunji.FieldAppKey) {
  46425. fields = append(fields, xunji.FieldAppKey)
  46426. }
  46427. if m.FieldCleared(xunji.FieldAppSecret) {
  46428. fields = append(fields, xunji.FieldAppSecret)
  46429. }
  46430. if m.FieldCleared(xunji.FieldToken) {
  46431. fields = append(fields, xunji.FieldToken)
  46432. }
  46433. if m.FieldCleared(xunji.FieldEncodingKey) {
  46434. fields = append(fields, xunji.FieldEncodingKey)
  46435. }
  46436. return fields
  46437. }
  46438. // FieldCleared returns a boolean indicating if a field with the given name was
  46439. // cleared in this mutation.
  46440. func (m *XunjiMutation) FieldCleared(name string) bool {
  46441. _, ok := m.clearedFields[name]
  46442. return ok
  46443. }
  46444. // ClearField clears the value of the field with the given name. It returns an
  46445. // error if the field is not defined in the schema.
  46446. func (m *XunjiMutation) ClearField(name string) error {
  46447. switch name {
  46448. case xunji.FieldStatus:
  46449. m.ClearStatus()
  46450. return nil
  46451. case xunji.FieldDeletedAt:
  46452. m.ClearDeletedAt()
  46453. return nil
  46454. case xunji.FieldAppKey:
  46455. m.ClearAppKey()
  46456. return nil
  46457. case xunji.FieldAppSecret:
  46458. m.ClearAppSecret()
  46459. return nil
  46460. case xunji.FieldToken:
  46461. m.ClearToken()
  46462. return nil
  46463. case xunji.FieldEncodingKey:
  46464. m.ClearEncodingKey()
  46465. return nil
  46466. }
  46467. return fmt.Errorf("unknown Xunji nullable field %s", name)
  46468. }
  46469. // ResetField resets all changes in the mutation for the field with the given name.
  46470. // It returns an error if the field is not defined in the schema.
  46471. func (m *XunjiMutation) ResetField(name string) error {
  46472. switch name {
  46473. case xunji.FieldCreatedAt:
  46474. m.ResetCreatedAt()
  46475. return nil
  46476. case xunji.FieldUpdatedAt:
  46477. m.ResetUpdatedAt()
  46478. return nil
  46479. case xunji.FieldStatus:
  46480. m.ResetStatus()
  46481. return nil
  46482. case xunji.FieldDeletedAt:
  46483. m.ResetDeletedAt()
  46484. return nil
  46485. case xunji.FieldAppKey:
  46486. m.ResetAppKey()
  46487. return nil
  46488. case xunji.FieldAppSecret:
  46489. m.ResetAppSecret()
  46490. return nil
  46491. case xunji.FieldToken:
  46492. m.ResetToken()
  46493. return nil
  46494. case xunji.FieldEncodingKey:
  46495. m.ResetEncodingKey()
  46496. return nil
  46497. case xunji.FieldOrganizationID:
  46498. m.ResetOrganizationID()
  46499. return nil
  46500. }
  46501. return fmt.Errorf("unknown Xunji field %s", name)
  46502. }
  46503. // AddedEdges returns all edge names that were set/added in this mutation.
  46504. func (m *XunjiMutation) AddedEdges() []string {
  46505. edges := make([]string, 0, 0)
  46506. return edges
  46507. }
  46508. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46509. // name in this mutation.
  46510. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  46511. return nil
  46512. }
  46513. // RemovedEdges returns all edge names that were removed in this mutation.
  46514. func (m *XunjiMutation) RemovedEdges() []string {
  46515. edges := make([]string, 0, 0)
  46516. return edges
  46517. }
  46518. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46519. // the given name in this mutation.
  46520. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  46521. return nil
  46522. }
  46523. // ClearedEdges returns all edge names that were cleared in this mutation.
  46524. func (m *XunjiMutation) ClearedEdges() []string {
  46525. edges := make([]string, 0, 0)
  46526. return edges
  46527. }
  46528. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46529. // was cleared in this mutation.
  46530. func (m *XunjiMutation) EdgeCleared(name string) bool {
  46531. return false
  46532. }
  46533. // ClearEdge clears the value of the edge with the given name. It returns an error
  46534. // if that edge is not defined in the schema.
  46535. func (m *XunjiMutation) ClearEdge(name string) error {
  46536. return fmt.Errorf("unknown Xunji unique edge %s", name)
  46537. }
  46538. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46539. // It returns an error if the edge is not defined in the schema.
  46540. func (m *XunjiMutation) ResetEdge(name string) error {
  46541. return fmt.Errorf("unknown Xunji edge %s", name)
  46542. }
  46543. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  46544. type XunjiServiceMutation struct {
  46545. config
  46546. op Op
  46547. typ string
  46548. id *uint64
  46549. created_at *time.Time
  46550. updated_at *time.Time
  46551. status *uint8
  46552. addstatus *int8
  46553. deleted_at *time.Time
  46554. xunji_id *uint64
  46555. addxunji_id *int64
  46556. organization_id *uint64
  46557. addorganization_id *int64
  46558. wxid *string
  46559. api_base *string
  46560. api_key *string
  46561. clearedFields map[string]struct{}
  46562. agent *uint64
  46563. clearedagent bool
  46564. done bool
  46565. oldValue func(context.Context) (*XunjiService, error)
  46566. predicates []predicate.XunjiService
  46567. }
  46568. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  46569. // xunjiserviceOption allows management of the mutation configuration using functional options.
  46570. type xunjiserviceOption func(*XunjiServiceMutation)
  46571. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  46572. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  46573. m := &XunjiServiceMutation{
  46574. config: c,
  46575. op: op,
  46576. typ: TypeXunjiService,
  46577. clearedFields: make(map[string]struct{}),
  46578. }
  46579. for _, opt := range opts {
  46580. opt(m)
  46581. }
  46582. return m
  46583. }
  46584. // withXunjiServiceID sets the ID field of the mutation.
  46585. func withXunjiServiceID(id uint64) xunjiserviceOption {
  46586. return func(m *XunjiServiceMutation) {
  46587. var (
  46588. err error
  46589. once sync.Once
  46590. value *XunjiService
  46591. )
  46592. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  46593. once.Do(func() {
  46594. if m.done {
  46595. err = errors.New("querying old values post mutation is not allowed")
  46596. } else {
  46597. value, err = m.Client().XunjiService.Get(ctx, id)
  46598. }
  46599. })
  46600. return value, err
  46601. }
  46602. m.id = &id
  46603. }
  46604. }
  46605. // withXunjiService sets the old XunjiService of the mutation.
  46606. func withXunjiService(node *XunjiService) xunjiserviceOption {
  46607. return func(m *XunjiServiceMutation) {
  46608. m.oldValue = func(context.Context) (*XunjiService, error) {
  46609. return node, nil
  46610. }
  46611. m.id = &node.ID
  46612. }
  46613. }
  46614. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46615. // executed in a transaction (ent.Tx), a transactional client is returned.
  46616. func (m XunjiServiceMutation) Client() *Client {
  46617. client := &Client{config: m.config}
  46618. client.init()
  46619. return client
  46620. }
  46621. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46622. // it returns an error otherwise.
  46623. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  46624. if _, ok := m.driver.(*txDriver); !ok {
  46625. return nil, errors.New("ent: mutation is not running in a transaction")
  46626. }
  46627. tx := &Tx{config: m.config}
  46628. tx.init()
  46629. return tx, nil
  46630. }
  46631. // SetID sets the value of the id field. Note that this
  46632. // operation is only accepted on creation of XunjiService entities.
  46633. func (m *XunjiServiceMutation) SetID(id uint64) {
  46634. m.id = &id
  46635. }
  46636. // ID returns the ID value in the mutation. Note that the ID is only available
  46637. // if it was provided to the builder or after it was returned from the database.
  46638. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  46639. if m.id == nil {
  46640. return
  46641. }
  46642. return *m.id, true
  46643. }
  46644. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46645. // That means, if the mutation is applied within a transaction with an isolation level such
  46646. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46647. // or updated by the mutation.
  46648. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  46649. switch {
  46650. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46651. id, exists := m.ID()
  46652. if exists {
  46653. return []uint64{id}, nil
  46654. }
  46655. fallthrough
  46656. case m.op.Is(OpUpdate | OpDelete):
  46657. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  46658. default:
  46659. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46660. }
  46661. }
  46662. // SetCreatedAt sets the "created_at" field.
  46663. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  46664. m.created_at = &t
  46665. }
  46666. // CreatedAt returns the value of the "created_at" field in the mutation.
  46667. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  46668. v := m.created_at
  46669. if v == nil {
  46670. return
  46671. }
  46672. return *v, true
  46673. }
  46674. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  46675. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46677. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46678. if !m.op.Is(OpUpdateOne) {
  46679. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46680. }
  46681. if m.id == nil || m.oldValue == nil {
  46682. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46683. }
  46684. oldValue, err := m.oldValue(ctx)
  46685. if err != nil {
  46686. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46687. }
  46688. return oldValue.CreatedAt, nil
  46689. }
  46690. // ResetCreatedAt resets all changes to the "created_at" field.
  46691. func (m *XunjiServiceMutation) ResetCreatedAt() {
  46692. m.created_at = nil
  46693. }
  46694. // SetUpdatedAt sets the "updated_at" field.
  46695. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  46696. m.updated_at = &t
  46697. }
  46698. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46699. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  46700. v := m.updated_at
  46701. if v == nil {
  46702. return
  46703. }
  46704. return *v, true
  46705. }
  46706. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  46707. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46709. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46710. if !m.op.Is(OpUpdateOne) {
  46711. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46712. }
  46713. if m.id == nil || m.oldValue == nil {
  46714. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46715. }
  46716. oldValue, err := m.oldValue(ctx)
  46717. if err != nil {
  46718. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46719. }
  46720. return oldValue.UpdatedAt, nil
  46721. }
  46722. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46723. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  46724. m.updated_at = nil
  46725. }
  46726. // SetStatus sets the "status" field.
  46727. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  46728. m.status = &u
  46729. m.addstatus = nil
  46730. }
  46731. // Status returns the value of the "status" field in the mutation.
  46732. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  46733. v := m.status
  46734. if v == nil {
  46735. return
  46736. }
  46737. return *v, true
  46738. }
  46739. // OldStatus returns the old "status" field's value of the XunjiService entity.
  46740. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46742. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46743. if !m.op.Is(OpUpdateOne) {
  46744. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46745. }
  46746. if m.id == nil || m.oldValue == nil {
  46747. return v, errors.New("OldStatus requires an ID field in the mutation")
  46748. }
  46749. oldValue, err := m.oldValue(ctx)
  46750. if err != nil {
  46751. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46752. }
  46753. return oldValue.Status, nil
  46754. }
  46755. // AddStatus adds u to the "status" field.
  46756. func (m *XunjiServiceMutation) AddStatus(u int8) {
  46757. if m.addstatus != nil {
  46758. *m.addstatus += u
  46759. } else {
  46760. m.addstatus = &u
  46761. }
  46762. }
  46763. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46764. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  46765. v := m.addstatus
  46766. if v == nil {
  46767. return
  46768. }
  46769. return *v, true
  46770. }
  46771. // ClearStatus clears the value of the "status" field.
  46772. func (m *XunjiServiceMutation) ClearStatus() {
  46773. m.status = nil
  46774. m.addstatus = nil
  46775. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  46776. }
  46777. // StatusCleared returns if the "status" field was cleared in this mutation.
  46778. func (m *XunjiServiceMutation) StatusCleared() bool {
  46779. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  46780. return ok
  46781. }
  46782. // ResetStatus resets all changes to the "status" field.
  46783. func (m *XunjiServiceMutation) ResetStatus() {
  46784. m.status = nil
  46785. m.addstatus = nil
  46786. delete(m.clearedFields, xunjiservice.FieldStatus)
  46787. }
  46788. // SetDeletedAt sets the "deleted_at" field.
  46789. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  46790. m.deleted_at = &t
  46791. }
  46792. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46793. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  46794. v := m.deleted_at
  46795. if v == nil {
  46796. return
  46797. }
  46798. return *v, true
  46799. }
  46800. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  46801. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46803. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46804. if !m.op.Is(OpUpdateOne) {
  46805. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46806. }
  46807. if m.id == nil || m.oldValue == nil {
  46808. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46809. }
  46810. oldValue, err := m.oldValue(ctx)
  46811. if err != nil {
  46812. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46813. }
  46814. return oldValue.DeletedAt, nil
  46815. }
  46816. // ClearDeletedAt clears the value of the "deleted_at" field.
  46817. func (m *XunjiServiceMutation) ClearDeletedAt() {
  46818. m.deleted_at = nil
  46819. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  46820. }
  46821. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46822. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  46823. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  46824. return ok
  46825. }
  46826. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46827. func (m *XunjiServiceMutation) ResetDeletedAt() {
  46828. m.deleted_at = nil
  46829. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  46830. }
  46831. // SetXunjiID sets the "xunji_id" field.
  46832. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  46833. m.xunji_id = &u
  46834. m.addxunji_id = nil
  46835. }
  46836. // XunjiID returns the value of the "xunji_id" field in the mutation.
  46837. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  46838. v := m.xunji_id
  46839. if v == nil {
  46840. return
  46841. }
  46842. return *v, true
  46843. }
  46844. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  46845. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46847. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  46848. if !m.op.Is(OpUpdateOne) {
  46849. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  46850. }
  46851. if m.id == nil || m.oldValue == nil {
  46852. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  46853. }
  46854. oldValue, err := m.oldValue(ctx)
  46855. if err != nil {
  46856. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  46857. }
  46858. return oldValue.XunjiID, nil
  46859. }
  46860. // AddXunjiID adds u to the "xunji_id" field.
  46861. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  46862. if m.addxunji_id != nil {
  46863. *m.addxunji_id += u
  46864. } else {
  46865. m.addxunji_id = &u
  46866. }
  46867. }
  46868. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  46869. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  46870. v := m.addxunji_id
  46871. if v == nil {
  46872. return
  46873. }
  46874. return *v, true
  46875. }
  46876. // ResetXunjiID resets all changes to the "xunji_id" field.
  46877. func (m *XunjiServiceMutation) ResetXunjiID() {
  46878. m.xunji_id = nil
  46879. m.addxunji_id = nil
  46880. }
  46881. // SetAgentID sets the "agent_id" field.
  46882. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  46883. m.agent = &u
  46884. }
  46885. // AgentID returns the value of the "agent_id" field in the mutation.
  46886. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  46887. v := m.agent
  46888. if v == nil {
  46889. return
  46890. }
  46891. return *v, true
  46892. }
  46893. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  46894. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46896. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46897. if !m.op.Is(OpUpdateOne) {
  46898. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46899. }
  46900. if m.id == nil || m.oldValue == nil {
  46901. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46902. }
  46903. oldValue, err := m.oldValue(ctx)
  46904. if err != nil {
  46905. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46906. }
  46907. return oldValue.AgentID, nil
  46908. }
  46909. // ResetAgentID resets all changes to the "agent_id" field.
  46910. func (m *XunjiServiceMutation) ResetAgentID() {
  46911. m.agent = nil
  46912. }
  46913. // SetOrganizationID sets the "organization_id" field.
  46914. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  46915. m.organization_id = &u
  46916. m.addorganization_id = nil
  46917. }
  46918. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46919. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  46920. v := m.organization_id
  46921. if v == nil {
  46922. return
  46923. }
  46924. return *v, true
  46925. }
  46926. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  46927. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46929. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46930. if !m.op.Is(OpUpdateOne) {
  46931. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46932. }
  46933. if m.id == nil || m.oldValue == nil {
  46934. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46935. }
  46936. oldValue, err := m.oldValue(ctx)
  46937. if err != nil {
  46938. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46939. }
  46940. return oldValue.OrganizationID, nil
  46941. }
  46942. // AddOrganizationID adds u to the "organization_id" field.
  46943. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  46944. if m.addorganization_id != nil {
  46945. *m.addorganization_id += u
  46946. } else {
  46947. m.addorganization_id = &u
  46948. }
  46949. }
  46950. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46951. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  46952. v := m.addorganization_id
  46953. if v == nil {
  46954. return
  46955. }
  46956. return *v, true
  46957. }
  46958. // ResetOrganizationID resets all changes to the "organization_id" field.
  46959. func (m *XunjiServiceMutation) ResetOrganizationID() {
  46960. m.organization_id = nil
  46961. m.addorganization_id = nil
  46962. }
  46963. // SetWxid sets the "wxid" field.
  46964. func (m *XunjiServiceMutation) SetWxid(s string) {
  46965. m.wxid = &s
  46966. }
  46967. // Wxid returns the value of the "wxid" field in the mutation.
  46968. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  46969. v := m.wxid
  46970. if v == nil {
  46971. return
  46972. }
  46973. return *v, true
  46974. }
  46975. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  46976. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46978. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  46979. if !m.op.Is(OpUpdateOne) {
  46980. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46981. }
  46982. if m.id == nil || m.oldValue == nil {
  46983. return v, errors.New("OldWxid requires an ID field in the mutation")
  46984. }
  46985. oldValue, err := m.oldValue(ctx)
  46986. if err != nil {
  46987. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46988. }
  46989. return oldValue.Wxid, nil
  46990. }
  46991. // ResetWxid resets all changes to the "wxid" field.
  46992. func (m *XunjiServiceMutation) ResetWxid() {
  46993. m.wxid = nil
  46994. }
  46995. // SetAPIBase sets the "api_base" field.
  46996. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  46997. m.api_base = &s
  46998. }
  46999. // APIBase returns the value of the "api_base" field in the mutation.
  47000. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  47001. v := m.api_base
  47002. if v == nil {
  47003. return
  47004. }
  47005. return *v, true
  47006. }
  47007. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  47008. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47010. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47011. if !m.op.Is(OpUpdateOne) {
  47012. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47013. }
  47014. if m.id == nil || m.oldValue == nil {
  47015. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47016. }
  47017. oldValue, err := m.oldValue(ctx)
  47018. if err != nil {
  47019. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47020. }
  47021. return oldValue.APIBase, nil
  47022. }
  47023. // ClearAPIBase clears the value of the "api_base" field.
  47024. func (m *XunjiServiceMutation) ClearAPIBase() {
  47025. m.api_base = nil
  47026. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  47027. }
  47028. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47029. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  47030. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  47031. return ok
  47032. }
  47033. // ResetAPIBase resets all changes to the "api_base" field.
  47034. func (m *XunjiServiceMutation) ResetAPIBase() {
  47035. m.api_base = nil
  47036. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  47037. }
  47038. // SetAPIKey sets the "api_key" field.
  47039. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  47040. m.api_key = &s
  47041. }
  47042. // APIKey returns the value of the "api_key" field in the mutation.
  47043. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  47044. v := m.api_key
  47045. if v == nil {
  47046. return
  47047. }
  47048. return *v, true
  47049. }
  47050. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  47051. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47053. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47054. if !m.op.Is(OpUpdateOne) {
  47055. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47056. }
  47057. if m.id == nil || m.oldValue == nil {
  47058. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47059. }
  47060. oldValue, err := m.oldValue(ctx)
  47061. if err != nil {
  47062. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47063. }
  47064. return oldValue.APIKey, nil
  47065. }
  47066. // ClearAPIKey clears the value of the "api_key" field.
  47067. func (m *XunjiServiceMutation) ClearAPIKey() {
  47068. m.api_key = nil
  47069. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  47070. }
  47071. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47072. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  47073. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  47074. return ok
  47075. }
  47076. // ResetAPIKey resets all changes to the "api_key" field.
  47077. func (m *XunjiServiceMutation) ResetAPIKey() {
  47078. m.api_key = nil
  47079. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  47080. }
  47081. // ClearAgent clears the "agent" edge to the Agent entity.
  47082. func (m *XunjiServiceMutation) ClearAgent() {
  47083. m.clearedagent = true
  47084. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  47085. }
  47086. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47087. func (m *XunjiServiceMutation) AgentCleared() bool {
  47088. return m.clearedagent
  47089. }
  47090. // AgentIDs returns the "agent" edge IDs in the mutation.
  47091. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47092. // AgentID instead. It exists only for internal usage by the builders.
  47093. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  47094. if id := m.agent; id != nil {
  47095. ids = append(ids, *id)
  47096. }
  47097. return
  47098. }
  47099. // ResetAgent resets all changes to the "agent" edge.
  47100. func (m *XunjiServiceMutation) ResetAgent() {
  47101. m.agent = nil
  47102. m.clearedagent = false
  47103. }
  47104. // Where appends a list predicates to the XunjiServiceMutation builder.
  47105. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  47106. m.predicates = append(m.predicates, ps...)
  47107. }
  47108. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  47109. // users can use type-assertion to append predicates that do not depend on any generated package.
  47110. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  47111. p := make([]predicate.XunjiService, len(ps))
  47112. for i := range ps {
  47113. p[i] = ps[i]
  47114. }
  47115. m.Where(p...)
  47116. }
  47117. // Op returns the operation name.
  47118. func (m *XunjiServiceMutation) Op() Op {
  47119. return m.op
  47120. }
  47121. // SetOp allows setting the mutation operation.
  47122. func (m *XunjiServiceMutation) SetOp(op Op) {
  47123. m.op = op
  47124. }
  47125. // Type returns the node type of this mutation (XunjiService).
  47126. func (m *XunjiServiceMutation) Type() string {
  47127. return m.typ
  47128. }
  47129. // Fields returns all fields that were changed during this mutation. Note that in
  47130. // order to get all numeric fields that were incremented/decremented, call
  47131. // AddedFields().
  47132. func (m *XunjiServiceMutation) Fields() []string {
  47133. fields := make([]string, 0, 10)
  47134. if m.created_at != nil {
  47135. fields = append(fields, xunjiservice.FieldCreatedAt)
  47136. }
  47137. if m.updated_at != nil {
  47138. fields = append(fields, xunjiservice.FieldUpdatedAt)
  47139. }
  47140. if m.status != nil {
  47141. fields = append(fields, xunjiservice.FieldStatus)
  47142. }
  47143. if m.deleted_at != nil {
  47144. fields = append(fields, xunjiservice.FieldDeletedAt)
  47145. }
  47146. if m.xunji_id != nil {
  47147. fields = append(fields, xunjiservice.FieldXunjiID)
  47148. }
  47149. if m.agent != nil {
  47150. fields = append(fields, xunjiservice.FieldAgentID)
  47151. }
  47152. if m.organization_id != nil {
  47153. fields = append(fields, xunjiservice.FieldOrganizationID)
  47154. }
  47155. if m.wxid != nil {
  47156. fields = append(fields, xunjiservice.FieldWxid)
  47157. }
  47158. if m.api_base != nil {
  47159. fields = append(fields, xunjiservice.FieldAPIBase)
  47160. }
  47161. if m.api_key != nil {
  47162. fields = append(fields, xunjiservice.FieldAPIKey)
  47163. }
  47164. return fields
  47165. }
  47166. // Field returns the value of a field with the given name. The second boolean
  47167. // return value indicates that this field was not set, or was not defined in the
  47168. // schema.
  47169. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  47170. switch name {
  47171. case xunjiservice.FieldCreatedAt:
  47172. return m.CreatedAt()
  47173. case xunjiservice.FieldUpdatedAt:
  47174. return m.UpdatedAt()
  47175. case xunjiservice.FieldStatus:
  47176. return m.Status()
  47177. case xunjiservice.FieldDeletedAt:
  47178. return m.DeletedAt()
  47179. case xunjiservice.FieldXunjiID:
  47180. return m.XunjiID()
  47181. case xunjiservice.FieldAgentID:
  47182. return m.AgentID()
  47183. case xunjiservice.FieldOrganizationID:
  47184. return m.OrganizationID()
  47185. case xunjiservice.FieldWxid:
  47186. return m.Wxid()
  47187. case xunjiservice.FieldAPIBase:
  47188. return m.APIBase()
  47189. case xunjiservice.FieldAPIKey:
  47190. return m.APIKey()
  47191. }
  47192. return nil, false
  47193. }
  47194. // OldField returns the old value of the field from the database. An error is
  47195. // returned if the mutation operation is not UpdateOne, or the query to the
  47196. // database failed.
  47197. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47198. switch name {
  47199. case xunjiservice.FieldCreatedAt:
  47200. return m.OldCreatedAt(ctx)
  47201. case xunjiservice.FieldUpdatedAt:
  47202. return m.OldUpdatedAt(ctx)
  47203. case xunjiservice.FieldStatus:
  47204. return m.OldStatus(ctx)
  47205. case xunjiservice.FieldDeletedAt:
  47206. return m.OldDeletedAt(ctx)
  47207. case xunjiservice.FieldXunjiID:
  47208. return m.OldXunjiID(ctx)
  47209. case xunjiservice.FieldAgentID:
  47210. return m.OldAgentID(ctx)
  47211. case xunjiservice.FieldOrganizationID:
  47212. return m.OldOrganizationID(ctx)
  47213. case xunjiservice.FieldWxid:
  47214. return m.OldWxid(ctx)
  47215. case xunjiservice.FieldAPIBase:
  47216. return m.OldAPIBase(ctx)
  47217. case xunjiservice.FieldAPIKey:
  47218. return m.OldAPIKey(ctx)
  47219. }
  47220. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  47221. }
  47222. // SetField sets the value of a field with the given name. It returns an error if
  47223. // the field is not defined in the schema, or if the type mismatched the field
  47224. // type.
  47225. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  47226. switch name {
  47227. case xunjiservice.FieldCreatedAt:
  47228. v, ok := value.(time.Time)
  47229. if !ok {
  47230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47231. }
  47232. m.SetCreatedAt(v)
  47233. return nil
  47234. case xunjiservice.FieldUpdatedAt:
  47235. v, ok := value.(time.Time)
  47236. if !ok {
  47237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47238. }
  47239. m.SetUpdatedAt(v)
  47240. return nil
  47241. case xunjiservice.FieldStatus:
  47242. v, ok := value.(uint8)
  47243. if !ok {
  47244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47245. }
  47246. m.SetStatus(v)
  47247. return nil
  47248. case xunjiservice.FieldDeletedAt:
  47249. v, ok := value.(time.Time)
  47250. if !ok {
  47251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47252. }
  47253. m.SetDeletedAt(v)
  47254. return nil
  47255. case xunjiservice.FieldXunjiID:
  47256. v, ok := value.(uint64)
  47257. if !ok {
  47258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47259. }
  47260. m.SetXunjiID(v)
  47261. return nil
  47262. case xunjiservice.FieldAgentID:
  47263. v, ok := value.(uint64)
  47264. if !ok {
  47265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47266. }
  47267. m.SetAgentID(v)
  47268. return nil
  47269. case xunjiservice.FieldOrganizationID:
  47270. v, ok := value.(uint64)
  47271. if !ok {
  47272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47273. }
  47274. m.SetOrganizationID(v)
  47275. return nil
  47276. case xunjiservice.FieldWxid:
  47277. v, ok := value.(string)
  47278. if !ok {
  47279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47280. }
  47281. m.SetWxid(v)
  47282. return nil
  47283. case xunjiservice.FieldAPIBase:
  47284. v, ok := value.(string)
  47285. if !ok {
  47286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47287. }
  47288. m.SetAPIBase(v)
  47289. return nil
  47290. case xunjiservice.FieldAPIKey:
  47291. v, ok := value.(string)
  47292. if !ok {
  47293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47294. }
  47295. m.SetAPIKey(v)
  47296. return nil
  47297. }
  47298. return fmt.Errorf("unknown XunjiService field %s", name)
  47299. }
  47300. // AddedFields returns all numeric fields that were incremented/decremented during
  47301. // this mutation.
  47302. func (m *XunjiServiceMutation) AddedFields() []string {
  47303. var fields []string
  47304. if m.addstatus != nil {
  47305. fields = append(fields, xunjiservice.FieldStatus)
  47306. }
  47307. if m.addxunji_id != nil {
  47308. fields = append(fields, xunjiservice.FieldXunjiID)
  47309. }
  47310. if m.addorganization_id != nil {
  47311. fields = append(fields, xunjiservice.FieldOrganizationID)
  47312. }
  47313. return fields
  47314. }
  47315. // AddedField returns the numeric value that was incremented/decremented on a field
  47316. // with the given name. The second boolean return value indicates that this field
  47317. // was not set, or was not defined in the schema.
  47318. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  47319. switch name {
  47320. case xunjiservice.FieldStatus:
  47321. return m.AddedStatus()
  47322. case xunjiservice.FieldXunjiID:
  47323. return m.AddedXunjiID()
  47324. case xunjiservice.FieldOrganizationID:
  47325. return m.AddedOrganizationID()
  47326. }
  47327. return nil, false
  47328. }
  47329. // AddField adds the value to the field with the given name. It returns an error if
  47330. // the field is not defined in the schema, or if the type mismatched the field
  47331. // type.
  47332. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  47333. switch name {
  47334. case xunjiservice.FieldStatus:
  47335. v, ok := value.(int8)
  47336. if !ok {
  47337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47338. }
  47339. m.AddStatus(v)
  47340. return nil
  47341. case xunjiservice.FieldXunjiID:
  47342. v, ok := value.(int64)
  47343. if !ok {
  47344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47345. }
  47346. m.AddXunjiID(v)
  47347. return nil
  47348. case xunjiservice.FieldOrganizationID:
  47349. v, ok := value.(int64)
  47350. if !ok {
  47351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47352. }
  47353. m.AddOrganizationID(v)
  47354. return nil
  47355. }
  47356. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  47357. }
  47358. // ClearedFields returns all nullable fields that were cleared during this
  47359. // mutation.
  47360. func (m *XunjiServiceMutation) ClearedFields() []string {
  47361. var fields []string
  47362. if m.FieldCleared(xunjiservice.FieldStatus) {
  47363. fields = append(fields, xunjiservice.FieldStatus)
  47364. }
  47365. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  47366. fields = append(fields, xunjiservice.FieldDeletedAt)
  47367. }
  47368. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  47369. fields = append(fields, xunjiservice.FieldAPIBase)
  47370. }
  47371. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  47372. fields = append(fields, xunjiservice.FieldAPIKey)
  47373. }
  47374. return fields
  47375. }
  47376. // FieldCleared returns a boolean indicating if a field with the given name was
  47377. // cleared in this mutation.
  47378. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  47379. _, ok := m.clearedFields[name]
  47380. return ok
  47381. }
  47382. // ClearField clears the value of the field with the given name. It returns an
  47383. // error if the field is not defined in the schema.
  47384. func (m *XunjiServiceMutation) ClearField(name string) error {
  47385. switch name {
  47386. case xunjiservice.FieldStatus:
  47387. m.ClearStatus()
  47388. return nil
  47389. case xunjiservice.FieldDeletedAt:
  47390. m.ClearDeletedAt()
  47391. return nil
  47392. case xunjiservice.FieldAPIBase:
  47393. m.ClearAPIBase()
  47394. return nil
  47395. case xunjiservice.FieldAPIKey:
  47396. m.ClearAPIKey()
  47397. return nil
  47398. }
  47399. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  47400. }
  47401. // ResetField resets all changes in the mutation for the field with the given name.
  47402. // It returns an error if the field is not defined in the schema.
  47403. func (m *XunjiServiceMutation) ResetField(name string) error {
  47404. switch name {
  47405. case xunjiservice.FieldCreatedAt:
  47406. m.ResetCreatedAt()
  47407. return nil
  47408. case xunjiservice.FieldUpdatedAt:
  47409. m.ResetUpdatedAt()
  47410. return nil
  47411. case xunjiservice.FieldStatus:
  47412. m.ResetStatus()
  47413. return nil
  47414. case xunjiservice.FieldDeletedAt:
  47415. m.ResetDeletedAt()
  47416. return nil
  47417. case xunjiservice.FieldXunjiID:
  47418. m.ResetXunjiID()
  47419. return nil
  47420. case xunjiservice.FieldAgentID:
  47421. m.ResetAgentID()
  47422. return nil
  47423. case xunjiservice.FieldOrganizationID:
  47424. m.ResetOrganizationID()
  47425. return nil
  47426. case xunjiservice.FieldWxid:
  47427. m.ResetWxid()
  47428. return nil
  47429. case xunjiservice.FieldAPIBase:
  47430. m.ResetAPIBase()
  47431. return nil
  47432. case xunjiservice.FieldAPIKey:
  47433. m.ResetAPIKey()
  47434. return nil
  47435. }
  47436. return fmt.Errorf("unknown XunjiService field %s", name)
  47437. }
  47438. // AddedEdges returns all edge names that were set/added in this mutation.
  47439. func (m *XunjiServiceMutation) AddedEdges() []string {
  47440. edges := make([]string, 0, 1)
  47441. if m.agent != nil {
  47442. edges = append(edges, xunjiservice.EdgeAgent)
  47443. }
  47444. return edges
  47445. }
  47446. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47447. // name in this mutation.
  47448. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  47449. switch name {
  47450. case xunjiservice.EdgeAgent:
  47451. if id := m.agent; id != nil {
  47452. return []ent.Value{*id}
  47453. }
  47454. }
  47455. return nil
  47456. }
  47457. // RemovedEdges returns all edge names that were removed in this mutation.
  47458. func (m *XunjiServiceMutation) RemovedEdges() []string {
  47459. edges := make([]string, 0, 1)
  47460. return edges
  47461. }
  47462. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47463. // the given name in this mutation.
  47464. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  47465. return nil
  47466. }
  47467. // ClearedEdges returns all edge names that were cleared in this mutation.
  47468. func (m *XunjiServiceMutation) ClearedEdges() []string {
  47469. edges := make([]string, 0, 1)
  47470. if m.clearedagent {
  47471. edges = append(edges, xunjiservice.EdgeAgent)
  47472. }
  47473. return edges
  47474. }
  47475. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47476. // was cleared in this mutation.
  47477. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  47478. switch name {
  47479. case xunjiservice.EdgeAgent:
  47480. return m.clearedagent
  47481. }
  47482. return false
  47483. }
  47484. // ClearEdge clears the value of the edge with the given name. It returns an error
  47485. // if that edge is not defined in the schema.
  47486. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  47487. switch name {
  47488. case xunjiservice.EdgeAgent:
  47489. m.ClearAgent()
  47490. return nil
  47491. }
  47492. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  47493. }
  47494. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47495. // It returns an error if the edge is not defined in the schema.
  47496. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  47497. switch name {
  47498. case xunjiservice.EdgeAgent:
  47499. m.ResetAgent()
  47500. return nil
  47501. }
  47502. return fmt.Errorf("unknown XunjiService edge %s", name)
  47503. }