mutation.go 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054
  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. }
  849. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  850. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  851. if m.key_agent == nil {
  852. m.key_agent = make(map[uint64]struct{})
  853. }
  854. for i := range ids {
  855. m.key_agent[ids[i]] = struct{}{}
  856. }
  857. }
  858. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  859. func (m *AgentMutation) ClearKeyAgent() {
  860. m.clearedkey_agent = true
  861. }
  862. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  863. func (m *AgentMutation) KeyAgentCleared() bool {
  864. return m.clearedkey_agent
  865. }
  866. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  867. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  868. if m.removedkey_agent == nil {
  869. m.removedkey_agent = make(map[uint64]struct{})
  870. }
  871. for i := range ids {
  872. delete(m.key_agent, ids[i])
  873. m.removedkey_agent[ids[i]] = struct{}{}
  874. }
  875. }
  876. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  877. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  878. for id := range m.removedkey_agent {
  879. ids = append(ids, id)
  880. }
  881. return
  882. }
  883. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  884. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  885. for id := range m.xjs_agent {
  886. ids = append(ids, id)
  887. }
  888. return
  889. }
  890. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  891. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  892. for id := range m.key_agent {
  893. ids = append(ids, id)
  894. }
  895. return
  896. }
  897. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  898. func (m *AgentMutation) ResetXjsAgent() {
  899. m.xjs_agent = nil
  900. m.clearedxjs_agent = false
  901. m.removedxjs_agent = nil
  902. }
  903. // ResetKeyAgent resets all changes to the "key_agent" edge.
  904. func (m *AgentMutation) ResetKeyAgent() {
  905. m.key_agent = nil
  906. m.clearedkey_agent = false
  907. m.removedkey_agent = nil
  908. }
  909. // Where appends a list predicates to the AgentMutation builder.
  910. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  911. m.predicates = append(m.predicates, ps...)
  912. }
  913. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  914. // users can use type-assertion to append predicates that do not depend on any generated package.
  915. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  916. p := make([]predicate.Agent, len(ps))
  917. for i := range ps {
  918. p[i] = ps[i]
  919. }
  920. m.Where(p...)
  921. }
  922. // Op returns the operation name.
  923. func (m *AgentMutation) Op() Op {
  924. return m.op
  925. }
  926. // SetOp allows setting the mutation operation.
  927. func (m *AgentMutation) SetOp(op Op) {
  928. m.op = op
  929. }
  930. // Type returns the node type of this mutation (Agent).
  931. func (m *AgentMutation) Type() string {
  932. return m.typ
  933. }
  934. // Fields returns all fields that were changed during this mutation. Note that in
  935. // order to get all numeric fields that were incremented/decremented, call
  936. // AddedFields().
  937. func (m *AgentMutation) Fields() []string {
  938. fields := make([]string, 0, 11)
  939. if m.created_at != nil {
  940. fields = append(fields, agent.FieldCreatedAt)
  941. }
  942. if m.updated_at != nil {
  943. fields = append(fields, agent.FieldUpdatedAt)
  944. }
  945. if m.deleted_at != nil {
  946. fields = append(fields, agent.FieldDeletedAt)
  947. }
  948. if m.name != nil {
  949. fields = append(fields, agent.FieldName)
  950. }
  951. if m.role != nil {
  952. fields = append(fields, agent.FieldRole)
  953. }
  954. if m.status != nil {
  955. fields = append(fields, agent.FieldStatus)
  956. }
  957. if m.background != nil {
  958. fields = append(fields, agent.FieldBackground)
  959. }
  960. if m.examples != nil {
  961. fields = append(fields, agent.FieldExamples)
  962. }
  963. if m.organization_id != nil {
  964. fields = append(fields, agent.FieldOrganizationID)
  965. }
  966. if m.dataset_id != nil {
  967. fields = append(fields, agent.FieldDatasetID)
  968. }
  969. if m.collection_id != nil {
  970. fields = append(fields, agent.FieldCollectionID)
  971. }
  972. return fields
  973. }
  974. // Field returns the value of a field with the given name. The second boolean
  975. // return value indicates that this field was not set, or was not defined in the
  976. // schema.
  977. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  978. switch name {
  979. case agent.FieldCreatedAt:
  980. return m.CreatedAt()
  981. case agent.FieldUpdatedAt:
  982. return m.UpdatedAt()
  983. case agent.FieldDeletedAt:
  984. return m.DeletedAt()
  985. case agent.FieldName:
  986. return m.Name()
  987. case agent.FieldRole:
  988. return m.Role()
  989. case agent.FieldStatus:
  990. return m.Status()
  991. case agent.FieldBackground:
  992. return m.Background()
  993. case agent.FieldExamples:
  994. return m.Examples()
  995. case agent.FieldOrganizationID:
  996. return m.OrganizationID()
  997. case agent.FieldDatasetID:
  998. return m.DatasetID()
  999. case agent.FieldCollectionID:
  1000. return m.CollectionID()
  1001. }
  1002. return nil, false
  1003. }
  1004. // OldField returns the old value of the field from the database. An error is
  1005. // returned if the mutation operation is not UpdateOne, or the query to the
  1006. // database failed.
  1007. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1008. switch name {
  1009. case agent.FieldCreatedAt:
  1010. return m.OldCreatedAt(ctx)
  1011. case agent.FieldUpdatedAt:
  1012. return m.OldUpdatedAt(ctx)
  1013. case agent.FieldDeletedAt:
  1014. return m.OldDeletedAt(ctx)
  1015. case agent.FieldName:
  1016. return m.OldName(ctx)
  1017. case agent.FieldRole:
  1018. return m.OldRole(ctx)
  1019. case agent.FieldStatus:
  1020. return m.OldStatus(ctx)
  1021. case agent.FieldBackground:
  1022. return m.OldBackground(ctx)
  1023. case agent.FieldExamples:
  1024. return m.OldExamples(ctx)
  1025. case agent.FieldOrganizationID:
  1026. return m.OldOrganizationID(ctx)
  1027. case agent.FieldDatasetID:
  1028. return m.OldDatasetID(ctx)
  1029. case agent.FieldCollectionID:
  1030. return m.OldCollectionID(ctx)
  1031. }
  1032. return nil, fmt.Errorf("unknown Agent field %s", name)
  1033. }
  1034. // SetField sets the value of a field with the given name. It returns an error if
  1035. // the field is not defined in the schema, or if the type mismatched the field
  1036. // type.
  1037. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1038. switch name {
  1039. case agent.FieldCreatedAt:
  1040. v, ok := value.(time.Time)
  1041. if !ok {
  1042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1043. }
  1044. m.SetCreatedAt(v)
  1045. return nil
  1046. case agent.FieldUpdatedAt:
  1047. v, ok := value.(time.Time)
  1048. if !ok {
  1049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1050. }
  1051. m.SetUpdatedAt(v)
  1052. return nil
  1053. case agent.FieldDeletedAt:
  1054. v, ok := value.(time.Time)
  1055. if !ok {
  1056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1057. }
  1058. m.SetDeletedAt(v)
  1059. return nil
  1060. case agent.FieldName:
  1061. v, ok := value.(string)
  1062. if !ok {
  1063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1064. }
  1065. m.SetName(v)
  1066. return nil
  1067. case agent.FieldRole:
  1068. v, ok := value.(string)
  1069. if !ok {
  1070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1071. }
  1072. m.SetRole(v)
  1073. return nil
  1074. case agent.FieldStatus:
  1075. v, ok := value.(int)
  1076. if !ok {
  1077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1078. }
  1079. m.SetStatus(v)
  1080. return nil
  1081. case agent.FieldBackground:
  1082. v, ok := value.(string)
  1083. if !ok {
  1084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1085. }
  1086. m.SetBackground(v)
  1087. return nil
  1088. case agent.FieldExamples:
  1089. v, ok := value.(string)
  1090. if !ok {
  1091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1092. }
  1093. m.SetExamples(v)
  1094. return nil
  1095. case agent.FieldOrganizationID:
  1096. v, ok := value.(uint64)
  1097. if !ok {
  1098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1099. }
  1100. m.SetOrganizationID(v)
  1101. return nil
  1102. case agent.FieldDatasetID:
  1103. v, ok := value.(string)
  1104. if !ok {
  1105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1106. }
  1107. m.SetDatasetID(v)
  1108. return nil
  1109. case agent.FieldCollectionID:
  1110. v, ok := value.(string)
  1111. if !ok {
  1112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1113. }
  1114. m.SetCollectionID(v)
  1115. return nil
  1116. }
  1117. return fmt.Errorf("unknown Agent field %s", name)
  1118. }
  1119. // AddedFields returns all numeric fields that were incremented/decremented during
  1120. // this mutation.
  1121. func (m *AgentMutation) AddedFields() []string {
  1122. var fields []string
  1123. if m.addstatus != nil {
  1124. fields = append(fields, agent.FieldStatus)
  1125. }
  1126. if m.addorganization_id != nil {
  1127. fields = append(fields, agent.FieldOrganizationID)
  1128. }
  1129. return fields
  1130. }
  1131. // AddedField returns the numeric value that was incremented/decremented on a field
  1132. // with the given name. The second boolean return value indicates that this field
  1133. // was not set, or was not defined in the schema.
  1134. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1135. switch name {
  1136. case agent.FieldStatus:
  1137. return m.AddedStatus()
  1138. case agent.FieldOrganizationID:
  1139. return m.AddedOrganizationID()
  1140. }
  1141. return nil, false
  1142. }
  1143. // AddField adds the value to the field with the given name. It returns an error if
  1144. // the field is not defined in the schema, or if the type mismatched the field
  1145. // type.
  1146. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1147. switch name {
  1148. case agent.FieldStatus:
  1149. v, ok := value.(int)
  1150. if !ok {
  1151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1152. }
  1153. m.AddStatus(v)
  1154. return nil
  1155. case agent.FieldOrganizationID:
  1156. v, ok := value.(int64)
  1157. if !ok {
  1158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1159. }
  1160. m.AddOrganizationID(v)
  1161. return nil
  1162. }
  1163. return fmt.Errorf("unknown Agent numeric field %s", name)
  1164. }
  1165. // ClearedFields returns all nullable fields that were cleared during this
  1166. // mutation.
  1167. func (m *AgentMutation) ClearedFields() []string {
  1168. var fields []string
  1169. if m.FieldCleared(agent.FieldDeletedAt) {
  1170. fields = append(fields, agent.FieldDeletedAt)
  1171. }
  1172. if m.FieldCleared(agent.FieldStatus) {
  1173. fields = append(fields, agent.FieldStatus)
  1174. }
  1175. if m.FieldCleared(agent.FieldBackground) {
  1176. fields = append(fields, agent.FieldBackground)
  1177. }
  1178. if m.FieldCleared(agent.FieldExamples) {
  1179. fields = append(fields, agent.FieldExamples)
  1180. }
  1181. return fields
  1182. }
  1183. // FieldCleared returns a boolean indicating if a field with the given name was
  1184. // cleared in this mutation.
  1185. func (m *AgentMutation) FieldCleared(name string) bool {
  1186. _, ok := m.clearedFields[name]
  1187. return ok
  1188. }
  1189. // ClearField clears the value of the field with the given name. It returns an
  1190. // error if the field is not defined in the schema.
  1191. func (m *AgentMutation) ClearField(name string) error {
  1192. switch name {
  1193. case agent.FieldDeletedAt:
  1194. m.ClearDeletedAt()
  1195. return nil
  1196. case agent.FieldStatus:
  1197. m.ClearStatus()
  1198. return nil
  1199. case agent.FieldBackground:
  1200. m.ClearBackground()
  1201. return nil
  1202. case agent.FieldExamples:
  1203. m.ClearExamples()
  1204. return nil
  1205. }
  1206. return fmt.Errorf("unknown Agent nullable field %s", name)
  1207. }
  1208. // ResetField resets all changes in the mutation for the field with the given name.
  1209. // It returns an error if the field is not defined in the schema.
  1210. func (m *AgentMutation) ResetField(name string) error {
  1211. switch name {
  1212. case agent.FieldCreatedAt:
  1213. m.ResetCreatedAt()
  1214. return nil
  1215. case agent.FieldUpdatedAt:
  1216. m.ResetUpdatedAt()
  1217. return nil
  1218. case agent.FieldDeletedAt:
  1219. m.ResetDeletedAt()
  1220. return nil
  1221. case agent.FieldName:
  1222. m.ResetName()
  1223. return nil
  1224. case agent.FieldRole:
  1225. m.ResetRole()
  1226. return nil
  1227. case agent.FieldStatus:
  1228. m.ResetStatus()
  1229. return nil
  1230. case agent.FieldBackground:
  1231. m.ResetBackground()
  1232. return nil
  1233. case agent.FieldExamples:
  1234. m.ResetExamples()
  1235. return nil
  1236. case agent.FieldOrganizationID:
  1237. m.ResetOrganizationID()
  1238. return nil
  1239. case agent.FieldDatasetID:
  1240. m.ResetDatasetID()
  1241. return nil
  1242. case agent.FieldCollectionID:
  1243. m.ResetCollectionID()
  1244. return nil
  1245. }
  1246. return fmt.Errorf("unknown Agent field %s", name)
  1247. }
  1248. // AddedEdges returns all edge names that were set/added in this mutation.
  1249. func (m *AgentMutation) AddedEdges() []string {
  1250. edges := make([]string, 0, 4)
  1251. if m.wx_agent != nil {
  1252. edges = append(edges, agent.EdgeWxAgent)
  1253. }
  1254. if m.token_agent != nil {
  1255. edges = append(edges, agent.EdgeTokenAgent)
  1256. }
  1257. if m.wa_agent != nil {
  1258. edges = append(edges, agent.EdgeWaAgent)
  1259. }
  1260. if m.xjs_agent != nil {
  1261. edges = append(edges, agent.EdgeXjsAgent)
  1262. }
  1263. if m.key_agent != nil {
  1264. edges = append(edges, agent.EdgeKeyAgent)
  1265. }
  1266. return edges
  1267. }
  1268. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1269. // name in this mutation.
  1270. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1271. switch name {
  1272. case agent.EdgeWxAgent:
  1273. ids := make([]ent.Value, 0, len(m.wx_agent))
  1274. for id := range m.wx_agent {
  1275. ids = append(ids, id)
  1276. }
  1277. return ids
  1278. case agent.EdgeTokenAgent:
  1279. ids := make([]ent.Value, 0, len(m.token_agent))
  1280. for id := range m.token_agent {
  1281. ids = append(ids, id)
  1282. }
  1283. return ids
  1284. case agent.EdgeWaAgent:
  1285. ids := make([]ent.Value, 0, len(m.wa_agent))
  1286. for id := range m.wa_agent {
  1287. ids = append(ids, id)
  1288. }
  1289. return ids
  1290. case agent.EdgeXjsAgent:
  1291. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1292. for id := range m.xjs_agent {
  1293. ids = append(ids, id)
  1294. }
  1295. return ids
  1296. case agent.EdgeKeyAgent:
  1297. ids := make([]ent.Value, 0, len(m.key_agent))
  1298. for id := range m.key_agent {
  1299. ids = append(ids, id)
  1300. }
  1301. return ids
  1302. }
  1303. return nil
  1304. }
  1305. // RemovedEdges returns all edge names that were removed in this mutation.
  1306. func (m *AgentMutation) RemovedEdges() []string {
  1307. edges := make([]string, 0, 4)
  1308. if m.removedwx_agent != nil {
  1309. edges = append(edges, agent.EdgeWxAgent)
  1310. }
  1311. if m.removedtoken_agent != nil {
  1312. edges = append(edges, agent.EdgeTokenAgent)
  1313. }
  1314. if m.removedwa_agent != nil {
  1315. edges = append(edges, agent.EdgeWaAgent)
  1316. }
  1317. if m.removedxjs_agent != nil {
  1318. edges = append(edges, agent.EdgeXjsAgent)
  1319. }
  1320. if m.removedkey_agent != nil {
  1321. edges = append(edges, agent.EdgeKeyAgent)
  1322. }
  1323. return edges
  1324. }
  1325. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1326. // the given name in this mutation.
  1327. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1328. switch name {
  1329. case agent.EdgeWxAgent:
  1330. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1331. for id := range m.removedwx_agent {
  1332. ids = append(ids, id)
  1333. }
  1334. return ids
  1335. case agent.EdgeTokenAgent:
  1336. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1337. for id := range m.removedtoken_agent {
  1338. ids = append(ids, id)
  1339. }
  1340. return ids
  1341. case agent.EdgeWaAgent:
  1342. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1343. for id := range m.removedwa_agent {
  1344. ids = append(ids, id)
  1345. }
  1346. return ids
  1347. case agent.EdgeXjsAgent:
  1348. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1349. for id := range m.removedxjs_agent {
  1350. ids = append(ids, id)
  1351. }
  1352. return ids
  1353. case agent.EdgeKeyAgent:
  1354. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1355. for id := range m.removedkey_agent {
  1356. ids = append(ids, id)
  1357. }
  1358. return ids
  1359. }
  1360. return nil
  1361. }
  1362. // ClearedEdges returns all edge names that were cleared in this mutation.
  1363. func (m *AgentMutation) ClearedEdges() []string {
  1364. edges := make([]string, 0, 4)
  1365. if m.clearedwx_agent {
  1366. edges = append(edges, agent.EdgeWxAgent)
  1367. }
  1368. if m.clearedtoken_agent {
  1369. edges = append(edges, agent.EdgeTokenAgent)
  1370. }
  1371. if m.clearedwa_agent {
  1372. edges = append(edges, agent.EdgeWaAgent)
  1373. }
  1374. if m.clearedxjs_agent {
  1375. edges = append(edges, agent.EdgeXjsAgent)
  1376. }
  1377. if m.clearedkey_agent {
  1378. edges = append(edges, agent.EdgeKeyAgent)
  1379. }
  1380. return edges
  1381. }
  1382. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1383. // was cleared in this mutation.
  1384. func (m *AgentMutation) EdgeCleared(name string) bool {
  1385. switch name {
  1386. case agent.EdgeWxAgent:
  1387. return m.clearedwx_agent
  1388. case agent.EdgeTokenAgent:
  1389. return m.clearedtoken_agent
  1390. case agent.EdgeWaAgent:
  1391. return m.clearedwa_agent
  1392. case agent.EdgeXjsAgent:
  1393. return m.clearedxjs_agent
  1394. case agent.EdgeKeyAgent:
  1395. return m.clearedkey_agent
  1396. }
  1397. return false
  1398. }
  1399. // ClearEdge clears the value of the edge with the given name. It returns an error
  1400. // if that edge is not defined in the schema.
  1401. func (m *AgentMutation) ClearEdge(name string) error {
  1402. switch name {
  1403. }
  1404. return fmt.Errorf("unknown Agent unique edge %s", name)
  1405. }
  1406. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1407. // It returns an error if the edge is not defined in the schema.
  1408. func (m *AgentMutation) ResetEdge(name string) error {
  1409. switch name {
  1410. case agent.EdgeWxAgent:
  1411. m.ResetWxAgent()
  1412. return nil
  1413. case agent.EdgeTokenAgent:
  1414. m.ResetTokenAgent()
  1415. return nil
  1416. case agent.EdgeWaAgent:
  1417. m.ResetWaAgent()
  1418. return nil
  1419. case agent.EdgeXjsAgent:
  1420. m.ResetXjsAgent()
  1421. case agent.EdgeKeyAgent:
  1422. m.ResetKeyAgent()
  1423. return nil
  1424. }
  1425. return fmt.Errorf("unknown Agent edge %s", name)
  1426. }
  1427. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1428. type AgentBaseMutation struct {
  1429. config
  1430. op Op
  1431. typ string
  1432. id *string
  1433. q *string
  1434. a *string
  1435. chunk_index *uint64
  1436. addchunk_index *int64
  1437. indexes *[]string
  1438. appendindexes []string
  1439. dataset_id *string
  1440. collection_id *string
  1441. source_name *string
  1442. can_write *[]bool
  1443. appendcan_write []bool
  1444. is_owner *[]bool
  1445. appendis_owner []bool
  1446. clearedFields map[string]struct{}
  1447. wx_agent map[uint64]struct{}
  1448. removedwx_agent map[uint64]struct{}
  1449. clearedwx_agent bool
  1450. done bool
  1451. oldValue func(context.Context) (*AgentBase, error)
  1452. predicates []predicate.AgentBase
  1453. }
  1454. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1455. // agentbaseOption allows management of the mutation configuration using functional options.
  1456. type agentbaseOption func(*AgentBaseMutation)
  1457. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1458. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1459. m := &AgentBaseMutation{
  1460. config: c,
  1461. op: op,
  1462. typ: TypeAgentBase,
  1463. clearedFields: make(map[string]struct{}),
  1464. }
  1465. for _, opt := range opts {
  1466. opt(m)
  1467. }
  1468. return m
  1469. }
  1470. // withAgentBaseID sets the ID field of the mutation.
  1471. func withAgentBaseID(id string) agentbaseOption {
  1472. return func(m *AgentBaseMutation) {
  1473. var (
  1474. err error
  1475. once sync.Once
  1476. value *AgentBase
  1477. )
  1478. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1479. once.Do(func() {
  1480. if m.done {
  1481. err = errors.New("querying old values post mutation is not allowed")
  1482. } else {
  1483. value, err = m.Client().AgentBase.Get(ctx, id)
  1484. }
  1485. })
  1486. return value, err
  1487. }
  1488. m.id = &id
  1489. }
  1490. }
  1491. // withAgentBase sets the old AgentBase of the mutation.
  1492. func withAgentBase(node *AgentBase) agentbaseOption {
  1493. return func(m *AgentBaseMutation) {
  1494. m.oldValue = func(context.Context) (*AgentBase, error) {
  1495. return node, nil
  1496. }
  1497. m.id = &node.ID
  1498. }
  1499. }
  1500. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1501. // executed in a transaction (ent.Tx), a transactional client is returned.
  1502. func (m AgentBaseMutation) Client() *Client {
  1503. client := &Client{config: m.config}
  1504. client.init()
  1505. return client
  1506. }
  1507. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1508. // it returns an error otherwise.
  1509. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1510. if _, ok := m.driver.(*txDriver); !ok {
  1511. return nil, errors.New("ent: mutation is not running in a transaction")
  1512. }
  1513. tx := &Tx{config: m.config}
  1514. tx.init()
  1515. return tx, nil
  1516. }
  1517. // SetID sets the value of the id field. Note that this
  1518. // operation is only accepted on creation of AgentBase entities.
  1519. func (m *AgentBaseMutation) SetID(id string) {
  1520. m.id = &id
  1521. }
  1522. // ID returns the ID value in the mutation. Note that the ID is only available
  1523. // if it was provided to the builder or after it was returned from the database.
  1524. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1525. if m.id == nil {
  1526. return
  1527. }
  1528. return *m.id, true
  1529. }
  1530. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1531. // That means, if the mutation is applied within a transaction with an isolation level such
  1532. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1533. // or updated by the mutation.
  1534. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1535. switch {
  1536. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1537. id, exists := m.ID()
  1538. if exists {
  1539. return []string{id}, nil
  1540. }
  1541. fallthrough
  1542. case m.op.Is(OpUpdate | OpDelete):
  1543. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1544. default:
  1545. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1546. }
  1547. }
  1548. // SetQ sets the "q" field.
  1549. func (m *AgentBaseMutation) SetQ(s string) {
  1550. m.q = &s
  1551. }
  1552. // Q returns the value of the "q" field in the mutation.
  1553. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1554. v := m.q
  1555. if v == nil {
  1556. return
  1557. }
  1558. return *v, true
  1559. }
  1560. // OldQ returns the old "q" field's value of the AgentBase entity.
  1561. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1563. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1564. if !m.op.Is(OpUpdateOne) {
  1565. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1566. }
  1567. if m.id == nil || m.oldValue == nil {
  1568. return v, errors.New("OldQ requires an ID field in the mutation")
  1569. }
  1570. oldValue, err := m.oldValue(ctx)
  1571. if err != nil {
  1572. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1573. }
  1574. return oldValue.Q, nil
  1575. }
  1576. // ClearQ clears the value of the "q" field.
  1577. func (m *AgentBaseMutation) ClearQ() {
  1578. m.q = nil
  1579. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1580. }
  1581. // QCleared returns if the "q" field was cleared in this mutation.
  1582. func (m *AgentBaseMutation) QCleared() bool {
  1583. _, ok := m.clearedFields[agentbase.FieldQ]
  1584. return ok
  1585. }
  1586. // ResetQ resets all changes to the "q" field.
  1587. func (m *AgentBaseMutation) ResetQ() {
  1588. m.q = nil
  1589. delete(m.clearedFields, agentbase.FieldQ)
  1590. }
  1591. // SetA sets the "a" field.
  1592. func (m *AgentBaseMutation) SetA(s string) {
  1593. m.a = &s
  1594. }
  1595. // A returns the value of the "a" field in the mutation.
  1596. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1597. v := m.a
  1598. if v == nil {
  1599. return
  1600. }
  1601. return *v, true
  1602. }
  1603. // OldA returns the old "a" field's value of the AgentBase entity.
  1604. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1606. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1607. if !m.op.Is(OpUpdateOne) {
  1608. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1609. }
  1610. if m.id == nil || m.oldValue == nil {
  1611. return v, errors.New("OldA requires an ID field in the mutation")
  1612. }
  1613. oldValue, err := m.oldValue(ctx)
  1614. if err != nil {
  1615. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1616. }
  1617. return oldValue.A, nil
  1618. }
  1619. // ClearA clears the value of the "a" field.
  1620. func (m *AgentBaseMutation) ClearA() {
  1621. m.a = nil
  1622. m.clearedFields[agentbase.FieldA] = struct{}{}
  1623. }
  1624. // ACleared returns if the "a" field was cleared in this mutation.
  1625. func (m *AgentBaseMutation) ACleared() bool {
  1626. _, ok := m.clearedFields[agentbase.FieldA]
  1627. return ok
  1628. }
  1629. // ResetA resets all changes to the "a" field.
  1630. func (m *AgentBaseMutation) ResetA() {
  1631. m.a = nil
  1632. delete(m.clearedFields, agentbase.FieldA)
  1633. }
  1634. // SetChunkIndex sets the "chunk_index" field.
  1635. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1636. m.chunk_index = &u
  1637. m.addchunk_index = nil
  1638. }
  1639. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1640. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1641. v := m.chunk_index
  1642. if v == nil {
  1643. return
  1644. }
  1645. return *v, true
  1646. }
  1647. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1648. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1650. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1651. if !m.op.Is(OpUpdateOne) {
  1652. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1653. }
  1654. if m.id == nil || m.oldValue == nil {
  1655. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1656. }
  1657. oldValue, err := m.oldValue(ctx)
  1658. if err != nil {
  1659. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1660. }
  1661. return oldValue.ChunkIndex, nil
  1662. }
  1663. // AddChunkIndex adds u to the "chunk_index" field.
  1664. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1665. if m.addchunk_index != nil {
  1666. *m.addchunk_index += u
  1667. } else {
  1668. m.addchunk_index = &u
  1669. }
  1670. }
  1671. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1672. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1673. v := m.addchunk_index
  1674. if v == nil {
  1675. return
  1676. }
  1677. return *v, true
  1678. }
  1679. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1680. func (m *AgentBaseMutation) ResetChunkIndex() {
  1681. m.chunk_index = nil
  1682. m.addchunk_index = nil
  1683. }
  1684. // SetIndexes sets the "indexes" field.
  1685. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1686. m.indexes = &s
  1687. m.appendindexes = nil
  1688. }
  1689. // Indexes returns the value of the "indexes" field in the mutation.
  1690. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1691. v := m.indexes
  1692. if v == nil {
  1693. return
  1694. }
  1695. return *v, true
  1696. }
  1697. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1698. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1700. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1701. if !m.op.Is(OpUpdateOne) {
  1702. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1703. }
  1704. if m.id == nil || m.oldValue == nil {
  1705. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1706. }
  1707. oldValue, err := m.oldValue(ctx)
  1708. if err != nil {
  1709. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1710. }
  1711. return oldValue.Indexes, nil
  1712. }
  1713. // AppendIndexes adds s to the "indexes" field.
  1714. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1715. m.appendindexes = append(m.appendindexes, s...)
  1716. }
  1717. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1718. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1719. if len(m.appendindexes) == 0 {
  1720. return nil, false
  1721. }
  1722. return m.appendindexes, true
  1723. }
  1724. // ClearIndexes clears the value of the "indexes" field.
  1725. func (m *AgentBaseMutation) ClearIndexes() {
  1726. m.indexes = nil
  1727. m.appendindexes = nil
  1728. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1729. }
  1730. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1731. func (m *AgentBaseMutation) IndexesCleared() bool {
  1732. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1733. return ok
  1734. }
  1735. // ResetIndexes resets all changes to the "indexes" field.
  1736. func (m *AgentBaseMutation) ResetIndexes() {
  1737. m.indexes = nil
  1738. m.appendindexes = nil
  1739. delete(m.clearedFields, agentbase.FieldIndexes)
  1740. }
  1741. // SetDatasetID sets the "dataset_id" field.
  1742. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1743. m.dataset_id = &s
  1744. }
  1745. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1746. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1747. v := m.dataset_id
  1748. if v == nil {
  1749. return
  1750. }
  1751. return *v, true
  1752. }
  1753. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1754. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1756. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1757. if !m.op.Is(OpUpdateOne) {
  1758. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1759. }
  1760. if m.id == nil || m.oldValue == nil {
  1761. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1762. }
  1763. oldValue, err := m.oldValue(ctx)
  1764. if err != nil {
  1765. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1766. }
  1767. return oldValue.DatasetID, nil
  1768. }
  1769. // ClearDatasetID clears the value of the "dataset_id" field.
  1770. func (m *AgentBaseMutation) ClearDatasetID() {
  1771. m.dataset_id = nil
  1772. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1773. }
  1774. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1775. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1776. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1777. return ok
  1778. }
  1779. // ResetDatasetID resets all changes to the "dataset_id" field.
  1780. func (m *AgentBaseMutation) ResetDatasetID() {
  1781. m.dataset_id = nil
  1782. delete(m.clearedFields, agentbase.FieldDatasetID)
  1783. }
  1784. // SetCollectionID sets the "collection_id" field.
  1785. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1786. m.collection_id = &s
  1787. }
  1788. // CollectionID returns the value of the "collection_id" field in the mutation.
  1789. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1790. v := m.collection_id
  1791. if v == nil {
  1792. return
  1793. }
  1794. return *v, true
  1795. }
  1796. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1797. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1799. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1800. if !m.op.Is(OpUpdateOne) {
  1801. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1802. }
  1803. if m.id == nil || m.oldValue == nil {
  1804. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1805. }
  1806. oldValue, err := m.oldValue(ctx)
  1807. if err != nil {
  1808. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1809. }
  1810. return oldValue.CollectionID, nil
  1811. }
  1812. // ClearCollectionID clears the value of the "collection_id" field.
  1813. func (m *AgentBaseMutation) ClearCollectionID() {
  1814. m.collection_id = nil
  1815. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1816. }
  1817. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1818. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1819. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1820. return ok
  1821. }
  1822. // ResetCollectionID resets all changes to the "collection_id" field.
  1823. func (m *AgentBaseMutation) ResetCollectionID() {
  1824. m.collection_id = nil
  1825. delete(m.clearedFields, agentbase.FieldCollectionID)
  1826. }
  1827. // SetSourceName sets the "source_name" field.
  1828. func (m *AgentBaseMutation) SetSourceName(s string) {
  1829. m.source_name = &s
  1830. }
  1831. // SourceName returns the value of the "source_name" field in the mutation.
  1832. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1833. v := m.source_name
  1834. if v == nil {
  1835. return
  1836. }
  1837. return *v, true
  1838. }
  1839. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1840. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1842. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1843. if !m.op.Is(OpUpdateOne) {
  1844. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1845. }
  1846. if m.id == nil || m.oldValue == nil {
  1847. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1848. }
  1849. oldValue, err := m.oldValue(ctx)
  1850. if err != nil {
  1851. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1852. }
  1853. return oldValue.SourceName, nil
  1854. }
  1855. // ClearSourceName clears the value of the "source_name" field.
  1856. func (m *AgentBaseMutation) ClearSourceName() {
  1857. m.source_name = nil
  1858. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1859. }
  1860. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1861. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1862. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1863. return ok
  1864. }
  1865. // ResetSourceName resets all changes to the "source_name" field.
  1866. func (m *AgentBaseMutation) ResetSourceName() {
  1867. m.source_name = nil
  1868. delete(m.clearedFields, agentbase.FieldSourceName)
  1869. }
  1870. // SetCanWrite sets the "can_write" field.
  1871. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1872. m.can_write = &b
  1873. m.appendcan_write = nil
  1874. }
  1875. // CanWrite returns the value of the "can_write" field in the mutation.
  1876. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1877. v := m.can_write
  1878. if v == nil {
  1879. return
  1880. }
  1881. return *v, true
  1882. }
  1883. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1884. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1886. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1887. if !m.op.Is(OpUpdateOne) {
  1888. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1889. }
  1890. if m.id == nil || m.oldValue == nil {
  1891. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1892. }
  1893. oldValue, err := m.oldValue(ctx)
  1894. if err != nil {
  1895. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1896. }
  1897. return oldValue.CanWrite, nil
  1898. }
  1899. // AppendCanWrite adds b to the "can_write" field.
  1900. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1901. m.appendcan_write = append(m.appendcan_write, b...)
  1902. }
  1903. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1904. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1905. if len(m.appendcan_write) == 0 {
  1906. return nil, false
  1907. }
  1908. return m.appendcan_write, true
  1909. }
  1910. // ClearCanWrite clears the value of the "can_write" field.
  1911. func (m *AgentBaseMutation) ClearCanWrite() {
  1912. m.can_write = nil
  1913. m.appendcan_write = nil
  1914. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1915. }
  1916. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1917. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1918. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1919. return ok
  1920. }
  1921. // ResetCanWrite resets all changes to the "can_write" field.
  1922. func (m *AgentBaseMutation) ResetCanWrite() {
  1923. m.can_write = nil
  1924. m.appendcan_write = nil
  1925. delete(m.clearedFields, agentbase.FieldCanWrite)
  1926. }
  1927. // SetIsOwner sets the "is_owner" field.
  1928. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1929. m.is_owner = &b
  1930. m.appendis_owner = nil
  1931. }
  1932. // IsOwner returns the value of the "is_owner" field in the mutation.
  1933. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1934. v := m.is_owner
  1935. if v == nil {
  1936. return
  1937. }
  1938. return *v, true
  1939. }
  1940. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1941. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1943. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1944. if !m.op.Is(OpUpdateOne) {
  1945. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1946. }
  1947. if m.id == nil || m.oldValue == nil {
  1948. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1949. }
  1950. oldValue, err := m.oldValue(ctx)
  1951. if err != nil {
  1952. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1953. }
  1954. return oldValue.IsOwner, nil
  1955. }
  1956. // AppendIsOwner adds b to the "is_owner" field.
  1957. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1958. m.appendis_owner = append(m.appendis_owner, b...)
  1959. }
  1960. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1961. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1962. if len(m.appendis_owner) == 0 {
  1963. return nil, false
  1964. }
  1965. return m.appendis_owner, true
  1966. }
  1967. // ClearIsOwner clears the value of the "is_owner" field.
  1968. func (m *AgentBaseMutation) ClearIsOwner() {
  1969. m.is_owner = nil
  1970. m.appendis_owner = nil
  1971. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1972. }
  1973. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1974. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1975. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1976. return ok
  1977. }
  1978. // ResetIsOwner resets all changes to the "is_owner" field.
  1979. func (m *AgentBaseMutation) ResetIsOwner() {
  1980. m.is_owner = nil
  1981. m.appendis_owner = nil
  1982. delete(m.clearedFields, agentbase.FieldIsOwner)
  1983. }
  1984. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1985. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1986. if m.wx_agent == nil {
  1987. m.wx_agent = make(map[uint64]struct{})
  1988. }
  1989. for i := range ids {
  1990. m.wx_agent[ids[i]] = struct{}{}
  1991. }
  1992. }
  1993. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1994. func (m *AgentBaseMutation) ClearWxAgent() {
  1995. m.clearedwx_agent = true
  1996. }
  1997. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1998. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1999. return m.clearedwx_agent
  2000. }
  2001. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2002. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2003. if m.removedwx_agent == nil {
  2004. m.removedwx_agent = make(map[uint64]struct{})
  2005. }
  2006. for i := range ids {
  2007. delete(m.wx_agent, ids[i])
  2008. m.removedwx_agent[ids[i]] = struct{}{}
  2009. }
  2010. }
  2011. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2012. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2013. for id := range m.removedwx_agent {
  2014. ids = append(ids, id)
  2015. }
  2016. return
  2017. }
  2018. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2019. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2020. for id := range m.wx_agent {
  2021. ids = append(ids, id)
  2022. }
  2023. return
  2024. }
  2025. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2026. func (m *AgentBaseMutation) ResetWxAgent() {
  2027. m.wx_agent = nil
  2028. m.clearedwx_agent = false
  2029. m.removedwx_agent = nil
  2030. }
  2031. // Where appends a list predicates to the AgentBaseMutation builder.
  2032. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2033. m.predicates = append(m.predicates, ps...)
  2034. }
  2035. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2036. // users can use type-assertion to append predicates that do not depend on any generated package.
  2037. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2038. p := make([]predicate.AgentBase, len(ps))
  2039. for i := range ps {
  2040. p[i] = ps[i]
  2041. }
  2042. m.Where(p...)
  2043. }
  2044. // Op returns the operation name.
  2045. func (m *AgentBaseMutation) Op() Op {
  2046. return m.op
  2047. }
  2048. // SetOp allows setting the mutation operation.
  2049. func (m *AgentBaseMutation) SetOp(op Op) {
  2050. m.op = op
  2051. }
  2052. // Type returns the node type of this mutation (AgentBase).
  2053. func (m *AgentBaseMutation) Type() string {
  2054. return m.typ
  2055. }
  2056. // Fields returns all fields that were changed during this mutation. Note that in
  2057. // order to get all numeric fields that were incremented/decremented, call
  2058. // AddedFields().
  2059. func (m *AgentBaseMutation) Fields() []string {
  2060. fields := make([]string, 0, 9)
  2061. if m.q != nil {
  2062. fields = append(fields, agentbase.FieldQ)
  2063. }
  2064. if m.a != nil {
  2065. fields = append(fields, agentbase.FieldA)
  2066. }
  2067. if m.chunk_index != nil {
  2068. fields = append(fields, agentbase.FieldChunkIndex)
  2069. }
  2070. if m.indexes != nil {
  2071. fields = append(fields, agentbase.FieldIndexes)
  2072. }
  2073. if m.dataset_id != nil {
  2074. fields = append(fields, agentbase.FieldDatasetID)
  2075. }
  2076. if m.collection_id != nil {
  2077. fields = append(fields, agentbase.FieldCollectionID)
  2078. }
  2079. if m.source_name != nil {
  2080. fields = append(fields, agentbase.FieldSourceName)
  2081. }
  2082. if m.can_write != nil {
  2083. fields = append(fields, agentbase.FieldCanWrite)
  2084. }
  2085. if m.is_owner != nil {
  2086. fields = append(fields, agentbase.FieldIsOwner)
  2087. }
  2088. return fields
  2089. }
  2090. // Field returns the value of a field with the given name. The second boolean
  2091. // return value indicates that this field was not set, or was not defined in the
  2092. // schema.
  2093. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2094. switch name {
  2095. case agentbase.FieldQ:
  2096. return m.Q()
  2097. case agentbase.FieldA:
  2098. return m.A()
  2099. case agentbase.FieldChunkIndex:
  2100. return m.ChunkIndex()
  2101. case agentbase.FieldIndexes:
  2102. return m.Indexes()
  2103. case agentbase.FieldDatasetID:
  2104. return m.DatasetID()
  2105. case agentbase.FieldCollectionID:
  2106. return m.CollectionID()
  2107. case agentbase.FieldSourceName:
  2108. return m.SourceName()
  2109. case agentbase.FieldCanWrite:
  2110. return m.CanWrite()
  2111. case agentbase.FieldIsOwner:
  2112. return m.IsOwner()
  2113. }
  2114. return nil, false
  2115. }
  2116. // OldField returns the old value of the field from the database. An error is
  2117. // returned if the mutation operation is not UpdateOne, or the query to the
  2118. // database failed.
  2119. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2120. switch name {
  2121. case agentbase.FieldQ:
  2122. return m.OldQ(ctx)
  2123. case agentbase.FieldA:
  2124. return m.OldA(ctx)
  2125. case agentbase.FieldChunkIndex:
  2126. return m.OldChunkIndex(ctx)
  2127. case agentbase.FieldIndexes:
  2128. return m.OldIndexes(ctx)
  2129. case agentbase.FieldDatasetID:
  2130. return m.OldDatasetID(ctx)
  2131. case agentbase.FieldCollectionID:
  2132. return m.OldCollectionID(ctx)
  2133. case agentbase.FieldSourceName:
  2134. return m.OldSourceName(ctx)
  2135. case agentbase.FieldCanWrite:
  2136. return m.OldCanWrite(ctx)
  2137. case agentbase.FieldIsOwner:
  2138. return m.OldIsOwner(ctx)
  2139. }
  2140. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2141. }
  2142. // SetField sets the value of a field with the given name. It returns an error if
  2143. // the field is not defined in the schema, or if the type mismatched the field
  2144. // type.
  2145. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2146. switch name {
  2147. case agentbase.FieldQ:
  2148. v, ok := value.(string)
  2149. if !ok {
  2150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2151. }
  2152. m.SetQ(v)
  2153. return nil
  2154. case agentbase.FieldA:
  2155. v, ok := value.(string)
  2156. if !ok {
  2157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2158. }
  2159. m.SetA(v)
  2160. return nil
  2161. case agentbase.FieldChunkIndex:
  2162. v, ok := value.(uint64)
  2163. if !ok {
  2164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2165. }
  2166. m.SetChunkIndex(v)
  2167. return nil
  2168. case agentbase.FieldIndexes:
  2169. v, ok := value.([]string)
  2170. if !ok {
  2171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2172. }
  2173. m.SetIndexes(v)
  2174. return nil
  2175. case agentbase.FieldDatasetID:
  2176. v, ok := value.(string)
  2177. if !ok {
  2178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2179. }
  2180. m.SetDatasetID(v)
  2181. return nil
  2182. case agentbase.FieldCollectionID:
  2183. v, ok := value.(string)
  2184. if !ok {
  2185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2186. }
  2187. m.SetCollectionID(v)
  2188. return nil
  2189. case agentbase.FieldSourceName:
  2190. v, ok := value.(string)
  2191. if !ok {
  2192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2193. }
  2194. m.SetSourceName(v)
  2195. return nil
  2196. case agentbase.FieldCanWrite:
  2197. v, ok := value.([]bool)
  2198. if !ok {
  2199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2200. }
  2201. m.SetCanWrite(v)
  2202. return nil
  2203. case agentbase.FieldIsOwner:
  2204. v, ok := value.([]bool)
  2205. if !ok {
  2206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2207. }
  2208. m.SetIsOwner(v)
  2209. return nil
  2210. }
  2211. return fmt.Errorf("unknown AgentBase field %s", name)
  2212. }
  2213. // AddedFields returns all numeric fields that were incremented/decremented during
  2214. // this mutation.
  2215. func (m *AgentBaseMutation) AddedFields() []string {
  2216. var fields []string
  2217. if m.addchunk_index != nil {
  2218. fields = append(fields, agentbase.FieldChunkIndex)
  2219. }
  2220. return fields
  2221. }
  2222. // AddedField returns the numeric value that was incremented/decremented on a field
  2223. // with the given name. The second boolean return value indicates that this field
  2224. // was not set, or was not defined in the schema.
  2225. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2226. switch name {
  2227. case agentbase.FieldChunkIndex:
  2228. return m.AddedChunkIndex()
  2229. }
  2230. return nil, false
  2231. }
  2232. // AddField adds the value to the field with the given name. It returns an error if
  2233. // the field is not defined in the schema, or if the type mismatched the field
  2234. // type.
  2235. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2236. switch name {
  2237. case agentbase.FieldChunkIndex:
  2238. v, ok := value.(int64)
  2239. if !ok {
  2240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2241. }
  2242. m.AddChunkIndex(v)
  2243. return nil
  2244. }
  2245. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2246. }
  2247. // ClearedFields returns all nullable fields that were cleared during this
  2248. // mutation.
  2249. func (m *AgentBaseMutation) ClearedFields() []string {
  2250. var fields []string
  2251. if m.FieldCleared(agentbase.FieldQ) {
  2252. fields = append(fields, agentbase.FieldQ)
  2253. }
  2254. if m.FieldCleared(agentbase.FieldA) {
  2255. fields = append(fields, agentbase.FieldA)
  2256. }
  2257. if m.FieldCleared(agentbase.FieldIndexes) {
  2258. fields = append(fields, agentbase.FieldIndexes)
  2259. }
  2260. if m.FieldCleared(agentbase.FieldDatasetID) {
  2261. fields = append(fields, agentbase.FieldDatasetID)
  2262. }
  2263. if m.FieldCleared(agentbase.FieldCollectionID) {
  2264. fields = append(fields, agentbase.FieldCollectionID)
  2265. }
  2266. if m.FieldCleared(agentbase.FieldSourceName) {
  2267. fields = append(fields, agentbase.FieldSourceName)
  2268. }
  2269. if m.FieldCleared(agentbase.FieldCanWrite) {
  2270. fields = append(fields, agentbase.FieldCanWrite)
  2271. }
  2272. if m.FieldCleared(agentbase.FieldIsOwner) {
  2273. fields = append(fields, agentbase.FieldIsOwner)
  2274. }
  2275. return fields
  2276. }
  2277. // FieldCleared returns a boolean indicating if a field with the given name was
  2278. // cleared in this mutation.
  2279. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2280. _, ok := m.clearedFields[name]
  2281. return ok
  2282. }
  2283. // ClearField clears the value of the field with the given name. It returns an
  2284. // error if the field is not defined in the schema.
  2285. func (m *AgentBaseMutation) ClearField(name string) error {
  2286. switch name {
  2287. case agentbase.FieldQ:
  2288. m.ClearQ()
  2289. return nil
  2290. case agentbase.FieldA:
  2291. m.ClearA()
  2292. return nil
  2293. case agentbase.FieldIndexes:
  2294. m.ClearIndexes()
  2295. return nil
  2296. case agentbase.FieldDatasetID:
  2297. m.ClearDatasetID()
  2298. return nil
  2299. case agentbase.FieldCollectionID:
  2300. m.ClearCollectionID()
  2301. return nil
  2302. case agentbase.FieldSourceName:
  2303. m.ClearSourceName()
  2304. return nil
  2305. case agentbase.FieldCanWrite:
  2306. m.ClearCanWrite()
  2307. return nil
  2308. case agentbase.FieldIsOwner:
  2309. m.ClearIsOwner()
  2310. return nil
  2311. }
  2312. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2313. }
  2314. // ResetField resets all changes in the mutation for the field with the given name.
  2315. // It returns an error if the field is not defined in the schema.
  2316. func (m *AgentBaseMutation) ResetField(name string) error {
  2317. switch name {
  2318. case agentbase.FieldQ:
  2319. m.ResetQ()
  2320. return nil
  2321. case agentbase.FieldA:
  2322. m.ResetA()
  2323. return nil
  2324. case agentbase.FieldChunkIndex:
  2325. m.ResetChunkIndex()
  2326. return nil
  2327. case agentbase.FieldIndexes:
  2328. m.ResetIndexes()
  2329. return nil
  2330. case agentbase.FieldDatasetID:
  2331. m.ResetDatasetID()
  2332. return nil
  2333. case agentbase.FieldCollectionID:
  2334. m.ResetCollectionID()
  2335. return nil
  2336. case agentbase.FieldSourceName:
  2337. m.ResetSourceName()
  2338. return nil
  2339. case agentbase.FieldCanWrite:
  2340. m.ResetCanWrite()
  2341. return nil
  2342. case agentbase.FieldIsOwner:
  2343. m.ResetIsOwner()
  2344. return nil
  2345. }
  2346. return fmt.Errorf("unknown AgentBase field %s", name)
  2347. }
  2348. // AddedEdges returns all edge names that were set/added in this mutation.
  2349. func (m *AgentBaseMutation) AddedEdges() []string {
  2350. edges := make([]string, 0, 1)
  2351. if m.wx_agent != nil {
  2352. edges = append(edges, agentbase.EdgeWxAgent)
  2353. }
  2354. return edges
  2355. }
  2356. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2357. // name in this mutation.
  2358. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2359. switch name {
  2360. case agentbase.EdgeWxAgent:
  2361. ids := make([]ent.Value, 0, len(m.wx_agent))
  2362. for id := range m.wx_agent {
  2363. ids = append(ids, id)
  2364. }
  2365. return ids
  2366. }
  2367. return nil
  2368. }
  2369. // RemovedEdges returns all edge names that were removed in this mutation.
  2370. func (m *AgentBaseMutation) RemovedEdges() []string {
  2371. edges := make([]string, 0, 1)
  2372. if m.removedwx_agent != nil {
  2373. edges = append(edges, agentbase.EdgeWxAgent)
  2374. }
  2375. return edges
  2376. }
  2377. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2378. // the given name in this mutation.
  2379. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2380. switch name {
  2381. case agentbase.EdgeWxAgent:
  2382. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2383. for id := range m.removedwx_agent {
  2384. ids = append(ids, id)
  2385. }
  2386. return ids
  2387. }
  2388. return nil
  2389. }
  2390. // ClearedEdges returns all edge names that were cleared in this mutation.
  2391. func (m *AgentBaseMutation) ClearedEdges() []string {
  2392. edges := make([]string, 0, 1)
  2393. if m.clearedwx_agent {
  2394. edges = append(edges, agentbase.EdgeWxAgent)
  2395. }
  2396. return edges
  2397. }
  2398. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2399. // was cleared in this mutation.
  2400. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2401. switch name {
  2402. case agentbase.EdgeWxAgent:
  2403. return m.clearedwx_agent
  2404. }
  2405. return false
  2406. }
  2407. // ClearEdge clears the value of the edge with the given name. It returns an error
  2408. // if that edge is not defined in the schema.
  2409. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2410. switch name {
  2411. }
  2412. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2413. }
  2414. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2415. // It returns an error if the edge is not defined in the schema.
  2416. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2417. switch name {
  2418. case agentbase.EdgeWxAgent:
  2419. m.ResetWxAgent()
  2420. return nil
  2421. }
  2422. return fmt.Errorf("unknown AgentBase edge %s", name)
  2423. }
  2424. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2425. type AliyunAvatarMutation struct {
  2426. config
  2427. op Op
  2428. typ string
  2429. id *uint64
  2430. created_at *time.Time
  2431. updated_at *time.Time
  2432. deleted_at *time.Time
  2433. user_id *uint64
  2434. adduser_id *int64
  2435. biz_id *string
  2436. access_key_id *string
  2437. access_key_secret *string
  2438. app_id *string
  2439. tenant_id *uint64
  2440. addtenant_id *int64
  2441. response *string
  2442. token *string
  2443. session_id *string
  2444. clearedFields map[string]struct{}
  2445. done bool
  2446. oldValue func(context.Context) (*AliyunAvatar, error)
  2447. predicates []predicate.AliyunAvatar
  2448. }
  2449. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2450. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2451. type aliyunavatarOption func(*AliyunAvatarMutation)
  2452. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2453. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2454. m := &AliyunAvatarMutation{
  2455. config: c,
  2456. op: op,
  2457. typ: TypeAliyunAvatar,
  2458. clearedFields: make(map[string]struct{}),
  2459. }
  2460. for _, opt := range opts {
  2461. opt(m)
  2462. }
  2463. return m
  2464. }
  2465. // withAliyunAvatarID sets the ID field of the mutation.
  2466. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2467. return func(m *AliyunAvatarMutation) {
  2468. var (
  2469. err error
  2470. once sync.Once
  2471. value *AliyunAvatar
  2472. )
  2473. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2474. once.Do(func() {
  2475. if m.done {
  2476. err = errors.New("querying old values post mutation is not allowed")
  2477. } else {
  2478. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2479. }
  2480. })
  2481. return value, err
  2482. }
  2483. m.id = &id
  2484. }
  2485. }
  2486. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2487. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2488. return func(m *AliyunAvatarMutation) {
  2489. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2490. return node, nil
  2491. }
  2492. m.id = &node.ID
  2493. }
  2494. }
  2495. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2496. // executed in a transaction (ent.Tx), a transactional client is returned.
  2497. func (m AliyunAvatarMutation) Client() *Client {
  2498. client := &Client{config: m.config}
  2499. client.init()
  2500. return client
  2501. }
  2502. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2503. // it returns an error otherwise.
  2504. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2505. if _, ok := m.driver.(*txDriver); !ok {
  2506. return nil, errors.New("ent: mutation is not running in a transaction")
  2507. }
  2508. tx := &Tx{config: m.config}
  2509. tx.init()
  2510. return tx, nil
  2511. }
  2512. // SetID sets the value of the id field. Note that this
  2513. // operation is only accepted on creation of AliyunAvatar entities.
  2514. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2515. m.id = &id
  2516. }
  2517. // ID returns the ID value in the mutation. Note that the ID is only available
  2518. // if it was provided to the builder or after it was returned from the database.
  2519. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2520. if m.id == nil {
  2521. return
  2522. }
  2523. return *m.id, true
  2524. }
  2525. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2526. // That means, if the mutation is applied within a transaction with an isolation level such
  2527. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2528. // or updated by the mutation.
  2529. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2530. switch {
  2531. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2532. id, exists := m.ID()
  2533. if exists {
  2534. return []uint64{id}, nil
  2535. }
  2536. fallthrough
  2537. case m.op.Is(OpUpdate | OpDelete):
  2538. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2539. default:
  2540. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2541. }
  2542. }
  2543. // SetCreatedAt sets the "created_at" field.
  2544. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2545. m.created_at = &t
  2546. }
  2547. // CreatedAt returns the value of the "created_at" field in the mutation.
  2548. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2549. v := m.created_at
  2550. if v == nil {
  2551. return
  2552. }
  2553. return *v, true
  2554. }
  2555. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2556. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2558. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2559. if !m.op.Is(OpUpdateOne) {
  2560. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2561. }
  2562. if m.id == nil || m.oldValue == nil {
  2563. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2564. }
  2565. oldValue, err := m.oldValue(ctx)
  2566. if err != nil {
  2567. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2568. }
  2569. return oldValue.CreatedAt, nil
  2570. }
  2571. // ResetCreatedAt resets all changes to the "created_at" field.
  2572. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2573. m.created_at = nil
  2574. }
  2575. // SetUpdatedAt sets the "updated_at" field.
  2576. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2577. m.updated_at = &t
  2578. }
  2579. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2580. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2581. v := m.updated_at
  2582. if v == nil {
  2583. return
  2584. }
  2585. return *v, true
  2586. }
  2587. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2588. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2590. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2591. if !m.op.Is(OpUpdateOne) {
  2592. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2593. }
  2594. if m.id == nil || m.oldValue == nil {
  2595. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2596. }
  2597. oldValue, err := m.oldValue(ctx)
  2598. if err != nil {
  2599. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2600. }
  2601. return oldValue.UpdatedAt, nil
  2602. }
  2603. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2604. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2605. m.updated_at = nil
  2606. }
  2607. // SetDeletedAt sets the "deleted_at" field.
  2608. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2609. m.deleted_at = &t
  2610. }
  2611. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2612. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2613. v := m.deleted_at
  2614. if v == nil {
  2615. return
  2616. }
  2617. return *v, true
  2618. }
  2619. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2620. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2622. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2623. if !m.op.Is(OpUpdateOne) {
  2624. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2625. }
  2626. if m.id == nil || m.oldValue == nil {
  2627. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2628. }
  2629. oldValue, err := m.oldValue(ctx)
  2630. if err != nil {
  2631. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2632. }
  2633. return oldValue.DeletedAt, nil
  2634. }
  2635. // ClearDeletedAt clears the value of the "deleted_at" field.
  2636. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2637. m.deleted_at = nil
  2638. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2639. }
  2640. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2641. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2642. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2643. return ok
  2644. }
  2645. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2646. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2647. m.deleted_at = nil
  2648. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2649. }
  2650. // SetUserID sets the "user_id" field.
  2651. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2652. m.user_id = &u
  2653. m.adduser_id = nil
  2654. }
  2655. // UserID returns the value of the "user_id" field in the mutation.
  2656. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2657. v := m.user_id
  2658. if v == nil {
  2659. return
  2660. }
  2661. return *v, true
  2662. }
  2663. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2664. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2666. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2667. if !m.op.Is(OpUpdateOne) {
  2668. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2669. }
  2670. if m.id == nil || m.oldValue == nil {
  2671. return v, errors.New("OldUserID requires an ID field in the mutation")
  2672. }
  2673. oldValue, err := m.oldValue(ctx)
  2674. if err != nil {
  2675. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2676. }
  2677. return oldValue.UserID, nil
  2678. }
  2679. // AddUserID adds u to the "user_id" field.
  2680. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2681. if m.adduser_id != nil {
  2682. *m.adduser_id += u
  2683. } else {
  2684. m.adduser_id = &u
  2685. }
  2686. }
  2687. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2688. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2689. v := m.adduser_id
  2690. if v == nil {
  2691. return
  2692. }
  2693. return *v, true
  2694. }
  2695. // ResetUserID resets all changes to the "user_id" field.
  2696. func (m *AliyunAvatarMutation) ResetUserID() {
  2697. m.user_id = nil
  2698. m.adduser_id = nil
  2699. }
  2700. // SetBizID sets the "biz_id" field.
  2701. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2702. m.biz_id = &s
  2703. }
  2704. // BizID returns the value of the "biz_id" field in the mutation.
  2705. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2706. v := m.biz_id
  2707. if v == nil {
  2708. return
  2709. }
  2710. return *v, true
  2711. }
  2712. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2713. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2715. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2716. if !m.op.Is(OpUpdateOne) {
  2717. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2718. }
  2719. if m.id == nil || m.oldValue == nil {
  2720. return v, errors.New("OldBizID requires an ID field in the mutation")
  2721. }
  2722. oldValue, err := m.oldValue(ctx)
  2723. if err != nil {
  2724. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2725. }
  2726. return oldValue.BizID, nil
  2727. }
  2728. // ResetBizID resets all changes to the "biz_id" field.
  2729. func (m *AliyunAvatarMutation) ResetBizID() {
  2730. m.biz_id = nil
  2731. }
  2732. // SetAccessKeyID sets the "access_key_id" field.
  2733. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2734. m.access_key_id = &s
  2735. }
  2736. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2737. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2738. v := m.access_key_id
  2739. if v == nil {
  2740. return
  2741. }
  2742. return *v, true
  2743. }
  2744. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2745. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2747. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2748. if !m.op.Is(OpUpdateOne) {
  2749. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2750. }
  2751. if m.id == nil || m.oldValue == nil {
  2752. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2753. }
  2754. oldValue, err := m.oldValue(ctx)
  2755. if err != nil {
  2756. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2757. }
  2758. return oldValue.AccessKeyID, nil
  2759. }
  2760. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2761. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2762. m.access_key_id = nil
  2763. }
  2764. // SetAccessKeySecret sets the "access_key_secret" field.
  2765. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2766. m.access_key_secret = &s
  2767. }
  2768. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2769. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2770. v := m.access_key_secret
  2771. if v == nil {
  2772. return
  2773. }
  2774. return *v, true
  2775. }
  2776. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2777. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2779. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2780. if !m.op.Is(OpUpdateOne) {
  2781. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2782. }
  2783. if m.id == nil || m.oldValue == nil {
  2784. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2785. }
  2786. oldValue, err := m.oldValue(ctx)
  2787. if err != nil {
  2788. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2789. }
  2790. return oldValue.AccessKeySecret, nil
  2791. }
  2792. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2793. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2794. m.access_key_secret = nil
  2795. }
  2796. // SetAppID sets the "app_id" field.
  2797. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2798. m.app_id = &s
  2799. }
  2800. // AppID returns the value of the "app_id" field in the mutation.
  2801. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2802. v := m.app_id
  2803. if v == nil {
  2804. return
  2805. }
  2806. return *v, true
  2807. }
  2808. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2809. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2811. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2812. if !m.op.Is(OpUpdateOne) {
  2813. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2814. }
  2815. if m.id == nil || m.oldValue == nil {
  2816. return v, errors.New("OldAppID requires an ID field in the mutation")
  2817. }
  2818. oldValue, err := m.oldValue(ctx)
  2819. if err != nil {
  2820. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2821. }
  2822. return oldValue.AppID, nil
  2823. }
  2824. // ClearAppID clears the value of the "app_id" field.
  2825. func (m *AliyunAvatarMutation) ClearAppID() {
  2826. m.app_id = nil
  2827. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2828. }
  2829. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2830. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2831. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2832. return ok
  2833. }
  2834. // ResetAppID resets all changes to the "app_id" field.
  2835. func (m *AliyunAvatarMutation) ResetAppID() {
  2836. m.app_id = nil
  2837. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2838. }
  2839. // SetTenantID sets the "tenant_id" field.
  2840. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2841. m.tenant_id = &u
  2842. m.addtenant_id = nil
  2843. }
  2844. // TenantID returns the value of the "tenant_id" field in the mutation.
  2845. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2846. v := m.tenant_id
  2847. if v == nil {
  2848. return
  2849. }
  2850. return *v, true
  2851. }
  2852. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2853. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2855. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2856. if !m.op.Is(OpUpdateOne) {
  2857. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2858. }
  2859. if m.id == nil || m.oldValue == nil {
  2860. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2861. }
  2862. oldValue, err := m.oldValue(ctx)
  2863. if err != nil {
  2864. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2865. }
  2866. return oldValue.TenantID, nil
  2867. }
  2868. // AddTenantID adds u to the "tenant_id" field.
  2869. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2870. if m.addtenant_id != nil {
  2871. *m.addtenant_id += u
  2872. } else {
  2873. m.addtenant_id = &u
  2874. }
  2875. }
  2876. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2877. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2878. v := m.addtenant_id
  2879. if v == nil {
  2880. return
  2881. }
  2882. return *v, true
  2883. }
  2884. // ResetTenantID resets all changes to the "tenant_id" field.
  2885. func (m *AliyunAvatarMutation) ResetTenantID() {
  2886. m.tenant_id = nil
  2887. m.addtenant_id = nil
  2888. }
  2889. // SetResponse sets the "response" field.
  2890. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2891. m.response = &s
  2892. }
  2893. // Response returns the value of the "response" field in the mutation.
  2894. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2895. v := m.response
  2896. if v == nil {
  2897. return
  2898. }
  2899. return *v, true
  2900. }
  2901. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2902. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2904. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2905. if !m.op.Is(OpUpdateOne) {
  2906. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2907. }
  2908. if m.id == nil || m.oldValue == nil {
  2909. return v, errors.New("OldResponse requires an ID field in the mutation")
  2910. }
  2911. oldValue, err := m.oldValue(ctx)
  2912. if err != nil {
  2913. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2914. }
  2915. return oldValue.Response, nil
  2916. }
  2917. // ResetResponse resets all changes to the "response" field.
  2918. func (m *AliyunAvatarMutation) ResetResponse() {
  2919. m.response = nil
  2920. }
  2921. // SetToken sets the "token" field.
  2922. func (m *AliyunAvatarMutation) SetToken(s string) {
  2923. m.token = &s
  2924. }
  2925. // Token returns the value of the "token" field in the mutation.
  2926. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2927. v := m.token
  2928. if v == nil {
  2929. return
  2930. }
  2931. return *v, true
  2932. }
  2933. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2934. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2936. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2937. if !m.op.Is(OpUpdateOne) {
  2938. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2939. }
  2940. if m.id == nil || m.oldValue == nil {
  2941. return v, errors.New("OldToken requires an ID field in the mutation")
  2942. }
  2943. oldValue, err := m.oldValue(ctx)
  2944. if err != nil {
  2945. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2946. }
  2947. return oldValue.Token, nil
  2948. }
  2949. // ResetToken resets all changes to the "token" field.
  2950. func (m *AliyunAvatarMutation) ResetToken() {
  2951. m.token = nil
  2952. }
  2953. // SetSessionID sets the "session_id" field.
  2954. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2955. m.session_id = &s
  2956. }
  2957. // SessionID returns the value of the "session_id" field in the mutation.
  2958. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2959. v := m.session_id
  2960. if v == nil {
  2961. return
  2962. }
  2963. return *v, true
  2964. }
  2965. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2966. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2968. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2969. if !m.op.Is(OpUpdateOne) {
  2970. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2971. }
  2972. if m.id == nil || m.oldValue == nil {
  2973. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2974. }
  2975. oldValue, err := m.oldValue(ctx)
  2976. if err != nil {
  2977. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2978. }
  2979. return oldValue.SessionID, nil
  2980. }
  2981. // ResetSessionID resets all changes to the "session_id" field.
  2982. func (m *AliyunAvatarMutation) ResetSessionID() {
  2983. m.session_id = nil
  2984. }
  2985. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2986. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2987. m.predicates = append(m.predicates, ps...)
  2988. }
  2989. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2990. // users can use type-assertion to append predicates that do not depend on any generated package.
  2991. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2992. p := make([]predicate.AliyunAvatar, len(ps))
  2993. for i := range ps {
  2994. p[i] = ps[i]
  2995. }
  2996. m.Where(p...)
  2997. }
  2998. // Op returns the operation name.
  2999. func (m *AliyunAvatarMutation) Op() Op {
  3000. return m.op
  3001. }
  3002. // SetOp allows setting the mutation operation.
  3003. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3004. m.op = op
  3005. }
  3006. // Type returns the node type of this mutation (AliyunAvatar).
  3007. func (m *AliyunAvatarMutation) Type() string {
  3008. return m.typ
  3009. }
  3010. // Fields returns all fields that were changed during this mutation. Note that in
  3011. // order to get all numeric fields that were incremented/decremented, call
  3012. // AddedFields().
  3013. func (m *AliyunAvatarMutation) Fields() []string {
  3014. fields := make([]string, 0, 12)
  3015. if m.created_at != nil {
  3016. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3017. }
  3018. if m.updated_at != nil {
  3019. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3020. }
  3021. if m.deleted_at != nil {
  3022. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3023. }
  3024. if m.user_id != nil {
  3025. fields = append(fields, aliyunavatar.FieldUserID)
  3026. }
  3027. if m.biz_id != nil {
  3028. fields = append(fields, aliyunavatar.FieldBizID)
  3029. }
  3030. if m.access_key_id != nil {
  3031. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3032. }
  3033. if m.access_key_secret != nil {
  3034. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3035. }
  3036. if m.app_id != nil {
  3037. fields = append(fields, aliyunavatar.FieldAppID)
  3038. }
  3039. if m.tenant_id != nil {
  3040. fields = append(fields, aliyunavatar.FieldTenantID)
  3041. }
  3042. if m.response != nil {
  3043. fields = append(fields, aliyunavatar.FieldResponse)
  3044. }
  3045. if m.token != nil {
  3046. fields = append(fields, aliyunavatar.FieldToken)
  3047. }
  3048. if m.session_id != nil {
  3049. fields = append(fields, aliyunavatar.FieldSessionID)
  3050. }
  3051. return fields
  3052. }
  3053. // Field returns the value of a field with the given name. The second boolean
  3054. // return value indicates that this field was not set, or was not defined in the
  3055. // schema.
  3056. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3057. switch name {
  3058. case aliyunavatar.FieldCreatedAt:
  3059. return m.CreatedAt()
  3060. case aliyunavatar.FieldUpdatedAt:
  3061. return m.UpdatedAt()
  3062. case aliyunavatar.FieldDeletedAt:
  3063. return m.DeletedAt()
  3064. case aliyunavatar.FieldUserID:
  3065. return m.UserID()
  3066. case aliyunavatar.FieldBizID:
  3067. return m.BizID()
  3068. case aliyunavatar.FieldAccessKeyID:
  3069. return m.AccessKeyID()
  3070. case aliyunavatar.FieldAccessKeySecret:
  3071. return m.AccessKeySecret()
  3072. case aliyunavatar.FieldAppID:
  3073. return m.AppID()
  3074. case aliyunavatar.FieldTenantID:
  3075. return m.TenantID()
  3076. case aliyunavatar.FieldResponse:
  3077. return m.Response()
  3078. case aliyunavatar.FieldToken:
  3079. return m.Token()
  3080. case aliyunavatar.FieldSessionID:
  3081. return m.SessionID()
  3082. }
  3083. return nil, false
  3084. }
  3085. // OldField returns the old value of the field from the database. An error is
  3086. // returned if the mutation operation is not UpdateOne, or the query to the
  3087. // database failed.
  3088. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3089. switch name {
  3090. case aliyunavatar.FieldCreatedAt:
  3091. return m.OldCreatedAt(ctx)
  3092. case aliyunavatar.FieldUpdatedAt:
  3093. return m.OldUpdatedAt(ctx)
  3094. case aliyunavatar.FieldDeletedAt:
  3095. return m.OldDeletedAt(ctx)
  3096. case aliyunavatar.FieldUserID:
  3097. return m.OldUserID(ctx)
  3098. case aliyunavatar.FieldBizID:
  3099. return m.OldBizID(ctx)
  3100. case aliyunavatar.FieldAccessKeyID:
  3101. return m.OldAccessKeyID(ctx)
  3102. case aliyunavatar.FieldAccessKeySecret:
  3103. return m.OldAccessKeySecret(ctx)
  3104. case aliyunavatar.FieldAppID:
  3105. return m.OldAppID(ctx)
  3106. case aliyunavatar.FieldTenantID:
  3107. return m.OldTenantID(ctx)
  3108. case aliyunavatar.FieldResponse:
  3109. return m.OldResponse(ctx)
  3110. case aliyunavatar.FieldToken:
  3111. return m.OldToken(ctx)
  3112. case aliyunavatar.FieldSessionID:
  3113. return m.OldSessionID(ctx)
  3114. }
  3115. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3116. }
  3117. // SetField sets the value of a field with the given name. It returns an error if
  3118. // the field is not defined in the schema, or if the type mismatched the field
  3119. // type.
  3120. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3121. switch name {
  3122. case aliyunavatar.FieldCreatedAt:
  3123. v, ok := value.(time.Time)
  3124. if !ok {
  3125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3126. }
  3127. m.SetCreatedAt(v)
  3128. return nil
  3129. case aliyunavatar.FieldUpdatedAt:
  3130. v, ok := value.(time.Time)
  3131. if !ok {
  3132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3133. }
  3134. m.SetUpdatedAt(v)
  3135. return nil
  3136. case aliyunavatar.FieldDeletedAt:
  3137. v, ok := value.(time.Time)
  3138. if !ok {
  3139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3140. }
  3141. m.SetDeletedAt(v)
  3142. return nil
  3143. case aliyunavatar.FieldUserID:
  3144. v, ok := value.(uint64)
  3145. if !ok {
  3146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3147. }
  3148. m.SetUserID(v)
  3149. return nil
  3150. case aliyunavatar.FieldBizID:
  3151. v, ok := value.(string)
  3152. if !ok {
  3153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3154. }
  3155. m.SetBizID(v)
  3156. return nil
  3157. case aliyunavatar.FieldAccessKeyID:
  3158. v, ok := value.(string)
  3159. if !ok {
  3160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3161. }
  3162. m.SetAccessKeyID(v)
  3163. return nil
  3164. case aliyunavatar.FieldAccessKeySecret:
  3165. v, ok := value.(string)
  3166. if !ok {
  3167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3168. }
  3169. m.SetAccessKeySecret(v)
  3170. return nil
  3171. case aliyunavatar.FieldAppID:
  3172. v, ok := value.(string)
  3173. if !ok {
  3174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3175. }
  3176. m.SetAppID(v)
  3177. return nil
  3178. case aliyunavatar.FieldTenantID:
  3179. v, ok := value.(uint64)
  3180. if !ok {
  3181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3182. }
  3183. m.SetTenantID(v)
  3184. return nil
  3185. case aliyunavatar.FieldResponse:
  3186. v, ok := value.(string)
  3187. if !ok {
  3188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3189. }
  3190. m.SetResponse(v)
  3191. return nil
  3192. case aliyunavatar.FieldToken:
  3193. v, ok := value.(string)
  3194. if !ok {
  3195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3196. }
  3197. m.SetToken(v)
  3198. return nil
  3199. case aliyunavatar.FieldSessionID:
  3200. v, ok := value.(string)
  3201. if !ok {
  3202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3203. }
  3204. m.SetSessionID(v)
  3205. return nil
  3206. }
  3207. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3208. }
  3209. // AddedFields returns all numeric fields that were incremented/decremented during
  3210. // this mutation.
  3211. func (m *AliyunAvatarMutation) AddedFields() []string {
  3212. var fields []string
  3213. if m.adduser_id != nil {
  3214. fields = append(fields, aliyunavatar.FieldUserID)
  3215. }
  3216. if m.addtenant_id != nil {
  3217. fields = append(fields, aliyunavatar.FieldTenantID)
  3218. }
  3219. return fields
  3220. }
  3221. // AddedField returns the numeric value that was incremented/decremented on a field
  3222. // with the given name. The second boolean return value indicates that this field
  3223. // was not set, or was not defined in the schema.
  3224. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3225. switch name {
  3226. case aliyunavatar.FieldUserID:
  3227. return m.AddedUserID()
  3228. case aliyunavatar.FieldTenantID:
  3229. return m.AddedTenantID()
  3230. }
  3231. return nil, false
  3232. }
  3233. // AddField adds the value to the field with the given name. It returns an error if
  3234. // the field is not defined in the schema, or if the type mismatched the field
  3235. // type.
  3236. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3237. switch name {
  3238. case aliyunavatar.FieldUserID:
  3239. v, ok := value.(int64)
  3240. if !ok {
  3241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3242. }
  3243. m.AddUserID(v)
  3244. return nil
  3245. case aliyunavatar.FieldTenantID:
  3246. v, ok := value.(int64)
  3247. if !ok {
  3248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3249. }
  3250. m.AddTenantID(v)
  3251. return nil
  3252. }
  3253. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3254. }
  3255. // ClearedFields returns all nullable fields that were cleared during this
  3256. // mutation.
  3257. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3258. var fields []string
  3259. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3260. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3261. }
  3262. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3263. fields = append(fields, aliyunavatar.FieldAppID)
  3264. }
  3265. return fields
  3266. }
  3267. // FieldCleared returns a boolean indicating if a field with the given name was
  3268. // cleared in this mutation.
  3269. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3270. _, ok := m.clearedFields[name]
  3271. return ok
  3272. }
  3273. // ClearField clears the value of the field with the given name. It returns an
  3274. // error if the field is not defined in the schema.
  3275. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3276. switch name {
  3277. case aliyunavatar.FieldDeletedAt:
  3278. m.ClearDeletedAt()
  3279. return nil
  3280. case aliyunavatar.FieldAppID:
  3281. m.ClearAppID()
  3282. return nil
  3283. }
  3284. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3285. }
  3286. // ResetField resets all changes in the mutation for the field with the given name.
  3287. // It returns an error if the field is not defined in the schema.
  3288. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3289. switch name {
  3290. case aliyunavatar.FieldCreatedAt:
  3291. m.ResetCreatedAt()
  3292. return nil
  3293. case aliyunavatar.FieldUpdatedAt:
  3294. m.ResetUpdatedAt()
  3295. return nil
  3296. case aliyunavatar.FieldDeletedAt:
  3297. m.ResetDeletedAt()
  3298. return nil
  3299. case aliyunavatar.FieldUserID:
  3300. m.ResetUserID()
  3301. return nil
  3302. case aliyunavatar.FieldBizID:
  3303. m.ResetBizID()
  3304. return nil
  3305. case aliyunavatar.FieldAccessKeyID:
  3306. m.ResetAccessKeyID()
  3307. return nil
  3308. case aliyunavatar.FieldAccessKeySecret:
  3309. m.ResetAccessKeySecret()
  3310. return nil
  3311. case aliyunavatar.FieldAppID:
  3312. m.ResetAppID()
  3313. return nil
  3314. case aliyunavatar.FieldTenantID:
  3315. m.ResetTenantID()
  3316. return nil
  3317. case aliyunavatar.FieldResponse:
  3318. m.ResetResponse()
  3319. return nil
  3320. case aliyunavatar.FieldToken:
  3321. m.ResetToken()
  3322. return nil
  3323. case aliyunavatar.FieldSessionID:
  3324. m.ResetSessionID()
  3325. return nil
  3326. }
  3327. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3328. }
  3329. // AddedEdges returns all edge names that were set/added in this mutation.
  3330. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3331. edges := make([]string, 0, 0)
  3332. return edges
  3333. }
  3334. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3335. // name in this mutation.
  3336. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3337. return nil
  3338. }
  3339. // RemovedEdges returns all edge names that were removed in this mutation.
  3340. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3341. edges := make([]string, 0, 0)
  3342. return edges
  3343. }
  3344. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3345. // the given name in this mutation.
  3346. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3347. return nil
  3348. }
  3349. // ClearedEdges returns all edge names that were cleared in this mutation.
  3350. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3351. edges := make([]string, 0, 0)
  3352. return edges
  3353. }
  3354. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3355. // was cleared in this mutation.
  3356. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3357. return false
  3358. }
  3359. // ClearEdge clears the value of the edge with the given name. It returns an error
  3360. // if that edge is not defined in the schema.
  3361. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3362. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3363. }
  3364. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3365. // It returns an error if the edge is not defined in the schema.
  3366. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3367. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3368. }
  3369. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3370. type AllocAgentMutation struct {
  3371. config
  3372. op Op
  3373. typ string
  3374. id *uint64
  3375. created_at *time.Time
  3376. updated_at *time.Time
  3377. deleted_at *time.Time
  3378. user_id *string
  3379. organization_id *uint64
  3380. addorganization_id *int64
  3381. agents *[]uint64
  3382. appendagents []uint64
  3383. status *int
  3384. addstatus *int
  3385. clearedFields map[string]struct{}
  3386. done bool
  3387. oldValue func(context.Context) (*AllocAgent, error)
  3388. predicates []predicate.AllocAgent
  3389. }
  3390. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3391. // allocagentOption allows management of the mutation configuration using functional options.
  3392. type allocagentOption func(*AllocAgentMutation)
  3393. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3394. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3395. m := &AllocAgentMutation{
  3396. config: c,
  3397. op: op,
  3398. typ: TypeAllocAgent,
  3399. clearedFields: make(map[string]struct{}),
  3400. }
  3401. for _, opt := range opts {
  3402. opt(m)
  3403. }
  3404. return m
  3405. }
  3406. // withAllocAgentID sets the ID field of the mutation.
  3407. func withAllocAgentID(id uint64) allocagentOption {
  3408. return func(m *AllocAgentMutation) {
  3409. var (
  3410. err error
  3411. once sync.Once
  3412. value *AllocAgent
  3413. )
  3414. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3415. once.Do(func() {
  3416. if m.done {
  3417. err = errors.New("querying old values post mutation is not allowed")
  3418. } else {
  3419. value, err = m.Client().AllocAgent.Get(ctx, id)
  3420. }
  3421. })
  3422. return value, err
  3423. }
  3424. m.id = &id
  3425. }
  3426. }
  3427. // withAllocAgent sets the old AllocAgent of the mutation.
  3428. func withAllocAgent(node *AllocAgent) allocagentOption {
  3429. return func(m *AllocAgentMutation) {
  3430. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3431. return node, nil
  3432. }
  3433. m.id = &node.ID
  3434. }
  3435. }
  3436. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3437. // executed in a transaction (ent.Tx), a transactional client is returned.
  3438. func (m AllocAgentMutation) Client() *Client {
  3439. client := &Client{config: m.config}
  3440. client.init()
  3441. return client
  3442. }
  3443. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3444. // it returns an error otherwise.
  3445. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3446. if _, ok := m.driver.(*txDriver); !ok {
  3447. return nil, errors.New("ent: mutation is not running in a transaction")
  3448. }
  3449. tx := &Tx{config: m.config}
  3450. tx.init()
  3451. return tx, nil
  3452. }
  3453. // SetID sets the value of the id field. Note that this
  3454. // operation is only accepted on creation of AllocAgent entities.
  3455. func (m *AllocAgentMutation) SetID(id uint64) {
  3456. m.id = &id
  3457. }
  3458. // ID returns the ID value in the mutation. Note that the ID is only available
  3459. // if it was provided to the builder or after it was returned from the database.
  3460. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3461. if m.id == nil {
  3462. return
  3463. }
  3464. return *m.id, true
  3465. }
  3466. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3467. // That means, if the mutation is applied within a transaction with an isolation level such
  3468. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3469. // or updated by the mutation.
  3470. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3471. switch {
  3472. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3473. id, exists := m.ID()
  3474. if exists {
  3475. return []uint64{id}, nil
  3476. }
  3477. fallthrough
  3478. case m.op.Is(OpUpdate | OpDelete):
  3479. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3480. default:
  3481. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3482. }
  3483. }
  3484. // SetCreatedAt sets the "created_at" field.
  3485. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3486. m.created_at = &t
  3487. }
  3488. // CreatedAt returns the value of the "created_at" field in the mutation.
  3489. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3490. v := m.created_at
  3491. if v == nil {
  3492. return
  3493. }
  3494. return *v, true
  3495. }
  3496. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3497. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3499. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3500. if !m.op.Is(OpUpdateOne) {
  3501. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3502. }
  3503. if m.id == nil || m.oldValue == nil {
  3504. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3505. }
  3506. oldValue, err := m.oldValue(ctx)
  3507. if err != nil {
  3508. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3509. }
  3510. return oldValue.CreatedAt, nil
  3511. }
  3512. // ResetCreatedAt resets all changes to the "created_at" field.
  3513. func (m *AllocAgentMutation) ResetCreatedAt() {
  3514. m.created_at = nil
  3515. }
  3516. // SetUpdatedAt sets the "updated_at" field.
  3517. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3518. m.updated_at = &t
  3519. }
  3520. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3521. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3522. v := m.updated_at
  3523. if v == nil {
  3524. return
  3525. }
  3526. return *v, true
  3527. }
  3528. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3529. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3531. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3532. if !m.op.Is(OpUpdateOne) {
  3533. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3534. }
  3535. if m.id == nil || m.oldValue == nil {
  3536. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3537. }
  3538. oldValue, err := m.oldValue(ctx)
  3539. if err != nil {
  3540. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3541. }
  3542. return oldValue.UpdatedAt, nil
  3543. }
  3544. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3545. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3546. m.updated_at = nil
  3547. }
  3548. // SetDeletedAt sets the "deleted_at" field.
  3549. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3550. m.deleted_at = &t
  3551. }
  3552. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3553. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3554. v := m.deleted_at
  3555. if v == nil {
  3556. return
  3557. }
  3558. return *v, true
  3559. }
  3560. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3561. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3563. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3564. if !m.op.Is(OpUpdateOne) {
  3565. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3566. }
  3567. if m.id == nil || m.oldValue == nil {
  3568. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3569. }
  3570. oldValue, err := m.oldValue(ctx)
  3571. if err != nil {
  3572. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3573. }
  3574. return oldValue.DeletedAt, nil
  3575. }
  3576. // ClearDeletedAt clears the value of the "deleted_at" field.
  3577. func (m *AllocAgentMutation) ClearDeletedAt() {
  3578. m.deleted_at = nil
  3579. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3580. }
  3581. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3582. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3583. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3584. return ok
  3585. }
  3586. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3587. func (m *AllocAgentMutation) ResetDeletedAt() {
  3588. m.deleted_at = nil
  3589. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3590. }
  3591. // SetUserID sets the "user_id" field.
  3592. func (m *AllocAgentMutation) SetUserID(s string) {
  3593. m.user_id = &s
  3594. }
  3595. // UserID returns the value of the "user_id" field in the mutation.
  3596. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3597. v := m.user_id
  3598. if v == nil {
  3599. return
  3600. }
  3601. return *v, true
  3602. }
  3603. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3604. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3606. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3607. if !m.op.Is(OpUpdateOne) {
  3608. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3609. }
  3610. if m.id == nil || m.oldValue == nil {
  3611. return v, errors.New("OldUserID requires an ID field in the mutation")
  3612. }
  3613. oldValue, err := m.oldValue(ctx)
  3614. if err != nil {
  3615. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3616. }
  3617. return oldValue.UserID, nil
  3618. }
  3619. // ClearUserID clears the value of the "user_id" field.
  3620. func (m *AllocAgentMutation) ClearUserID() {
  3621. m.user_id = nil
  3622. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3623. }
  3624. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3625. func (m *AllocAgentMutation) UserIDCleared() bool {
  3626. _, ok := m.clearedFields[allocagent.FieldUserID]
  3627. return ok
  3628. }
  3629. // ResetUserID resets all changes to the "user_id" field.
  3630. func (m *AllocAgentMutation) ResetUserID() {
  3631. m.user_id = nil
  3632. delete(m.clearedFields, allocagent.FieldUserID)
  3633. }
  3634. // SetOrganizationID sets the "organization_id" field.
  3635. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3636. m.organization_id = &u
  3637. m.addorganization_id = nil
  3638. }
  3639. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3640. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3641. v := m.organization_id
  3642. if v == nil {
  3643. return
  3644. }
  3645. return *v, true
  3646. }
  3647. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3648. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3650. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3651. if !m.op.Is(OpUpdateOne) {
  3652. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3653. }
  3654. if m.id == nil || m.oldValue == nil {
  3655. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3656. }
  3657. oldValue, err := m.oldValue(ctx)
  3658. if err != nil {
  3659. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3660. }
  3661. return oldValue.OrganizationID, nil
  3662. }
  3663. // AddOrganizationID adds u to the "organization_id" field.
  3664. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3665. if m.addorganization_id != nil {
  3666. *m.addorganization_id += u
  3667. } else {
  3668. m.addorganization_id = &u
  3669. }
  3670. }
  3671. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3672. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3673. v := m.addorganization_id
  3674. if v == nil {
  3675. return
  3676. }
  3677. return *v, true
  3678. }
  3679. // ClearOrganizationID clears the value of the "organization_id" field.
  3680. func (m *AllocAgentMutation) ClearOrganizationID() {
  3681. m.organization_id = nil
  3682. m.addorganization_id = nil
  3683. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3684. }
  3685. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3686. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3687. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3688. return ok
  3689. }
  3690. // ResetOrganizationID resets all changes to the "organization_id" field.
  3691. func (m *AllocAgentMutation) ResetOrganizationID() {
  3692. m.organization_id = nil
  3693. m.addorganization_id = nil
  3694. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3695. }
  3696. // SetAgents sets the "agents" field.
  3697. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3698. m.agents = &u
  3699. m.appendagents = nil
  3700. }
  3701. // Agents returns the value of the "agents" field in the mutation.
  3702. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3703. v := m.agents
  3704. if v == nil {
  3705. return
  3706. }
  3707. return *v, true
  3708. }
  3709. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3710. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3712. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3713. if !m.op.Is(OpUpdateOne) {
  3714. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3715. }
  3716. if m.id == nil || m.oldValue == nil {
  3717. return v, errors.New("OldAgents requires an ID field in the mutation")
  3718. }
  3719. oldValue, err := m.oldValue(ctx)
  3720. if err != nil {
  3721. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3722. }
  3723. return oldValue.Agents, nil
  3724. }
  3725. // AppendAgents adds u to the "agents" field.
  3726. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3727. m.appendagents = append(m.appendagents, u...)
  3728. }
  3729. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3730. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3731. if len(m.appendagents) == 0 {
  3732. return nil, false
  3733. }
  3734. return m.appendagents, true
  3735. }
  3736. // ResetAgents resets all changes to the "agents" field.
  3737. func (m *AllocAgentMutation) ResetAgents() {
  3738. m.agents = nil
  3739. m.appendagents = nil
  3740. }
  3741. // SetStatus sets the "status" field.
  3742. func (m *AllocAgentMutation) SetStatus(i int) {
  3743. m.status = &i
  3744. m.addstatus = nil
  3745. }
  3746. // Status returns the value of the "status" field in the mutation.
  3747. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3748. v := m.status
  3749. if v == nil {
  3750. return
  3751. }
  3752. return *v, true
  3753. }
  3754. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3755. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3757. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3758. if !m.op.Is(OpUpdateOne) {
  3759. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3760. }
  3761. if m.id == nil || m.oldValue == nil {
  3762. return v, errors.New("OldStatus requires an ID field in the mutation")
  3763. }
  3764. oldValue, err := m.oldValue(ctx)
  3765. if err != nil {
  3766. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3767. }
  3768. return oldValue.Status, nil
  3769. }
  3770. // AddStatus adds i to the "status" field.
  3771. func (m *AllocAgentMutation) AddStatus(i int) {
  3772. if m.addstatus != nil {
  3773. *m.addstatus += i
  3774. } else {
  3775. m.addstatus = &i
  3776. }
  3777. }
  3778. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3779. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3780. v := m.addstatus
  3781. if v == nil {
  3782. return
  3783. }
  3784. return *v, true
  3785. }
  3786. // ClearStatus clears the value of the "status" field.
  3787. func (m *AllocAgentMutation) ClearStatus() {
  3788. m.status = nil
  3789. m.addstatus = nil
  3790. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3791. }
  3792. // StatusCleared returns if the "status" field was cleared in this mutation.
  3793. func (m *AllocAgentMutation) StatusCleared() bool {
  3794. _, ok := m.clearedFields[allocagent.FieldStatus]
  3795. return ok
  3796. }
  3797. // ResetStatus resets all changes to the "status" field.
  3798. func (m *AllocAgentMutation) ResetStatus() {
  3799. m.status = nil
  3800. m.addstatus = nil
  3801. delete(m.clearedFields, allocagent.FieldStatus)
  3802. }
  3803. // Where appends a list predicates to the AllocAgentMutation builder.
  3804. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3805. m.predicates = append(m.predicates, ps...)
  3806. }
  3807. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3808. // users can use type-assertion to append predicates that do not depend on any generated package.
  3809. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3810. p := make([]predicate.AllocAgent, len(ps))
  3811. for i := range ps {
  3812. p[i] = ps[i]
  3813. }
  3814. m.Where(p...)
  3815. }
  3816. // Op returns the operation name.
  3817. func (m *AllocAgentMutation) Op() Op {
  3818. return m.op
  3819. }
  3820. // SetOp allows setting the mutation operation.
  3821. func (m *AllocAgentMutation) SetOp(op Op) {
  3822. m.op = op
  3823. }
  3824. // Type returns the node type of this mutation (AllocAgent).
  3825. func (m *AllocAgentMutation) Type() string {
  3826. return m.typ
  3827. }
  3828. // Fields returns all fields that were changed during this mutation. Note that in
  3829. // order to get all numeric fields that were incremented/decremented, call
  3830. // AddedFields().
  3831. func (m *AllocAgentMutation) Fields() []string {
  3832. fields := make([]string, 0, 7)
  3833. if m.created_at != nil {
  3834. fields = append(fields, allocagent.FieldCreatedAt)
  3835. }
  3836. if m.updated_at != nil {
  3837. fields = append(fields, allocagent.FieldUpdatedAt)
  3838. }
  3839. if m.deleted_at != nil {
  3840. fields = append(fields, allocagent.FieldDeletedAt)
  3841. }
  3842. if m.user_id != nil {
  3843. fields = append(fields, allocagent.FieldUserID)
  3844. }
  3845. if m.organization_id != nil {
  3846. fields = append(fields, allocagent.FieldOrganizationID)
  3847. }
  3848. if m.agents != nil {
  3849. fields = append(fields, allocagent.FieldAgents)
  3850. }
  3851. if m.status != nil {
  3852. fields = append(fields, allocagent.FieldStatus)
  3853. }
  3854. return fields
  3855. }
  3856. // Field returns the value of a field with the given name. The second boolean
  3857. // return value indicates that this field was not set, or was not defined in the
  3858. // schema.
  3859. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3860. switch name {
  3861. case allocagent.FieldCreatedAt:
  3862. return m.CreatedAt()
  3863. case allocagent.FieldUpdatedAt:
  3864. return m.UpdatedAt()
  3865. case allocagent.FieldDeletedAt:
  3866. return m.DeletedAt()
  3867. case allocagent.FieldUserID:
  3868. return m.UserID()
  3869. case allocagent.FieldOrganizationID:
  3870. return m.OrganizationID()
  3871. case allocagent.FieldAgents:
  3872. return m.Agents()
  3873. case allocagent.FieldStatus:
  3874. return m.Status()
  3875. }
  3876. return nil, false
  3877. }
  3878. // OldField returns the old value of the field from the database. An error is
  3879. // returned if the mutation operation is not UpdateOne, or the query to the
  3880. // database failed.
  3881. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3882. switch name {
  3883. case allocagent.FieldCreatedAt:
  3884. return m.OldCreatedAt(ctx)
  3885. case allocagent.FieldUpdatedAt:
  3886. return m.OldUpdatedAt(ctx)
  3887. case allocagent.FieldDeletedAt:
  3888. return m.OldDeletedAt(ctx)
  3889. case allocagent.FieldUserID:
  3890. return m.OldUserID(ctx)
  3891. case allocagent.FieldOrganizationID:
  3892. return m.OldOrganizationID(ctx)
  3893. case allocagent.FieldAgents:
  3894. return m.OldAgents(ctx)
  3895. case allocagent.FieldStatus:
  3896. return m.OldStatus(ctx)
  3897. }
  3898. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3899. }
  3900. // SetField sets the value of a field with the given name. It returns an error if
  3901. // the field is not defined in the schema, or if the type mismatched the field
  3902. // type.
  3903. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3904. switch name {
  3905. case allocagent.FieldCreatedAt:
  3906. v, ok := value.(time.Time)
  3907. if !ok {
  3908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3909. }
  3910. m.SetCreatedAt(v)
  3911. return nil
  3912. case allocagent.FieldUpdatedAt:
  3913. v, ok := value.(time.Time)
  3914. if !ok {
  3915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3916. }
  3917. m.SetUpdatedAt(v)
  3918. return nil
  3919. case allocagent.FieldDeletedAt:
  3920. v, ok := value.(time.Time)
  3921. if !ok {
  3922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3923. }
  3924. m.SetDeletedAt(v)
  3925. return nil
  3926. case allocagent.FieldUserID:
  3927. v, ok := value.(string)
  3928. if !ok {
  3929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3930. }
  3931. m.SetUserID(v)
  3932. return nil
  3933. case allocagent.FieldOrganizationID:
  3934. v, ok := value.(uint64)
  3935. if !ok {
  3936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3937. }
  3938. m.SetOrganizationID(v)
  3939. return nil
  3940. case allocagent.FieldAgents:
  3941. v, ok := value.([]uint64)
  3942. if !ok {
  3943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3944. }
  3945. m.SetAgents(v)
  3946. return nil
  3947. case allocagent.FieldStatus:
  3948. v, ok := value.(int)
  3949. if !ok {
  3950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3951. }
  3952. m.SetStatus(v)
  3953. return nil
  3954. }
  3955. return fmt.Errorf("unknown AllocAgent field %s", name)
  3956. }
  3957. // AddedFields returns all numeric fields that were incremented/decremented during
  3958. // this mutation.
  3959. func (m *AllocAgentMutation) AddedFields() []string {
  3960. var fields []string
  3961. if m.addorganization_id != nil {
  3962. fields = append(fields, allocagent.FieldOrganizationID)
  3963. }
  3964. if m.addstatus != nil {
  3965. fields = append(fields, allocagent.FieldStatus)
  3966. }
  3967. return fields
  3968. }
  3969. // AddedField returns the numeric value that was incremented/decremented on a field
  3970. // with the given name. The second boolean return value indicates that this field
  3971. // was not set, or was not defined in the schema.
  3972. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3973. switch name {
  3974. case allocagent.FieldOrganizationID:
  3975. return m.AddedOrganizationID()
  3976. case allocagent.FieldStatus:
  3977. return m.AddedStatus()
  3978. }
  3979. return nil, false
  3980. }
  3981. // AddField adds the value to the field with the given name. It returns an error if
  3982. // the field is not defined in the schema, or if the type mismatched the field
  3983. // type.
  3984. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3985. switch name {
  3986. case allocagent.FieldOrganizationID:
  3987. v, ok := value.(int64)
  3988. if !ok {
  3989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3990. }
  3991. m.AddOrganizationID(v)
  3992. return nil
  3993. case allocagent.FieldStatus:
  3994. v, ok := value.(int)
  3995. if !ok {
  3996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3997. }
  3998. m.AddStatus(v)
  3999. return nil
  4000. }
  4001. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4002. }
  4003. // ClearedFields returns all nullable fields that were cleared during this
  4004. // mutation.
  4005. func (m *AllocAgentMutation) ClearedFields() []string {
  4006. var fields []string
  4007. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4008. fields = append(fields, allocagent.FieldDeletedAt)
  4009. }
  4010. if m.FieldCleared(allocagent.FieldUserID) {
  4011. fields = append(fields, allocagent.FieldUserID)
  4012. }
  4013. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4014. fields = append(fields, allocagent.FieldOrganizationID)
  4015. }
  4016. if m.FieldCleared(allocagent.FieldStatus) {
  4017. fields = append(fields, allocagent.FieldStatus)
  4018. }
  4019. return fields
  4020. }
  4021. // FieldCleared returns a boolean indicating if a field with the given name was
  4022. // cleared in this mutation.
  4023. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4024. _, ok := m.clearedFields[name]
  4025. return ok
  4026. }
  4027. // ClearField clears the value of the field with the given name. It returns an
  4028. // error if the field is not defined in the schema.
  4029. func (m *AllocAgentMutation) ClearField(name string) error {
  4030. switch name {
  4031. case allocagent.FieldDeletedAt:
  4032. m.ClearDeletedAt()
  4033. return nil
  4034. case allocagent.FieldUserID:
  4035. m.ClearUserID()
  4036. return nil
  4037. case allocagent.FieldOrganizationID:
  4038. m.ClearOrganizationID()
  4039. return nil
  4040. case allocagent.FieldStatus:
  4041. m.ClearStatus()
  4042. return nil
  4043. }
  4044. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4045. }
  4046. // ResetField resets all changes in the mutation for the field with the given name.
  4047. // It returns an error if the field is not defined in the schema.
  4048. func (m *AllocAgentMutation) ResetField(name string) error {
  4049. switch name {
  4050. case allocagent.FieldCreatedAt:
  4051. m.ResetCreatedAt()
  4052. return nil
  4053. case allocagent.FieldUpdatedAt:
  4054. m.ResetUpdatedAt()
  4055. return nil
  4056. case allocagent.FieldDeletedAt:
  4057. m.ResetDeletedAt()
  4058. return nil
  4059. case allocagent.FieldUserID:
  4060. m.ResetUserID()
  4061. return nil
  4062. case allocagent.FieldOrganizationID:
  4063. m.ResetOrganizationID()
  4064. return nil
  4065. case allocagent.FieldAgents:
  4066. m.ResetAgents()
  4067. return nil
  4068. case allocagent.FieldStatus:
  4069. m.ResetStatus()
  4070. return nil
  4071. }
  4072. return fmt.Errorf("unknown AllocAgent field %s", name)
  4073. }
  4074. // AddedEdges returns all edge names that were set/added in this mutation.
  4075. func (m *AllocAgentMutation) AddedEdges() []string {
  4076. edges := make([]string, 0, 0)
  4077. return edges
  4078. }
  4079. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4080. // name in this mutation.
  4081. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4082. return nil
  4083. }
  4084. // RemovedEdges returns all edge names that were removed in this mutation.
  4085. func (m *AllocAgentMutation) RemovedEdges() []string {
  4086. edges := make([]string, 0, 0)
  4087. return edges
  4088. }
  4089. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4090. // the given name in this mutation.
  4091. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4092. return nil
  4093. }
  4094. // ClearedEdges returns all edge names that were cleared in this mutation.
  4095. func (m *AllocAgentMutation) ClearedEdges() []string {
  4096. edges := make([]string, 0, 0)
  4097. return edges
  4098. }
  4099. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4100. // was cleared in this mutation.
  4101. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4102. return false
  4103. }
  4104. // ClearEdge clears the value of the edge with the given name. It returns an error
  4105. // if that edge is not defined in the schema.
  4106. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4107. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4108. }
  4109. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4110. // It returns an error if the edge is not defined in the schema.
  4111. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4112. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4113. }
  4114. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4115. type ApiKeyMutation struct {
  4116. config
  4117. op Op
  4118. typ string
  4119. id *uint64
  4120. created_at *time.Time
  4121. updated_at *time.Time
  4122. deleted_at *time.Time
  4123. title *string
  4124. key *string
  4125. organization_id *uint64
  4126. addorganization_id *int64
  4127. custom_agent_base *string
  4128. custom_agent_key *string
  4129. openai_base *string
  4130. openai_key *string
  4131. clearedFields map[string]struct{}
  4132. agent *uint64
  4133. clearedagent bool
  4134. done bool
  4135. oldValue func(context.Context) (*ApiKey, error)
  4136. predicates []predicate.ApiKey
  4137. }
  4138. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4139. // apikeyOption allows management of the mutation configuration using functional options.
  4140. type apikeyOption func(*ApiKeyMutation)
  4141. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4142. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4143. m := &ApiKeyMutation{
  4144. config: c,
  4145. op: op,
  4146. typ: TypeApiKey,
  4147. clearedFields: make(map[string]struct{}),
  4148. }
  4149. for _, opt := range opts {
  4150. opt(m)
  4151. }
  4152. return m
  4153. }
  4154. // withApiKeyID sets the ID field of the mutation.
  4155. func withApiKeyID(id uint64) apikeyOption {
  4156. return func(m *ApiKeyMutation) {
  4157. var (
  4158. err error
  4159. once sync.Once
  4160. value *ApiKey
  4161. )
  4162. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4163. once.Do(func() {
  4164. if m.done {
  4165. err = errors.New("querying old values post mutation is not allowed")
  4166. } else {
  4167. value, err = m.Client().ApiKey.Get(ctx, id)
  4168. }
  4169. })
  4170. return value, err
  4171. }
  4172. m.id = &id
  4173. }
  4174. }
  4175. // withApiKey sets the old ApiKey of the mutation.
  4176. func withApiKey(node *ApiKey) apikeyOption {
  4177. return func(m *ApiKeyMutation) {
  4178. m.oldValue = func(context.Context) (*ApiKey, error) {
  4179. return node, nil
  4180. }
  4181. m.id = &node.ID
  4182. }
  4183. }
  4184. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4185. // executed in a transaction (ent.Tx), a transactional client is returned.
  4186. func (m ApiKeyMutation) Client() *Client {
  4187. client := &Client{config: m.config}
  4188. client.init()
  4189. return client
  4190. }
  4191. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4192. // it returns an error otherwise.
  4193. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4194. if _, ok := m.driver.(*txDriver); !ok {
  4195. return nil, errors.New("ent: mutation is not running in a transaction")
  4196. }
  4197. tx := &Tx{config: m.config}
  4198. tx.init()
  4199. return tx, nil
  4200. }
  4201. // SetID sets the value of the id field. Note that this
  4202. // operation is only accepted on creation of ApiKey entities.
  4203. func (m *ApiKeyMutation) SetID(id uint64) {
  4204. m.id = &id
  4205. }
  4206. // ID returns the ID value in the mutation. Note that the ID is only available
  4207. // if it was provided to the builder or after it was returned from the database.
  4208. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4209. if m.id == nil {
  4210. return
  4211. }
  4212. return *m.id, true
  4213. }
  4214. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4215. // That means, if the mutation is applied within a transaction with an isolation level such
  4216. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4217. // or updated by the mutation.
  4218. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4219. switch {
  4220. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4221. id, exists := m.ID()
  4222. if exists {
  4223. return []uint64{id}, nil
  4224. }
  4225. fallthrough
  4226. case m.op.Is(OpUpdate | OpDelete):
  4227. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4228. default:
  4229. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4230. }
  4231. }
  4232. // SetCreatedAt sets the "created_at" field.
  4233. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4234. m.created_at = &t
  4235. }
  4236. // CreatedAt returns the value of the "created_at" field in the mutation.
  4237. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4238. v := m.created_at
  4239. if v == nil {
  4240. return
  4241. }
  4242. return *v, true
  4243. }
  4244. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4245. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4247. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4248. if !m.op.Is(OpUpdateOne) {
  4249. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4250. }
  4251. if m.id == nil || m.oldValue == nil {
  4252. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4253. }
  4254. oldValue, err := m.oldValue(ctx)
  4255. if err != nil {
  4256. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4257. }
  4258. return oldValue.CreatedAt, nil
  4259. }
  4260. // ResetCreatedAt resets all changes to the "created_at" field.
  4261. func (m *ApiKeyMutation) ResetCreatedAt() {
  4262. m.created_at = nil
  4263. }
  4264. // SetUpdatedAt sets the "updated_at" field.
  4265. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4266. m.updated_at = &t
  4267. }
  4268. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4269. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4270. v := m.updated_at
  4271. if v == nil {
  4272. return
  4273. }
  4274. return *v, true
  4275. }
  4276. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4277. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4279. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4280. if !m.op.Is(OpUpdateOne) {
  4281. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4282. }
  4283. if m.id == nil || m.oldValue == nil {
  4284. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4285. }
  4286. oldValue, err := m.oldValue(ctx)
  4287. if err != nil {
  4288. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4289. }
  4290. return oldValue.UpdatedAt, nil
  4291. }
  4292. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4293. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4294. m.updated_at = nil
  4295. }
  4296. // SetDeletedAt sets the "deleted_at" field.
  4297. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4298. m.deleted_at = &t
  4299. }
  4300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4301. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4302. v := m.deleted_at
  4303. if v == nil {
  4304. return
  4305. }
  4306. return *v, true
  4307. }
  4308. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4309. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4311. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4312. if !m.op.Is(OpUpdateOne) {
  4313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4314. }
  4315. if m.id == nil || m.oldValue == nil {
  4316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4317. }
  4318. oldValue, err := m.oldValue(ctx)
  4319. if err != nil {
  4320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4321. }
  4322. return oldValue.DeletedAt, nil
  4323. }
  4324. // ClearDeletedAt clears the value of the "deleted_at" field.
  4325. func (m *ApiKeyMutation) ClearDeletedAt() {
  4326. m.deleted_at = nil
  4327. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4328. }
  4329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4330. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4331. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4332. return ok
  4333. }
  4334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4335. func (m *ApiKeyMutation) ResetDeletedAt() {
  4336. m.deleted_at = nil
  4337. delete(m.clearedFields, apikey.FieldDeletedAt)
  4338. }
  4339. // SetTitle sets the "title" field.
  4340. func (m *ApiKeyMutation) SetTitle(s string) {
  4341. m.title = &s
  4342. }
  4343. // Title returns the value of the "title" field in the mutation.
  4344. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4345. v := m.title
  4346. if v == nil {
  4347. return
  4348. }
  4349. return *v, true
  4350. }
  4351. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4352. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4354. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4355. if !m.op.Is(OpUpdateOne) {
  4356. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4357. }
  4358. if m.id == nil || m.oldValue == nil {
  4359. return v, errors.New("OldTitle requires an ID field in the mutation")
  4360. }
  4361. oldValue, err := m.oldValue(ctx)
  4362. if err != nil {
  4363. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4364. }
  4365. return oldValue.Title, nil
  4366. }
  4367. // ClearTitle clears the value of the "title" field.
  4368. func (m *ApiKeyMutation) ClearTitle() {
  4369. m.title = nil
  4370. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4371. }
  4372. // TitleCleared returns if the "title" field was cleared in this mutation.
  4373. func (m *ApiKeyMutation) TitleCleared() bool {
  4374. _, ok := m.clearedFields[apikey.FieldTitle]
  4375. return ok
  4376. }
  4377. // ResetTitle resets all changes to the "title" field.
  4378. func (m *ApiKeyMutation) ResetTitle() {
  4379. m.title = nil
  4380. delete(m.clearedFields, apikey.FieldTitle)
  4381. }
  4382. // SetKey sets the "key" field.
  4383. func (m *ApiKeyMutation) SetKey(s string) {
  4384. m.key = &s
  4385. }
  4386. // Key returns the value of the "key" field in the mutation.
  4387. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4388. v := m.key
  4389. if v == nil {
  4390. return
  4391. }
  4392. return *v, true
  4393. }
  4394. // OldKey returns the old "key" field's value of the ApiKey entity.
  4395. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4397. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4398. if !m.op.Is(OpUpdateOne) {
  4399. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4400. }
  4401. if m.id == nil || m.oldValue == nil {
  4402. return v, errors.New("OldKey requires an ID field in the mutation")
  4403. }
  4404. oldValue, err := m.oldValue(ctx)
  4405. if err != nil {
  4406. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4407. }
  4408. return oldValue.Key, nil
  4409. }
  4410. // ClearKey clears the value of the "key" field.
  4411. func (m *ApiKeyMutation) ClearKey() {
  4412. m.key = nil
  4413. m.clearedFields[apikey.FieldKey] = struct{}{}
  4414. }
  4415. // KeyCleared returns if the "key" field was cleared in this mutation.
  4416. func (m *ApiKeyMutation) KeyCleared() bool {
  4417. _, ok := m.clearedFields[apikey.FieldKey]
  4418. return ok
  4419. }
  4420. // ResetKey resets all changes to the "key" field.
  4421. func (m *ApiKeyMutation) ResetKey() {
  4422. m.key = nil
  4423. delete(m.clearedFields, apikey.FieldKey)
  4424. }
  4425. // SetOrganizationID sets the "organization_id" field.
  4426. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4427. m.organization_id = &u
  4428. m.addorganization_id = nil
  4429. }
  4430. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4431. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4432. v := m.organization_id
  4433. if v == nil {
  4434. return
  4435. }
  4436. return *v, true
  4437. }
  4438. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4439. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4441. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4442. if !m.op.Is(OpUpdateOne) {
  4443. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4444. }
  4445. if m.id == nil || m.oldValue == nil {
  4446. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4447. }
  4448. oldValue, err := m.oldValue(ctx)
  4449. if err != nil {
  4450. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4451. }
  4452. return oldValue.OrganizationID, nil
  4453. }
  4454. // AddOrganizationID adds u to the "organization_id" field.
  4455. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4456. if m.addorganization_id != nil {
  4457. *m.addorganization_id += u
  4458. } else {
  4459. m.addorganization_id = &u
  4460. }
  4461. }
  4462. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4463. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4464. v := m.addorganization_id
  4465. if v == nil {
  4466. return
  4467. }
  4468. return *v, true
  4469. }
  4470. // ResetOrganizationID resets all changes to the "organization_id" field.
  4471. func (m *ApiKeyMutation) ResetOrganizationID() {
  4472. m.organization_id = nil
  4473. m.addorganization_id = nil
  4474. }
  4475. // SetAgentID sets the "agent_id" field.
  4476. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4477. m.agent = &u
  4478. }
  4479. // AgentID returns the value of the "agent_id" field in the mutation.
  4480. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4481. v := m.agent
  4482. if v == nil {
  4483. return
  4484. }
  4485. return *v, true
  4486. }
  4487. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4488. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4490. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4491. if !m.op.Is(OpUpdateOne) {
  4492. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4493. }
  4494. if m.id == nil || m.oldValue == nil {
  4495. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4496. }
  4497. oldValue, err := m.oldValue(ctx)
  4498. if err != nil {
  4499. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4500. }
  4501. return oldValue.AgentID, nil
  4502. }
  4503. // ResetAgentID resets all changes to the "agent_id" field.
  4504. func (m *ApiKeyMutation) ResetAgentID() {
  4505. m.agent = nil
  4506. }
  4507. // SetCustomAgentBase sets the "custom_agent_base" field.
  4508. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4509. m.custom_agent_base = &s
  4510. }
  4511. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4512. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4513. v := m.custom_agent_base
  4514. if v == nil {
  4515. return
  4516. }
  4517. return *v, true
  4518. }
  4519. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4520. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4522. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4523. if !m.op.Is(OpUpdateOne) {
  4524. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4525. }
  4526. if m.id == nil || m.oldValue == nil {
  4527. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4528. }
  4529. oldValue, err := m.oldValue(ctx)
  4530. if err != nil {
  4531. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4532. }
  4533. return oldValue.CustomAgentBase, nil
  4534. }
  4535. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4536. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4537. m.custom_agent_base = nil
  4538. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4539. }
  4540. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4541. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4542. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4543. return ok
  4544. }
  4545. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4546. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4547. m.custom_agent_base = nil
  4548. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4549. }
  4550. // SetCustomAgentKey sets the "custom_agent_key" field.
  4551. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4552. m.custom_agent_key = &s
  4553. }
  4554. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4555. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4556. v := m.custom_agent_key
  4557. if v == nil {
  4558. return
  4559. }
  4560. return *v, true
  4561. }
  4562. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4563. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4565. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4566. if !m.op.Is(OpUpdateOne) {
  4567. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4568. }
  4569. if m.id == nil || m.oldValue == nil {
  4570. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4571. }
  4572. oldValue, err := m.oldValue(ctx)
  4573. if err != nil {
  4574. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4575. }
  4576. return oldValue.CustomAgentKey, nil
  4577. }
  4578. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4579. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4580. m.custom_agent_key = nil
  4581. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4582. }
  4583. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4584. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4585. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4586. return ok
  4587. }
  4588. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4589. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4590. m.custom_agent_key = nil
  4591. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4592. }
  4593. // SetOpenaiBase sets the "openai_base" field.
  4594. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4595. m.openai_base = &s
  4596. }
  4597. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4598. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4599. v := m.openai_base
  4600. if v == nil {
  4601. return
  4602. }
  4603. return *v, true
  4604. }
  4605. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4606. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4608. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4609. if !m.op.Is(OpUpdateOne) {
  4610. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4611. }
  4612. if m.id == nil || m.oldValue == nil {
  4613. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4614. }
  4615. oldValue, err := m.oldValue(ctx)
  4616. if err != nil {
  4617. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4618. }
  4619. return oldValue.OpenaiBase, nil
  4620. }
  4621. // ClearOpenaiBase clears the value of the "openai_base" field.
  4622. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4623. m.openai_base = nil
  4624. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4625. }
  4626. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4627. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4628. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4629. return ok
  4630. }
  4631. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4632. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4633. m.openai_base = nil
  4634. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4635. }
  4636. // SetOpenaiKey sets the "openai_key" field.
  4637. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4638. m.openai_key = &s
  4639. }
  4640. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4641. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4642. v := m.openai_key
  4643. if v == nil {
  4644. return
  4645. }
  4646. return *v, true
  4647. }
  4648. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4649. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4651. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4652. if !m.op.Is(OpUpdateOne) {
  4653. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4654. }
  4655. if m.id == nil || m.oldValue == nil {
  4656. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4657. }
  4658. oldValue, err := m.oldValue(ctx)
  4659. if err != nil {
  4660. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4661. }
  4662. return oldValue.OpenaiKey, nil
  4663. }
  4664. // ClearOpenaiKey clears the value of the "openai_key" field.
  4665. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4666. m.openai_key = nil
  4667. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4668. }
  4669. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4670. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4671. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4672. return ok
  4673. }
  4674. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4675. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4676. m.openai_key = nil
  4677. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4678. }
  4679. // ClearAgent clears the "agent" edge to the Agent entity.
  4680. func (m *ApiKeyMutation) ClearAgent() {
  4681. m.clearedagent = true
  4682. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4683. }
  4684. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4685. func (m *ApiKeyMutation) AgentCleared() bool {
  4686. return m.clearedagent
  4687. }
  4688. // AgentIDs returns the "agent" edge IDs in the mutation.
  4689. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4690. // AgentID instead. It exists only for internal usage by the builders.
  4691. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4692. if id := m.agent; id != nil {
  4693. ids = append(ids, *id)
  4694. }
  4695. return
  4696. }
  4697. // ResetAgent resets all changes to the "agent" edge.
  4698. func (m *ApiKeyMutation) ResetAgent() {
  4699. m.agent = nil
  4700. m.clearedagent = false
  4701. }
  4702. // Where appends a list predicates to the ApiKeyMutation builder.
  4703. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4704. m.predicates = append(m.predicates, ps...)
  4705. }
  4706. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4707. // users can use type-assertion to append predicates that do not depend on any generated package.
  4708. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4709. p := make([]predicate.ApiKey, len(ps))
  4710. for i := range ps {
  4711. p[i] = ps[i]
  4712. }
  4713. m.Where(p...)
  4714. }
  4715. // Op returns the operation name.
  4716. func (m *ApiKeyMutation) Op() Op {
  4717. return m.op
  4718. }
  4719. // SetOp allows setting the mutation operation.
  4720. func (m *ApiKeyMutation) SetOp(op Op) {
  4721. m.op = op
  4722. }
  4723. // Type returns the node type of this mutation (ApiKey).
  4724. func (m *ApiKeyMutation) Type() string {
  4725. return m.typ
  4726. }
  4727. // Fields returns all fields that were changed during this mutation. Note that in
  4728. // order to get all numeric fields that were incremented/decremented, call
  4729. // AddedFields().
  4730. func (m *ApiKeyMutation) Fields() []string {
  4731. fields := make([]string, 0, 11)
  4732. if m.created_at != nil {
  4733. fields = append(fields, apikey.FieldCreatedAt)
  4734. }
  4735. if m.updated_at != nil {
  4736. fields = append(fields, apikey.FieldUpdatedAt)
  4737. }
  4738. if m.deleted_at != nil {
  4739. fields = append(fields, apikey.FieldDeletedAt)
  4740. }
  4741. if m.title != nil {
  4742. fields = append(fields, apikey.FieldTitle)
  4743. }
  4744. if m.key != nil {
  4745. fields = append(fields, apikey.FieldKey)
  4746. }
  4747. if m.organization_id != nil {
  4748. fields = append(fields, apikey.FieldOrganizationID)
  4749. }
  4750. if m.agent != nil {
  4751. fields = append(fields, apikey.FieldAgentID)
  4752. }
  4753. if m.custom_agent_base != nil {
  4754. fields = append(fields, apikey.FieldCustomAgentBase)
  4755. }
  4756. if m.custom_agent_key != nil {
  4757. fields = append(fields, apikey.FieldCustomAgentKey)
  4758. }
  4759. if m.openai_base != nil {
  4760. fields = append(fields, apikey.FieldOpenaiBase)
  4761. }
  4762. if m.openai_key != nil {
  4763. fields = append(fields, apikey.FieldOpenaiKey)
  4764. }
  4765. return fields
  4766. }
  4767. // Field returns the value of a field with the given name. The second boolean
  4768. // return value indicates that this field was not set, or was not defined in the
  4769. // schema.
  4770. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4771. switch name {
  4772. case apikey.FieldCreatedAt:
  4773. return m.CreatedAt()
  4774. case apikey.FieldUpdatedAt:
  4775. return m.UpdatedAt()
  4776. case apikey.FieldDeletedAt:
  4777. return m.DeletedAt()
  4778. case apikey.FieldTitle:
  4779. return m.Title()
  4780. case apikey.FieldKey:
  4781. return m.Key()
  4782. case apikey.FieldOrganizationID:
  4783. return m.OrganizationID()
  4784. case apikey.FieldAgentID:
  4785. return m.AgentID()
  4786. case apikey.FieldCustomAgentBase:
  4787. return m.CustomAgentBase()
  4788. case apikey.FieldCustomAgentKey:
  4789. return m.CustomAgentKey()
  4790. case apikey.FieldOpenaiBase:
  4791. return m.OpenaiBase()
  4792. case apikey.FieldOpenaiKey:
  4793. return m.OpenaiKey()
  4794. }
  4795. return nil, false
  4796. }
  4797. // OldField returns the old value of the field from the database. An error is
  4798. // returned if the mutation operation is not UpdateOne, or the query to the
  4799. // database failed.
  4800. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4801. switch name {
  4802. case apikey.FieldCreatedAt:
  4803. return m.OldCreatedAt(ctx)
  4804. case apikey.FieldUpdatedAt:
  4805. return m.OldUpdatedAt(ctx)
  4806. case apikey.FieldDeletedAt:
  4807. return m.OldDeletedAt(ctx)
  4808. case apikey.FieldTitle:
  4809. return m.OldTitle(ctx)
  4810. case apikey.FieldKey:
  4811. return m.OldKey(ctx)
  4812. case apikey.FieldOrganizationID:
  4813. return m.OldOrganizationID(ctx)
  4814. case apikey.FieldAgentID:
  4815. return m.OldAgentID(ctx)
  4816. case apikey.FieldCustomAgentBase:
  4817. return m.OldCustomAgentBase(ctx)
  4818. case apikey.FieldCustomAgentKey:
  4819. return m.OldCustomAgentKey(ctx)
  4820. case apikey.FieldOpenaiBase:
  4821. return m.OldOpenaiBase(ctx)
  4822. case apikey.FieldOpenaiKey:
  4823. return m.OldOpenaiKey(ctx)
  4824. }
  4825. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4826. }
  4827. // SetField sets the value of a field with the given name. It returns an error if
  4828. // the field is not defined in the schema, or if the type mismatched the field
  4829. // type.
  4830. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4831. switch name {
  4832. case apikey.FieldCreatedAt:
  4833. v, ok := value.(time.Time)
  4834. if !ok {
  4835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4836. }
  4837. m.SetCreatedAt(v)
  4838. return nil
  4839. case apikey.FieldUpdatedAt:
  4840. v, ok := value.(time.Time)
  4841. if !ok {
  4842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4843. }
  4844. m.SetUpdatedAt(v)
  4845. return nil
  4846. case apikey.FieldDeletedAt:
  4847. v, ok := value.(time.Time)
  4848. if !ok {
  4849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4850. }
  4851. m.SetDeletedAt(v)
  4852. return nil
  4853. case apikey.FieldTitle:
  4854. v, ok := value.(string)
  4855. if !ok {
  4856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4857. }
  4858. m.SetTitle(v)
  4859. return nil
  4860. case apikey.FieldKey:
  4861. v, ok := value.(string)
  4862. if !ok {
  4863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4864. }
  4865. m.SetKey(v)
  4866. return nil
  4867. case apikey.FieldOrganizationID:
  4868. v, ok := value.(uint64)
  4869. if !ok {
  4870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4871. }
  4872. m.SetOrganizationID(v)
  4873. return nil
  4874. case apikey.FieldAgentID:
  4875. v, ok := value.(uint64)
  4876. if !ok {
  4877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4878. }
  4879. m.SetAgentID(v)
  4880. return nil
  4881. case apikey.FieldCustomAgentBase:
  4882. v, ok := value.(string)
  4883. if !ok {
  4884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4885. }
  4886. m.SetCustomAgentBase(v)
  4887. return nil
  4888. case apikey.FieldCustomAgentKey:
  4889. v, ok := value.(string)
  4890. if !ok {
  4891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4892. }
  4893. m.SetCustomAgentKey(v)
  4894. return nil
  4895. case apikey.FieldOpenaiBase:
  4896. v, ok := value.(string)
  4897. if !ok {
  4898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4899. }
  4900. m.SetOpenaiBase(v)
  4901. return nil
  4902. case apikey.FieldOpenaiKey:
  4903. v, ok := value.(string)
  4904. if !ok {
  4905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4906. }
  4907. m.SetOpenaiKey(v)
  4908. return nil
  4909. }
  4910. return fmt.Errorf("unknown ApiKey field %s", name)
  4911. }
  4912. // AddedFields returns all numeric fields that were incremented/decremented during
  4913. // this mutation.
  4914. func (m *ApiKeyMutation) AddedFields() []string {
  4915. var fields []string
  4916. if m.addorganization_id != nil {
  4917. fields = append(fields, apikey.FieldOrganizationID)
  4918. }
  4919. return fields
  4920. }
  4921. // AddedField returns the numeric value that was incremented/decremented on a field
  4922. // with the given name. The second boolean return value indicates that this field
  4923. // was not set, or was not defined in the schema.
  4924. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4925. switch name {
  4926. case apikey.FieldOrganizationID:
  4927. return m.AddedOrganizationID()
  4928. }
  4929. return nil, false
  4930. }
  4931. // AddField adds the value to the field with the given name. It returns an error if
  4932. // the field is not defined in the schema, or if the type mismatched the field
  4933. // type.
  4934. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4935. switch name {
  4936. case apikey.FieldOrganizationID:
  4937. v, ok := value.(int64)
  4938. if !ok {
  4939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4940. }
  4941. m.AddOrganizationID(v)
  4942. return nil
  4943. }
  4944. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4945. }
  4946. // ClearedFields returns all nullable fields that were cleared during this
  4947. // mutation.
  4948. func (m *ApiKeyMutation) ClearedFields() []string {
  4949. var fields []string
  4950. if m.FieldCleared(apikey.FieldDeletedAt) {
  4951. fields = append(fields, apikey.FieldDeletedAt)
  4952. }
  4953. if m.FieldCleared(apikey.FieldTitle) {
  4954. fields = append(fields, apikey.FieldTitle)
  4955. }
  4956. if m.FieldCleared(apikey.FieldKey) {
  4957. fields = append(fields, apikey.FieldKey)
  4958. }
  4959. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4960. fields = append(fields, apikey.FieldCustomAgentBase)
  4961. }
  4962. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4963. fields = append(fields, apikey.FieldCustomAgentKey)
  4964. }
  4965. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4966. fields = append(fields, apikey.FieldOpenaiBase)
  4967. }
  4968. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4969. fields = append(fields, apikey.FieldOpenaiKey)
  4970. }
  4971. return fields
  4972. }
  4973. // FieldCleared returns a boolean indicating if a field with the given name was
  4974. // cleared in this mutation.
  4975. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4976. _, ok := m.clearedFields[name]
  4977. return ok
  4978. }
  4979. // ClearField clears the value of the field with the given name. It returns an
  4980. // error if the field is not defined in the schema.
  4981. func (m *ApiKeyMutation) ClearField(name string) error {
  4982. switch name {
  4983. case apikey.FieldDeletedAt:
  4984. m.ClearDeletedAt()
  4985. return nil
  4986. case apikey.FieldTitle:
  4987. m.ClearTitle()
  4988. return nil
  4989. case apikey.FieldKey:
  4990. m.ClearKey()
  4991. return nil
  4992. case apikey.FieldCustomAgentBase:
  4993. m.ClearCustomAgentBase()
  4994. return nil
  4995. case apikey.FieldCustomAgentKey:
  4996. m.ClearCustomAgentKey()
  4997. return nil
  4998. case apikey.FieldOpenaiBase:
  4999. m.ClearOpenaiBase()
  5000. return nil
  5001. case apikey.FieldOpenaiKey:
  5002. m.ClearOpenaiKey()
  5003. return nil
  5004. }
  5005. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5006. }
  5007. // ResetField resets all changes in the mutation for the field with the given name.
  5008. // It returns an error if the field is not defined in the schema.
  5009. func (m *ApiKeyMutation) ResetField(name string) error {
  5010. switch name {
  5011. case apikey.FieldCreatedAt:
  5012. m.ResetCreatedAt()
  5013. return nil
  5014. case apikey.FieldUpdatedAt:
  5015. m.ResetUpdatedAt()
  5016. return nil
  5017. case apikey.FieldDeletedAt:
  5018. m.ResetDeletedAt()
  5019. return nil
  5020. case apikey.FieldTitle:
  5021. m.ResetTitle()
  5022. return nil
  5023. case apikey.FieldKey:
  5024. m.ResetKey()
  5025. return nil
  5026. case apikey.FieldOrganizationID:
  5027. m.ResetOrganizationID()
  5028. return nil
  5029. case apikey.FieldAgentID:
  5030. m.ResetAgentID()
  5031. return nil
  5032. case apikey.FieldCustomAgentBase:
  5033. m.ResetCustomAgentBase()
  5034. return nil
  5035. case apikey.FieldCustomAgentKey:
  5036. m.ResetCustomAgentKey()
  5037. return nil
  5038. case apikey.FieldOpenaiBase:
  5039. m.ResetOpenaiBase()
  5040. return nil
  5041. case apikey.FieldOpenaiKey:
  5042. m.ResetOpenaiKey()
  5043. return nil
  5044. }
  5045. return fmt.Errorf("unknown ApiKey field %s", name)
  5046. }
  5047. // AddedEdges returns all edge names that were set/added in this mutation.
  5048. func (m *ApiKeyMutation) AddedEdges() []string {
  5049. edges := make([]string, 0, 1)
  5050. if m.agent != nil {
  5051. edges = append(edges, apikey.EdgeAgent)
  5052. }
  5053. return edges
  5054. }
  5055. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5056. // name in this mutation.
  5057. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5058. switch name {
  5059. case apikey.EdgeAgent:
  5060. if id := m.agent; id != nil {
  5061. return []ent.Value{*id}
  5062. }
  5063. }
  5064. return nil
  5065. }
  5066. // RemovedEdges returns all edge names that were removed in this mutation.
  5067. func (m *ApiKeyMutation) RemovedEdges() []string {
  5068. edges := make([]string, 0, 1)
  5069. return edges
  5070. }
  5071. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5072. // the given name in this mutation.
  5073. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5074. return nil
  5075. }
  5076. // ClearedEdges returns all edge names that were cleared in this mutation.
  5077. func (m *ApiKeyMutation) ClearedEdges() []string {
  5078. edges := make([]string, 0, 1)
  5079. if m.clearedagent {
  5080. edges = append(edges, apikey.EdgeAgent)
  5081. }
  5082. return edges
  5083. }
  5084. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5085. // was cleared in this mutation.
  5086. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5087. switch name {
  5088. case apikey.EdgeAgent:
  5089. return m.clearedagent
  5090. }
  5091. return false
  5092. }
  5093. // ClearEdge clears the value of the edge with the given name. It returns an error
  5094. // if that edge is not defined in the schema.
  5095. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5096. switch name {
  5097. case apikey.EdgeAgent:
  5098. m.ClearAgent()
  5099. return nil
  5100. }
  5101. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5102. }
  5103. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5104. // It returns an error if the edge is not defined in the schema.
  5105. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5106. switch name {
  5107. case apikey.EdgeAgent:
  5108. m.ResetAgent()
  5109. return nil
  5110. }
  5111. return fmt.Errorf("unknown ApiKey edge %s", name)
  5112. }
  5113. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5114. type BatchMsgMutation struct {
  5115. config
  5116. op Op
  5117. typ string
  5118. id *uint64
  5119. created_at *time.Time
  5120. updated_at *time.Time
  5121. deleted_at *time.Time
  5122. status *uint8
  5123. addstatus *int8
  5124. batch_no *string
  5125. task_name *string
  5126. fromwxid *string
  5127. msg *string
  5128. tag *string
  5129. tagids *string
  5130. total *int32
  5131. addtotal *int32
  5132. success *int32
  5133. addsuccess *int32
  5134. fail *int32
  5135. addfail *int32
  5136. start_time *time.Time
  5137. stop_time *time.Time
  5138. send_time *time.Time
  5139. _type *int32
  5140. add_type *int32
  5141. organization_id *uint64
  5142. addorganization_id *int64
  5143. ctype *uint64
  5144. addctype *int64
  5145. cc *string
  5146. phone *string
  5147. template_name *string
  5148. template_code *string
  5149. lang *string
  5150. clearedFields map[string]struct{}
  5151. done bool
  5152. oldValue func(context.Context) (*BatchMsg, error)
  5153. predicates []predicate.BatchMsg
  5154. }
  5155. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5156. // batchmsgOption allows management of the mutation configuration using functional options.
  5157. type batchmsgOption func(*BatchMsgMutation)
  5158. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5159. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5160. m := &BatchMsgMutation{
  5161. config: c,
  5162. op: op,
  5163. typ: TypeBatchMsg,
  5164. clearedFields: make(map[string]struct{}),
  5165. }
  5166. for _, opt := range opts {
  5167. opt(m)
  5168. }
  5169. return m
  5170. }
  5171. // withBatchMsgID sets the ID field of the mutation.
  5172. func withBatchMsgID(id uint64) batchmsgOption {
  5173. return func(m *BatchMsgMutation) {
  5174. var (
  5175. err error
  5176. once sync.Once
  5177. value *BatchMsg
  5178. )
  5179. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5180. once.Do(func() {
  5181. if m.done {
  5182. err = errors.New("querying old values post mutation is not allowed")
  5183. } else {
  5184. value, err = m.Client().BatchMsg.Get(ctx, id)
  5185. }
  5186. })
  5187. return value, err
  5188. }
  5189. m.id = &id
  5190. }
  5191. }
  5192. // withBatchMsg sets the old BatchMsg of the mutation.
  5193. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5194. return func(m *BatchMsgMutation) {
  5195. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5196. return node, nil
  5197. }
  5198. m.id = &node.ID
  5199. }
  5200. }
  5201. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5202. // executed in a transaction (ent.Tx), a transactional client is returned.
  5203. func (m BatchMsgMutation) Client() *Client {
  5204. client := &Client{config: m.config}
  5205. client.init()
  5206. return client
  5207. }
  5208. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5209. // it returns an error otherwise.
  5210. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5211. if _, ok := m.driver.(*txDriver); !ok {
  5212. return nil, errors.New("ent: mutation is not running in a transaction")
  5213. }
  5214. tx := &Tx{config: m.config}
  5215. tx.init()
  5216. return tx, nil
  5217. }
  5218. // SetID sets the value of the id field. Note that this
  5219. // operation is only accepted on creation of BatchMsg entities.
  5220. func (m *BatchMsgMutation) SetID(id uint64) {
  5221. m.id = &id
  5222. }
  5223. // ID returns the ID value in the mutation. Note that the ID is only available
  5224. // if it was provided to the builder or after it was returned from the database.
  5225. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5226. if m.id == nil {
  5227. return
  5228. }
  5229. return *m.id, true
  5230. }
  5231. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5232. // That means, if the mutation is applied within a transaction with an isolation level such
  5233. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5234. // or updated by the mutation.
  5235. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5236. switch {
  5237. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5238. id, exists := m.ID()
  5239. if exists {
  5240. return []uint64{id}, nil
  5241. }
  5242. fallthrough
  5243. case m.op.Is(OpUpdate | OpDelete):
  5244. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5245. default:
  5246. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5247. }
  5248. }
  5249. // SetCreatedAt sets the "created_at" field.
  5250. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5251. m.created_at = &t
  5252. }
  5253. // CreatedAt returns the value of the "created_at" field in the mutation.
  5254. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5255. v := m.created_at
  5256. if v == nil {
  5257. return
  5258. }
  5259. return *v, true
  5260. }
  5261. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5262. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5264. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5265. if !m.op.Is(OpUpdateOne) {
  5266. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5267. }
  5268. if m.id == nil || m.oldValue == nil {
  5269. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5270. }
  5271. oldValue, err := m.oldValue(ctx)
  5272. if err != nil {
  5273. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5274. }
  5275. return oldValue.CreatedAt, nil
  5276. }
  5277. // ResetCreatedAt resets all changes to the "created_at" field.
  5278. func (m *BatchMsgMutation) ResetCreatedAt() {
  5279. m.created_at = nil
  5280. }
  5281. // SetUpdatedAt sets the "updated_at" field.
  5282. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5283. m.updated_at = &t
  5284. }
  5285. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5286. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5287. v := m.updated_at
  5288. if v == nil {
  5289. return
  5290. }
  5291. return *v, true
  5292. }
  5293. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5294. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5296. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5297. if !m.op.Is(OpUpdateOne) {
  5298. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5299. }
  5300. if m.id == nil || m.oldValue == nil {
  5301. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5302. }
  5303. oldValue, err := m.oldValue(ctx)
  5304. if err != nil {
  5305. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5306. }
  5307. return oldValue.UpdatedAt, nil
  5308. }
  5309. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5310. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5311. m.updated_at = nil
  5312. }
  5313. // SetDeletedAt sets the "deleted_at" field.
  5314. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5315. m.deleted_at = &t
  5316. }
  5317. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5318. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5319. v := m.deleted_at
  5320. if v == nil {
  5321. return
  5322. }
  5323. return *v, true
  5324. }
  5325. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5326. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5328. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5329. if !m.op.Is(OpUpdateOne) {
  5330. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5331. }
  5332. if m.id == nil || m.oldValue == nil {
  5333. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5334. }
  5335. oldValue, err := m.oldValue(ctx)
  5336. if err != nil {
  5337. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5338. }
  5339. return oldValue.DeletedAt, nil
  5340. }
  5341. // ClearDeletedAt clears the value of the "deleted_at" field.
  5342. func (m *BatchMsgMutation) ClearDeletedAt() {
  5343. m.deleted_at = nil
  5344. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5345. }
  5346. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5347. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5348. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5349. return ok
  5350. }
  5351. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5352. func (m *BatchMsgMutation) ResetDeletedAt() {
  5353. m.deleted_at = nil
  5354. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5355. }
  5356. // SetStatus sets the "status" field.
  5357. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5358. m.status = &u
  5359. m.addstatus = nil
  5360. }
  5361. // Status returns the value of the "status" field in the mutation.
  5362. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5363. v := m.status
  5364. if v == nil {
  5365. return
  5366. }
  5367. return *v, true
  5368. }
  5369. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5370. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5372. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5373. if !m.op.Is(OpUpdateOne) {
  5374. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5375. }
  5376. if m.id == nil || m.oldValue == nil {
  5377. return v, errors.New("OldStatus requires an ID field in the mutation")
  5378. }
  5379. oldValue, err := m.oldValue(ctx)
  5380. if err != nil {
  5381. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5382. }
  5383. return oldValue.Status, nil
  5384. }
  5385. // AddStatus adds u to the "status" field.
  5386. func (m *BatchMsgMutation) AddStatus(u int8) {
  5387. if m.addstatus != nil {
  5388. *m.addstatus += u
  5389. } else {
  5390. m.addstatus = &u
  5391. }
  5392. }
  5393. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5394. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5395. v := m.addstatus
  5396. if v == nil {
  5397. return
  5398. }
  5399. return *v, true
  5400. }
  5401. // ClearStatus clears the value of the "status" field.
  5402. func (m *BatchMsgMutation) ClearStatus() {
  5403. m.status = nil
  5404. m.addstatus = nil
  5405. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5406. }
  5407. // StatusCleared returns if the "status" field was cleared in this mutation.
  5408. func (m *BatchMsgMutation) StatusCleared() bool {
  5409. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5410. return ok
  5411. }
  5412. // ResetStatus resets all changes to the "status" field.
  5413. func (m *BatchMsgMutation) ResetStatus() {
  5414. m.status = nil
  5415. m.addstatus = nil
  5416. delete(m.clearedFields, batchmsg.FieldStatus)
  5417. }
  5418. // SetBatchNo sets the "batch_no" field.
  5419. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5420. m.batch_no = &s
  5421. }
  5422. // BatchNo returns the value of the "batch_no" field in the mutation.
  5423. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5424. v := m.batch_no
  5425. if v == nil {
  5426. return
  5427. }
  5428. return *v, true
  5429. }
  5430. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5431. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5433. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5434. if !m.op.Is(OpUpdateOne) {
  5435. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5436. }
  5437. if m.id == nil || m.oldValue == nil {
  5438. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5439. }
  5440. oldValue, err := m.oldValue(ctx)
  5441. if err != nil {
  5442. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5443. }
  5444. return oldValue.BatchNo, nil
  5445. }
  5446. // ClearBatchNo clears the value of the "batch_no" field.
  5447. func (m *BatchMsgMutation) ClearBatchNo() {
  5448. m.batch_no = nil
  5449. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5450. }
  5451. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5452. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5453. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5454. return ok
  5455. }
  5456. // ResetBatchNo resets all changes to the "batch_no" field.
  5457. func (m *BatchMsgMutation) ResetBatchNo() {
  5458. m.batch_no = nil
  5459. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5460. }
  5461. // SetTaskName sets the "task_name" field.
  5462. func (m *BatchMsgMutation) SetTaskName(s string) {
  5463. m.task_name = &s
  5464. }
  5465. // TaskName returns the value of the "task_name" field in the mutation.
  5466. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5467. v := m.task_name
  5468. if v == nil {
  5469. return
  5470. }
  5471. return *v, true
  5472. }
  5473. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5474. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5476. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5477. if !m.op.Is(OpUpdateOne) {
  5478. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5479. }
  5480. if m.id == nil || m.oldValue == nil {
  5481. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5482. }
  5483. oldValue, err := m.oldValue(ctx)
  5484. if err != nil {
  5485. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5486. }
  5487. return oldValue.TaskName, nil
  5488. }
  5489. // ClearTaskName clears the value of the "task_name" field.
  5490. func (m *BatchMsgMutation) ClearTaskName() {
  5491. m.task_name = nil
  5492. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5493. }
  5494. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5495. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5496. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5497. return ok
  5498. }
  5499. // ResetTaskName resets all changes to the "task_name" field.
  5500. func (m *BatchMsgMutation) ResetTaskName() {
  5501. m.task_name = nil
  5502. delete(m.clearedFields, batchmsg.FieldTaskName)
  5503. }
  5504. // SetFromwxid sets the "fromwxid" field.
  5505. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5506. m.fromwxid = &s
  5507. }
  5508. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5509. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5510. v := m.fromwxid
  5511. if v == nil {
  5512. return
  5513. }
  5514. return *v, true
  5515. }
  5516. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5517. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5519. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5520. if !m.op.Is(OpUpdateOne) {
  5521. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5522. }
  5523. if m.id == nil || m.oldValue == nil {
  5524. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5525. }
  5526. oldValue, err := m.oldValue(ctx)
  5527. if err != nil {
  5528. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5529. }
  5530. return oldValue.Fromwxid, nil
  5531. }
  5532. // ClearFromwxid clears the value of the "fromwxid" field.
  5533. func (m *BatchMsgMutation) ClearFromwxid() {
  5534. m.fromwxid = nil
  5535. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5536. }
  5537. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5538. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5539. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5540. return ok
  5541. }
  5542. // ResetFromwxid resets all changes to the "fromwxid" field.
  5543. func (m *BatchMsgMutation) ResetFromwxid() {
  5544. m.fromwxid = nil
  5545. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5546. }
  5547. // SetMsg sets the "msg" field.
  5548. func (m *BatchMsgMutation) SetMsg(s string) {
  5549. m.msg = &s
  5550. }
  5551. // Msg returns the value of the "msg" field in the mutation.
  5552. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5553. v := m.msg
  5554. if v == nil {
  5555. return
  5556. }
  5557. return *v, true
  5558. }
  5559. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5560. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5562. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5563. if !m.op.Is(OpUpdateOne) {
  5564. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5565. }
  5566. if m.id == nil || m.oldValue == nil {
  5567. return v, errors.New("OldMsg requires an ID field in the mutation")
  5568. }
  5569. oldValue, err := m.oldValue(ctx)
  5570. if err != nil {
  5571. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5572. }
  5573. return oldValue.Msg, nil
  5574. }
  5575. // ClearMsg clears the value of the "msg" field.
  5576. func (m *BatchMsgMutation) ClearMsg() {
  5577. m.msg = nil
  5578. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5579. }
  5580. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5581. func (m *BatchMsgMutation) MsgCleared() bool {
  5582. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5583. return ok
  5584. }
  5585. // ResetMsg resets all changes to the "msg" field.
  5586. func (m *BatchMsgMutation) ResetMsg() {
  5587. m.msg = nil
  5588. delete(m.clearedFields, batchmsg.FieldMsg)
  5589. }
  5590. // SetTag sets the "tag" field.
  5591. func (m *BatchMsgMutation) SetTag(s string) {
  5592. m.tag = &s
  5593. }
  5594. // Tag returns the value of the "tag" field in the mutation.
  5595. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5596. v := m.tag
  5597. if v == nil {
  5598. return
  5599. }
  5600. return *v, true
  5601. }
  5602. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5603. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5605. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5606. if !m.op.Is(OpUpdateOne) {
  5607. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5608. }
  5609. if m.id == nil || m.oldValue == nil {
  5610. return v, errors.New("OldTag requires an ID field in the mutation")
  5611. }
  5612. oldValue, err := m.oldValue(ctx)
  5613. if err != nil {
  5614. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5615. }
  5616. return oldValue.Tag, nil
  5617. }
  5618. // ClearTag clears the value of the "tag" field.
  5619. func (m *BatchMsgMutation) ClearTag() {
  5620. m.tag = nil
  5621. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5622. }
  5623. // TagCleared returns if the "tag" field was cleared in this mutation.
  5624. func (m *BatchMsgMutation) TagCleared() bool {
  5625. _, ok := m.clearedFields[batchmsg.FieldTag]
  5626. return ok
  5627. }
  5628. // ResetTag resets all changes to the "tag" field.
  5629. func (m *BatchMsgMutation) ResetTag() {
  5630. m.tag = nil
  5631. delete(m.clearedFields, batchmsg.FieldTag)
  5632. }
  5633. // SetTagids sets the "tagids" field.
  5634. func (m *BatchMsgMutation) SetTagids(s string) {
  5635. m.tagids = &s
  5636. }
  5637. // Tagids returns the value of the "tagids" field in the mutation.
  5638. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5639. v := m.tagids
  5640. if v == nil {
  5641. return
  5642. }
  5643. return *v, true
  5644. }
  5645. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5646. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5648. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5649. if !m.op.Is(OpUpdateOne) {
  5650. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5651. }
  5652. if m.id == nil || m.oldValue == nil {
  5653. return v, errors.New("OldTagids requires an ID field in the mutation")
  5654. }
  5655. oldValue, err := m.oldValue(ctx)
  5656. if err != nil {
  5657. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5658. }
  5659. return oldValue.Tagids, nil
  5660. }
  5661. // ClearTagids clears the value of the "tagids" field.
  5662. func (m *BatchMsgMutation) ClearTagids() {
  5663. m.tagids = nil
  5664. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5665. }
  5666. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5667. func (m *BatchMsgMutation) TagidsCleared() bool {
  5668. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5669. return ok
  5670. }
  5671. // ResetTagids resets all changes to the "tagids" field.
  5672. func (m *BatchMsgMutation) ResetTagids() {
  5673. m.tagids = nil
  5674. delete(m.clearedFields, batchmsg.FieldTagids)
  5675. }
  5676. // SetTotal sets the "total" field.
  5677. func (m *BatchMsgMutation) SetTotal(i int32) {
  5678. m.total = &i
  5679. m.addtotal = nil
  5680. }
  5681. // Total returns the value of the "total" field in the mutation.
  5682. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5683. v := m.total
  5684. if v == nil {
  5685. return
  5686. }
  5687. return *v, true
  5688. }
  5689. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5690. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5692. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5693. if !m.op.Is(OpUpdateOne) {
  5694. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5695. }
  5696. if m.id == nil || m.oldValue == nil {
  5697. return v, errors.New("OldTotal requires an ID field in the mutation")
  5698. }
  5699. oldValue, err := m.oldValue(ctx)
  5700. if err != nil {
  5701. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5702. }
  5703. return oldValue.Total, nil
  5704. }
  5705. // AddTotal adds i to the "total" field.
  5706. func (m *BatchMsgMutation) AddTotal(i int32) {
  5707. if m.addtotal != nil {
  5708. *m.addtotal += i
  5709. } else {
  5710. m.addtotal = &i
  5711. }
  5712. }
  5713. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5714. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5715. v := m.addtotal
  5716. if v == nil {
  5717. return
  5718. }
  5719. return *v, true
  5720. }
  5721. // ClearTotal clears the value of the "total" field.
  5722. func (m *BatchMsgMutation) ClearTotal() {
  5723. m.total = nil
  5724. m.addtotal = nil
  5725. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5726. }
  5727. // TotalCleared returns if the "total" field was cleared in this mutation.
  5728. func (m *BatchMsgMutation) TotalCleared() bool {
  5729. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5730. return ok
  5731. }
  5732. // ResetTotal resets all changes to the "total" field.
  5733. func (m *BatchMsgMutation) ResetTotal() {
  5734. m.total = nil
  5735. m.addtotal = nil
  5736. delete(m.clearedFields, batchmsg.FieldTotal)
  5737. }
  5738. // SetSuccess sets the "success" field.
  5739. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5740. m.success = &i
  5741. m.addsuccess = nil
  5742. }
  5743. // Success returns the value of the "success" field in the mutation.
  5744. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5745. v := m.success
  5746. if v == nil {
  5747. return
  5748. }
  5749. return *v, true
  5750. }
  5751. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5752. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5754. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5755. if !m.op.Is(OpUpdateOne) {
  5756. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5757. }
  5758. if m.id == nil || m.oldValue == nil {
  5759. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5760. }
  5761. oldValue, err := m.oldValue(ctx)
  5762. if err != nil {
  5763. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5764. }
  5765. return oldValue.Success, nil
  5766. }
  5767. // AddSuccess adds i to the "success" field.
  5768. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5769. if m.addsuccess != nil {
  5770. *m.addsuccess += i
  5771. } else {
  5772. m.addsuccess = &i
  5773. }
  5774. }
  5775. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5776. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5777. v := m.addsuccess
  5778. if v == nil {
  5779. return
  5780. }
  5781. return *v, true
  5782. }
  5783. // ClearSuccess clears the value of the "success" field.
  5784. func (m *BatchMsgMutation) ClearSuccess() {
  5785. m.success = nil
  5786. m.addsuccess = nil
  5787. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5788. }
  5789. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5790. func (m *BatchMsgMutation) SuccessCleared() bool {
  5791. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5792. return ok
  5793. }
  5794. // ResetSuccess resets all changes to the "success" field.
  5795. func (m *BatchMsgMutation) ResetSuccess() {
  5796. m.success = nil
  5797. m.addsuccess = nil
  5798. delete(m.clearedFields, batchmsg.FieldSuccess)
  5799. }
  5800. // SetFail sets the "fail" field.
  5801. func (m *BatchMsgMutation) SetFail(i int32) {
  5802. m.fail = &i
  5803. m.addfail = nil
  5804. }
  5805. // Fail returns the value of the "fail" field in the mutation.
  5806. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5807. v := m.fail
  5808. if v == nil {
  5809. return
  5810. }
  5811. return *v, true
  5812. }
  5813. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5814. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5816. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5817. if !m.op.Is(OpUpdateOne) {
  5818. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5819. }
  5820. if m.id == nil || m.oldValue == nil {
  5821. return v, errors.New("OldFail requires an ID field in the mutation")
  5822. }
  5823. oldValue, err := m.oldValue(ctx)
  5824. if err != nil {
  5825. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5826. }
  5827. return oldValue.Fail, nil
  5828. }
  5829. // AddFail adds i to the "fail" field.
  5830. func (m *BatchMsgMutation) AddFail(i int32) {
  5831. if m.addfail != nil {
  5832. *m.addfail += i
  5833. } else {
  5834. m.addfail = &i
  5835. }
  5836. }
  5837. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5838. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5839. v := m.addfail
  5840. if v == nil {
  5841. return
  5842. }
  5843. return *v, true
  5844. }
  5845. // ClearFail clears the value of the "fail" field.
  5846. func (m *BatchMsgMutation) ClearFail() {
  5847. m.fail = nil
  5848. m.addfail = nil
  5849. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5850. }
  5851. // FailCleared returns if the "fail" field was cleared in this mutation.
  5852. func (m *BatchMsgMutation) FailCleared() bool {
  5853. _, ok := m.clearedFields[batchmsg.FieldFail]
  5854. return ok
  5855. }
  5856. // ResetFail resets all changes to the "fail" field.
  5857. func (m *BatchMsgMutation) ResetFail() {
  5858. m.fail = nil
  5859. m.addfail = nil
  5860. delete(m.clearedFields, batchmsg.FieldFail)
  5861. }
  5862. // SetStartTime sets the "start_time" field.
  5863. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5864. m.start_time = &t
  5865. }
  5866. // StartTime returns the value of the "start_time" field in the mutation.
  5867. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5868. v := m.start_time
  5869. if v == nil {
  5870. return
  5871. }
  5872. return *v, true
  5873. }
  5874. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5875. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5877. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5878. if !m.op.Is(OpUpdateOne) {
  5879. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5880. }
  5881. if m.id == nil || m.oldValue == nil {
  5882. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5883. }
  5884. oldValue, err := m.oldValue(ctx)
  5885. if err != nil {
  5886. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5887. }
  5888. return oldValue.StartTime, nil
  5889. }
  5890. // ClearStartTime clears the value of the "start_time" field.
  5891. func (m *BatchMsgMutation) ClearStartTime() {
  5892. m.start_time = nil
  5893. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5894. }
  5895. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5896. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5897. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5898. return ok
  5899. }
  5900. // ResetStartTime resets all changes to the "start_time" field.
  5901. func (m *BatchMsgMutation) ResetStartTime() {
  5902. m.start_time = nil
  5903. delete(m.clearedFields, batchmsg.FieldStartTime)
  5904. }
  5905. // SetStopTime sets the "stop_time" field.
  5906. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5907. m.stop_time = &t
  5908. }
  5909. // StopTime returns the value of the "stop_time" field in the mutation.
  5910. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5911. v := m.stop_time
  5912. if v == nil {
  5913. return
  5914. }
  5915. return *v, true
  5916. }
  5917. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5918. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5920. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5921. if !m.op.Is(OpUpdateOne) {
  5922. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5923. }
  5924. if m.id == nil || m.oldValue == nil {
  5925. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5926. }
  5927. oldValue, err := m.oldValue(ctx)
  5928. if err != nil {
  5929. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5930. }
  5931. return oldValue.StopTime, nil
  5932. }
  5933. // ClearStopTime clears the value of the "stop_time" field.
  5934. func (m *BatchMsgMutation) ClearStopTime() {
  5935. m.stop_time = nil
  5936. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5937. }
  5938. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5939. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5940. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5941. return ok
  5942. }
  5943. // ResetStopTime resets all changes to the "stop_time" field.
  5944. func (m *BatchMsgMutation) ResetStopTime() {
  5945. m.stop_time = nil
  5946. delete(m.clearedFields, batchmsg.FieldStopTime)
  5947. }
  5948. // SetSendTime sets the "send_time" field.
  5949. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5950. m.send_time = &t
  5951. }
  5952. // SendTime returns the value of the "send_time" field in the mutation.
  5953. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5954. v := m.send_time
  5955. if v == nil {
  5956. return
  5957. }
  5958. return *v, true
  5959. }
  5960. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5961. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5963. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5964. if !m.op.Is(OpUpdateOne) {
  5965. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5966. }
  5967. if m.id == nil || m.oldValue == nil {
  5968. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5969. }
  5970. oldValue, err := m.oldValue(ctx)
  5971. if err != nil {
  5972. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5973. }
  5974. return oldValue.SendTime, nil
  5975. }
  5976. // ClearSendTime clears the value of the "send_time" field.
  5977. func (m *BatchMsgMutation) ClearSendTime() {
  5978. m.send_time = nil
  5979. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5980. }
  5981. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5982. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5983. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5984. return ok
  5985. }
  5986. // ResetSendTime resets all changes to the "send_time" field.
  5987. func (m *BatchMsgMutation) ResetSendTime() {
  5988. m.send_time = nil
  5989. delete(m.clearedFields, batchmsg.FieldSendTime)
  5990. }
  5991. // SetType sets the "type" field.
  5992. func (m *BatchMsgMutation) SetType(i int32) {
  5993. m._type = &i
  5994. m.add_type = nil
  5995. }
  5996. // GetType returns the value of the "type" field in the mutation.
  5997. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  5998. v := m._type
  5999. if v == nil {
  6000. return
  6001. }
  6002. return *v, true
  6003. }
  6004. // OldType returns the old "type" field's value of the BatchMsg entity.
  6005. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6007. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6008. if !m.op.Is(OpUpdateOne) {
  6009. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6010. }
  6011. if m.id == nil || m.oldValue == nil {
  6012. return v, errors.New("OldType requires an ID field in the mutation")
  6013. }
  6014. oldValue, err := m.oldValue(ctx)
  6015. if err != nil {
  6016. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6017. }
  6018. return oldValue.Type, nil
  6019. }
  6020. // AddType adds i to the "type" field.
  6021. func (m *BatchMsgMutation) AddType(i int32) {
  6022. if m.add_type != nil {
  6023. *m.add_type += i
  6024. } else {
  6025. m.add_type = &i
  6026. }
  6027. }
  6028. // AddedType returns the value that was added to the "type" field in this mutation.
  6029. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6030. v := m.add_type
  6031. if v == nil {
  6032. return
  6033. }
  6034. return *v, true
  6035. }
  6036. // ClearType clears the value of the "type" field.
  6037. func (m *BatchMsgMutation) ClearType() {
  6038. m._type = nil
  6039. m.add_type = nil
  6040. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6041. }
  6042. // TypeCleared returns if the "type" field was cleared in this mutation.
  6043. func (m *BatchMsgMutation) TypeCleared() bool {
  6044. _, ok := m.clearedFields[batchmsg.FieldType]
  6045. return ok
  6046. }
  6047. // ResetType resets all changes to the "type" field.
  6048. func (m *BatchMsgMutation) ResetType() {
  6049. m._type = nil
  6050. m.add_type = nil
  6051. delete(m.clearedFields, batchmsg.FieldType)
  6052. }
  6053. // SetOrganizationID sets the "organization_id" field.
  6054. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6055. m.organization_id = &u
  6056. m.addorganization_id = nil
  6057. }
  6058. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6059. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6060. v := m.organization_id
  6061. if v == nil {
  6062. return
  6063. }
  6064. return *v, true
  6065. }
  6066. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6067. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6069. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6070. if !m.op.Is(OpUpdateOne) {
  6071. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6072. }
  6073. if m.id == nil || m.oldValue == nil {
  6074. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6075. }
  6076. oldValue, err := m.oldValue(ctx)
  6077. if err != nil {
  6078. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6079. }
  6080. return oldValue.OrganizationID, nil
  6081. }
  6082. // AddOrganizationID adds u to the "organization_id" field.
  6083. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6084. if m.addorganization_id != nil {
  6085. *m.addorganization_id += u
  6086. } else {
  6087. m.addorganization_id = &u
  6088. }
  6089. }
  6090. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6091. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6092. v := m.addorganization_id
  6093. if v == nil {
  6094. return
  6095. }
  6096. return *v, true
  6097. }
  6098. // ResetOrganizationID resets all changes to the "organization_id" field.
  6099. func (m *BatchMsgMutation) ResetOrganizationID() {
  6100. m.organization_id = nil
  6101. m.addorganization_id = nil
  6102. }
  6103. // SetCtype sets the "ctype" field.
  6104. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6105. m.ctype = &u
  6106. m.addctype = nil
  6107. }
  6108. // Ctype returns the value of the "ctype" field in the mutation.
  6109. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6110. v := m.ctype
  6111. if v == nil {
  6112. return
  6113. }
  6114. return *v, true
  6115. }
  6116. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6117. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6119. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6120. if !m.op.Is(OpUpdateOne) {
  6121. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6122. }
  6123. if m.id == nil || m.oldValue == nil {
  6124. return v, errors.New("OldCtype requires an ID field in the mutation")
  6125. }
  6126. oldValue, err := m.oldValue(ctx)
  6127. if err != nil {
  6128. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6129. }
  6130. return oldValue.Ctype, nil
  6131. }
  6132. // AddCtype adds u to the "ctype" field.
  6133. func (m *BatchMsgMutation) AddCtype(u int64) {
  6134. if m.addctype != nil {
  6135. *m.addctype += u
  6136. } else {
  6137. m.addctype = &u
  6138. }
  6139. }
  6140. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6141. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6142. v := m.addctype
  6143. if v == nil {
  6144. return
  6145. }
  6146. return *v, true
  6147. }
  6148. // ResetCtype resets all changes to the "ctype" field.
  6149. func (m *BatchMsgMutation) ResetCtype() {
  6150. m.ctype = nil
  6151. m.addctype = nil
  6152. }
  6153. // SetCc sets the "cc" field.
  6154. func (m *BatchMsgMutation) SetCc(s string) {
  6155. m.cc = &s
  6156. }
  6157. // Cc returns the value of the "cc" field in the mutation.
  6158. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6159. v := m.cc
  6160. if v == nil {
  6161. return
  6162. }
  6163. return *v, true
  6164. }
  6165. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6166. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6168. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6169. if !m.op.Is(OpUpdateOne) {
  6170. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6171. }
  6172. if m.id == nil || m.oldValue == nil {
  6173. return v, errors.New("OldCc requires an ID field in the mutation")
  6174. }
  6175. oldValue, err := m.oldValue(ctx)
  6176. if err != nil {
  6177. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6178. }
  6179. return oldValue.Cc, nil
  6180. }
  6181. // ClearCc clears the value of the "cc" field.
  6182. func (m *BatchMsgMutation) ClearCc() {
  6183. m.cc = nil
  6184. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6185. }
  6186. // CcCleared returns if the "cc" field was cleared in this mutation.
  6187. func (m *BatchMsgMutation) CcCleared() bool {
  6188. _, ok := m.clearedFields[batchmsg.FieldCc]
  6189. return ok
  6190. }
  6191. // ResetCc resets all changes to the "cc" field.
  6192. func (m *BatchMsgMutation) ResetCc() {
  6193. m.cc = nil
  6194. delete(m.clearedFields, batchmsg.FieldCc)
  6195. }
  6196. // SetPhone sets the "phone" field.
  6197. func (m *BatchMsgMutation) SetPhone(s string) {
  6198. m.phone = &s
  6199. }
  6200. // Phone returns the value of the "phone" field in the mutation.
  6201. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6202. v := m.phone
  6203. if v == nil {
  6204. return
  6205. }
  6206. return *v, true
  6207. }
  6208. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6209. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6211. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6212. if !m.op.Is(OpUpdateOne) {
  6213. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6214. }
  6215. if m.id == nil || m.oldValue == nil {
  6216. return v, errors.New("OldPhone requires an ID field in the mutation")
  6217. }
  6218. oldValue, err := m.oldValue(ctx)
  6219. if err != nil {
  6220. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6221. }
  6222. return oldValue.Phone, nil
  6223. }
  6224. // ClearPhone clears the value of the "phone" field.
  6225. func (m *BatchMsgMutation) ClearPhone() {
  6226. m.phone = nil
  6227. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6228. }
  6229. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6230. func (m *BatchMsgMutation) PhoneCleared() bool {
  6231. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6232. return ok
  6233. }
  6234. // ResetPhone resets all changes to the "phone" field.
  6235. func (m *BatchMsgMutation) ResetPhone() {
  6236. m.phone = nil
  6237. delete(m.clearedFields, batchmsg.FieldPhone)
  6238. }
  6239. // SetTemplateName sets the "template_name" field.
  6240. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6241. m.template_name = &s
  6242. }
  6243. // TemplateName returns the value of the "template_name" field in the mutation.
  6244. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6245. v := m.template_name
  6246. if v == nil {
  6247. return
  6248. }
  6249. return *v, true
  6250. }
  6251. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6252. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6254. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6255. if !m.op.Is(OpUpdateOne) {
  6256. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6257. }
  6258. if m.id == nil || m.oldValue == nil {
  6259. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6260. }
  6261. oldValue, err := m.oldValue(ctx)
  6262. if err != nil {
  6263. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6264. }
  6265. return oldValue.TemplateName, nil
  6266. }
  6267. // ClearTemplateName clears the value of the "template_name" field.
  6268. func (m *BatchMsgMutation) ClearTemplateName() {
  6269. m.template_name = nil
  6270. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6271. }
  6272. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6273. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6274. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6275. return ok
  6276. }
  6277. // ResetTemplateName resets all changes to the "template_name" field.
  6278. func (m *BatchMsgMutation) ResetTemplateName() {
  6279. m.template_name = nil
  6280. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6281. }
  6282. // SetTemplateCode sets the "template_code" field.
  6283. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6284. m.template_code = &s
  6285. }
  6286. // TemplateCode returns the value of the "template_code" field in the mutation.
  6287. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6288. v := m.template_code
  6289. if v == nil {
  6290. return
  6291. }
  6292. return *v, true
  6293. }
  6294. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6295. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6297. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6298. if !m.op.Is(OpUpdateOne) {
  6299. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6300. }
  6301. if m.id == nil || m.oldValue == nil {
  6302. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6303. }
  6304. oldValue, err := m.oldValue(ctx)
  6305. if err != nil {
  6306. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6307. }
  6308. return oldValue.TemplateCode, nil
  6309. }
  6310. // ClearTemplateCode clears the value of the "template_code" field.
  6311. func (m *BatchMsgMutation) ClearTemplateCode() {
  6312. m.template_code = nil
  6313. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6314. }
  6315. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6316. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6317. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6318. return ok
  6319. }
  6320. // ResetTemplateCode resets all changes to the "template_code" field.
  6321. func (m *BatchMsgMutation) ResetTemplateCode() {
  6322. m.template_code = nil
  6323. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6324. }
  6325. // SetLang sets the "lang" field.
  6326. func (m *BatchMsgMutation) SetLang(s string) {
  6327. m.lang = &s
  6328. }
  6329. // Lang returns the value of the "lang" field in the mutation.
  6330. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6331. v := m.lang
  6332. if v == nil {
  6333. return
  6334. }
  6335. return *v, true
  6336. }
  6337. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6338. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6340. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6341. if !m.op.Is(OpUpdateOne) {
  6342. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6343. }
  6344. if m.id == nil || m.oldValue == nil {
  6345. return v, errors.New("OldLang requires an ID field in the mutation")
  6346. }
  6347. oldValue, err := m.oldValue(ctx)
  6348. if err != nil {
  6349. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6350. }
  6351. return oldValue.Lang, nil
  6352. }
  6353. // ClearLang clears the value of the "lang" field.
  6354. func (m *BatchMsgMutation) ClearLang() {
  6355. m.lang = nil
  6356. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6357. }
  6358. // LangCleared returns if the "lang" field was cleared in this mutation.
  6359. func (m *BatchMsgMutation) LangCleared() bool {
  6360. _, ok := m.clearedFields[batchmsg.FieldLang]
  6361. return ok
  6362. }
  6363. // ResetLang resets all changes to the "lang" field.
  6364. func (m *BatchMsgMutation) ResetLang() {
  6365. m.lang = nil
  6366. delete(m.clearedFields, batchmsg.FieldLang)
  6367. }
  6368. // Where appends a list predicates to the BatchMsgMutation builder.
  6369. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6370. m.predicates = append(m.predicates, ps...)
  6371. }
  6372. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6373. // users can use type-assertion to append predicates that do not depend on any generated package.
  6374. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6375. p := make([]predicate.BatchMsg, len(ps))
  6376. for i := range ps {
  6377. p[i] = ps[i]
  6378. }
  6379. m.Where(p...)
  6380. }
  6381. // Op returns the operation name.
  6382. func (m *BatchMsgMutation) Op() Op {
  6383. return m.op
  6384. }
  6385. // SetOp allows setting the mutation operation.
  6386. func (m *BatchMsgMutation) SetOp(op Op) {
  6387. m.op = op
  6388. }
  6389. // Type returns the node type of this mutation (BatchMsg).
  6390. func (m *BatchMsgMutation) Type() string {
  6391. return m.typ
  6392. }
  6393. // Fields returns all fields that were changed during this mutation. Note that in
  6394. // order to get all numeric fields that were incremented/decremented, call
  6395. // AddedFields().
  6396. func (m *BatchMsgMutation) Fields() []string {
  6397. fields := make([]string, 0, 24)
  6398. if m.created_at != nil {
  6399. fields = append(fields, batchmsg.FieldCreatedAt)
  6400. }
  6401. if m.updated_at != nil {
  6402. fields = append(fields, batchmsg.FieldUpdatedAt)
  6403. }
  6404. if m.deleted_at != nil {
  6405. fields = append(fields, batchmsg.FieldDeletedAt)
  6406. }
  6407. if m.status != nil {
  6408. fields = append(fields, batchmsg.FieldStatus)
  6409. }
  6410. if m.batch_no != nil {
  6411. fields = append(fields, batchmsg.FieldBatchNo)
  6412. }
  6413. if m.task_name != nil {
  6414. fields = append(fields, batchmsg.FieldTaskName)
  6415. }
  6416. if m.fromwxid != nil {
  6417. fields = append(fields, batchmsg.FieldFromwxid)
  6418. }
  6419. if m.msg != nil {
  6420. fields = append(fields, batchmsg.FieldMsg)
  6421. }
  6422. if m.tag != nil {
  6423. fields = append(fields, batchmsg.FieldTag)
  6424. }
  6425. if m.tagids != nil {
  6426. fields = append(fields, batchmsg.FieldTagids)
  6427. }
  6428. if m.total != nil {
  6429. fields = append(fields, batchmsg.FieldTotal)
  6430. }
  6431. if m.success != nil {
  6432. fields = append(fields, batchmsg.FieldSuccess)
  6433. }
  6434. if m.fail != nil {
  6435. fields = append(fields, batchmsg.FieldFail)
  6436. }
  6437. if m.start_time != nil {
  6438. fields = append(fields, batchmsg.FieldStartTime)
  6439. }
  6440. if m.stop_time != nil {
  6441. fields = append(fields, batchmsg.FieldStopTime)
  6442. }
  6443. if m.send_time != nil {
  6444. fields = append(fields, batchmsg.FieldSendTime)
  6445. }
  6446. if m._type != nil {
  6447. fields = append(fields, batchmsg.FieldType)
  6448. }
  6449. if m.organization_id != nil {
  6450. fields = append(fields, batchmsg.FieldOrganizationID)
  6451. }
  6452. if m.ctype != nil {
  6453. fields = append(fields, batchmsg.FieldCtype)
  6454. }
  6455. if m.cc != nil {
  6456. fields = append(fields, batchmsg.FieldCc)
  6457. }
  6458. if m.phone != nil {
  6459. fields = append(fields, batchmsg.FieldPhone)
  6460. }
  6461. if m.template_name != nil {
  6462. fields = append(fields, batchmsg.FieldTemplateName)
  6463. }
  6464. if m.template_code != nil {
  6465. fields = append(fields, batchmsg.FieldTemplateCode)
  6466. }
  6467. if m.lang != nil {
  6468. fields = append(fields, batchmsg.FieldLang)
  6469. }
  6470. return fields
  6471. }
  6472. // Field returns the value of a field with the given name. The second boolean
  6473. // return value indicates that this field was not set, or was not defined in the
  6474. // schema.
  6475. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6476. switch name {
  6477. case batchmsg.FieldCreatedAt:
  6478. return m.CreatedAt()
  6479. case batchmsg.FieldUpdatedAt:
  6480. return m.UpdatedAt()
  6481. case batchmsg.FieldDeletedAt:
  6482. return m.DeletedAt()
  6483. case batchmsg.FieldStatus:
  6484. return m.Status()
  6485. case batchmsg.FieldBatchNo:
  6486. return m.BatchNo()
  6487. case batchmsg.FieldTaskName:
  6488. return m.TaskName()
  6489. case batchmsg.FieldFromwxid:
  6490. return m.Fromwxid()
  6491. case batchmsg.FieldMsg:
  6492. return m.Msg()
  6493. case batchmsg.FieldTag:
  6494. return m.Tag()
  6495. case batchmsg.FieldTagids:
  6496. return m.Tagids()
  6497. case batchmsg.FieldTotal:
  6498. return m.Total()
  6499. case batchmsg.FieldSuccess:
  6500. return m.Success()
  6501. case batchmsg.FieldFail:
  6502. return m.Fail()
  6503. case batchmsg.FieldStartTime:
  6504. return m.StartTime()
  6505. case batchmsg.FieldStopTime:
  6506. return m.StopTime()
  6507. case batchmsg.FieldSendTime:
  6508. return m.SendTime()
  6509. case batchmsg.FieldType:
  6510. return m.GetType()
  6511. case batchmsg.FieldOrganizationID:
  6512. return m.OrganizationID()
  6513. case batchmsg.FieldCtype:
  6514. return m.Ctype()
  6515. case batchmsg.FieldCc:
  6516. return m.Cc()
  6517. case batchmsg.FieldPhone:
  6518. return m.Phone()
  6519. case batchmsg.FieldTemplateName:
  6520. return m.TemplateName()
  6521. case batchmsg.FieldTemplateCode:
  6522. return m.TemplateCode()
  6523. case batchmsg.FieldLang:
  6524. return m.Lang()
  6525. }
  6526. return nil, false
  6527. }
  6528. // OldField returns the old value of the field from the database. An error is
  6529. // returned if the mutation operation is not UpdateOne, or the query to the
  6530. // database failed.
  6531. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6532. switch name {
  6533. case batchmsg.FieldCreatedAt:
  6534. return m.OldCreatedAt(ctx)
  6535. case batchmsg.FieldUpdatedAt:
  6536. return m.OldUpdatedAt(ctx)
  6537. case batchmsg.FieldDeletedAt:
  6538. return m.OldDeletedAt(ctx)
  6539. case batchmsg.FieldStatus:
  6540. return m.OldStatus(ctx)
  6541. case batchmsg.FieldBatchNo:
  6542. return m.OldBatchNo(ctx)
  6543. case batchmsg.FieldTaskName:
  6544. return m.OldTaskName(ctx)
  6545. case batchmsg.FieldFromwxid:
  6546. return m.OldFromwxid(ctx)
  6547. case batchmsg.FieldMsg:
  6548. return m.OldMsg(ctx)
  6549. case batchmsg.FieldTag:
  6550. return m.OldTag(ctx)
  6551. case batchmsg.FieldTagids:
  6552. return m.OldTagids(ctx)
  6553. case batchmsg.FieldTotal:
  6554. return m.OldTotal(ctx)
  6555. case batchmsg.FieldSuccess:
  6556. return m.OldSuccess(ctx)
  6557. case batchmsg.FieldFail:
  6558. return m.OldFail(ctx)
  6559. case batchmsg.FieldStartTime:
  6560. return m.OldStartTime(ctx)
  6561. case batchmsg.FieldStopTime:
  6562. return m.OldStopTime(ctx)
  6563. case batchmsg.FieldSendTime:
  6564. return m.OldSendTime(ctx)
  6565. case batchmsg.FieldType:
  6566. return m.OldType(ctx)
  6567. case batchmsg.FieldOrganizationID:
  6568. return m.OldOrganizationID(ctx)
  6569. case batchmsg.FieldCtype:
  6570. return m.OldCtype(ctx)
  6571. case batchmsg.FieldCc:
  6572. return m.OldCc(ctx)
  6573. case batchmsg.FieldPhone:
  6574. return m.OldPhone(ctx)
  6575. case batchmsg.FieldTemplateName:
  6576. return m.OldTemplateName(ctx)
  6577. case batchmsg.FieldTemplateCode:
  6578. return m.OldTemplateCode(ctx)
  6579. case batchmsg.FieldLang:
  6580. return m.OldLang(ctx)
  6581. }
  6582. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6583. }
  6584. // SetField sets the value of a field with the given name. It returns an error if
  6585. // the field is not defined in the schema, or if the type mismatched the field
  6586. // type.
  6587. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6588. switch name {
  6589. case batchmsg.FieldCreatedAt:
  6590. v, ok := value.(time.Time)
  6591. if !ok {
  6592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6593. }
  6594. m.SetCreatedAt(v)
  6595. return nil
  6596. case batchmsg.FieldUpdatedAt:
  6597. v, ok := value.(time.Time)
  6598. if !ok {
  6599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6600. }
  6601. m.SetUpdatedAt(v)
  6602. return nil
  6603. case batchmsg.FieldDeletedAt:
  6604. v, ok := value.(time.Time)
  6605. if !ok {
  6606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6607. }
  6608. m.SetDeletedAt(v)
  6609. return nil
  6610. case batchmsg.FieldStatus:
  6611. v, ok := value.(uint8)
  6612. if !ok {
  6613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6614. }
  6615. m.SetStatus(v)
  6616. return nil
  6617. case batchmsg.FieldBatchNo:
  6618. v, ok := value.(string)
  6619. if !ok {
  6620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6621. }
  6622. m.SetBatchNo(v)
  6623. return nil
  6624. case batchmsg.FieldTaskName:
  6625. v, ok := value.(string)
  6626. if !ok {
  6627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6628. }
  6629. m.SetTaskName(v)
  6630. return nil
  6631. case batchmsg.FieldFromwxid:
  6632. v, ok := value.(string)
  6633. if !ok {
  6634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6635. }
  6636. m.SetFromwxid(v)
  6637. return nil
  6638. case batchmsg.FieldMsg:
  6639. v, ok := value.(string)
  6640. if !ok {
  6641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6642. }
  6643. m.SetMsg(v)
  6644. return nil
  6645. case batchmsg.FieldTag:
  6646. v, ok := value.(string)
  6647. if !ok {
  6648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6649. }
  6650. m.SetTag(v)
  6651. return nil
  6652. case batchmsg.FieldTagids:
  6653. v, ok := value.(string)
  6654. if !ok {
  6655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6656. }
  6657. m.SetTagids(v)
  6658. return nil
  6659. case batchmsg.FieldTotal:
  6660. v, ok := value.(int32)
  6661. if !ok {
  6662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6663. }
  6664. m.SetTotal(v)
  6665. return nil
  6666. case batchmsg.FieldSuccess:
  6667. v, ok := value.(int32)
  6668. if !ok {
  6669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6670. }
  6671. m.SetSuccess(v)
  6672. return nil
  6673. case batchmsg.FieldFail:
  6674. v, ok := value.(int32)
  6675. if !ok {
  6676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6677. }
  6678. m.SetFail(v)
  6679. return nil
  6680. case batchmsg.FieldStartTime:
  6681. v, ok := value.(time.Time)
  6682. if !ok {
  6683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6684. }
  6685. m.SetStartTime(v)
  6686. return nil
  6687. case batchmsg.FieldStopTime:
  6688. v, ok := value.(time.Time)
  6689. if !ok {
  6690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6691. }
  6692. m.SetStopTime(v)
  6693. return nil
  6694. case batchmsg.FieldSendTime:
  6695. v, ok := value.(time.Time)
  6696. if !ok {
  6697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6698. }
  6699. m.SetSendTime(v)
  6700. return nil
  6701. case batchmsg.FieldType:
  6702. v, ok := value.(int32)
  6703. if !ok {
  6704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6705. }
  6706. m.SetType(v)
  6707. return nil
  6708. case batchmsg.FieldOrganizationID:
  6709. v, ok := value.(uint64)
  6710. if !ok {
  6711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6712. }
  6713. m.SetOrganizationID(v)
  6714. return nil
  6715. case batchmsg.FieldCtype:
  6716. v, ok := value.(uint64)
  6717. if !ok {
  6718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6719. }
  6720. m.SetCtype(v)
  6721. return nil
  6722. case batchmsg.FieldCc:
  6723. v, ok := value.(string)
  6724. if !ok {
  6725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6726. }
  6727. m.SetCc(v)
  6728. return nil
  6729. case batchmsg.FieldPhone:
  6730. v, ok := value.(string)
  6731. if !ok {
  6732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6733. }
  6734. m.SetPhone(v)
  6735. return nil
  6736. case batchmsg.FieldTemplateName:
  6737. v, ok := value.(string)
  6738. if !ok {
  6739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6740. }
  6741. m.SetTemplateName(v)
  6742. return nil
  6743. case batchmsg.FieldTemplateCode:
  6744. v, ok := value.(string)
  6745. if !ok {
  6746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6747. }
  6748. m.SetTemplateCode(v)
  6749. return nil
  6750. case batchmsg.FieldLang:
  6751. v, ok := value.(string)
  6752. if !ok {
  6753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6754. }
  6755. m.SetLang(v)
  6756. return nil
  6757. }
  6758. return fmt.Errorf("unknown BatchMsg field %s", name)
  6759. }
  6760. // AddedFields returns all numeric fields that were incremented/decremented during
  6761. // this mutation.
  6762. func (m *BatchMsgMutation) AddedFields() []string {
  6763. var fields []string
  6764. if m.addstatus != nil {
  6765. fields = append(fields, batchmsg.FieldStatus)
  6766. }
  6767. if m.addtotal != nil {
  6768. fields = append(fields, batchmsg.FieldTotal)
  6769. }
  6770. if m.addsuccess != nil {
  6771. fields = append(fields, batchmsg.FieldSuccess)
  6772. }
  6773. if m.addfail != nil {
  6774. fields = append(fields, batchmsg.FieldFail)
  6775. }
  6776. if m.add_type != nil {
  6777. fields = append(fields, batchmsg.FieldType)
  6778. }
  6779. if m.addorganization_id != nil {
  6780. fields = append(fields, batchmsg.FieldOrganizationID)
  6781. }
  6782. if m.addctype != nil {
  6783. fields = append(fields, batchmsg.FieldCtype)
  6784. }
  6785. return fields
  6786. }
  6787. // AddedField returns the numeric value that was incremented/decremented on a field
  6788. // with the given name. The second boolean return value indicates that this field
  6789. // was not set, or was not defined in the schema.
  6790. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6791. switch name {
  6792. case batchmsg.FieldStatus:
  6793. return m.AddedStatus()
  6794. case batchmsg.FieldTotal:
  6795. return m.AddedTotal()
  6796. case batchmsg.FieldSuccess:
  6797. return m.AddedSuccess()
  6798. case batchmsg.FieldFail:
  6799. return m.AddedFail()
  6800. case batchmsg.FieldType:
  6801. return m.AddedType()
  6802. case batchmsg.FieldOrganizationID:
  6803. return m.AddedOrganizationID()
  6804. case batchmsg.FieldCtype:
  6805. return m.AddedCtype()
  6806. }
  6807. return nil, false
  6808. }
  6809. // AddField adds the value to the field with the given name. It returns an error if
  6810. // the field is not defined in the schema, or if the type mismatched the field
  6811. // type.
  6812. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6813. switch name {
  6814. case batchmsg.FieldStatus:
  6815. v, ok := value.(int8)
  6816. if !ok {
  6817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6818. }
  6819. m.AddStatus(v)
  6820. return nil
  6821. case batchmsg.FieldTotal:
  6822. v, ok := value.(int32)
  6823. if !ok {
  6824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6825. }
  6826. m.AddTotal(v)
  6827. return nil
  6828. case batchmsg.FieldSuccess:
  6829. v, ok := value.(int32)
  6830. if !ok {
  6831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6832. }
  6833. m.AddSuccess(v)
  6834. return nil
  6835. case batchmsg.FieldFail:
  6836. v, ok := value.(int32)
  6837. if !ok {
  6838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6839. }
  6840. m.AddFail(v)
  6841. return nil
  6842. case batchmsg.FieldType:
  6843. v, ok := value.(int32)
  6844. if !ok {
  6845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6846. }
  6847. m.AddType(v)
  6848. return nil
  6849. case batchmsg.FieldOrganizationID:
  6850. v, ok := value.(int64)
  6851. if !ok {
  6852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6853. }
  6854. m.AddOrganizationID(v)
  6855. return nil
  6856. case batchmsg.FieldCtype:
  6857. v, ok := value.(int64)
  6858. if !ok {
  6859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6860. }
  6861. m.AddCtype(v)
  6862. return nil
  6863. }
  6864. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6865. }
  6866. // ClearedFields returns all nullable fields that were cleared during this
  6867. // mutation.
  6868. func (m *BatchMsgMutation) ClearedFields() []string {
  6869. var fields []string
  6870. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6871. fields = append(fields, batchmsg.FieldDeletedAt)
  6872. }
  6873. if m.FieldCleared(batchmsg.FieldStatus) {
  6874. fields = append(fields, batchmsg.FieldStatus)
  6875. }
  6876. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6877. fields = append(fields, batchmsg.FieldBatchNo)
  6878. }
  6879. if m.FieldCleared(batchmsg.FieldTaskName) {
  6880. fields = append(fields, batchmsg.FieldTaskName)
  6881. }
  6882. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6883. fields = append(fields, batchmsg.FieldFromwxid)
  6884. }
  6885. if m.FieldCleared(batchmsg.FieldMsg) {
  6886. fields = append(fields, batchmsg.FieldMsg)
  6887. }
  6888. if m.FieldCleared(batchmsg.FieldTag) {
  6889. fields = append(fields, batchmsg.FieldTag)
  6890. }
  6891. if m.FieldCleared(batchmsg.FieldTagids) {
  6892. fields = append(fields, batchmsg.FieldTagids)
  6893. }
  6894. if m.FieldCleared(batchmsg.FieldTotal) {
  6895. fields = append(fields, batchmsg.FieldTotal)
  6896. }
  6897. if m.FieldCleared(batchmsg.FieldSuccess) {
  6898. fields = append(fields, batchmsg.FieldSuccess)
  6899. }
  6900. if m.FieldCleared(batchmsg.FieldFail) {
  6901. fields = append(fields, batchmsg.FieldFail)
  6902. }
  6903. if m.FieldCleared(batchmsg.FieldStartTime) {
  6904. fields = append(fields, batchmsg.FieldStartTime)
  6905. }
  6906. if m.FieldCleared(batchmsg.FieldStopTime) {
  6907. fields = append(fields, batchmsg.FieldStopTime)
  6908. }
  6909. if m.FieldCleared(batchmsg.FieldSendTime) {
  6910. fields = append(fields, batchmsg.FieldSendTime)
  6911. }
  6912. if m.FieldCleared(batchmsg.FieldType) {
  6913. fields = append(fields, batchmsg.FieldType)
  6914. }
  6915. if m.FieldCleared(batchmsg.FieldCc) {
  6916. fields = append(fields, batchmsg.FieldCc)
  6917. }
  6918. if m.FieldCleared(batchmsg.FieldPhone) {
  6919. fields = append(fields, batchmsg.FieldPhone)
  6920. }
  6921. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6922. fields = append(fields, batchmsg.FieldTemplateName)
  6923. }
  6924. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6925. fields = append(fields, batchmsg.FieldTemplateCode)
  6926. }
  6927. if m.FieldCleared(batchmsg.FieldLang) {
  6928. fields = append(fields, batchmsg.FieldLang)
  6929. }
  6930. return fields
  6931. }
  6932. // FieldCleared returns a boolean indicating if a field with the given name was
  6933. // cleared in this mutation.
  6934. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6935. _, ok := m.clearedFields[name]
  6936. return ok
  6937. }
  6938. // ClearField clears the value of the field with the given name. It returns an
  6939. // error if the field is not defined in the schema.
  6940. func (m *BatchMsgMutation) ClearField(name string) error {
  6941. switch name {
  6942. case batchmsg.FieldDeletedAt:
  6943. m.ClearDeletedAt()
  6944. return nil
  6945. case batchmsg.FieldStatus:
  6946. m.ClearStatus()
  6947. return nil
  6948. case batchmsg.FieldBatchNo:
  6949. m.ClearBatchNo()
  6950. return nil
  6951. case batchmsg.FieldTaskName:
  6952. m.ClearTaskName()
  6953. return nil
  6954. case batchmsg.FieldFromwxid:
  6955. m.ClearFromwxid()
  6956. return nil
  6957. case batchmsg.FieldMsg:
  6958. m.ClearMsg()
  6959. return nil
  6960. case batchmsg.FieldTag:
  6961. m.ClearTag()
  6962. return nil
  6963. case batchmsg.FieldTagids:
  6964. m.ClearTagids()
  6965. return nil
  6966. case batchmsg.FieldTotal:
  6967. m.ClearTotal()
  6968. return nil
  6969. case batchmsg.FieldSuccess:
  6970. m.ClearSuccess()
  6971. return nil
  6972. case batchmsg.FieldFail:
  6973. m.ClearFail()
  6974. return nil
  6975. case batchmsg.FieldStartTime:
  6976. m.ClearStartTime()
  6977. return nil
  6978. case batchmsg.FieldStopTime:
  6979. m.ClearStopTime()
  6980. return nil
  6981. case batchmsg.FieldSendTime:
  6982. m.ClearSendTime()
  6983. return nil
  6984. case batchmsg.FieldType:
  6985. m.ClearType()
  6986. return nil
  6987. case batchmsg.FieldCc:
  6988. m.ClearCc()
  6989. return nil
  6990. case batchmsg.FieldPhone:
  6991. m.ClearPhone()
  6992. return nil
  6993. case batchmsg.FieldTemplateName:
  6994. m.ClearTemplateName()
  6995. return nil
  6996. case batchmsg.FieldTemplateCode:
  6997. m.ClearTemplateCode()
  6998. return nil
  6999. case batchmsg.FieldLang:
  7000. m.ClearLang()
  7001. return nil
  7002. }
  7003. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7004. }
  7005. // ResetField resets all changes in the mutation for the field with the given name.
  7006. // It returns an error if the field is not defined in the schema.
  7007. func (m *BatchMsgMutation) ResetField(name string) error {
  7008. switch name {
  7009. case batchmsg.FieldCreatedAt:
  7010. m.ResetCreatedAt()
  7011. return nil
  7012. case batchmsg.FieldUpdatedAt:
  7013. m.ResetUpdatedAt()
  7014. return nil
  7015. case batchmsg.FieldDeletedAt:
  7016. m.ResetDeletedAt()
  7017. return nil
  7018. case batchmsg.FieldStatus:
  7019. m.ResetStatus()
  7020. return nil
  7021. case batchmsg.FieldBatchNo:
  7022. m.ResetBatchNo()
  7023. return nil
  7024. case batchmsg.FieldTaskName:
  7025. m.ResetTaskName()
  7026. return nil
  7027. case batchmsg.FieldFromwxid:
  7028. m.ResetFromwxid()
  7029. return nil
  7030. case batchmsg.FieldMsg:
  7031. m.ResetMsg()
  7032. return nil
  7033. case batchmsg.FieldTag:
  7034. m.ResetTag()
  7035. return nil
  7036. case batchmsg.FieldTagids:
  7037. m.ResetTagids()
  7038. return nil
  7039. case batchmsg.FieldTotal:
  7040. m.ResetTotal()
  7041. return nil
  7042. case batchmsg.FieldSuccess:
  7043. m.ResetSuccess()
  7044. return nil
  7045. case batchmsg.FieldFail:
  7046. m.ResetFail()
  7047. return nil
  7048. case batchmsg.FieldStartTime:
  7049. m.ResetStartTime()
  7050. return nil
  7051. case batchmsg.FieldStopTime:
  7052. m.ResetStopTime()
  7053. return nil
  7054. case batchmsg.FieldSendTime:
  7055. m.ResetSendTime()
  7056. return nil
  7057. case batchmsg.FieldType:
  7058. m.ResetType()
  7059. return nil
  7060. case batchmsg.FieldOrganizationID:
  7061. m.ResetOrganizationID()
  7062. return nil
  7063. case batchmsg.FieldCtype:
  7064. m.ResetCtype()
  7065. return nil
  7066. case batchmsg.FieldCc:
  7067. m.ResetCc()
  7068. return nil
  7069. case batchmsg.FieldPhone:
  7070. m.ResetPhone()
  7071. return nil
  7072. case batchmsg.FieldTemplateName:
  7073. m.ResetTemplateName()
  7074. return nil
  7075. case batchmsg.FieldTemplateCode:
  7076. m.ResetTemplateCode()
  7077. return nil
  7078. case batchmsg.FieldLang:
  7079. m.ResetLang()
  7080. return nil
  7081. }
  7082. return fmt.Errorf("unknown BatchMsg field %s", name)
  7083. }
  7084. // AddedEdges returns all edge names that were set/added in this mutation.
  7085. func (m *BatchMsgMutation) AddedEdges() []string {
  7086. edges := make([]string, 0, 0)
  7087. return edges
  7088. }
  7089. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7090. // name in this mutation.
  7091. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7092. return nil
  7093. }
  7094. // RemovedEdges returns all edge names that were removed in this mutation.
  7095. func (m *BatchMsgMutation) RemovedEdges() []string {
  7096. edges := make([]string, 0, 0)
  7097. return edges
  7098. }
  7099. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7100. // the given name in this mutation.
  7101. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7102. return nil
  7103. }
  7104. // ClearedEdges returns all edge names that were cleared in this mutation.
  7105. func (m *BatchMsgMutation) ClearedEdges() []string {
  7106. edges := make([]string, 0, 0)
  7107. return edges
  7108. }
  7109. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7110. // was cleared in this mutation.
  7111. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7112. return false
  7113. }
  7114. // ClearEdge clears the value of the edge with the given name. It returns an error
  7115. // if that edge is not defined in the schema.
  7116. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7117. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7118. }
  7119. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7120. // It returns an error if the edge is not defined in the schema.
  7121. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7122. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7123. }
  7124. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7125. type CategoryMutation struct {
  7126. config
  7127. op Op
  7128. typ string
  7129. id *uint64
  7130. created_at *time.Time
  7131. updated_at *time.Time
  7132. deleted_at *time.Time
  7133. name *string
  7134. organization_id *uint64
  7135. addorganization_id *int64
  7136. clearedFields map[string]struct{}
  7137. done bool
  7138. oldValue func(context.Context) (*Category, error)
  7139. predicates []predicate.Category
  7140. }
  7141. var _ ent.Mutation = (*CategoryMutation)(nil)
  7142. // categoryOption allows management of the mutation configuration using functional options.
  7143. type categoryOption func(*CategoryMutation)
  7144. // newCategoryMutation creates new mutation for the Category entity.
  7145. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7146. m := &CategoryMutation{
  7147. config: c,
  7148. op: op,
  7149. typ: TypeCategory,
  7150. clearedFields: make(map[string]struct{}),
  7151. }
  7152. for _, opt := range opts {
  7153. opt(m)
  7154. }
  7155. return m
  7156. }
  7157. // withCategoryID sets the ID field of the mutation.
  7158. func withCategoryID(id uint64) categoryOption {
  7159. return func(m *CategoryMutation) {
  7160. var (
  7161. err error
  7162. once sync.Once
  7163. value *Category
  7164. )
  7165. m.oldValue = func(ctx context.Context) (*Category, error) {
  7166. once.Do(func() {
  7167. if m.done {
  7168. err = errors.New("querying old values post mutation is not allowed")
  7169. } else {
  7170. value, err = m.Client().Category.Get(ctx, id)
  7171. }
  7172. })
  7173. return value, err
  7174. }
  7175. m.id = &id
  7176. }
  7177. }
  7178. // withCategory sets the old Category of the mutation.
  7179. func withCategory(node *Category) categoryOption {
  7180. return func(m *CategoryMutation) {
  7181. m.oldValue = func(context.Context) (*Category, error) {
  7182. return node, nil
  7183. }
  7184. m.id = &node.ID
  7185. }
  7186. }
  7187. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7188. // executed in a transaction (ent.Tx), a transactional client is returned.
  7189. func (m CategoryMutation) Client() *Client {
  7190. client := &Client{config: m.config}
  7191. client.init()
  7192. return client
  7193. }
  7194. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7195. // it returns an error otherwise.
  7196. func (m CategoryMutation) Tx() (*Tx, error) {
  7197. if _, ok := m.driver.(*txDriver); !ok {
  7198. return nil, errors.New("ent: mutation is not running in a transaction")
  7199. }
  7200. tx := &Tx{config: m.config}
  7201. tx.init()
  7202. return tx, nil
  7203. }
  7204. // SetID sets the value of the id field. Note that this
  7205. // operation is only accepted on creation of Category entities.
  7206. func (m *CategoryMutation) SetID(id uint64) {
  7207. m.id = &id
  7208. }
  7209. // ID returns the ID value in the mutation. Note that the ID is only available
  7210. // if it was provided to the builder or after it was returned from the database.
  7211. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7212. if m.id == nil {
  7213. return
  7214. }
  7215. return *m.id, true
  7216. }
  7217. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7218. // That means, if the mutation is applied within a transaction with an isolation level such
  7219. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7220. // or updated by the mutation.
  7221. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7222. switch {
  7223. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7224. id, exists := m.ID()
  7225. if exists {
  7226. return []uint64{id}, nil
  7227. }
  7228. fallthrough
  7229. case m.op.Is(OpUpdate | OpDelete):
  7230. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7231. default:
  7232. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7233. }
  7234. }
  7235. // SetCreatedAt sets the "created_at" field.
  7236. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7237. m.created_at = &t
  7238. }
  7239. // CreatedAt returns the value of the "created_at" field in the mutation.
  7240. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7241. v := m.created_at
  7242. if v == nil {
  7243. return
  7244. }
  7245. return *v, true
  7246. }
  7247. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7248. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7250. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7251. if !m.op.Is(OpUpdateOne) {
  7252. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7253. }
  7254. if m.id == nil || m.oldValue == nil {
  7255. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7256. }
  7257. oldValue, err := m.oldValue(ctx)
  7258. if err != nil {
  7259. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7260. }
  7261. return oldValue.CreatedAt, nil
  7262. }
  7263. // ResetCreatedAt resets all changes to the "created_at" field.
  7264. func (m *CategoryMutation) ResetCreatedAt() {
  7265. m.created_at = nil
  7266. }
  7267. // SetUpdatedAt sets the "updated_at" field.
  7268. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7269. m.updated_at = &t
  7270. }
  7271. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7272. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7273. v := m.updated_at
  7274. if v == nil {
  7275. return
  7276. }
  7277. return *v, true
  7278. }
  7279. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7280. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7282. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7283. if !m.op.Is(OpUpdateOne) {
  7284. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7285. }
  7286. if m.id == nil || m.oldValue == nil {
  7287. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7288. }
  7289. oldValue, err := m.oldValue(ctx)
  7290. if err != nil {
  7291. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7292. }
  7293. return oldValue.UpdatedAt, nil
  7294. }
  7295. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7296. func (m *CategoryMutation) ResetUpdatedAt() {
  7297. m.updated_at = nil
  7298. }
  7299. // SetDeletedAt sets the "deleted_at" field.
  7300. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7301. m.deleted_at = &t
  7302. }
  7303. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7304. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7305. v := m.deleted_at
  7306. if v == nil {
  7307. return
  7308. }
  7309. return *v, true
  7310. }
  7311. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7312. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7314. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7315. if !m.op.Is(OpUpdateOne) {
  7316. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7317. }
  7318. if m.id == nil || m.oldValue == nil {
  7319. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7320. }
  7321. oldValue, err := m.oldValue(ctx)
  7322. if err != nil {
  7323. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7324. }
  7325. return oldValue.DeletedAt, nil
  7326. }
  7327. // ClearDeletedAt clears the value of the "deleted_at" field.
  7328. func (m *CategoryMutation) ClearDeletedAt() {
  7329. m.deleted_at = nil
  7330. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7331. }
  7332. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7333. func (m *CategoryMutation) DeletedAtCleared() bool {
  7334. _, ok := m.clearedFields[category.FieldDeletedAt]
  7335. return ok
  7336. }
  7337. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7338. func (m *CategoryMutation) ResetDeletedAt() {
  7339. m.deleted_at = nil
  7340. delete(m.clearedFields, category.FieldDeletedAt)
  7341. }
  7342. // SetName sets the "name" field.
  7343. func (m *CategoryMutation) SetName(s string) {
  7344. m.name = &s
  7345. }
  7346. // Name returns the value of the "name" field in the mutation.
  7347. func (m *CategoryMutation) Name() (r string, exists bool) {
  7348. v := m.name
  7349. if v == nil {
  7350. return
  7351. }
  7352. return *v, true
  7353. }
  7354. // OldName returns the old "name" field's value of the Category entity.
  7355. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7357. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7358. if !m.op.Is(OpUpdateOne) {
  7359. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7360. }
  7361. if m.id == nil || m.oldValue == nil {
  7362. return v, errors.New("OldName requires an ID field in the mutation")
  7363. }
  7364. oldValue, err := m.oldValue(ctx)
  7365. if err != nil {
  7366. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7367. }
  7368. return oldValue.Name, nil
  7369. }
  7370. // ResetName resets all changes to the "name" field.
  7371. func (m *CategoryMutation) ResetName() {
  7372. m.name = nil
  7373. }
  7374. // SetOrganizationID sets the "organization_id" field.
  7375. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7376. m.organization_id = &u
  7377. m.addorganization_id = nil
  7378. }
  7379. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7380. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7381. v := m.organization_id
  7382. if v == nil {
  7383. return
  7384. }
  7385. return *v, true
  7386. }
  7387. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7388. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7390. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7391. if !m.op.Is(OpUpdateOne) {
  7392. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7393. }
  7394. if m.id == nil || m.oldValue == nil {
  7395. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7396. }
  7397. oldValue, err := m.oldValue(ctx)
  7398. if err != nil {
  7399. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7400. }
  7401. return oldValue.OrganizationID, nil
  7402. }
  7403. // AddOrganizationID adds u to the "organization_id" field.
  7404. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7405. if m.addorganization_id != nil {
  7406. *m.addorganization_id += u
  7407. } else {
  7408. m.addorganization_id = &u
  7409. }
  7410. }
  7411. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7412. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7413. v := m.addorganization_id
  7414. if v == nil {
  7415. return
  7416. }
  7417. return *v, true
  7418. }
  7419. // ResetOrganizationID resets all changes to the "organization_id" field.
  7420. func (m *CategoryMutation) ResetOrganizationID() {
  7421. m.organization_id = nil
  7422. m.addorganization_id = nil
  7423. }
  7424. // Where appends a list predicates to the CategoryMutation builder.
  7425. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7426. m.predicates = append(m.predicates, ps...)
  7427. }
  7428. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7429. // users can use type-assertion to append predicates that do not depend on any generated package.
  7430. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7431. p := make([]predicate.Category, len(ps))
  7432. for i := range ps {
  7433. p[i] = ps[i]
  7434. }
  7435. m.Where(p...)
  7436. }
  7437. // Op returns the operation name.
  7438. func (m *CategoryMutation) Op() Op {
  7439. return m.op
  7440. }
  7441. // SetOp allows setting the mutation operation.
  7442. func (m *CategoryMutation) SetOp(op Op) {
  7443. m.op = op
  7444. }
  7445. // Type returns the node type of this mutation (Category).
  7446. func (m *CategoryMutation) Type() string {
  7447. return m.typ
  7448. }
  7449. // Fields returns all fields that were changed during this mutation. Note that in
  7450. // order to get all numeric fields that were incremented/decremented, call
  7451. // AddedFields().
  7452. func (m *CategoryMutation) Fields() []string {
  7453. fields := make([]string, 0, 5)
  7454. if m.created_at != nil {
  7455. fields = append(fields, category.FieldCreatedAt)
  7456. }
  7457. if m.updated_at != nil {
  7458. fields = append(fields, category.FieldUpdatedAt)
  7459. }
  7460. if m.deleted_at != nil {
  7461. fields = append(fields, category.FieldDeletedAt)
  7462. }
  7463. if m.name != nil {
  7464. fields = append(fields, category.FieldName)
  7465. }
  7466. if m.organization_id != nil {
  7467. fields = append(fields, category.FieldOrganizationID)
  7468. }
  7469. return fields
  7470. }
  7471. // Field returns the value of a field with the given name. The second boolean
  7472. // return value indicates that this field was not set, or was not defined in the
  7473. // schema.
  7474. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7475. switch name {
  7476. case category.FieldCreatedAt:
  7477. return m.CreatedAt()
  7478. case category.FieldUpdatedAt:
  7479. return m.UpdatedAt()
  7480. case category.FieldDeletedAt:
  7481. return m.DeletedAt()
  7482. case category.FieldName:
  7483. return m.Name()
  7484. case category.FieldOrganizationID:
  7485. return m.OrganizationID()
  7486. }
  7487. return nil, false
  7488. }
  7489. // OldField returns the old value of the field from the database. An error is
  7490. // returned if the mutation operation is not UpdateOne, or the query to the
  7491. // database failed.
  7492. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7493. switch name {
  7494. case category.FieldCreatedAt:
  7495. return m.OldCreatedAt(ctx)
  7496. case category.FieldUpdatedAt:
  7497. return m.OldUpdatedAt(ctx)
  7498. case category.FieldDeletedAt:
  7499. return m.OldDeletedAt(ctx)
  7500. case category.FieldName:
  7501. return m.OldName(ctx)
  7502. case category.FieldOrganizationID:
  7503. return m.OldOrganizationID(ctx)
  7504. }
  7505. return nil, fmt.Errorf("unknown Category field %s", name)
  7506. }
  7507. // SetField sets the value of a field with the given name. It returns an error if
  7508. // the field is not defined in the schema, or if the type mismatched the field
  7509. // type.
  7510. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7511. switch name {
  7512. case category.FieldCreatedAt:
  7513. v, ok := value.(time.Time)
  7514. if !ok {
  7515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7516. }
  7517. m.SetCreatedAt(v)
  7518. return nil
  7519. case category.FieldUpdatedAt:
  7520. v, ok := value.(time.Time)
  7521. if !ok {
  7522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7523. }
  7524. m.SetUpdatedAt(v)
  7525. return nil
  7526. case category.FieldDeletedAt:
  7527. v, ok := value.(time.Time)
  7528. if !ok {
  7529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7530. }
  7531. m.SetDeletedAt(v)
  7532. return nil
  7533. case category.FieldName:
  7534. v, ok := value.(string)
  7535. if !ok {
  7536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7537. }
  7538. m.SetName(v)
  7539. return nil
  7540. case category.FieldOrganizationID:
  7541. v, ok := value.(uint64)
  7542. if !ok {
  7543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7544. }
  7545. m.SetOrganizationID(v)
  7546. return nil
  7547. }
  7548. return fmt.Errorf("unknown Category field %s", name)
  7549. }
  7550. // AddedFields returns all numeric fields that were incremented/decremented during
  7551. // this mutation.
  7552. func (m *CategoryMutation) AddedFields() []string {
  7553. var fields []string
  7554. if m.addorganization_id != nil {
  7555. fields = append(fields, category.FieldOrganizationID)
  7556. }
  7557. return fields
  7558. }
  7559. // AddedField returns the numeric value that was incremented/decremented on a field
  7560. // with the given name. The second boolean return value indicates that this field
  7561. // was not set, or was not defined in the schema.
  7562. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7563. switch name {
  7564. case category.FieldOrganizationID:
  7565. return m.AddedOrganizationID()
  7566. }
  7567. return nil, false
  7568. }
  7569. // AddField adds the value to the field with the given name. It returns an error if
  7570. // the field is not defined in the schema, or if the type mismatched the field
  7571. // type.
  7572. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7573. switch name {
  7574. case category.FieldOrganizationID:
  7575. v, ok := value.(int64)
  7576. if !ok {
  7577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7578. }
  7579. m.AddOrganizationID(v)
  7580. return nil
  7581. }
  7582. return fmt.Errorf("unknown Category numeric field %s", name)
  7583. }
  7584. // ClearedFields returns all nullable fields that were cleared during this
  7585. // mutation.
  7586. func (m *CategoryMutation) ClearedFields() []string {
  7587. var fields []string
  7588. if m.FieldCleared(category.FieldDeletedAt) {
  7589. fields = append(fields, category.FieldDeletedAt)
  7590. }
  7591. return fields
  7592. }
  7593. // FieldCleared returns a boolean indicating if a field with the given name was
  7594. // cleared in this mutation.
  7595. func (m *CategoryMutation) FieldCleared(name string) bool {
  7596. _, ok := m.clearedFields[name]
  7597. return ok
  7598. }
  7599. // ClearField clears the value of the field with the given name. It returns an
  7600. // error if the field is not defined in the schema.
  7601. func (m *CategoryMutation) ClearField(name string) error {
  7602. switch name {
  7603. case category.FieldDeletedAt:
  7604. m.ClearDeletedAt()
  7605. return nil
  7606. }
  7607. return fmt.Errorf("unknown Category nullable field %s", name)
  7608. }
  7609. // ResetField resets all changes in the mutation for the field with the given name.
  7610. // It returns an error if the field is not defined in the schema.
  7611. func (m *CategoryMutation) ResetField(name string) error {
  7612. switch name {
  7613. case category.FieldCreatedAt:
  7614. m.ResetCreatedAt()
  7615. return nil
  7616. case category.FieldUpdatedAt:
  7617. m.ResetUpdatedAt()
  7618. return nil
  7619. case category.FieldDeletedAt:
  7620. m.ResetDeletedAt()
  7621. return nil
  7622. case category.FieldName:
  7623. m.ResetName()
  7624. return nil
  7625. case category.FieldOrganizationID:
  7626. m.ResetOrganizationID()
  7627. return nil
  7628. }
  7629. return fmt.Errorf("unknown Category field %s", name)
  7630. }
  7631. // AddedEdges returns all edge names that were set/added in this mutation.
  7632. func (m *CategoryMutation) AddedEdges() []string {
  7633. edges := make([]string, 0, 0)
  7634. return edges
  7635. }
  7636. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7637. // name in this mutation.
  7638. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7639. return nil
  7640. }
  7641. // RemovedEdges returns all edge names that were removed in this mutation.
  7642. func (m *CategoryMutation) RemovedEdges() []string {
  7643. edges := make([]string, 0, 0)
  7644. return edges
  7645. }
  7646. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7647. // the given name in this mutation.
  7648. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7649. return nil
  7650. }
  7651. // ClearedEdges returns all edge names that were cleared in this mutation.
  7652. func (m *CategoryMutation) ClearedEdges() []string {
  7653. edges := make([]string, 0, 0)
  7654. return edges
  7655. }
  7656. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7657. // was cleared in this mutation.
  7658. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7659. return false
  7660. }
  7661. // ClearEdge clears the value of the edge with the given name. It returns an error
  7662. // if that edge is not defined in the schema.
  7663. func (m *CategoryMutation) ClearEdge(name string) error {
  7664. return fmt.Errorf("unknown Category unique edge %s", name)
  7665. }
  7666. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7667. // It returns an error if the edge is not defined in the schema.
  7668. func (m *CategoryMutation) ResetEdge(name string) error {
  7669. return fmt.Errorf("unknown Category edge %s", name)
  7670. }
  7671. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7672. type ChatRecordsMutation struct {
  7673. config
  7674. op Op
  7675. typ string
  7676. id *uint64
  7677. created_at *time.Time
  7678. updated_at *time.Time
  7679. deleted_at *time.Time
  7680. content *string
  7681. content_type *uint8
  7682. addcontent_type *int8
  7683. session_id *uint64
  7684. addsession_id *int64
  7685. user_id *uint64
  7686. adduser_id *int64
  7687. bot_id *uint64
  7688. addbot_id *int64
  7689. bot_type *uint8
  7690. addbot_type *int8
  7691. clearedFields map[string]struct{}
  7692. done bool
  7693. oldValue func(context.Context) (*ChatRecords, error)
  7694. predicates []predicate.ChatRecords
  7695. }
  7696. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7697. // chatrecordsOption allows management of the mutation configuration using functional options.
  7698. type chatrecordsOption func(*ChatRecordsMutation)
  7699. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7700. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7701. m := &ChatRecordsMutation{
  7702. config: c,
  7703. op: op,
  7704. typ: TypeChatRecords,
  7705. clearedFields: make(map[string]struct{}),
  7706. }
  7707. for _, opt := range opts {
  7708. opt(m)
  7709. }
  7710. return m
  7711. }
  7712. // withChatRecordsID sets the ID field of the mutation.
  7713. func withChatRecordsID(id uint64) chatrecordsOption {
  7714. return func(m *ChatRecordsMutation) {
  7715. var (
  7716. err error
  7717. once sync.Once
  7718. value *ChatRecords
  7719. )
  7720. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7721. once.Do(func() {
  7722. if m.done {
  7723. err = errors.New("querying old values post mutation is not allowed")
  7724. } else {
  7725. value, err = m.Client().ChatRecords.Get(ctx, id)
  7726. }
  7727. })
  7728. return value, err
  7729. }
  7730. m.id = &id
  7731. }
  7732. }
  7733. // withChatRecords sets the old ChatRecords of the mutation.
  7734. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7735. return func(m *ChatRecordsMutation) {
  7736. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7737. return node, nil
  7738. }
  7739. m.id = &node.ID
  7740. }
  7741. }
  7742. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7743. // executed in a transaction (ent.Tx), a transactional client is returned.
  7744. func (m ChatRecordsMutation) Client() *Client {
  7745. client := &Client{config: m.config}
  7746. client.init()
  7747. return client
  7748. }
  7749. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7750. // it returns an error otherwise.
  7751. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7752. if _, ok := m.driver.(*txDriver); !ok {
  7753. return nil, errors.New("ent: mutation is not running in a transaction")
  7754. }
  7755. tx := &Tx{config: m.config}
  7756. tx.init()
  7757. return tx, nil
  7758. }
  7759. // SetID sets the value of the id field. Note that this
  7760. // operation is only accepted on creation of ChatRecords entities.
  7761. func (m *ChatRecordsMutation) SetID(id uint64) {
  7762. m.id = &id
  7763. }
  7764. // ID returns the ID value in the mutation. Note that the ID is only available
  7765. // if it was provided to the builder or after it was returned from the database.
  7766. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7767. if m.id == nil {
  7768. return
  7769. }
  7770. return *m.id, true
  7771. }
  7772. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7773. // That means, if the mutation is applied within a transaction with an isolation level such
  7774. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7775. // or updated by the mutation.
  7776. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7777. switch {
  7778. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7779. id, exists := m.ID()
  7780. if exists {
  7781. return []uint64{id}, nil
  7782. }
  7783. fallthrough
  7784. case m.op.Is(OpUpdate | OpDelete):
  7785. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7786. default:
  7787. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7788. }
  7789. }
  7790. // SetCreatedAt sets the "created_at" field.
  7791. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7792. m.created_at = &t
  7793. }
  7794. // CreatedAt returns the value of the "created_at" field in the mutation.
  7795. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7796. v := m.created_at
  7797. if v == nil {
  7798. return
  7799. }
  7800. return *v, true
  7801. }
  7802. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7803. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7805. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7806. if !m.op.Is(OpUpdateOne) {
  7807. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7808. }
  7809. if m.id == nil || m.oldValue == nil {
  7810. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7811. }
  7812. oldValue, err := m.oldValue(ctx)
  7813. if err != nil {
  7814. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7815. }
  7816. return oldValue.CreatedAt, nil
  7817. }
  7818. // ResetCreatedAt resets all changes to the "created_at" field.
  7819. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7820. m.created_at = nil
  7821. }
  7822. // SetUpdatedAt sets the "updated_at" field.
  7823. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7824. m.updated_at = &t
  7825. }
  7826. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7827. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7828. v := m.updated_at
  7829. if v == nil {
  7830. return
  7831. }
  7832. return *v, true
  7833. }
  7834. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7835. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7837. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7838. if !m.op.Is(OpUpdateOne) {
  7839. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7840. }
  7841. if m.id == nil || m.oldValue == nil {
  7842. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7843. }
  7844. oldValue, err := m.oldValue(ctx)
  7845. if err != nil {
  7846. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7847. }
  7848. return oldValue.UpdatedAt, nil
  7849. }
  7850. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7851. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7852. m.updated_at = nil
  7853. }
  7854. // SetDeletedAt sets the "deleted_at" field.
  7855. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7856. m.deleted_at = &t
  7857. }
  7858. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7859. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7860. v := m.deleted_at
  7861. if v == nil {
  7862. return
  7863. }
  7864. return *v, true
  7865. }
  7866. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7867. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7869. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7870. if !m.op.Is(OpUpdateOne) {
  7871. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7872. }
  7873. if m.id == nil || m.oldValue == nil {
  7874. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7875. }
  7876. oldValue, err := m.oldValue(ctx)
  7877. if err != nil {
  7878. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7879. }
  7880. return oldValue.DeletedAt, nil
  7881. }
  7882. // ClearDeletedAt clears the value of the "deleted_at" field.
  7883. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7884. m.deleted_at = nil
  7885. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7886. }
  7887. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7888. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7889. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7890. return ok
  7891. }
  7892. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7893. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7894. m.deleted_at = nil
  7895. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7896. }
  7897. // SetContent sets the "content" field.
  7898. func (m *ChatRecordsMutation) SetContent(s string) {
  7899. m.content = &s
  7900. }
  7901. // Content returns the value of the "content" field in the mutation.
  7902. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7903. v := m.content
  7904. if v == nil {
  7905. return
  7906. }
  7907. return *v, true
  7908. }
  7909. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7910. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7912. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7913. if !m.op.Is(OpUpdateOne) {
  7914. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7915. }
  7916. if m.id == nil || m.oldValue == nil {
  7917. return v, errors.New("OldContent requires an ID field in the mutation")
  7918. }
  7919. oldValue, err := m.oldValue(ctx)
  7920. if err != nil {
  7921. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7922. }
  7923. return oldValue.Content, nil
  7924. }
  7925. // ResetContent resets all changes to the "content" field.
  7926. func (m *ChatRecordsMutation) ResetContent() {
  7927. m.content = nil
  7928. }
  7929. // SetContentType sets the "content_type" field.
  7930. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7931. m.content_type = &u
  7932. m.addcontent_type = nil
  7933. }
  7934. // ContentType returns the value of the "content_type" field in the mutation.
  7935. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7936. v := m.content_type
  7937. if v == nil {
  7938. return
  7939. }
  7940. return *v, true
  7941. }
  7942. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7943. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7945. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7946. if !m.op.Is(OpUpdateOne) {
  7947. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7948. }
  7949. if m.id == nil || m.oldValue == nil {
  7950. return v, errors.New("OldContentType requires an ID field in the mutation")
  7951. }
  7952. oldValue, err := m.oldValue(ctx)
  7953. if err != nil {
  7954. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7955. }
  7956. return oldValue.ContentType, nil
  7957. }
  7958. // AddContentType adds u to the "content_type" field.
  7959. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7960. if m.addcontent_type != nil {
  7961. *m.addcontent_type += u
  7962. } else {
  7963. m.addcontent_type = &u
  7964. }
  7965. }
  7966. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7967. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7968. v := m.addcontent_type
  7969. if v == nil {
  7970. return
  7971. }
  7972. return *v, true
  7973. }
  7974. // ResetContentType resets all changes to the "content_type" field.
  7975. func (m *ChatRecordsMutation) ResetContentType() {
  7976. m.content_type = nil
  7977. m.addcontent_type = nil
  7978. }
  7979. // SetSessionID sets the "session_id" field.
  7980. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7981. m.session_id = &u
  7982. m.addsession_id = nil
  7983. }
  7984. // SessionID returns the value of the "session_id" field in the mutation.
  7985. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7986. v := m.session_id
  7987. if v == nil {
  7988. return
  7989. }
  7990. return *v, true
  7991. }
  7992. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7993. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7995. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7996. if !m.op.Is(OpUpdateOne) {
  7997. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  7998. }
  7999. if m.id == nil || m.oldValue == nil {
  8000. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8001. }
  8002. oldValue, err := m.oldValue(ctx)
  8003. if err != nil {
  8004. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8005. }
  8006. return oldValue.SessionID, nil
  8007. }
  8008. // AddSessionID adds u to the "session_id" field.
  8009. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8010. if m.addsession_id != nil {
  8011. *m.addsession_id += u
  8012. } else {
  8013. m.addsession_id = &u
  8014. }
  8015. }
  8016. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8017. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8018. v := m.addsession_id
  8019. if v == nil {
  8020. return
  8021. }
  8022. return *v, true
  8023. }
  8024. // ResetSessionID resets all changes to the "session_id" field.
  8025. func (m *ChatRecordsMutation) ResetSessionID() {
  8026. m.session_id = nil
  8027. m.addsession_id = nil
  8028. }
  8029. // SetUserID sets the "user_id" field.
  8030. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8031. m.user_id = &u
  8032. m.adduser_id = nil
  8033. }
  8034. // UserID returns the value of the "user_id" field in the mutation.
  8035. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8036. v := m.user_id
  8037. if v == nil {
  8038. return
  8039. }
  8040. return *v, true
  8041. }
  8042. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8043. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8045. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8046. if !m.op.Is(OpUpdateOne) {
  8047. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8048. }
  8049. if m.id == nil || m.oldValue == nil {
  8050. return v, errors.New("OldUserID requires an ID field in the mutation")
  8051. }
  8052. oldValue, err := m.oldValue(ctx)
  8053. if err != nil {
  8054. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8055. }
  8056. return oldValue.UserID, nil
  8057. }
  8058. // AddUserID adds u to the "user_id" field.
  8059. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8060. if m.adduser_id != nil {
  8061. *m.adduser_id += u
  8062. } else {
  8063. m.adduser_id = &u
  8064. }
  8065. }
  8066. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8067. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8068. v := m.adduser_id
  8069. if v == nil {
  8070. return
  8071. }
  8072. return *v, true
  8073. }
  8074. // ResetUserID resets all changes to the "user_id" field.
  8075. func (m *ChatRecordsMutation) ResetUserID() {
  8076. m.user_id = nil
  8077. m.adduser_id = nil
  8078. }
  8079. // SetBotID sets the "bot_id" field.
  8080. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8081. m.bot_id = &u
  8082. m.addbot_id = nil
  8083. }
  8084. // BotID returns the value of the "bot_id" field in the mutation.
  8085. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8086. v := m.bot_id
  8087. if v == nil {
  8088. return
  8089. }
  8090. return *v, true
  8091. }
  8092. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8093. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8095. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8096. if !m.op.Is(OpUpdateOne) {
  8097. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8098. }
  8099. if m.id == nil || m.oldValue == nil {
  8100. return v, errors.New("OldBotID requires an ID field in the mutation")
  8101. }
  8102. oldValue, err := m.oldValue(ctx)
  8103. if err != nil {
  8104. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8105. }
  8106. return oldValue.BotID, nil
  8107. }
  8108. // AddBotID adds u to the "bot_id" field.
  8109. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8110. if m.addbot_id != nil {
  8111. *m.addbot_id += u
  8112. } else {
  8113. m.addbot_id = &u
  8114. }
  8115. }
  8116. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8117. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8118. v := m.addbot_id
  8119. if v == nil {
  8120. return
  8121. }
  8122. return *v, true
  8123. }
  8124. // ResetBotID resets all changes to the "bot_id" field.
  8125. func (m *ChatRecordsMutation) ResetBotID() {
  8126. m.bot_id = nil
  8127. m.addbot_id = nil
  8128. }
  8129. // SetBotType sets the "bot_type" field.
  8130. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8131. m.bot_type = &u
  8132. m.addbot_type = nil
  8133. }
  8134. // BotType returns the value of the "bot_type" field in the mutation.
  8135. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8136. v := m.bot_type
  8137. if v == nil {
  8138. return
  8139. }
  8140. return *v, true
  8141. }
  8142. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8143. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8145. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8146. if !m.op.Is(OpUpdateOne) {
  8147. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8148. }
  8149. if m.id == nil || m.oldValue == nil {
  8150. return v, errors.New("OldBotType requires an ID field in the mutation")
  8151. }
  8152. oldValue, err := m.oldValue(ctx)
  8153. if err != nil {
  8154. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8155. }
  8156. return oldValue.BotType, nil
  8157. }
  8158. // AddBotType adds u to the "bot_type" field.
  8159. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8160. if m.addbot_type != nil {
  8161. *m.addbot_type += u
  8162. } else {
  8163. m.addbot_type = &u
  8164. }
  8165. }
  8166. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8167. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8168. v := m.addbot_type
  8169. if v == nil {
  8170. return
  8171. }
  8172. return *v, true
  8173. }
  8174. // ResetBotType resets all changes to the "bot_type" field.
  8175. func (m *ChatRecordsMutation) ResetBotType() {
  8176. m.bot_type = nil
  8177. m.addbot_type = nil
  8178. }
  8179. // Where appends a list predicates to the ChatRecordsMutation builder.
  8180. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8181. m.predicates = append(m.predicates, ps...)
  8182. }
  8183. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8184. // users can use type-assertion to append predicates that do not depend on any generated package.
  8185. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8186. p := make([]predicate.ChatRecords, len(ps))
  8187. for i := range ps {
  8188. p[i] = ps[i]
  8189. }
  8190. m.Where(p...)
  8191. }
  8192. // Op returns the operation name.
  8193. func (m *ChatRecordsMutation) Op() Op {
  8194. return m.op
  8195. }
  8196. // SetOp allows setting the mutation operation.
  8197. func (m *ChatRecordsMutation) SetOp(op Op) {
  8198. m.op = op
  8199. }
  8200. // Type returns the node type of this mutation (ChatRecords).
  8201. func (m *ChatRecordsMutation) Type() string {
  8202. return m.typ
  8203. }
  8204. // Fields returns all fields that were changed during this mutation. Note that in
  8205. // order to get all numeric fields that were incremented/decremented, call
  8206. // AddedFields().
  8207. func (m *ChatRecordsMutation) Fields() []string {
  8208. fields := make([]string, 0, 9)
  8209. if m.created_at != nil {
  8210. fields = append(fields, chatrecords.FieldCreatedAt)
  8211. }
  8212. if m.updated_at != nil {
  8213. fields = append(fields, chatrecords.FieldUpdatedAt)
  8214. }
  8215. if m.deleted_at != nil {
  8216. fields = append(fields, chatrecords.FieldDeletedAt)
  8217. }
  8218. if m.content != nil {
  8219. fields = append(fields, chatrecords.FieldContent)
  8220. }
  8221. if m.content_type != nil {
  8222. fields = append(fields, chatrecords.FieldContentType)
  8223. }
  8224. if m.session_id != nil {
  8225. fields = append(fields, chatrecords.FieldSessionID)
  8226. }
  8227. if m.user_id != nil {
  8228. fields = append(fields, chatrecords.FieldUserID)
  8229. }
  8230. if m.bot_id != nil {
  8231. fields = append(fields, chatrecords.FieldBotID)
  8232. }
  8233. if m.bot_type != nil {
  8234. fields = append(fields, chatrecords.FieldBotType)
  8235. }
  8236. return fields
  8237. }
  8238. // Field returns the value of a field with the given name. The second boolean
  8239. // return value indicates that this field was not set, or was not defined in the
  8240. // schema.
  8241. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8242. switch name {
  8243. case chatrecords.FieldCreatedAt:
  8244. return m.CreatedAt()
  8245. case chatrecords.FieldUpdatedAt:
  8246. return m.UpdatedAt()
  8247. case chatrecords.FieldDeletedAt:
  8248. return m.DeletedAt()
  8249. case chatrecords.FieldContent:
  8250. return m.Content()
  8251. case chatrecords.FieldContentType:
  8252. return m.ContentType()
  8253. case chatrecords.FieldSessionID:
  8254. return m.SessionID()
  8255. case chatrecords.FieldUserID:
  8256. return m.UserID()
  8257. case chatrecords.FieldBotID:
  8258. return m.BotID()
  8259. case chatrecords.FieldBotType:
  8260. return m.BotType()
  8261. }
  8262. return nil, false
  8263. }
  8264. // OldField returns the old value of the field from the database. An error is
  8265. // returned if the mutation operation is not UpdateOne, or the query to the
  8266. // database failed.
  8267. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8268. switch name {
  8269. case chatrecords.FieldCreatedAt:
  8270. return m.OldCreatedAt(ctx)
  8271. case chatrecords.FieldUpdatedAt:
  8272. return m.OldUpdatedAt(ctx)
  8273. case chatrecords.FieldDeletedAt:
  8274. return m.OldDeletedAt(ctx)
  8275. case chatrecords.FieldContent:
  8276. return m.OldContent(ctx)
  8277. case chatrecords.FieldContentType:
  8278. return m.OldContentType(ctx)
  8279. case chatrecords.FieldSessionID:
  8280. return m.OldSessionID(ctx)
  8281. case chatrecords.FieldUserID:
  8282. return m.OldUserID(ctx)
  8283. case chatrecords.FieldBotID:
  8284. return m.OldBotID(ctx)
  8285. case chatrecords.FieldBotType:
  8286. return m.OldBotType(ctx)
  8287. }
  8288. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8289. }
  8290. // SetField sets the value of a field with the given name. It returns an error if
  8291. // the field is not defined in the schema, or if the type mismatched the field
  8292. // type.
  8293. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8294. switch name {
  8295. case chatrecords.FieldCreatedAt:
  8296. v, ok := value.(time.Time)
  8297. if !ok {
  8298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8299. }
  8300. m.SetCreatedAt(v)
  8301. return nil
  8302. case chatrecords.FieldUpdatedAt:
  8303. v, ok := value.(time.Time)
  8304. if !ok {
  8305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8306. }
  8307. m.SetUpdatedAt(v)
  8308. return nil
  8309. case chatrecords.FieldDeletedAt:
  8310. v, ok := value.(time.Time)
  8311. if !ok {
  8312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8313. }
  8314. m.SetDeletedAt(v)
  8315. return nil
  8316. case chatrecords.FieldContent:
  8317. v, ok := value.(string)
  8318. if !ok {
  8319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8320. }
  8321. m.SetContent(v)
  8322. return nil
  8323. case chatrecords.FieldContentType:
  8324. v, ok := value.(uint8)
  8325. if !ok {
  8326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8327. }
  8328. m.SetContentType(v)
  8329. return nil
  8330. case chatrecords.FieldSessionID:
  8331. v, ok := value.(uint64)
  8332. if !ok {
  8333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8334. }
  8335. m.SetSessionID(v)
  8336. return nil
  8337. case chatrecords.FieldUserID:
  8338. v, ok := value.(uint64)
  8339. if !ok {
  8340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8341. }
  8342. m.SetUserID(v)
  8343. return nil
  8344. case chatrecords.FieldBotID:
  8345. v, ok := value.(uint64)
  8346. if !ok {
  8347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8348. }
  8349. m.SetBotID(v)
  8350. return nil
  8351. case chatrecords.FieldBotType:
  8352. v, ok := value.(uint8)
  8353. if !ok {
  8354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8355. }
  8356. m.SetBotType(v)
  8357. return nil
  8358. }
  8359. return fmt.Errorf("unknown ChatRecords field %s", name)
  8360. }
  8361. // AddedFields returns all numeric fields that were incremented/decremented during
  8362. // this mutation.
  8363. func (m *ChatRecordsMutation) AddedFields() []string {
  8364. var fields []string
  8365. if m.addcontent_type != nil {
  8366. fields = append(fields, chatrecords.FieldContentType)
  8367. }
  8368. if m.addsession_id != nil {
  8369. fields = append(fields, chatrecords.FieldSessionID)
  8370. }
  8371. if m.adduser_id != nil {
  8372. fields = append(fields, chatrecords.FieldUserID)
  8373. }
  8374. if m.addbot_id != nil {
  8375. fields = append(fields, chatrecords.FieldBotID)
  8376. }
  8377. if m.addbot_type != nil {
  8378. fields = append(fields, chatrecords.FieldBotType)
  8379. }
  8380. return fields
  8381. }
  8382. // AddedField returns the numeric value that was incremented/decremented on a field
  8383. // with the given name. The second boolean return value indicates that this field
  8384. // was not set, or was not defined in the schema.
  8385. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8386. switch name {
  8387. case chatrecords.FieldContentType:
  8388. return m.AddedContentType()
  8389. case chatrecords.FieldSessionID:
  8390. return m.AddedSessionID()
  8391. case chatrecords.FieldUserID:
  8392. return m.AddedUserID()
  8393. case chatrecords.FieldBotID:
  8394. return m.AddedBotID()
  8395. case chatrecords.FieldBotType:
  8396. return m.AddedBotType()
  8397. }
  8398. return nil, false
  8399. }
  8400. // AddField adds the value to the field with the given name. It returns an error if
  8401. // the field is not defined in the schema, or if the type mismatched the field
  8402. // type.
  8403. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8404. switch name {
  8405. case chatrecords.FieldContentType:
  8406. v, ok := value.(int8)
  8407. if !ok {
  8408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8409. }
  8410. m.AddContentType(v)
  8411. return nil
  8412. case chatrecords.FieldSessionID:
  8413. v, ok := value.(int64)
  8414. if !ok {
  8415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8416. }
  8417. m.AddSessionID(v)
  8418. return nil
  8419. case chatrecords.FieldUserID:
  8420. v, ok := value.(int64)
  8421. if !ok {
  8422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8423. }
  8424. m.AddUserID(v)
  8425. return nil
  8426. case chatrecords.FieldBotID:
  8427. v, ok := value.(int64)
  8428. if !ok {
  8429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8430. }
  8431. m.AddBotID(v)
  8432. return nil
  8433. case chatrecords.FieldBotType:
  8434. v, ok := value.(int8)
  8435. if !ok {
  8436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8437. }
  8438. m.AddBotType(v)
  8439. return nil
  8440. }
  8441. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8442. }
  8443. // ClearedFields returns all nullable fields that were cleared during this
  8444. // mutation.
  8445. func (m *ChatRecordsMutation) ClearedFields() []string {
  8446. var fields []string
  8447. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8448. fields = append(fields, chatrecords.FieldDeletedAt)
  8449. }
  8450. return fields
  8451. }
  8452. // FieldCleared returns a boolean indicating if a field with the given name was
  8453. // cleared in this mutation.
  8454. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8455. _, ok := m.clearedFields[name]
  8456. return ok
  8457. }
  8458. // ClearField clears the value of the field with the given name. It returns an
  8459. // error if the field is not defined in the schema.
  8460. func (m *ChatRecordsMutation) ClearField(name string) error {
  8461. switch name {
  8462. case chatrecords.FieldDeletedAt:
  8463. m.ClearDeletedAt()
  8464. return nil
  8465. }
  8466. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8467. }
  8468. // ResetField resets all changes in the mutation for the field with the given name.
  8469. // It returns an error if the field is not defined in the schema.
  8470. func (m *ChatRecordsMutation) ResetField(name string) error {
  8471. switch name {
  8472. case chatrecords.FieldCreatedAt:
  8473. m.ResetCreatedAt()
  8474. return nil
  8475. case chatrecords.FieldUpdatedAt:
  8476. m.ResetUpdatedAt()
  8477. return nil
  8478. case chatrecords.FieldDeletedAt:
  8479. m.ResetDeletedAt()
  8480. return nil
  8481. case chatrecords.FieldContent:
  8482. m.ResetContent()
  8483. return nil
  8484. case chatrecords.FieldContentType:
  8485. m.ResetContentType()
  8486. return nil
  8487. case chatrecords.FieldSessionID:
  8488. m.ResetSessionID()
  8489. return nil
  8490. case chatrecords.FieldUserID:
  8491. m.ResetUserID()
  8492. return nil
  8493. case chatrecords.FieldBotID:
  8494. m.ResetBotID()
  8495. return nil
  8496. case chatrecords.FieldBotType:
  8497. m.ResetBotType()
  8498. return nil
  8499. }
  8500. return fmt.Errorf("unknown ChatRecords field %s", name)
  8501. }
  8502. // AddedEdges returns all edge names that were set/added in this mutation.
  8503. func (m *ChatRecordsMutation) AddedEdges() []string {
  8504. edges := make([]string, 0, 0)
  8505. return edges
  8506. }
  8507. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8508. // name in this mutation.
  8509. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8510. return nil
  8511. }
  8512. // RemovedEdges returns all edge names that were removed in this mutation.
  8513. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8514. edges := make([]string, 0, 0)
  8515. return edges
  8516. }
  8517. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8518. // the given name in this mutation.
  8519. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8520. return nil
  8521. }
  8522. // ClearedEdges returns all edge names that were cleared in this mutation.
  8523. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8524. edges := make([]string, 0, 0)
  8525. return edges
  8526. }
  8527. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8528. // was cleared in this mutation.
  8529. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8530. return false
  8531. }
  8532. // ClearEdge clears the value of the edge with the given name. It returns an error
  8533. // if that edge is not defined in the schema.
  8534. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8535. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8536. }
  8537. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8538. // It returns an error if the edge is not defined in the schema.
  8539. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8540. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8541. }
  8542. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8543. type ChatSessionMutation struct {
  8544. config
  8545. op Op
  8546. typ string
  8547. id *uint64
  8548. created_at *time.Time
  8549. updated_at *time.Time
  8550. deleted_at *time.Time
  8551. name *string
  8552. user_id *uint64
  8553. adduser_id *int64
  8554. bot_id *uint64
  8555. addbot_id *int64
  8556. bot_type *uint8
  8557. addbot_type *int8
  8558. clearedFields map[string]struct{}
  8559. done bool
  8560. oldValue func(context.Context) (*ChatSession, error)
  8561. predicates []predicate.ChatSession
  8562. }
  8563. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8564. // chatsessionOption allows management of the mutation configuration using functional options.
  8565. type chatsessionOption func(*ChatSessionMutation)
  8566. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8567. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8568. m := &ChatSessionMutation{
  8569. config: c,
  8570. op: op,
  8571. typ: TypeChatSession,
  8572. clearedFields: make(map[string]struct{}),
  8573. }
  8574. for _, opt := range opts {
  8575. opt(m)
  8576. }
  8577. return m
  8578. }
  8579. // withChatSessionID sets the ID field of the mutation.
  8580. func withChatSessionID(id uint64) chatsessionOption {
  8581. return func(m *ChatSessionMutation) {
  8582. var (
  8583. err error
  8584. once sync.Once
  8585. value *ChatSession
  8586. )
  8587. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8588. once.Do(func() {
  8589. if m.done {
  8590. err = errors.New("querying old values post mutation is not allowed")
  8591. } else {
  8592. value, err = m.Client().ChatSession.Get(ctx, id)
  8593. }
  8594. })
  8595. return value, err
  8596. }
  8597. m.id = &id
  8598. }
  8599. }
  8600. // withChatSession sets the old ChatSession of the mutation.
  8601. func withChatSession(node *ChatSession) chatsessionOption {
  8602. return func(m *ChatSessionMutation) {
  8603. m.oldValue = func(context.Context) (*ChatSession, error) {
  8604. return node, nil
  8605. }
  8606. m.id = &node.ID
  8607. }
  8608. }
  8609. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8610. // executed in a transaction (ent.Tx), a transactional client is returned.
  8611. func (m ChatSessionMutation) Client() *Client {
  8612. client := &Client{config: m.config}
  8613. client.init()
  8614. return client
  8615. }
  8616. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8617. // it returns an error otherwise.
  8618. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8619. if _, ok := m.driver.(*txDriver); !ok {
  8620. return nil, errors.New("ent: mutation is not running in a transaction")
  8621. }
  8622. tx := &Tx{config: m.config}
  8623. tx.init()
  8624. return tx, nil
  8625. }
  8626. // SetID sets the value of the id field. Note that this
  8627. // operation is only accepted on creation of ChatSession entities.
  8628. func (m *ChatSessionMutation) SetID(id uint64) {
  8629. m.id = &id
  8630. }
  8631. // ID returns the ID value in the mutation. Note that the ID is only available
  8632. // if it was provided to the builder or after it was returned from the database.
  8633. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8634. if m.id == nil {
  8635. return
  8636. }
  8637. return *m.id, true
  8638. }
  8639. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8640. // That means, if the mutation is applied within a transaction with an isolation level such
  8641. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8642. // or updated by the mutation.
  8643. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8644. switch {
  8645. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8646. id, exists := m.ID()
  8647. if exists {
  8648. return []uint64{id}, nil
  8649. }
  8650. fallthrough
  8651. case m.op.Is(OpUpdate | OpDelete):
  8652. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8653. default:
  8654. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8655. }
  8656. }
  8657. // SetCreatedAt sets the "created_at" field.
  8658. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8659. m.created_at = &t
  8660. }
  8661. // CreatedAt returns the value of the "created_at" field in the mutation.
  8662. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8663. v := m.created_at
  8664. if v == nil {
  8665. return
  8666. }
  8667. return *v, true
  8668. }
  8669. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8670. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8672. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8673. if !m.op.Is(OpUpdateOne) {
  8674. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8675. }
  8676. if m.id == nil || m.oldValue == nil {
  8677. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8678. }
  8679. oldValue, err := m.oldValue(ctx)
  8680. if err != nil {
  8681. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8682. }
  8683. return oldValue.CreatedAt, nil
  8684. }
  8685. // ResetCreatedAt resets all changes to the "created_at" field.
  8686. func (m *ChatSessionMutation) ResetCreatedAt() {
  8687. m.created_at = nil
  8688. }
  8689. // SetUpdatedAt sets the "updated_at" field.
  8690. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8691. m.updated_at = &t
  8692. }
  8693. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8694. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8695. v := m.updated_at
  8696. if v == nil {
  8697. return
  8698. }
  8699. return *v, true
  8700. }
  8701. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8702. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8704. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8705. if !m.op.Is(OpUpdateOne) {
  8706. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8707. }
  8708. if m.id == nil || m.oldValue == nil {
  8709. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8710. }
  8711. oldValue, err := m.oldValue(ctx)
  8712. if err != nil {
  8713. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8714. }
  8715. return oldValue.UpdatedAt, nil
  8716. }
  8717. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8718. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8719. m.updated_at = nil
  8720. }
  8721. // SetDeletedAt sets the "deleted_at" field.
  8722. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8723. m.deleted_at = &t
  8724. }
  8725. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8726. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8727. v := m.deleted_at
  8728. if v == nil {
  8729. return
  8730. }
  8731. return *v, true
  8732. }
  8733. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8734. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8736. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8737. if !m.op.Is(OpUpdateOne) {
  8738. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8739. }
  8740. if m.id == nil || m.oldValue == nil {
  8741. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8742. }
  8743. oldValue, err := m.oldValue(ctx)
  8744. if err != nil {
  8745. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8746. }
  8747. return oldValue.DeletedAt, nil
  8748. }
  8749. // ClearDeletedAt clears the value of the "deleted_at" field.
  8750. func (m *ChatSessionMutation) ClearDeletedAt() {
  8751. m.deleted_at = nil
  8752. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8753. }
  8754. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8755. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8756. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8757. return ok
  8758. }
  8759. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8760. func (m *ChatSessionMutation) ResetDeletedAt() {
  8761. m.deleted_at = nil
  8762. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8763. }
  8764. // SetName sets the "name" field.
  8765. func (m *ChatSessionMutation) SetName(s string) {
  8766. m.name = &s
  8767. }
  8768. // Name returns the value of the "name" field in the mutation.
  8769. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8770. v := m.name
  8771. if v == nil {
  8772. return
  8773. }
  8774. return *v, true
  8775. }
  8776. // OldName returns the old "name" field's value of the ChatSession entity.
  8777. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8779. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8780. if !m.op.Is(OpUpdateOne) {
  8781. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8782. }
  8783. if m.id == nil || m.oldValue == nil {
  8784. return v, errors.New("OldName requires an ID field in the mutation")
  8785. }
  8786. oldValue, err := m.oldValue(ctx)
  8787. if err != nil {
  8788. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8789. }
  8790. return oldValue.Name, nil
  8791. }
  8792. // ResetName resets all changes to the "name" field.
  8793. func (m *ChatSessionMutation) ResetName() {
  8794. m.name = nil
  8795. }
  8796. // SetUserID sets the "user_id" field.
  8797. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8798. m.user_id = &u
  8799. m.adduser_id = nil
  8800. }
  8801. // UserID returns the value of the "user_id" field in the mutation.
  8802. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8803. v := m.user_id
  8804. if v == nil {
  8805. return
  8806. }
  8807. return *v, true
  8808. }
  8809. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8810. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8812. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8813. if !m.op.Is(OpUpdateOne) {
  8814. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8815. }
  8816. if m.id == nil || m.oldValue == nil {
  8817. return v, errors.New("OldUserID requires an ID field in the mutation")
  8818. }
  8819. oldValue, err := m.oldValue(ctx)
  8820. if err != nil {
  8821. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8822. }
  8823. return oldValue.UserID, nil
  8824. }
  8825. // AddUserID adds u to the "user_id" field.
  8826. func (m *ChatSessionMutation) AddUserID(u int64) {
  8827. if m.adduser_id != nil {
  8828. *m.adduser_id += u
  8829. } else {
  8830. m.adduser_id = &u
  8831. }
  8832. }
  8833. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8834. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8835. v := m.adduser_id
  8836. if v == nil {
  8837. return
  8838. }
  8839. return *v, true
  8840. }
  8841. // ResetUserID resets all changes to the "user_id" field.
  8842. func (m *ChatSessionMutation) ResetUserID() {
  8843. m.user_id = nil
  8844. m.adduser_id = nil
  8845. }
  8846. // SetBotID sets the "bot_id" field.
  8847. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8848. m.bot_id = &u
  8849. m.addbot_id = nil
  8850. }
  8851. // BotID returns the value of the "bot_id" field in the mutation.
  8852. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8853. v := m.bot_id
  8854. if v == nil {
  8855. return
  8856. }
  8857. return *v, true
  8858. }
  8859. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8860. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8862. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8863. if !m.op.Is(OpUpdateOne) {
  8864. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8865. }
  8866. if m.id == nil || m.oldValue == nil {
  8867. return v, errors.New("OldBotID requires an ID field in the mutation")
  8868. }
  8869. oldValue, err := m.oldValue(ctx)
  8870. if err != nil {
  8871. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8872. }
  8873. return oldValue.BotID, nil
  8874. }
  8875. // AddBotID adds u to the "bot_id" field.
  8876. func (m *ChatSessionMutation) AddBotID(u int64) {
  8877. if m.addbot_id != nil {
  8878. *m.addbot_id += u
  8879. } else {
  8880. m.addbot_id = &u
  8881. }
  8882. }
  8883. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8884. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8885. v := m.addbot_id
  8886. if v == nil {
  8887. return
  8888. }
  8889. return *v, true
  8890. }
  8891. // ResetBotID resets all changes to the "bot_id" field.
  8892. func (m *ChatSessionMutation) ResetBotID() {
  8893. m.bot_id = nil
  8894. m.addbot_id = nil
  8895. }
  8896. // SetBotType sets the "bot_type" field.
  8897. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8898. m.bot_type = &u
  8899. m.addbot_type = nil
  8900. }
  8901. // BotType returns the value of the "bot_type" field in the mutation.
  8902. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8903. v := m.bot_type
  8904. if v == nil {
  8905. return
  8906. }
  8907. return *v, true
  8908. }
  8909. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8910. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8912. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8913. if !m.op.Is(OpUpdateOne) {
  8914. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8915. }
  8916. if m.id == nil || m.oldValue == nil {
  8917. return v, errors.New("OldBotType requires an ID field in the mutation")
  8918. }
  8919. oldValue, err := m.oldValue(ctx)
  8920. if err != nil {
  8921. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8922. }
  8923. return oldValue.BotType, nil
  8924. }
  8925. // AddBotType adds u to the "bot_type" field.
  8926. func (m *ChatSessionMutation) AddBotType(u int8) {
  8927. if m.addbot_type != nil {
  8928. *m.addbot_type += u
  8929. } else {
  8930. m.addbot_type = &u
  8931. }
  8932. }
  8933. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8934. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8935. v := m.addbot_type
  8936. if v == nil {
  8937. return
  8938. }
  8939. return *v, true
  8940. }
  8941. // ResetBotType resets all changes to the "bot_type" field.
  8942. func (m *ChatSessionMutation) ResetBotType() {
  8943. m.bot_type = nil
  8944. m.addbot_type = nil
  8945. }
  8946. // Where appends a list predicates to the ChatSessionMutation builder.
  8947. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8948. m.predicates = append(m.predicates, ps...)
  8949. }
  8950. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8951. // users can use type-assertion to append predicates that do not depend on any generated package.
  8952. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8953. p := make([]predicate.ChatSession, len(ps))
  8954. for i := range ps {
  8955. p[i] = ps[i]
  8956. }
  8957. m.Where(p...)
  8958. }
  8959. // Op returns the operation name.
  8960. func (m *ChatSessionMutation) Op() Op {
  8961. return m.op
  8962. }
  8963. // SetOp allows setting the mutation operation.
  8964. func (m *ChatSessionMutation) SetOp(op Op) {
  8965. m.op = op
  8966. }
  8967. // Type returns the node type of this mutation (ChatSession).
  8968. func (m *ChatSessionMutation) Type() string {
  8969. return m.typ
  8970. }
  8971. // Fields returns all fields that were changed during this mutation. Note that in
  8972. // order to get all numeric fields that were incremented/decremented, call
  8973. // AddedFields().
  8974. func (m *ChatSessionMutation) Fields() []string {
  8975. fields := make([]string, 0, 7)
  8976. if m.created_at != nil {
  8977. fields = append(fields, chatsession.FieldCreatedAt)
  8978. }
  8979. if m.updated_at != nil {
  8980. fields = append(fields, chatsession.FieldUpdatedAt)
  8981. }
  8982. if m.deleted_at != nil {
  8983. fields = append(fields, chatsession.FieldDeletedAt)
  8984. }
  8985. if m.name != nil {
  8986. fields = append(fields, chatsession.FieldName)
  8987. }
  8988. if m.user_id != nil {
  8989. fields = append(fields, chatsession.FieldUserID)
  8990. }
  8991. if m.bot_id != nil {
  8992. fields = append(fields, chatsession.FieldBotID)
  8993. }
  8994. if m.bot_type != nil {
  8995. fields = append(fields, chatsession.FieldBotType)
  8996. }
  8997. return fields
  8998. }
  8999. // Field returns the value of a field with the given name. The second boolean
  9000. // return value indicates that this field was not set, or was not defined in the
  9001. // schema.
  9002. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9003. switch name {
  9004. case chatsession.FieldCreatedAt:
  9005. return m.CreatedAt()
  9006. case chatsession.FieldUpdatedAt:
  9007. return m.UpdatedAt()
  9008. case chatsession.FieldDeletedAt:
  9009. return m.DeletedAt()
  9010. case chatsession.FieldName:
  9011. return m.Name()
  9012. case chatsession.FieldUserID:
  9013. return m.UserID()
  9014. case chatsession.FieldBotID:
  9015. return m.BotID()
  9016. case chatsession.FieldBotType:
  9017. return m.BotType()
  9018. }
  9019. return nil, false
  9020. }
  9021. // OldField returns the old value of the field from the database. An error is
  9022. // returned if the mutation operation is not UpdateOne, or the query to the
  9023. // database failed.
  9024. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9025. switch name {
  9026. case chatsession.FieldCreatedAt:
  9027. return m.OldCreatedAt(ctx)
  9028. case chatsession.FieldUpdatedAt:
  9029. return m.OldUpdatedAt(ctx)
  9030. case chatsession.FieldDeletedAt:
  9031. return m.OldDeletedAt(ctx)
  9032. case chatsession.FieldName:
  9033. return m.OldName(ctx)
  9034. case chatsession.FieldUserID:
  9035. return m.OldUserID(ctx)
  9036. case chatsession.FieldBotID:
  9037. return m.OldBotID(ctx)
  9038. case chatsession.FieldBotType:
  9039. return m.OldBotType(ctx)
  9040. }
  9041. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9042. }
  9043. // SetField sets the value of a field with the given name. It returns an error if
  9044. // the field is not defined in the schema, or if the type mismatched the field
  9045. // type.
  9046. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9047. switch name {
  9048. case chatsession.FieldCreatedAt:
  9049. v, ok := value.(time.Time)
  9050. if !ok {
  9051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9052. }
  9053. m.SetCreatedAt(v)
  9054. return nil
  9055. case chatsession.FieldUpdatedAt:
  9056. v, ok := value.(time.Time)
  9057. if !ok {
  9058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9059. }
  9060. m.SetUpdatedAt(v)
  9061. return nil
  9062. case chatsession.FieldDeletedAt:
  9063. v, ok := value.(time.Time)
  9064. if !ok {
  9065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9066. }
  9067. m.SetDeletedAt(v)
  9068. return nil
  9069. case chatsession.FieldName:
  9070. v, ok := value.(string)
  9071. if !ok {
  9072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9073. }
  9074. m.SetName(v)
  9075. return nil
  9076. case chatsession.FieldUserID:
  9077. v, ok := value.(uint64)
  9078. if !ok {
  9079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9080. }
  9081. m.SetUserID(v)
  9082. return nil
  9083. case chatsession.FieldBotID:
  9084. v, ok := value.(uint64)
  9085. if !ok {
  9086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9087. }
  9088. m.SetBotID(v)
  9089. return nil
  9090. case chatsession.FieldBotType:
  9091. v, ok := value.(uint8)
  9092. if !ok {
  9093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9094. }
  9095. m.SetBotType(v)
  9096. return nil
  9097. }
  9098. return fmt.Errorf("unknown ChatSession field %s", name)
  9099. }
  9100. // AddedFields returns all numeric fields that were incremented/decremented during
  9101. // this mutation.
  9102. func (m *ChatSessionMutation) AddedFields() []string {
  9103. var fields []string
  9104. if m.adduser_id != nil {
  9105. fields = append(fields, chatsession.FieldUserID)
  9106. }
  9107. if m.addbot_id != nil {
  9108. fields = append(fields, chatsession.FieldBotID)
  9109. }
  9110. if m.addbot_type != nil {
  9111. fields = append(fields, chatsession.FieldBotType)
  9112. }
  9113. return fields
  9114. }
  9115. // AddedField returns the numeric value that was incremented/decremented on a field
  9116. // with the given name. The second boolean return value indicates that this field
  9117. // was not set, or was not defined in the schema.
  9118. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9119. switch name {
  9120. case chatsession.FieldUserID:
  9121. return m.AddedUserID()
  9122. case chatsession.FieldBotID:
  9123. return m.AddedBotID()
  9124. case chatsession.FieldBotType:
  9125. return m.AddedBotType()
  9126. }
  9127. return nil, false
  9128. }
  9129. // AddField adds the value to the field with the given name. It returns an error if
  9130. // the field is not defined in the schema, or if the type mismatched the field
  9131. // type.
  9132. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9133. switch name {
  9134. case chatsession.FieldUserID:
  9135. v, ok := value.(int64)
  9136. if !ok {
  9137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9138. }
  9139. m.AddUserID(v)
  9140. return nil
  9141. case chatsession.FieldBotID:
  9142. v, ok := value.(int64)
  9143. if !ok {
  9144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9145. }
  9146. m.AddBotID(v)
  9147. return nil
  9148. case chatsession.FieldBotType:
  9149. v, ok := value.(int8)
  9150. if !ok {
  9151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9152. }
  9153. m.AddBotType(v)
  9154. return nil
  9155. }
  9156. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9157. }
  9158. // ClearedFields returns all nullable fields that were cleared during this
  9159. // mutation.
  9160. func (m *ChatSessionMutation) ClearedFields() []string {
  9161. var fields []string
  9162. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9163. fields = append(fields, chatsession.FieldDeletedAt)
  9164. }
  9165. return fields
  9166. }
  9167. // FieldCleared returns a boolean indicating if a field with the given name was
  9168. // cleared in this mutation.
  9169. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9170. _, ok := m.clearedFields[name]
  9171. return ok
  9172. }
  9173. // ClearField clears the value of the field with the given name. It returns an
  9174. // error if the field is not defined in the schema.
  9175. func (m *ChatSessionMutation) ClearField(name string) error {
  9176. switch name {
  9177. case chatsession.FieldDeletedAt:
  9178. m.ClearDeletedAt()
  9179. return nil
  9180. }
  9181. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9182. }
  9183. // ResetField resets all changes in the mutation for the field with the given name.
  9184. // It returns an error if the field is not defined in the schema.
  9185. func (m *ChatSessionMutation) ResetField(name string) error {
  9186. switch name {
  9187. case chatsession.FieldCreatedAt:
  9188. m.ResetCreatedAt()
  9189. return nil
  9190. case chatsession.FieldUpdatedAt:
  9191. m.ResetUpdatedAt()
  9192. return nil
  9193. case chatsession.FieldDeletedAt:
  9194. m.ResetDeletedAt()
  9195. return nil
  9196. case chatsession.FieldName:
  9197. m.ResetName()
  9198. return nil
  9199. case chatsession.FieldUserID:
  9200. m.ResetUserID()
  9201. return nil
  9202. case chatsession.FieldBotID:
  9203. m.ResetBotID()
  9204. return nil
  9205. case chatsession.FieldBotType:
  9206. m.ResetBotType()
  9207. return nil
  9208. }
  9209. return fmt.Errorf("unknown ChatSession field %s", name)
  9210. }
  9211. // AddedEdges returns all edge names that were set/added in this mutation.
  9212. func (m *ChatSessionMutation) AddedEdges() []string {
  9213. edges := make([]string, 0, 0)
  9214. return edges
  9215. }
  9216. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9217. // name in this mutation.
  9218. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9219. return nil
  9220. }
  9221. // RemovedEdges returns all edge names that were removed in this mutation.
  9222. func (m *ChatSessionMutation) RemovedEdges() []string {
  9223. edges := make([]string, 0, 0)
  9224. return edges
  9225. }
  9226. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9227. // the given name in this mutation.
  9228. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9229. return nil
  9230. }
  9231. // ClearedEdges returns all edge names that were cleared in this mutation.
  9232. func (m *ChatSessionMutation) ClearedEdges() []string {
  9233. edges := make([]string, 0, 0)
  9234. return edges
  9235. }
  9236. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9237. // was cleared in this mutation.
  9238. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9239. return false
  9240. }
  9241. // ClearEdge clears the value of the edge with the given name. It returns an error
  9242. // if that edge is not defined in the schema.
  9243. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9244. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9245. }
  9246. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9247. // It returns an error if the edge is not defined in the schema.
  9248. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9249. return fmt.Errorf("unknown ChatSession edge %s", name)
  9250. }
  9251. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9252. type ContactMutation struct {
  9253. config
  9254. op Op
  9255. typ string
  9256. id *uint64
  9257. created_at *time.Time
  9258. updated_at *time.Time
  9259. status *uint8
  9260. addstatus *int8
  9261. deleted_at *time.Time
  9262. wx_wxid *string
  9263. _type *int
  9264. add_type *int
  9265. wxid *string
  9266. account *string
  9267. nickname *string
  9268. markname *string
  9269. headimg *string
  9270. sex *int
  9271. addsex *int
  9272. starrole *string
  9273. dontseeit *int
  9274. adddontseeit *int
  9275. dontseeme *int
  9276. adddontseeme *int
  9277. lag *string
  9278. gid *string
  9279. gname *string
  9280. v3 *string
  9281. organization_id *uint64
  9282. addorganization_id *int64
  9283. ctype *uint64
  9284. addctype *int64
  9285. cage *int
  9286. addcage *int
  9287. cname *string
  9288. carea *string
  9289. cbirthday *string
  9290. cbirtharea *string
  9291. cidcard_no *string
  9292. ctitle *string
  9293. cc *string
  9294. phone *string
  9295. clearedFields map[string]struct{}
  9296. contact_relationships map[uint64]struct{}
  9297. removedcontact_relationships map[uint64]struct{}
  9298. clearedcontact_relationships bool
  9299. contact_messages map[uint64]struct{}
  9300. removedcontact_messages map[uint64]struct{}
  9301. clearedcontact_messages bool
  9302. done bool
  9303. oldValue func(context.Context) (*Contact, error)
  9304. predicates []predicate.Contact
  9305. }
  9306. var _ ent.Mutation = (*ContactMutation)(nil)
  9307. // contactOption allows management of the mutation configuration using functional options.
  9308. type contactOption func(*ContactMutation)
  9309. // newContactMutation creates new mutation for the Contact entity.
  9310. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9311. m := &ContactMutation{
  9312. config: c,
  9313. op: op,
  9314. typ: TypeContact,
  9315. clearedFields: make(map[string]struct{}),
  9316. }
  9317. for _, opt := range opts {
  9318. opt(m)
  9319. }
  9320. return m
  9321. }
  9322. // withContactID sets the ID field of the mutation.
  9323. func withContactID(id uint64) contactOption {
  9324. return func(m *ContactMutation) {
  9325. var (
  9326. err error
  9327. once sync.Once
  9328. value *Contact
  9329. )
  9330. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9331. once.Do(func() {
  9332. if m.done {
  9333. err = errors.New("querying old values post mutation is not allowed")
  9334. } else {
  9335. value, err = m.Client().Contact.Get(ctx, id)
  9336. }
  9337. })
  9338. return value, err
  9339. }
  9340. m.id = &id
  9341. }
  9342. }
  9343. // withContact sets the old Contact of the mutation.
  9344. func withContact(node *Contact) contactOption {
  9345. return func(m *ContactMutation) {
  9346. m.oldValue = func(context.Context) (*Contact, error) {
  9347. return node, nil
  9348. }
  9349. m.id = &node.ID
  9350. }
  9351. }
  9352. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9353. // executed in a transaction (ent.Tx), a transactional client is returned.
  9354. func (m ContactMutation) Client() *Client {
  9355. client := &Client{config: m.config}
  9356. client.init()
  9357. return client
  9358. }
  9359. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9360. // it returns an error otherwise.
  9361. func (m ContactMutation) Tx() (*Tx, error) {
  9362. if _, ok := m.driver.(*txDriver); !ok {
  9363. return nil, errors.New("ent: mutation is not running in a transaction")
  9364. }
  9365. tx := &Tx{config: m.config}
  9366. tx.init()
  9367. return tx, nil
  9368. }
  9369. // SetID sets the value of the id field. Note that this
  9370. // operation is only accepted on creation of Contact entities.
  9371. func (m *ContactMutation) SetID(id uint64) {
  9372. m.id = &id
  9373. }
  9374. // ID returns the ID value in the mutation. Note that the ID is only available
  9375. // if it was provided to the builder or after it was returned from the database.
  9376. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9377. if m.id == nil {
  9378. return
  9379. }
  9380. return *m.id, true
  9381. }
  9382. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9383. // That means, if the mutation is applied within a transaction with an isolation level such
  9384. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9385. // or updated by the mutation.
  9386. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9387. switch {
  9388. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9389. id, exists := m.ID()
  9390. if exists {
  9391. return []uint64{id}, nil
  9392. }
  9393. fallthrough
  9394. case m.op.Is(OpUpdate | OpDelete):
  9395. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9396. default:
  9397. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9398. }
  9399. }
  9400. // SetCreatedAt sets the "created_at" field.
  9401. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9402. m.created_at = &t
  9403. }
  9404. // CreatedAt returns the value of the "created_at" field in the mutation.
  9405. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9406. v := m.created_at
  9407. if v == nil {
  9408. return
  9409. }
  9410. return *v, true
  9411. }
  9412. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9413. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9415. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9416. if !m.op.Is(OpUpdateOne) {
  9417. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9418. }
  9419. if m.id == nil || m.oldValue == nil {
  9420. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9421. }
  9422. oldValue, err := m.oldValue(ctx)
  9423. if err != nil {
  9424. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9425. }
  9426. return oldValue.CreatedAt, nil
  9427. }
  9428. // ResetCreatedAt resets all changes to the "created_at" field.
  9429. func (m *ContactMutation) ResetCreatedAt() {
  9430. m.created_at = nil
  9431. }
  9432. // SetUpdatedAt sets the "updated_at" field.
  9433. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9434. m.updated_at = &t
  9435. }
  9436. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9437. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9438. v := m.updated_at
  9439. if v == nil {
  9440. return
  9441. }
  9442. return *v, true
  9443. }
  9444. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9445. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9447. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9448. if !m.op.Is(OpUpdateOne) {
  9449. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9450. }
  9451. if m.id == nil || m.oldValue == nil {
  9452. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9453. }
  9454. oldValue, err := m.oldValue(ctx)
  9455. if err != nil {
  9456. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9457. }
  9458. return oldValue.UpdatedAt, nil
  9459. }
  9460. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9461. func (m *ContactMutation) ResetUpdatedAt() {
  9462. m.updated_at = nil
  9463. }
  9464. // SetStatus sets the "status" field.
  9465. func (m *ContactMutation) SetStatus(u uint8) {
  9466. m.status = &u
  9467. m.addstatus = nil
  9468. }
  9469. // Status returns the value of the "status" field in the mutation.
  9470. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9471. v := m.status
  9472. if v == nil {
  9473. return
  9474. }
  9475. return *v, true
  9476. }
  9477. // OldStatus returns the old "status" field's value of the Contact entity.
  9478. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9480. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9481. if !m.op.Is(OpUpdateOne) {
  9482. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9483. }
  9484. if m.id == nil || m.oldValue == nil {
  9485. return v, errors.New("OldStatus requires an ID field in the mutation")
  9486. }
  9487. oldValue, err := m.oldValue(ctx)
  9488. if err != nil {
  9489. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9490. }
  9491. return oldValue.Status, nil
  9492. }
  9493. // AddStatus adds u to the "status" field.
  9494. func (m *ContactMutation) AddStatus(u int8) {
  9495. if m.addstatus != nil {
  9496. *m.addstatus += u
  9497. } else {
  9498. m.addstatus = &u
  9499. }
  9500. }
  9501. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9502. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9503. v := m.addstatus
  9504. if v == nil {
  9505. return
  9506. }
  9507. return *v, true
  9508. }
  9509. // ClearStatus clears the value of the "status" field.
  9510. func (m *ContactMutation) ClearStatus() {
  9511. m.status = nil
  9512. m.addstatus = nil
  9513. m.clearedFields[contact.FieldStatus] = struct{}{}
  9514. }
  9515. // StatusCleared returns if the "status" field was cleared in this mutation.
  9516. func (m *ContactMutation) StatusCleared() bool {
  9517. _, ok := m.clearedFields[contact.FieldStatus]
  9518. return ok
  9519. }
  9520. // ResetStatus resets all changes to the "status" field.
  9521. func (m *ContactMutation) ResetStatus() {
  9522. m.status = nil
  9523. m.addstatus = nil
  9524. delete(m.clearedFields, contact.FieldStatus)
  9525. }
  9526. // SetDeletedAt sets the "deleted_at" field.
  9527. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9528. m.deleted_at = &t
  9529. }
  9530. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9531. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9532. v := m.deleted_at
  9533. if v == nil {
  9534. return
  9535. }
  9536. return *v, true
  9537. }
  9538. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9539. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9541. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9542. if !m.op.Is(OpUpdateOne) {
  9543. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9544. }
  9545. if m.id == nil || m.oldValue == nil {
  9546. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9547. }
  9548. oldValue, err := m.oldValue(ctx)
  9549. if err != nil {
  9550. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9551. }
  9552. return oldValue.DeletedAt, nil
  9553. }
  9554. // ClearDeletedAt clears the value of the "deleted_at" field.
  9555. func (m *ContactMutation) ClearDeletedAt() {
  9556. m.deleted_at = nil
  9557. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9558. }
  9559. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9560. func (m *ContactMutation) DeletedAtCleared() bool {
  9561. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9562. return ok
  9563. }
  9564. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9565. func (m *ContactMutation) ResetDeletedAt() {
  9566. m.deleted_at = nil
  9567. delete(m.clearedFields, contact.FieldDeletedAt)
  9568. }
  9569. // SetWxWxid sets the "wx_wxid" field.
  9570. func (m *ContactMutation) SetWxWxid(s string) {
  9571. m.wx_wxid = &s
  9572. }
  9573. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9574. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9575. v := m.wx_wxid
  9576. if v == nil {
  9577. return
  9578. }
  9579. return *v, true
  9580. }
  9581. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9582. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9584. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9585. if !m.op.Is(OpUpdateOne) {
  9586. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9587. }
  9588. if m.id == nil || m.oldValue == nil {
  9589. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9590. }
  9591. oldValue, err := m.oldValue(ctx)
  9592. if err != nil {
  9593. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9594. }
  9595. return oldValue.WxWxid, nil
  9596. }
  9597. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9598. func (m *ContactMutation) ResetWxWxid() {
  9599. m.wx_wxid = nil
  9600. }
  9601. // SetType sets the "type" field.
  9602. func (m *ContactMutation) SetType(i int) {
  9603. m._type = &i
  9604. m.add_type = nil
  9605. }
  9606. // GetType returns the value of the "type" field in the mutation.
  9607. func (m *ContactMutation) GetType() (r int, exists bool) {
  9608. v := m._type
  9609. if v == nil {
  9610. return
  9611. }
  9612. return *v, true
  9613. }
  9614. // OldType returns the old "type" field's value of the Contact entity.
  9615. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9617. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9618. if !m.op.Is(OpUpdateOne) {
  9619. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9620. }
  9621. if m.id == nil || m.oldValue == nil {
  9622. return v, errors.New("OldType requires an ID field in the mutation")
  9623. }
  9624. oldValue, err := m.oldValue(ctx)
  9625. if err != nil {
  9626. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9627. }
  9628. return oldValue.Type, nil
  9629. }
  9630. // AddType adds i to the "type" field.
  9631. func (m *ContactMutation) AddType(i int) {
  9632. if m.add_type != nil {
  9633. *m.add_type += i
  9634. } else {
  9635. m.add_type = &i
  9636. }
  9637. }
  9638. // AddedType returns the value that was added to the "type" field in this mutation.
  9639. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9640. v := m.add_type
  9641. if v == nil {
  9642. return
  9643. }
  9644. return *v, true
  9645. }
  9646. // ClearType clears the value of the "type" field.
  9647. func (m *ContactMutation) ClearType() {
  9648. m._type = nil
  9649. m.add_type = nil
  9650. m.clearedFields[contact.FieldType] = struct{}{}
  9651. }
  9652. // TypeCleared returns if the "type" field was cleared in this mutation.
  9653. func (m *ContactMutation) TypeCleared() bool {
  9654. _, ok := m.clearedFields[contact.FieldType]
  9655. return ok
  9656. }
  9657. // ResetType resets all changes to the "type" field.
  9658. func (m *ContactMutation) ResetType() {
  9659. m._type = nil
  9660. m.add_type = nil
  9661. delete(m.clearedFields, contact.FieldType)
  9662. }
  9663. // SetWxid sets the "wxid" field.
  9664. func (m *ContactMutation) SetWxid(s string) {
  9665. m.wxid = &s
  9666. }
  9667. // Wxid returns the value of the "wxid" field in the mutation.
  9668. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9669. v := m.wxid
  9670. if v == nil {
  9671. return
  9672. }
  9673. return *v, true
  9674. }
  9675. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9676. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9678. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9679. if !m.op.Is(OpUpdateOne) {
  9680. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9681. }
  9682. if m.id == nil || m.oldValue == nil {
  9683. return v, errors.New("OldWxid requires an ID field in the mutation")
  9684. }
  9685. oldValue, err := m.oldValue(ctx)
  9686. if err != nil {
  9687. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9688. }
  9689. return oldValue.Wxid, nil
  9690. }
  9691. // ResetWxid resets all changes to the "wxid" field.
  9692. func (m *ContactMutation) ResetWxid() {
  9693. m.wxid = nil
  9694. }
  9695. // SetAccount sets the "account" field.
  9696. func (m *ContactMutation) SetAccount(s string) {
  9697. m.account = &s
  9698. }
  9699. // Account returns the value of the "account" field in the mutation.
  9700. func (m *ContactMutation) Account() (r string, exists bool) {
  9701. v := m.account
  9702. if v == nil {
  9703. return
  9704. }
  9705. return *v, true
  9706. }
  9707. // OldAccount returns the old "account" field's value of the Contact entity.
  9708. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9710. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9711. if !m.op.Is(OpUpdateOne) {
  9712. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9713. }
  9714. if m.id == nil || m.oldValue == nil {
  9715. return v, errors.New("OldAccount requires an ID field in the mutation")
  9716. }
  9717. oldValue, err := m.oldValue(ctx)
  9718. if err != nil {
  9719. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9720. }
  9721. return oldValue.Account, nil
  9722. }
  9723. // ResetAccount resets all changes to the "account" field.
  9724. func (m *ContactMutation) ResetAccount() {
  9725. m.account = nil
  9726. }
  9727. // SetNickname sets the "nickname" field.
  9728. func (m *ContactMutation) SetNickname(s string) {
  9729. m.nickname = &s
  9730. }
  9731. // Nickname returns the value of the "nickname" field in the mutation.
  9732. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9733. v := m.nickname
  9734. if v == nil {
  9735. return
  9736. }
  9737. return *v, true
  9738. }
  9739. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9740. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9742. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9743. if !m.op.Is(OpUpdateOne) {
  9744. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9745. }
  9746. if m.id == nil || m.oldValue == nil {
  9747. return v, errors.New("OldNickname requires an ID field in the mutation")
  9748. }
  9749. oldValue, err := m.oldValue(ctx)
  9750. if err != nil {
  9751. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9752. }
  9753. return oldValue.Nickname, nil
  9754. }
  9755. // ResetNickname resets all changes to the "nickname" field.
  9756. func (m *ContactMutation) ResetNickname() {
  9757. m.nickname = nil
  9758. }
  9759. // SetMarkname sets the "markname" field.
  9760. func (m *ContactMutation) SetMarkname(s string) {
  9761. m.markname = &s
  9762. }
  9763. // Markname returns the value of the "markname" field in the mutation.
  9764. func (m *ContactMutation) Markname() (r string, exists bool) {
  9765. v := m.markname
  9766. if v == nil {
  9767. return
  9768. }
  9769. return *v, true
  9770. }
  9771. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9772. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9774. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9775. if !m.op.Is(OpUpdateOne) {
  9776. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9777. }
  9778. if m.id == nil || m.oldValue == nil {
  9779. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9780. }
  9781. oldValue, err := m.oldValue(ctx)
  9782. if err != nil {
  9783. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9784. }
  9785. return oldValue.Markname, nil
  9786. }
  9787. // ResetMarkname resets all changes to the "markname" field.
  9788. func (m *ContactMutation) ResetMarkname() {
  9789. m.markname = nil
  9790. }
  9791. // SetHeadimg sets the "headimg" field.
  9792. func (m *ContactMutation) SetHeadimg(s string) {
  9793. m.headimg = &s
  9794. }
  9795. // Headimg returns the value of the "headimg" field in the mutation.
  9796. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9797. v := m.headimg
  9798. if v == nil {
  9799. return
  9800. }
  9801. return *v, true
  9802. }
  9803. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9804. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9806. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9807. if !m.op.Is(OpUpdateOne) {
  9808. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9809. }
  9810. if m.id == nil || m.oldValue == nil {
  9811. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9812. }
  9813. oldValue, err := m.oldValue(ctx)
  9814. if err != nil {
  9815. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9816. }
  9817. return oldValue.Headimg, nil
  9818. }
  9819. // ResetHeadimg resets all changes to the "headimg" field.
  9820. func (m *ContactMutation) ResetHeadimg() {
  9821. m.headimg = nil
  9822. }
  9823. // SetSex sets the "sex" field.
  9824. func (m *ContactMutation) SetSex(i int) {
  9825. m.sex = &i
  9826. m.addsex = nil
  9827. }
  9828. // Sex returns the value of the "sex" field in the mutation.
  9829. func (m *ContactMutation) Sex() (r int, exists bool) {
  9830. v := m.sex
  9831. if v == nil {
  9832. return
  9833. }
  9834. return *v, true
  9835. }
  9836. // OldSex returns the old "sex" field's value of the Contact entity.
  9837. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9839. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9840. if !m.op.Is(OpUpdateOne) {
  9841. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9842. }
  9843. if m.id == nil || m.oldValue == nil {
  9844. return v, errors.New("OldSex requires an ID field in the mutation")
  9845. }
  9846. oldValue, err := m.oldValue(ctx)
  9847. if err != nil {
  9848. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9849. }
  9850. return oldValue.Sex, nil
  9851. }
  9852. // AddSex adds i to the "sex" field.
  9853. func (m *ContactMutation) AddSex(i int) {
  9854. if m.addsex != nil {
  9855. *m.addsex += i
  9856. } else {
  9857. m.addsex = &i
  9858. }
  9859. }
  9860. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9861. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9862. v := m.addsex
  9863. if v == nil {
  9864. return
  9865. }
  9866. return *v, true
  9867. }
  9868. // ResetSex resets all changes to the "sex" field.
  9869. func (m *ContactMutation) ResetSex() {
  9870. m.sex = nil
  9871. m.addsex = nil
  9872. }
  9873. // SetStarrole sets the "starrole" field.
  9874. func (m *ContactMutation) SetStarrole(s string) {
  9875. m.starrole = &s
  9876. }
  9877. // Starrole returns the value of the "starrole" field in the mutation.
  9878. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9879. v := m.starrole
  9880. if v == nil {
  9881. return
  9882. }
  9883. return *v, true
  9884. }
  9885. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9886. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9888. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9889. if !m.op.Is(OpUpdateOne) {
  9890. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9891. }
  9892. if m.id == nil || m.oldValue == nil {
  9893. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9894. }
  9895. oldValue, err := m.oldValue(ctx)
  9896. if err != nil {
  9897. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9898. }
  9899. return oldValue.Starrole, nil
  9900. }
  9901. // ResetStarrole resets all changes to the "starrole" field.
  9902. func (m *ContactMutation) ResetStarrole() {
  9903. m.starrole = nil
  9904. }
  9905. // SetDontseeit sets the "dontseeit" field.
  9906. func (m *ContactMutation) SetDontseeit(i int) {
  9907. m.dontseeit = &i
  9908. m.adddontseeit = nil
  9909. }
  9910. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9911. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9912. v := m.dontseeit
  9913. if v == nil {
  9914. return
  9915. }
  9916. return *v, true
  9917. }
  9918. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9919. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9921. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9922. if !m.op.Is(OpUpdateOne) {
  9923. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9924. }
  9925. if m.id == nil || m.oldValue == nil {
  9926. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9927. }
  9928. oldValue, err := m.oldValue(ctx)
  9929. if err != nil {
  9930. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9931. }
  9932. return oldValue.Dontseeit, nil
  9933. }
  9934. // AddDontseeit adds i to the "dontseeit" field.
  9935. func (m *ContactMutation) AddDontseeit(i int) {
  9936. if m.adddontseeit != nil {
  9937. *m.adddontseeit += i
  9938. } else {
  9939. m.adddontseeit = &i
  9940. }
  9941. }
  9942. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9943. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9944. v := m.adddontseeit
  9945. if v == nil {
  9946. return
  9947. }
  9948. return *v, true
  9949. }
  9950. // ResetDontseeit resets all changes to the "dontseeit" field.
  9951. func (m *ContactMutation) ResetDontseeit() {
  9952. m.dontseeit = nil
  9953. m.adddontseeit = nil
  9954. }
  9955. // SetDontseeme sets the "dontseeme" field.
  9956. func (m *ContactMutation) SetDontseeme(i int) {
  9957. m.dontseeme = &i
  9958. m.adddontseeme = nil
  9959. }
  9960. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9961. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9962. v := m.dontseeme
  9963. if v == nil {
  9964. return
  9965. }
  9966. return *v, true
  9967. }
  9968. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9969. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9971. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9972. if !m.op.Is(OpUpdateOne) {
  9973. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9974. }
  9975. if m.id == nil || m.oldValue == nil {
  9976. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  9977. }
  9978. oldValue, err := m.oldValue(ctx)
  9979. if err != nil {
  9980. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  9981. }
  9982. return oldValue.Dontseeme, nil
  9983. }
  9984. // AddDontseeme adds i to the "dontseeme" field.
  9985. func (m *ContactMutation) AddDontseeme(i int) {
  9986. if m.adddontseeme != nil {
  9987. *m.adddontseeme += i
  9988. } else {
  9989. m.adddontseeme = &i
  9990. }
  9991. }
  9992. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  9993. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  9994. v := m.adddontseeme
  9995. if v == nil {
  9996. return
  9997. }
  9998. return *v, true
  9999. }
  10000. // ResetDontseeme resets all changes to the "dontseeme" field.
  10001. func (m *ContactMutation) ResetDontseeme() {
  10002. m.dontseeme = nil
  10003. m.adddontseeme = nil
  10004. }
  10005. // SetLag sets the "lag" field.
  10006. func (m *ContactMutation) SetLag(s string) {
  10007. m.lag = &s
  10008. }
  10009. // Lag returns the value of the "lag" field in the mutation.
  10010. func (m *ContactMutation) Lag() (r string, exists bool) {
  10011. v := m.lag
  10012. if v == nil {
  10013. return
  10014. }
  10015. return *v, true
  10016. }
  10017. // OldLag returns the old "lag" field's value of the Contact entity.
  10018. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10020. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10021. if !m.op.Is(OpUpdateOne) {
  10022. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10023. }
  10024. if m.id == nil || m.oldValue == nil {
  10025. return v, errors.New("OldLag requires an ID field in the mutation")
  10026. }
  10027. oldValue, err := m.oldValue(ctx)
  10028. if err != nil {
  10029. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10030. }
  10031. return oldValue.Lag, nil
  10032. }
  10033. // ResetLag resets all changes to the "lag" field.
  10034. func (m *ContactMutation) ResetLag() {
  10035. m.lag = nil
  10036. }
  10037. // SetGid sets the "gid" field.
  10038. func (m *ContactMutation) SetGid(s string) {
  10039. m.gid = &s
  10040. }
  10041. // Gid returns the value of the "gid" field in the mutation.
  10042. func (m *ContactMutation) Gid() (r string, exists bool) {
  10043. v := m.gid
  10044. if v == nil {
  10045. return
  10046. }
  10047. return *v, true
  10048. }
  10049. // OldGid returns the old "gid" field's value of the Contact entity.
  10050. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10052. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10053. if !m.op.Is(OpUpdateOne) {
  10054. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10055. }
  10056. if m.id == nil || m.oldValue == nil {
  10057. return v, errors.New("OldGid requires an ID field in the mutation")
  10058. }
  10059. oldValue, err := m.oldValue(ctx)
  10060. if err != nil {
  10061. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10062. }
  10063. return oldValue.Gid, nil
  10064. }
  10065. // ResetGid resets all changes to the "gid" field.
  10066. func (m *ContactMutation) ResetGid() {
  10067. m.gid = nil
  10068. }
  10069. // SetGname sets the "gname" field.
  10070. func (m *ContactMutation) SetGname(s string) {
  10071. m.gname = &s
  10072. }
  10073. // Gname returns the value of the "gname" field in the mutation.
  10074. func (m *ContactMutation) Gname() (r string, exists bool) {
  10075. v := m.gname
  10076. if v == nil {
  10077. return
  10078. }
  10079. return *v, true
  10080. }
  10081. // OldGname returns the old "gname" field's value of the Contact entity.
  10082. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10084. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10085. if !m.op.Is(OpUpdateOne) {
  10086. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10087. }
  10088. if m.id == nil || m.oldValue == nil {
  10089. return v, errors.New("OldGname requires an ID field in the mutation")
  10090. }
  10091. oldValue, err := m.oldValue(ctx)
  10092. if err != nil {
  10093. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10094. }
  10095. return oldValue.Gname, nil
  10096. }
  10097. // ResetGname resets all changes to the "gname" field.
  10098. func (m *ContactMutation) ResetGname() {
  10099. m.gname = nil
  10100. }
  10101. // SetV3 sets the "v3" field.
  10102. func (m *ContactMutation) SetV3(s string) {
  10103. m.v3 = &s
  10104. }
  10105. // V3 returns the value of the "v3" field in the mutation.
  10106. func (m *ContactMutation) V3() (r string, exists bool) {
  10107. v := m.v3
  10108. if v == nil {
  10109. return
  10110. }
  10111. return *v, true
  10112. }
  10113. // OldV3 returns the old "v3" field's value of the Contact entity.
  10114. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10116. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10117. if !m.op.Is(OpUpdateOne) {
  10118. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10119. }
  10120. if m.id == nil || m.oldValue == nil {
  10121. return v, errors.New("OldV3 requires an ID field in the mutation")
  10122. }
  10123. oldValue, err := m.oldValue(ctx)
  10124. if err != nil {
  10125. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10126. }
  10127. return oldValue.V3, nil
  10128. }
  10129. // ResetV3 resets all changes to the "v3" field.
  10130. func (m *ContactMutation) ResetV3() {
  10131. m.v3 = nil
  10132. }
  10133. // SetOrganizationID sets the "organization_id" field.
  10134. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10135. m.organization_id = &u
  10136. m.addorganization_id = nil
  10137. }
  10138. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10139. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10140. v := m.organization_id
  10141. if v == nil {
  10142. return
  10143. }
  10144. return *v, true
  10145. }
  10146. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10147. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10149. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10150. if !m.op.Is(OpUpdateOne) {
  10151. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10152. }
  10153. if m.id == nil || m.oldValue == nil {
  10154. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10155. }
  10156. oldValue, err := m.oldValue(ctx)
  10157. if err != nil {
  10158. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10159. }
  10160. return oldValue.OrganizationID, nil
  10161. }
  10162. // AddOrganizationID adds u to the "organization_id" field.
  10163. func (m *ContactMutation) AddOrganizationID(u int64) {
  10164. if m.addorganization_id != nil {
  10165. *m.addorganization_id += u
  10166. } else {
  10167. m.addorganization_id = &u
  10168. }
  10169. }
  10170. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10171. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10172. v := m.addorganization_id
  10173. if v == nil {
  10174. return
  10175. }
  10176. return *v, true
  10177. }
  10178. // ClearOrganizationID clears the value of the "organization_id" field.
  10179. func (m *ContactMutation) ClearOrganizationID() {
  10180. m.organization_id = nil
  10181. m.addorganization_id = nil
  10182. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10183. }
  10184. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10185. func (m *ContactMutation) OrganizationIDCleared() bool {
  10186. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10187. return ok
  10188. }
  10189. // ResetOrganizationID resets all changes to the "organization_id" field.
  10190. func (m *ContactMutation) ResetOrganizationID() {
  10191. m.organization_id = nil
  10192. m.addorganization_id = nil
  10193. delete(m.clearedFields, contact.FieldOrganizationID)
  10194. }
  10195. // SetCtype sets the "ctype" field.
  10196. func (m *ContactMutation) SetCtype(u uint64) {
  10197. m.ctype = &u
  10198. m.addctype = nil
  10199. }
  10200. // Ctype returns the value of the "ctype" field in the mutation.
  10201. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10202. v := m.ctype
  10203. if v == nil {
  10204. return
  10205. }
  10206. return *v, true
  10207. }
  10208. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10209. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10211. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10212. if !m.op.Is(OpUpdateOne) {
  10213. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10214. }
  10215. if m.id == nil || m.oldValue == nil {
  10216. return v, errors.New("OldCtype requires an ID field in the mutation")
  10217. }
  10218. oldValue, err := m.oldValue(ctx)
  10219. if err != nil {
  10220. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10221. }
  10222. return oldValue.Ctype, nil
  10223. }
  10224. // AddCtype adds u to the "ctype" field.
  10225. func (m *ContactMutation) AddCtype(u int64) {
  10226. if m.addctype != nil {
  10227. *m.addctype += u
  10228. } else {
  10229. m.addctype = &u
  10230. }
  10231. }
  10232. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10233. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10234. v := m.addctype
  10235. if v == nil {
  10236. return
  10237. }
  10238. return *v, true
  10239. }
  10240. // ResetCtype resets all changes to the "ctype" field.
  10241. func (m *ContactMutation) ResetCtype() {
  10242. m.ctype = nil
  10243. m.addctype = nil
  10244. }
  10245. // SetCage sets the "cage" field.
  10246. func (m *ContactMutation) SetCage(i int) {
  10247. m.cage = &i
  10248. m.addcage = nil
  10249. }
  10250. // Cage returns the value of the "cage" field in the mutation.
  10251. func (m *ContactMutation) Cage() (r int, exists bool) {
  10252. v := m.cage
  10253. if v == nil {
  10254. return
  10255. }
  10256. return *v, true
  10257. }
  10258. // OldCage returns the old "cage" field's value of the Contact entity.
  10259. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10261. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10262. if !m.op.Is(OpUpdateOne) {
  10263. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10264. }
  10265. if m.id == nil || m.oldValue == nil {
  10266. return v, errors.New("OldCage requires an ID field in the mutation")
  10267. }
  10268. oldValue, err := m.oldValue(ctx)
  10269. if err != nil {
  10270. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10271. }
  10272. return oldValue.Cage, nil
  10273. }
  10274. // AddCage adds i to the "cage" field.
  10275. func (m *ContactMutation) AddCage(i int) {
  10276. if m.addcage != nil {
  10277. *m.addcage += i
  10278. } else {
  10279. m.addcage = &i
  10280. }
  10281. }
  10282. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10283. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10284. v := m.addcage
  10285. if v == nil {
  10286. return
  10287. }
  10288. return *v, true
  10289. }
  10290. // ResetCage resets all changes to the "cage" field.
  10291. func (m *ContactMutation) ResetCage() {
  10292. m.cage = nil
  10293. m.addcage = nil
  10294. }
  10295. // SetCname sets the "cname" field.
  10296. func (m *ContactMutation) SetCname(s string) {
  10297. m.cname = &s
  10298. }
  10299. // Cname returns the value of the "cname" field in the mutation.
  10300. func (m *ContactMutation) Cname() (r string, exists bool) {
  10301. v := m.cname
  10302. if v == nil {
  10303. return
  10304. }
  10305. return *v, true
  10306. }
  10307. // OldCname returns the old "cname" field's value of the Contact entity.
  10308. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10310. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10311. if !m.op.Is(OpUpdateOne) {
  10312. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10313. }
  10314. if m.id == nil || m.oldValue == nil {
  10315. return v, errors.New("OldCname requires an ID field in the mutation")
  10316. }
  10317. oldValue, err := m.oldValue(ctx)
  10318. if err != nil {
  10319. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10320. }
  10321. return oldValue.Cname, nil
  10322. }
  10323. // ResetCname resets all changes to the "cname" field.
  10324. func (m *ContactMutation) ResetCname() {
  10325. m.cname = nil
  10326. }
  10327. // SetCarea sets the "carea" field.
  10328. func (m *ContactMutation) SetCarea(s string) {
  10329. m.carea = &s
  10330. }
  10331. // Carea returns the value of the "carea" field in the mutation.
  10332. func (m *ContactMutation) Carea() (r string, exists bool) {
  10333. v := m.carea
  10334. if v == nil {
  10335. return
  10336. }
  10337. return *v, true
  10338. }
  10339. // OldCarea returns the old "carea" field's value of the Contact entity.
  10340. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10342. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10343. if !m.op.Is(OpUpdateOne) {
  10344. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10345. }
  10346. if m.id == nil || m.oldValue == nil {
  10347. return v, errors.New("OldCarea requires an ID field in the mutation")
  10348. }
  10349. oldValue, err := m.oldValue(ctx)
  10350. if err != nil {
  10351. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10352. }
  10353. return oldValue.Carea, nil
  10354. }
  10355. // ResetCarea resets all changes to the "carea" field.
  10356. func (m *ContactMutation) ResetCarea() {
  10357. m.carea = nil
  10358. }
  10359. // SetCbirthday sets the "cbirthday" field.
  10360. func (m *ContactMutation) SetCbirthday(s string) {
  10361. m.cbirthday = &s
  10362. }
  10363. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10364. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10365. v := m.cbirthday
  10366. if v == nil {
  10367. return
  10368. }
  10369. return *v, true
  10370. }
  10371. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10372. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10374. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10375. if !m.op.Is(OpUpdateOne) {
  10376. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10377. }
  10378. if m.id == nil || m.oldValue == nil {
  10379. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10380. }
  10381. oldValue, err := m.oldValue(ctx)
  10382. if err != nil {
  10383. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10384. }
  10385. return oldValue.Cbirthday, nil
  10386. }
  10387. // ResetCbirthday resets all changes to the "cbirthday" field.
  10388. func (m *ContactMutation) ResetCbirthday() {
  10389. m.cbirthday = nil
  10390. }
  10391. // SetCbirtharea sets the "cbirtharea" field.
  10392. func (m *ContactMutation) SetCbirtharea(s string) {
  10393. m.cbirtharea = &s
  10394. }
  10395. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10396. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10397. v := m.cbirtharea
  10398. if v == nil {
  10399. return
  10400. }
  10401. return *v, true
  10402. }
  10403. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10404. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10406. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10407. if !m.op.Is(OpUpdateOne) {
  10408. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10409. }
  10410. if m.id == nil || m.oldValue == nil {
  10411. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10412. }
  10413. oldValue, err := m.oldValue(ctx)
  10414. if err != nil {
  10415. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10416. }
  10417. return oldValue.Cbirtharea, nil
  10418. }
  10419. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10420. func (m *ContactMutation) ResetCbirtharea() {
  10421. m.cbirtharea = nil
  10422. }
  10423. // SetCidcardNo sets the "cidcard_no" field.
  10424. func (m *ContactMutation) SetCidcardNo(s string) {
  10425. m.cidcard_no = &s
  10426. }
  10427. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10428. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10429. v := m.cidcard_no
  10430. if v == nil {
  10431. return
  10432. }
  10433. return *v, true
  10434. }
  10435. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10436. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10438. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10439. if !m.op.Is(OpUpdateOne) {
  10440. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10441. }
  10442. if m.id == nil || m.oldValue == nil {
  10443. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10444. }
  10445. oldValue, err := m.oldValue(ctx)
  10446. if err != nil {
  10447. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10448. }
  10449. return oldValue.CidcardNo, nil
  10450. }
  10451. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10452. func (m *ContactMutation) ResetCidcardNo() {
  10453. m.cidcard_no = nil
  10454. }
  10455. // SetCtitle sets the "ctitle" field.
  10456. func (m *ContactMutation) SetCtitle(s string) {
  10457. m.ctitle = &s
  10458. }
  10459. // Ctitle returns the value of the "ctitle" field in the mutation.
  10460. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10461. v := m.ctitle
  10462. if v == nil {
  10463. return
  10464. }
  10465. return *v, true
  10466. }
  10467. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10468. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10470. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10471. if !m.op.Is(OpUpdateOne) {
  10472. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10473. }
  10474. if m.id == nil || m.oldValue == nil {
  10475. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10476. }
  10477. oldValue, err := m.oldValue(ctx)
  10478. if err != nil {
  10479. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10480. }
  10481. return oldValue.Ctitle, nil
  10482. }
  10483. // ResetCtitle resets all changes to the "ctitle" field.
  10484. func (m *ContactMutation) ResetCtitle() {
  10485. m.ctitle = nil
  10486. }
  10487. // SetCc sets the "cc" field.
  10488. func (m *ContactMutation) SetCc(s string) {
  10489. m.cc = &s
  10490. }
  10491. // Cc returns the value of the "cc" field in the mutation.
  10492. func (m *ContactMutation) Cc() (r string, exists bool) {
  10493. v := m.cc
  10494. if v == nil {
  10495. return
  10496. }
  10497. return *v, true
  10498. }
  10499. // OldCc returns the old "cc" field's value of the Contact entity.
  10500. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10502. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10503. if !m.op.Is(OpUpdateOne) {
  10504. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10505. }
  10506. if m.id == nil || m.oldValue == nil {
  10507. return v, errors.New("OldCc requires an ID field in the mutation")
  10508. }
  10509. oldValue, err := m.oldValue(ctx)
  10510. if err != nil {
  10511. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10512. }
  10513. return oldValue.Cc, nil
  10514. }
  10515. // ResetCc resets all changes to the "cc" field.
  10516. func (m *ContactMutation) ResetCc() {
  10517. m.cc = nil
  10518. }
  10519. // SetPhone sets the "phone" field.
  10520. func (m *ContactMutation) SetPhone(s string) {
  10521. m.phone = &s
  10522. }
  10523. // Phone returns the value of the "phone" field in the mutation.
  10524. func (m *ContactMutation) Phone() (r string, exists bool) {
  10525. v := m.phone
  10526. if v == nil {
  10527. return
  10528. }
  10529. return *v, true
  10530. }
  10531. // OldPhone returns the old "phone" field's value of the Contact entity.
  10532. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10534. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10535. if !m.op.Is(OpUpdateOne) {
  10536. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10537. }
  10538. if m.id == nil || m.oldValue == nil {
  10539. return v, errors.New("OldPhone requires an ID field in the mutation")
  10540. }
  10541. oldValue, err := m.oldValue(ctx)
  10542. if err != nil {
  10543. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10544. }
  10545. return oldValue.Phone, nil
  10546. }
  10547. // ResetPhone resets all changes to the "phone" field.
  10548. func (m *ContactMutation) ResetPhone() {
  10549. m.phone = nil
  10550. }
  10551. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10552. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10553. if m.contact_relationships == nil {
  10554. m.contact_relationships = make(map[uint64]struct{})
  10555. }
  10556. for i := range ids {
  10557. m.contact_relationships[ids[i]] = struct{}{}
  10558. }
  10559. }
  10560. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10561. func (m *ContactMutation) ClearContactRelationships() {
  10562. m.clearedcontact_relationships = true
  10563. }
  10564. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10565. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10566. return m.clearedcontact_relationships
  10567. }
  10568. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10569. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10570. if m.removedcontact_relationships == nil {
  10571. m.removedcontact_relationships = make(map[uint64]struct{})
  10572. }
  10573. for i := range ids {
  10574. delete(m.contact_relationships, ids[i])
  10575. m.removedcontact_relationships[ids[i]] = struct{}{}
  10576. }
  10577. }
  10578. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10579. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10580. for id := range m.removedcontact_relationships {
  10581. ids = append(ids, id)
  10582. }
  10583. return
  10584. }
  10585. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10586. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10587. for id := range m.contact_relationships {
  10588. ids = append(ids, id)
  10589. }
  10590. return
  10591. }
  10592. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10593. func (m *ContactMutation) ResetContactRelationships() {
  10594. m.contact_relationships = nil
  10595. m.clearedcontact_relationships = false
  10596. m.removedcontact_relationships = nil
  10597. }
  10598. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10599. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10600. if m.contact_messages == nil {
  10601. m.contact_messages = make(map[uint64]struct{})
  10602. }
  10603. for i := range ids {
  10604. m.contact_messages[ids[i]] = struct{}{}
  10605. }
  10606. }
  10607. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10608. func (m *ContactMutation) ClearContactMessages() {
  10609. m.clearedcontact_messages = true
  10610. }
  10611. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10612. func (m *ContactMutation) ContactMessagesCleared() bool {
  10613. return m.clearedcontact_messages
  10614. }
  10615. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10616. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10617. if m.removedcontact_messages == nil {
  10618. m.removedcontact_messages = make(map[uint64]struct{})
  10619. }
  10620. for i := range ids {
  10621. delete(m.contact_messages, ids[i])
  10622. m.removedcontact_messages[ids[i]] = struct{}{}
  10623. }
  10624. }
  10625. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10626. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10627. for id := range m.removedcontact_messages {
  10628. ids = append(ids, id)
  10629. }
  10630. return
  10631. }
  10632. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10633. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10634. for id := range m.contact_messages {
  10635. ids = append(ids, id)
  10636. }
  10637. return
  10638. }
  10639. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10640. func (m *ContactMutation) ResetContactMessages() {
  10641. m.contact_messages = nil
  10642. m.clearedcontact_messages = false
  10643. m.removedcontact_messages = nil
  10644. }
  10645. // Where appends a list predicates to the ContactMutation builder.
  10646. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10647. m.predicates = append(m.predicates, ps...)
  10648. }
  10649. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10650. // users can use type-assertion to append predicates that do not depend on any generated package.
  10651. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10652. p := make([]predicate.Contact, len(ps))
  10653. for i := range ps {
  10654. p[i] = ps[i]
  10655. }
  10656. m.Where(p...)
  10657. }
  10658. // Op returns the operation name.
  10659. func (m *ContactMutation) Op() Op {
  10660. return m.op
  10661. }
  10662. // SetOp allows setting the mutation operation.
  10663. func (m *ContactMutation) SetOp(op Op) {
  10664. m.op = op
  10665. }
  10666. // Type returns the node type of this mutation (Contact).
  10667. func (m *ContactMutation) Type() string {
  10668. return m.typ
  10669. }
  10670. // Fields returns all fields that were changed during this mutation. Note that in
  10671. // order to get all numeric fields that were incremented/decremented, call
  10672. // AddedFields().
  10673. func (m *ContactMutation) Fields() []string {
  10674. fields := make([]string, 0, 30)
  10675. if m.created_at != nil {
  10676. fields = append(fields, contact.FieldCreatedAt)
  10677. }
  10678. if m.updated_at != nil {
  10679. fields = append(fields, contact.FieldUpdatedAt)
  10680. }
  10681. if m.status != nil {
  10682. fields = append(fields, contact.FieldStatus)
  10683. }
  10684. if m.deleted_at != nil {
  10685. fields = append(fields, contact.FieldDeletedAt)
  10686. }
  10687. if m.wx_wxid != nil {
  10688. fields = append(fields, contact.FieldWxWxid)
  10689. }
  10690. if m._type != nil {
  10691. fields = append(fields, contact.FieldType)
  10692. }
  10693. if m.wxid != nil {
  10694. fields = append(fields, contact.FieldWxid)
  10695. }
  10696. if m.account != nil {
  10697. fields = append(fields, contact.FieldAccount)
  10698. }
  10699. if m.nickname != nil {
  10700. fields = append(fields, contact.FieldNickname)
  10701. }
  10702. if m.markname != nil {
  10703. fields = append(fields, contact.FieldMarkname)
  10704. }
  10705. if m.headimg != nil {
  10706. fields = append(fields, contact.FieldHeadimg)
  10707. }
  10708. if m.sex != nil {
  10709. fields = append(fields, contact.FieldSex)
  10710. }
  10711. if m.starrole != nil {
  10712. fields = append(fields, contact.FieldStarrole)
  10713. }
  10714. if m.dontseeit != nil {
  10715. fields = append(fields, contact.FieldDontseeit)
  10716. }
  10717. if m.dontseeme != nil {
  10718. fields = append(fields, contact.FieldDontseeme)
  10719. }
  10720. if m.lag != nil {
  10721. fields = append(fields, contact.FieldLag)
  10722. }
  10723. if m.gid != nil {
  10724. fields = append(fields, contact.FieldGid)
  10725. }
  10726. if m.gname != nil {
  10727. fields = append(fields, contact.FieldGname)
  10728. }
  10729. if m.v3 != nil {
  10730. fields = append(fields, contact.FieldV3)
  10731. }
  10732. if m.organization_id != nil {
  10733. fields = append(fields, contact.FieldOrganizationID)
  10734. }
  10735. if m.ctype != nil {
  10736. fields = append(fields, contact.FieldCtype)
  10737. }
  10738. if m.cage != nil {
  10739. fields = append(fields, contact.FieldCage)
  10740. }
  10741. if m.cname != nil {
  10742. fields = append(fields, contact.FieldCname)
  10743. }
  10744. if m.carea != nil {
  10745. fields = append(fields, contact.FieldCarea)
  10746. }
  10747. if m.cbirthday != nil {
  10748. fields = append(fields, contact.FieldCbirthday)
  10749. }
  10750. if m.cbirtharea != nil {
  10751. fields = append(fields, contact.FieldCbirtharea)
  10752. }
  10753. if m.cidcard_no != nil {
  10754. fields = append(fields, contact.FieldCidcardNo)
  10755. }
  10756. if m.ctitle != nil {
  10757. fields = append(fields, contact.FieldCtitle)
  10758. }
  10759. if m.cc != nil {
  10760. fields = append(fields, contact.FieldCc)
  10761. }
  10762. if m.phone != nil {
  10763. fields = append(fields, contact.FieldPhone)
  10764. }
  10765. return fields
  10766. }
  10767. // Field returns the value of a field with the given name. The second boolean
  10768. // return value indicates that this field was not set, or was not defined in the
  10769. // schema.
  10770. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10771. switch name {
  10772. case contact.FieldCreatedAt:
  10773. return m.CreatedAt()
  10774. case contact.FieldUpdatedAt:
  10775. return m.UpdatedAt()
  10776. case contact.FieldStatus:
  10777. return m.Status()
  10778. case contact.FieldDeletedAt:
  10779. return m.DeletedAt()
  10780. case contact.FieldWxWxid:
  10781. return m.WxWxid()
  10782. case contact.FieldType:
  10783. return m.GetType()
  10784. case contact.FieldWxid:
  10785. return m.Wxid()
  10786. case contact.FieldAccount:
  10787. return m.Account()
  10788. case contact.FieldNickname:
  10789. return m.Nickname()
  10790. case contact.FieldMarkname:
  10791. return m.Markname()
  10792. case contact.FieldHeadimg:
  10793. return m.Headimg()
  10794. case contact.FieldSex:
  10795. return m.Sex()
  10796. case contact.FieldStarrole:
  10797. return m.Starrole()
  10798. case contact.FieldDontseeit:
  10799. return m.Dontseeit()
  10800. case contact.FieldDontseeme:
  10801. return m.Dontseeme()
  10802. case contact.FieldLag:
  10803. return m.Lag()
  10804. case contact.FieldGid:
  10805. return m.Gid()
  10806. case contact.FieldGname:
  10807. return m.Gname()
  10808. case contact.FieldV3:
  10809. return m.V3()
  10810. case contact.FieldOrganizationID:
  10811. return m.OrganizationID()
  10812. case contact.FieldCtype:
  10813. return m.Ctype()
  10814. case contact.FieldCage:
  10815. return m.Cage()
  10816. case contact.FieldCname:
  10817. return m.Cname()
  10818. case contact.FieldCarea:
  10819. return m.Carea()
  10820. case contact.FieldCbirthday:
  10821. return m.Cbirthday()
  10822. case contact.FieldCbirtharea:
  10823. return m.Cbirtharea()
  10824. case contact.FieldCidcardNo:
  10825. return m.CidcardNo()
  10826. case contact.FieldCtitle:
  10827. return m.Ctitle()
  10828. case contact.FieldCc:
  10829. return m.Cc()
  10830. case contact.FieldPhone:
  10831. return m.Phone()
  10832. }
  10833. return nil, false
  10834. }
  10835. // OldField returns the old value of the field from the database. An error is
  10836. // returned if the mutation operation is not UpdateOne, or the query to the
  10837. // database failed.
  10838. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10839. switch name {
  10840. case contact.FieldCreatedAt:
  10841. return m.OldCreatedAt(ctx)
  10842. case contact.FieldUpdatedAt:
  10843. return m.OldUpdatedAt(ctx)
  10844. case contact.FieldStatus:
  10845. return m.OldStatus(ctx)
  10846. case contact.FieldDeletedAt:
  10847. return m.OldDeletedAt(ctx)
  10848. case contact.FieldWxWxid:
  10849. return m.OldWxWxid(ctx)
  10850. case contact.FieldType:
  10851. return m.OldType(ctx)
  10852. case contact.FieldWxid:
  10853. return m.OldWxid(ctx)
  10854. case contact.FieldAccount:
  10855. return m.OldAccount(ctx)
  10856. case contact.FieldNickname:
  10857. return m.OldNickname(ctx)
  10858. case contact.FieldMarkname:
  10859. return m.OldMarkname(ctx)
  10860. case contact.FieldHeadimg:
  10861. return m.OldHeadimg(ctx)
  10862. case contact.FieldSex:
  10863. return m.OldSex(ctx)
  10864. case contact.FieldStarrole:
  10865. return m.OldStarrole(ctx)
  10866. case contact.FieldDontseeit:
  10867. return m.OldDontseeit(ctx)
  10868. case contact.FieldDontseeme:
  10869. return m.OldDontseeme(ctx)
  10870. case contact.FieldLag:
  10871. return m.OldLag(ctx)
  10872. case contact.FieldGid:
  10873. return m.OldGid(ctx)
  10874. case contact.FieldGname:
  10875. return m.OldGname(ctx)
  10876. case contact.FieldV3:
  10877. return m.OldV3(ctx)
  10878. case contact.FieldOrganizationID:
  10879. return m.OldOrganizationID(ctx)
  10880. case contact.FieldCtype:
  10881. return m.OldCtype(ctx)
  10882. case contact.FieldCage:
  10883. return m.OldCage(ctx)
  10884. case contact.FieldCname:
  10885. return m.OldCname(ctx)
  10886. case contact.FieldCarea:
  10887. return m.OldCarea(ctx)
  10888. case contact.FieldCbirthday:
  10889. return m.OldCbirthday(ctx)
  10890. case contact.FieldCbirtharea:
  10891. return m.OldCbirtharea(ctx)
  10892. case contact.FieldCidcardNo:
  10893. return m.OldCidcardNo(ctx)
  10894. case contact.FieldCtitle:
  10895. return m.OldCtitle(ctx)
  10896. case contact.FieldCc:
  10897. return m.OldCc(ctx)
  10898. case contact.FieldPhone:
  10899. return m.OldPhone(ctx)
  10900. }
  10901. return nil, fmt.Errorf("unknown Contact field %s", name)
  10902. }
  10903. // SetField sets the value of a field with the given name. It returns an error if
  10904. // the field is not defined in the schema, or if the type mismatched the field
  10905. // type.
  10906. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10907. switch name {
  10908. case contact.FieldCreatedAt:
  10909. v, ok := value.(time.Time)
  10910. if !ok {
  10911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10912. }
  10913. m.SetCreatedAt(v)
  10914. return nil
  10915. case contact.FieldUpdatedAt:
  10916. v, ok := value.(time.Time)
  10917. if !ok {
  10918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10919. }
  10920. m.SetUpdatedAt(v)
  10921. return nil
  10922. case contact.FieldStatus:
  10923. v, ok := value.(uint8)
  10924. if !ok {
  10925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10926. }
  10927. m.SetStatus(v)
  10928. return nil
  10929. case contact.FieldDeletedAt:
  10930. v, ok := value.(time.Time)
  10931. if !ok {
  10932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10933. }
  10934. m.SetDeletedAt(v)
  10935. return nil
  10936. case contact.FieldWxWxid:
  10937. v, ok := value.(string)
  10938. if !ok {
  10939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10940. }
  10941. m.SetWxWxid(v)
  10942. return nil
  10943. case contact.FieldType:
  10944. v, ok := value.(int)
  10945. if !ok {
  10946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10947. }
  10948. m.SetType(v)
  10949. return nil
  10950. case contact.FieldWxid:
  10951. v, ok := value.(string)
  10952. if !ok {
  10953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10954. }
  10955. m.SetWxid(v)
  10956. return nil
  10957. case contact.FieldAccount:
  10958. v, ok := value.(string)
  10959. if !ok {
  10960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10961. }
  10962. m.SetAccount(v)
  10963. return nil
  10964. case contact.FieldNickname:
  10965. v, ok := value.(string)
  10966. if !ok {
  10967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10968. }
  10969. m.SetNickname(v)
  10970. return nil
  10971. case contact.FieldMarkname:
  10972. v, ok := value.(string)
  10973. if !ok {
  10974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10975. }
  10976. m.SetMarkname(v)
  10977. return nil
  10978. case contact.FieldHeadimg:
  10979. v, ok := value.(string)
  10980. if !ok {
  10981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10982. }
  10983. m.SetHeadimg(v)
  10984. return nil
  10985. case contact.FieldSex:
  10986. v, ok := value.(int)
  10987. if !ok {
  10988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10989. }
  10990. m.SetSex(v)
  10991. return nil
  10992. case contact.FieldStarrole:
  10993. v, ok := value.(string)
  10994. if !ok {
  10995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10996. }
  10997. m.SetStarrole(v)
  10998. return nil
  10999. case contact.FieldDontseeit:
  11000. v, ok := value.(int)
  11001. if !ok {
  11002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11003. }
  11004. m.SetDontseeit(v)
  11005. return nil
  11006. case contact.FieldDontseeme:
  11007. v, ok := value.(int)
  11008. if !ok {
  11009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11010. }
  11011. m.SetDontseeme(v)
  11012. return nil
  11013. case contact.FieldLag:
  11014. v, ok := value.(string)
  11015. if !ok {
  11016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11017. }
  11018. m.SetLag(v)
  11019. return nil
  11020. case contact.FieldGid:
  11021. v, ok := value.(string)
  11022. if !ok {
  11023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11024. }
  11025. m.SetGid(v)
  11026. return nil
  11027. case contact.FieldGname:
  11028. v, ok := value.(string)
  11029. if !ok {
  11030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11031. }
  11032. m.SetGname(v)
  11033. return nil
  11034. case contact.FieldV3:
  11035. v, ok := value.(string)
  11036. if !ok {
  11037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11038. }
  11039. m.SetV3(v)
  11040. return nil
  11041. case contact.FieldOrganizationID:
  11042. v, ok := value.(uint64)
  11043. if !ok {
  11044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11045. }
  11046. m.SetOrganizationID(v)
  11047. return nil
  11048. case contact.FieldCtype:
  11049. v, ok := value.(uint64)
  11050. if !ok {
  11051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11052. }
  11053. m.SetCtype(v)
  11054. return nil
  11055. case contact.FieldCage:
  11056. v, ok := value.(int)
  11057. if !ok {
  11058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11059. }
  11060. m.SetCage(v)
  11061. return nil
  11062. case contact.FieldCname:
  11063. v, ok := value.(string)
  11064. if !ok {
  11065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11066. }
  11067. m.SetCname(v)
  11068. return nil
  11069. case contact.FieldCarea:
  11070. v, ok := value.(string)
  11071. if !ok {
  11072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11073. }
  11074. m.SetCarea(v)
  11075. return nil
  11076. case contact.FieldCbirthday:
  11077. v, ok := value.(string)
  11078. if !ok {
  11079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11080. }
  11081. m.SetCbirthday(v)
  11082. return nil
  11083. case contact.FieldCbirtharea:
  11084. v, ok := value.(string)
  11085. if !ok {
  11086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11087. }
  11088. m.SetCbirtharea(v)
  11089. return nil
  11090. case contact.FieldCidcardNo:
  11091. v, ok := value.(string)
  11092. if !ok {
  11093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11094. }
  11095. m.SetCidcardNo(v)
  11096. return nil
  11097. case contact.FieldCtitle:
  11098. v, ok := value.(string)
  11099. if !ok {
  11100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11101. }
  11102. m.SetCtitle(v)
  11103. return nil
  11104. case contact.FieldCc:
  11105. v, ok := value.(string)
  11106. if !ok {
  11107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11108. }
  11109. m.SetCc(v)
  11110. return nil
  11111. case contact.FieldPhone:
  11112. v, ok := value.(string)
  11113. if !ok {
  11114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11115. }
  11116. m.SetPhone(v)
  11117. return nil
  11118. }
  11119. return fmt.Errorf("unknown Contact field %s", name)
  11120. }
  11121. // AddedFields returns all numeric fields that were incremented/decremented during
  11122. // this mutation.
  11123. func (m *ContactMutation) AddedFields() []string {
  11124. var fields []string
  11125. if m.addstatus != nil {
  11126. fields = append(fields, contact.FieldStatus)
  11127. }
  11128. if m.add_type != nil {
  11129. fields = append(fields, contact.FieldType)
  11130. }
  11131. if m.addsex != nil {
  11132. fields = append(fields, contact.FieldSex)
  11133. }
  11134. if m.adddontseeit != nil {
  11135. fields = append(fields, contact.FieldDontseeit)
  11136. }
  11137. if m.adddontseeme != nil {
  11138. fields = append(fields, contact.FieldDontseeme)
  11139. }
  11140. if m.addorganization_id != nil {
  11141. fields = append(fields, contact.FieldOrganizationID)
  11142. }
  11143. if m.addctype != nil {
  11144. fields = append(fields, contact.FieldCtype)
  11145. }
  11146. if m.addcage != nil {
  11147. fields = append(fields, contact.FieldCage)
  11148. }
  11149. return fields
  11150. }
  11151. // AddedField returns the numeric value that was incremented/decremented on a field
  11152. // with the given name. The second boolean return value indicates that this field
  11153. // was not set, or was not defined in the schema.
  11154. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11155. switch name {
  11156. case contact.FieldStatus:
  11157. return m.AddedStatus()
  11158. case contact.FieldType:
  11159. return m.AddedType()
  11160. case contact.FieldSex:
  11161. return m.AddedSex()
  11162. case contact.FieldDontseeit:
  11163. return m.AddedDontseeit()
  11164. case contact.FieldDontseeme:
  11165. return m.AddedDontseeme()
  11166. case contact.FieldOrganizationID:
  11167. return m.AddedOrganizationID()
  11168. case contact.FieldCtype:
  11169. return m.AddedCtype()
  11170. case contact.FieldCage:
  11171. return m.AddedCage()
  11172. }
  11173. return nil, false
  11174. }
  11175. // AddField adds the value to the field with the given name. It returns an error if
  11176. // the field is not defined in the schema, or if the type mismatched the field
  11177. // type.
  11178. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11179. switch name {
  11180. case contact.FieldStatus:
  11181. v, ok := value.(int8)
  11182. if !ok {
  11183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11184. }
  11185. m.AddStatus(v)
  11186. return nil
  11187. case contact.FieldType:
  11188. v, ok := value.(int)
  11189. if !ok {
  11190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11191. }
  11192. m.AddType(v)
  11193. return nil
  11194. case contact.FieldSex:
  11195. v, ok := value.(int)
  11196. if !ok {
  11197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11198. }
  11199. m.AddSex(v)
  11200. return nil
  11201. case contact.FieldDontseeit:
  11202. v, ok := value.(int)
  11203. if !ok {
  11204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11205. }
  11206. m.AddDontseeit(v)
  11207. return nil
  11208. case contact.FieldDontseeme:
  11209. v, ok := value.(int)
  11210. if !ok {
  11211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11212. }
  11213. m.AddDontseeme(v)
  11214. return nil
  11215. case contact.FieldOrganizationID:
  11216. v, ok := value.(int64)
  11217. if !ok {
  11218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11219. }
  11220. m.AddOrganizationID(v)
  11221. return nil
  11222. case contact.FieldCtype:
  11223. v, ok := value.(int64)
  11224. if !ok {
  11225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11226. }
  11227. m.AddCtype(v)
  11228. return nil
  11229. case contact.FieldCage:
  11230. v, ok := value.(int)
  11231. if !ok {
  11232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11233. }
  11234. m.AddCage(v)
  11235. return nil
  11236. }
  11237. return fmt.Errorf("unknown Contact numeric field %s", name)
  11238. }
  11239. // ClearedFields returns all nullable fields that were cleared during this
  11240. // mutation.
  11241. func (m *ContactMutation) ClearedFields() []string {
  11242. var fields []string
  11243. if m.FieldCleared(contact.FieldStatus) {
  11244. fields = append(fields, contact.FieldStatus)
  11245. }
  11246. if m.FieldCleared(contact.FieldDeletedAt) {
  11247. fields = append(fields, contact.FieldDeletedAt)
  11248. }
  11249. if m.FieldCleared(contact.FieldType) {
  11250. fields = append(fields, contact.FieldType)
  11251. }
  11252. if m.FieldCleared(contact.FieldOrganizationID) {
  11253. fields = append(fields, contact.FieldOrganizationID)
  11254. }
  11255. return fields
  11256. }
  11257. // FieldCleared returns a boolean indicating if a field with the given name was
  11258. // cleared in this mutation.
  11259. func (m *ContactMutation) FieldCleared(name string) bool {
  11260. _, ok := m.clearedFields[name]
  11261. return ok
  11262. }
  11263. // ClearField clears the value of the field with the given name. It returns an
  11264. // error if the field is not defined in the schema.
  11265. func (m *ContactMutation) ClearField(name string) error {
  11266. switch name {
  11267. case contact.FieldStatus:
  11268. m.ClearStatus()
  11269. return nil
  11270. case contact.FieldDeletedAt:
  11271. m.ClearDeletedAt()
  11272. return nil
  11273. case contact.FieldType:
  11274. m.ClearType()
  11275. return nil
  11276. case contact.FieldOrganizationID:
  11277. m.ClearOrganizationID()
  11278. return nil
  11279. }
  11280. return fmt.Errorf("unknown Contact nullable field %s", name)
  11281. }
  11282. // ResetField resets all changes in the mutation for the field with the given name.
  11283. // It returns an error if the field is not defined in the schema.
  11284. func (m *ContactMutation) ResetField(name string) error {
  11285. switch name {
  11286. case contact.FieldCreatedAt:
  11287. m.ResetCreatedAt()
  11288. return nil
  11289. case contact.FieldUpdatedAt:
  11290. m.ResetUpdatedAt()
  11291. return nil
  11292. case contact.FieldStatus:
  11293. m.ResetStatus()
  11294. return nil
  11295. case contact.FieldDeletedAt:
  11296. m.ResetDeletedAt()
  11297. return nil
  11298. case contact.FieldWxWxid:
  11299. m.ResetWxWxid()
  11300. return nil
  11301. case contact.FieldType:
  11302. m.ResetType()
  11303. return nil
  11304. case contact.FieldWxid:
  11305. m.ResetWxid()
  11306. return nil
  11307. case contact.FieldAccount:
  11308. m.ResetAccount()
  11309. return nil
  11310. case contact.FieldNickname:
  11311. m.ResetNickname()
  11312. return nil
  11313. case contact.FieldMarkname:
  11314. m.ResetMarkname()
  11315. return nil
  11316. case contact.FieldHeadimg:
  11317. m.ResetHeadimg()
  11318. return nil
  11319. case contact.FieldSex:
  11320. m.ResetSex()
  11321. return nil
  11322. case contact.FieldStarrole:
  11323. m.ResetStarrole()
  11324. return nil
  11325. case contact.FieldDontseeit:
  11326. m.ResetDontseeit()
  11327. return nil
  11328. case contact.FieldDontseeme:
  11329. m.ResetDontseeme()
  11330. return nil
  11331. case contact.FieldLag:
  11332. m.ResetLag()
  11333. return nil
  11334. case contact.FieldGid:
  11335. m.ResetGid()
  11336. return nil
  11337. case contact.FieldGname:
  11338. m.ResetGname()
  11339. return nil
  11340. case contact.FieldV3:
  11341. m.ResetV3()
  11342. return nil
  11343. case contact.FieldOrganizationID:
  11344. m.ResetOrganizationID()
  11345. return nil
  11346. case contact.FieldCtype:
  11347. m.ResetCtype()
  11348. return nil
  11349. case contact.FieldCage:
  11350. m.ResetCage()
  11351. return nil
  11352. case contact.FieldCname:
  11353. m.ResetCname()
  11354. return nil
  11355. case contact.FieldCarea:
  11356. m.ResetCarea()
  11357. return nil
  11358. case contact.FieldCbirthday:
  11359. m.ResetCbirthday()
  11360. return nil
  11361. case contact.FieldCbirtharea:
  11362. m.ResetCbirtharea()
  11363. return nil
  11364. case contact.FieldCidcardNo:
  11365. m.ResetCidcardNo()
  11366. return nil
  11367. case contact.FieldCtitle:
  11368. m.ResetCtitle()
  11369. return nil
  11370. case contact.FieldCc:
  11371. m.ResetCc()
  11372. return nil
  11373. case contact.FieldPhone:
  11374. m.ResetPhone()
  11375. return nil
  11376. }
  11377. return fmt.Errorf("unknown Contact field %s", name)
  11378. }
  11379. // AddedEdges returns all edge names that were set/added in this mutation.
  11380. func (m *ContactMutation) AddedEdges() []string {
  11381. edges := make([]string, 0, 2)
  11382. if m.contact_relationships != nil {
  11383. edges = append(edges, contact.EdgeContactRelationships)
  11384. }
  11385. if m.contact_messages != nil {
  11386. edges = append(edges, contact.EdgeContactMessages)
  11387. }
  11388. return edges
  11389. }
  11390. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11391. // name in this mutation.
  11392. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11393. switch name {
  11394. case contact.EdgeContactRelationships:
  11395. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11396. for id := range m.contact_relationships {
  11397. ids = append(ids, id)
  11398. }
  11399. return ids
  11400. case contact.EdgeContactMessages:
  11401. ids := make([]ent.Value, 0, len(m.contact_messages))
  11402. for id := range m.contact_messages {
  11403. ids = append(ids, id)
  11404. }
  11405. return ids
  11406. }
  11407. return nil
  11408. }
  11409. // RemovedEdges returns all edge names that were removed in this mutation.
  11410. func (m *ContactMutation) RemovedEdges() []string {
  11411. edges := make([]string, 0, 2)
  11412. if m.removedcontact_relationships != nil {
  11413. edges = append(edges, contact.EdgeContactRelationships)
  11414. }
  11415. if m.removedcontact_messages != nil {
  11416. edges = append(edges, contact.EdgeContactMessages)
  11417. }
  11418. return edges
  11419. }
  11420. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11421. // the given name in this mutation.
  11422. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11423. switch name {
  11424. case contact.EdgeContactRelationships:
  11425. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11426. for id := range m.removedcontact_relationships {
  11427. ids = append(ids, id)
  11428. }
  11429. return ids
  11430. case contact.EdgeContactMessages:
  11431. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11432. for id := range m.removedcontact_messages {
  11433. ids = append(ids, id)
  11434. }
  11435. return ids
  11436. }
  11437. return nil
  11438. }
  11439. // ClearedEdges returns all edge names that were cleared in this mutation.
  11440. func (m *ContactMutation) ClearedEdges() []string {
  11441. edges := make([]string, 0, 2)
  11442. if m.clearedcontact_relationships {
  11443. edges = append(edges, contact.EdgeContactRelationships)
  11444. }
  11445. if m.clearedcontact_messages {
  11446. edges = append(edges, contact.EdgeContactMessages)
  11447. }
  11448. return edges
  11449. }
  11450. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11451. // was cleared in this mutation.
  11452. func (m *ContactMutation) EdgeCleared(name string) bool {
  11453. switch name {
  11454. case contact.EdgeContactRelationships:
  11455. return m.clearedcontact_relationships
  11456. case contact.EdgeContactMessages:
  11457. return m.clearedcontact_messages
  11458. }
  11459. return false
  11460. }
  11461. // ClearEdge clears the value of the edge with the given name. It returns an error
  11462. // if that edge is not defined in the schema.
  11463. func (m *ContactMutation) ClearEdge(name string) error {
  11464. switch name {
  11465. }
  11466. return fmt.Errorf("unknown Contact unique edge %s", name)
  11467. }
  11468. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11469. // It returns an error if the edge is not defined in the schema.
  11470. func (m *ContactMutation) ResetEdge(name string) error {
  11471. switch name {
  11472. case contact.EdgeContactRelationships:
  11473. m.ResetContactRelationships()
  11474. return nil
  11475. case contact.EdgeContactMessages:
  11476. m.ResetContactMessages()
  11477. return nil
  11478. }
  11479. return fmt.Errorf("unknown Contact edge %s", name)
  11480. }
  11481. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11482. type CreditBalanceMutation struct {
  11483. config
  11484. op Op
  11485. typ string
  11486. id *uint64
  11487. created_at *time.Time
  11488. updated_at *time.Time
  11489. deleted_at *time.Time
  11490. user_id *string
  11491. balance *float32
  11492. addbalance *float32
  11493. status *int
  11494. addstatus *int
  11495. organization_id *uint64
  11496. addorganization_id *int64
  11497. clearedFields map[string]struct{}
  11498. done bool
  11499. oldValue func(context.Context) (*CreditBalance, error)
  11500. predicates []predicate.CreditBalance
  11501. }
  11502. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11503. // creditbalanceOption allows management of the mutation configuration using functional options.
  11504. type creditbalanceOption func(*CreditBalanceMutation)
  11505. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11506. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11507. m := &CreditBalanceMutation{
  11508. config: c,
  11509. op: op,
  11510. typ: TypeCreditBalance,
  11511. clearedFields: make(map[string]struct{}),
  11512. }
  11513. for _, opt := range opts {
  11514. opt(m)
  11515. }
  11516. return m
  11517. }
  11518. // withCreditBalanceID sets the ID field of the mutation.
  11519. func withCreditBalanceID(id uint64) creditbalanceOption {
  11520. return func(m *CreditBalanceMutation) {
  11521. var (
  11522. err error
  11523. once sync.Once
  11524. value *CreditBalance
  11525. )
  11526. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11527. once.Do(func() {
  11528. if m.done {
  11529. err = errors.New("querying old values post mutation is not allowed")
  11530. } else {
  11531. value, err = m.Client().CreditBalance.Get(ctx, id)
  11532. }
  11533. })
  11534. return value, err
  11535. }
  11536. m.id = &id
  11537. }
  11538. }
  11539. // withCreditBalance sets the old CreditBalance of the mutation.
  11540. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11541. return func(m *CreditBalanceMutation) {
  11542. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11543. return node, nil
  11544. }
  11545. m.id = &node.ID
  11546. }
  11547. }
  11548. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11549. // executed in a transaction (ent.Tx), a transactional client is returned.
  11550. func (m CreditBalanceMutation) Client() *Client {
  11551. client := &Client{config: m.config}
  11552. client.init()
  11553. return client
  11554. }
  11555. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11556. // it returns an error otherwise.
  11557. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11558. if _, ok := m.driver.(*txDriver); !ok {
  11559. return nil, errors.New("ent: mutation is not running in a transaction")
  11560. }
  11561. tx := &Tx{config: m.config}
  11562. tx.init()
  11563. return tx, nil
  11564. }
  11565. // SetID sets the value of the id field. Note that this
  11566. // operation is only accepted on creation of CreditBalance entities.
  11567. func (m *CreditBalanceMutation) SetID(id uint64) {
  11568. m.id = &id
  11569. }
  11570. // ID returns the ID value in the mutation. Note that the ID is only available
  11571. // if it was provided to the builder or after it was returned from the database.
  11572. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11573. if m.id == nil {
  11574. return
  11575. }
  11576. return *m.id, true
  11577. }
  11578. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11579. // That means, if the mutation is applied within a transaction with an isolation level such
  11580. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11581. // or updated by the mutation.
  11582. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11583. switch {
  11584. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11585. id, exists := m.ID()
  11586. if exists {
  11587. return []uint64{id}, nil
  11588. }
  11589. fallthrough
  11590. case m.op.Is(OpUpdate | OpDelete):
  11591. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11592. default:
  11593. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11594. }
  11595. }
  11596. // SetCreatedAt sets the "created_at" field.
  11597. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11598. m.created_at = &t
  11599. }
  11600. // CreatedAt returns the value of the "created_at" field in the mutation.
  11601. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11602. v := m.created_at
  11603. if v == nil {
  11604. return
  11605. }
  11606. return *v, true
  11607. }
  11608. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11609. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11611. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11612. if !m.op.Is(OpUpdateOne) {
  11613. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11614. }
  11615. if m.id == nil || m.oldValue == nil {
  11616. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11617. }
  11618. oldValue, err := m.oldValue(ctx)
  11619. if err != nil {
  11620. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11621. }
  11622. return oldValue.CreatedAt, nil
  11623. }
  11624. // ResetCreatedAt resets all changes to the "created_at" field.
  11625. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11626. m.created_at = nil
  11627. }
  11628. // SetUpdatedAt sets the "updated_at" field.
  11629. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11630. m.updated_at = &t
  11631. }
  11632. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11633. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11634. v := m.updated_at
  11635. if v == nil {
  11636. return
  11637. }
  11638. return *v, true
  11639. }
  11640. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11641. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11643. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11644. if !m.op.Is(OpUpdateOne) {
  11645. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11646. }
  11647. if m.id == nil || m.oldValue == nil {
  11648. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11649. }
  11650. oldValue, err := m.oldValue(ctx)
  11651. if err != nil {
  11652. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11653. }
  11654. return oldValue.UpdatedAt, nil
  11655. }
  11656. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11657. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11658. m.updated_at = nil
  11659. }
  11660. // SetDeletedAt sets the "deleted_at" field.
  11661. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11662. m.deleted_at = &t
  11663. }
  11664. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11665. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11666. v := m.deleted_at
  11667. if v == nil {
  11668. return
  11669. }
  11670. return *v, true
  11671. }
  11672. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11673. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11675. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11676. if !m.op.Is(OpUpdateOne) {
  11677. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11678. }
  11679. if m.id == nil || m.oldValue == nil {
  11680. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11681. }
  11682. oldValue, err := m.oldValue(ctx)
  11683. if err != nil {
  11684. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11685. }
  11686. return oldValue.DeletedAt, nil
  11687. }
  11688. // ClearDeletedAt clears the value of the "deleted_at" field.
  11689. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11690. m.deleted_at = nil
  11691. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11692. }
  11693. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11694. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11695. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11696. return ok
  11697. }
  11698. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11699. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11700. m.deleted_at = nil
  11701. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11702. }
  11703. // SetUserID sets the "user_id" field.
  11704. func (m *CreditBalanceMutation) SetUserID(s string) {
  11705. m.user_id = &s
  11706. }
  11707. // UserID returns the value of the "user_id" field in the mutation.
  11708. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11709. v := m.user_id
  11710. if v == nil {
  11711. return
  11712. }
  11713. return *v, true
  11714. }
  11715. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11716. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11718. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11719. if !m.op.Is(OpUpdateOne) {
  11720. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11721. }
  11722. if m.id == nil || m.oldValue == nil {
  11723. return v, errors.New("OldUserID requires an ID field in the mutation")
  11724. }
  11725. oldValue, err := m.oldValue(ctx)
  11726. if err != nil {
  11727. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11728. }
  11729. return oldValue.UserID, nil
  11730. }
  11731. // ClearUserID clears the value of the "user_id" field.
  11732. func (m *CreditBalanceMutation) ClearUserID() {
  11733. m.user_id = nil
  11734. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11735. }
  11736. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11737. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11738. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11739. return ok
  11740. }
  11741. // ResetUserID resets all changes to the "user_id" field.
  11742. func (m *CreditBalanceMutation) ResetUserID() {
  11743. m.user_id = nil
  11744. delete(m.clearedFields, creditbalance.FieldUserID)
  11745. }
  11746. // SetBalance sets the "balance" field.
  11747. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11748. m.balance = &f
  11749. m.addbalance = nil
  11750. }
  11751. // Balance returns the value of the "balance" field in the mutation.
  11752. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11753. v := m.balance
  11754. if v == nil {
  11755. return
  11756. }
  11757. return *v, true
  11758. }
  11759. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11760. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11762. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  11763. if !m.op.Is(OpUpdateOne) {
  11764. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  11765. }
  11766. if m.id == nil || m.oldValue == nil {
  11767. return v, errors.New("OldBalance requires an ID field in the mutation")
  11768. }
  11769. oldValue, err := m.oldValue(ctx)
  11770. if err != nil {
  11771. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  11772. }
  11773. return oldValue.Balance, nil
  11774. }
  11775. // AddBalance adds f to the "balance" field.
  11776. func (m *CreditBalanceMutation) AddBalance(f float32) {
  11777. if m.addbalance != nil {
  11778. *m.addbalance += f
  11779. } else {
  11780. m.addbalance = &f
  11781. }
  11782. }
  11783. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  11784. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  11785. v := m.addbalance
  11786. if v == nil {
  11787. return
  11788. }
  11789. return *v, true
  11790. }
  11791. // ResetBalance resets all changes to the "balance" field.
  11792. func (m *CreditBalanceMutation) ResetBalance() {
  11793. m.balance = nil
  11794. m.addbalance = nil
  11795. }
  11796. // SetStatus sets the "status" field.
  11797. func (m *CreditBalanceMutation) SetStatus(i int) {
  11798. m.status = &i
  11799. m.addstatus = nil
  11800. }
  11801. // Status returns the value of the "status" field in the mutation.
  11802. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  11803. v := m.status
  11804. if v == nil {
  11805. return
  11806. }
  11807. return *v, true
  11808. }
  11809. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  11810. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11812. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  11813. if !m.op.Is(OpUpdateOne) {
  11814. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11815. }
  11816. if m.id == nil || m.oldValue == nil {
  11817. return v, errors.New("OldStatus requires an ID field in the mutation")
  11818. }
  11819. oldValue, err := m.oldValue(ctx)
  11820. if err != nil {
  11821. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11822. }
  11823. return oldValue.Status, nil
  11824. }
  11825. // AddStatus adds i to the "status" field.
  11826. func (m *CreditBalanceMutation) AddStatus(i int) {
  11827. if m.addstatus != nil {
  11828. *m.addstatus += i
  11829. } else {
  11830. m.addstatus = &i
  11831. }
  11832. }
  11833. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11834. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  11835. v := m.addstatus
  11836. if v == nil {
  11837. return
  11838. }
  11839. return *v, true
  11840. }
  11841. // ClearStatus clears the value of the "status" field.
  11842. func (m *CreditBalanceMutation) ClearStatus() {
  11843. m.status = nil
  11844. m.addstatus = nil
  11845. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  11846. }
  11847. // StatusCleared returns if the "status" field was cleared in this mutation.
  11848. func (m *CreditBalanceMutation) StatusCleared() bool {
  11849. _, ok := m.clearedFields[creditbalance.FieldStatus]
  11850. return ok
  11851. }
  11852. // ResetStatus resets all changes to the "status" field.
  11853. func (m *CreditBalanceMutation) ResetStatus() {
  11854. m.status = nil
  11855. m.addstatus = nil
  11856. delete(m.clearedFields, creditbalance.FieldStatus)
  11857. }
  11858. // SetOrganizationID sets the "organization_id" field.
  11859. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  11860. m.organization_id = &u
  11861. m.addorganization_id = nil
  11862. }
  11863. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11864. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  11865. v := m.organization_id
  11866. if v == nil {
  11867. return
  11868. }
  11869. return *v, true
  11870. }
  11871. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  11872. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11874. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11875. if !m.op.Is(OpUpdateOne) {
  11876. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11877. }
  11878. if m.id == nil || m.oldValue == nil {
  11879. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11880. }
  11881. oldValue, err := m.oldValue(ctx)
  11882. if err != nil {
  11883. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11884. }
  11885. return oldValue.OrganizationID, nil
  11886. }
  11887. // AddOrganizationID adds u to the "organization_id" field.
  11888. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  11889. if m.addorganization_id != nil {
  11890. *m.addorganization_id += u
  11891. } else {
  11892. m.addorganization_id = &u
  11893. }
  11894. }
  11895. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11896. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  11897. v := m.addorganization_id
  11898. if v == nil {
  11899. return
  11900. }
  11901. return *v, true
  11902. }
  11903. // ClearOrganizationID clears the value of the "organization_id" field.
  11904. func (m *CreditBalanceMutation) ClearOrganizationID() {
  11905. m.organization_id = nil
  11906. m.addorganization_id = nil
  11907. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  11908. }
  11909. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11910. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  11911. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  11912. return ok
  11913. }
  11914. // ResetOrganizationID resets all changes to the "organization_id" field.
  11915. func (m *CreditBalanceMutation) ResetOrganizationID() {
  11916. m.organization_id = nil
  11917. m.addorganization_id = nil
  11918. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  11919. }
  11920. // Where appends a list predicates to the CreditBalanceMutation builder.
  11921. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  11922. m.predicates = append(m.predicates, ps...)
  11923. }
  11924. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  11925. // users can use type-assertion to append predicates that do not depend on any generated package.
  11926. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  11927. p := make([]predicate.CreditBalance, len(ps))
  11928. for i := range ps {
  11929. p[i] = ps[i]
  11930. }
  11931. m.Where(p...)
  11932. }
  11933. // Op returns the operation name.
  11934. func (m *CreditBalanceMutation) Op() Op {
  11935. return m.op
  11936. }
  11937. // SetOp allows setting the mutation operation.
  11938. func (m *CreditBalanceMutation) SetOp(op Op) {
  11939. m.op = op
  11940. }
  11941. // Type returns the node type of this mutation (CreditBalance).
  11942. func (m *CreditBalanceMutation) Type() string {
  11943. return m.typ
  11944. }
  11945. // Fields returns all fields that were changed during this mutation. Note that in
  11946. // order to get all numeric fields that were incremented/decremented, call
  11947. // AddedFields().
  11948. func (m *CreditBalanceMutation) Fields() []string {
  11949. fields := make([]string, 0, 7)
  11950. if m.created_at != nil {
  11951. fields = append(fields, creditbalance.FieldCreatedAt)
  11952. }
  11953. if m.updated_at != nil {
  11954. fields = append(fields, creditbalance.FieldUpdatedAt)
  11955. }
  11956. if m.deleted_at != nil {
  11957. fields = append(fields, creditbalance.FieldDeletedAt)
  11958. }
  11959. if m.user_id != nil {
  11960. fields = append(fields, creditbalance.FieldUserID)
  11961. }
  11962. if m.balance != nil {
  11963. fields = append(fields, creditbalance.FieldBalance)
  11964. }
  11965. if m.status != nil {
  11966. fields = append(fields, creditbalance.FieldStatus)
  11967. }
  11968. if m.organization_id != nil {
  11969. fields = append(fields, creditbalance.FieldOrganizationID)
  11970. }
  11971. return fields
  11972. }
  11973. // Field returns the value of a field with the given name. The second boolean
  11974. // return value indicates that this field was not set, or was not defined in the
  11975. // schema.
  11976. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  11977. switch name {
  11978. case creditbalance.FieldCreatedAt:
  11979. return m.CreatedAt()
  11980. case creditbalance.FieldUpdatedAt:
  11981. return m.UpdatedAt()
  11982. case creditbalance.FieldDeletedAt:
  11983. return m.DeletedAt()
  11984. case creditbalance.FieldUserID:
  11985. return m.UserID()
  11986. case creditbalance.FieldBalance:
  11987. return m.Balance()
  11988. case creditbalance.FieldStatus:
  11989. return m.Status()
  11990. case creditbalance.FieldOrganizationID:
  11991. return m.OrganizationID()
  11992. }
  11993. return nil, false
  11994. }
  11995. // OldField returns the old value of the field from the database. An error is
  11996. // returned if the mutation operation is not UpdateOne, or the query to the
  11997. // database failed.
  11998. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11999. switch name {
  12000. case creditbalance.FieldCreatedAt:
  12001. return m.OldCreatedAt(ctx)
  12002. case creditbalance.FieldUpdatedAt:
  12003. return m.OldUpdatedAt(ctx)
  12004. case creditbalance.FieldDeletedAt:
  12005. return m.OldDeletedAt(ctx)
  12006. case creditbalance.FieldUserID:
  12007. return m.OldUserID(ctx)
  12008. case creditbalance.FieldBalance:
  12009. return m.OldBalance(ctx)
  12010. case creditbalance.FieldStatus:
  12011. return m.OldStatus(ctx)
  12012. case creditbalance.FieldOrganizationID:
  12013. return m.OldOrganizationID(ctx)
  12014. }
  12015. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  12016. }
  12017. // SetField sets the value of a field with the given name. It returns an error if
  12018. // the field is not defined in the schema, or if the type mismatched the field
  12019. // type.
  12020. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  12021. switch name {
  12022. case creditbalance.FieldCreatedAt:
  12023. v, ok := value.(time.Time)
  12024. if !ok {
  12025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12026. }
  12027. m.SetCreatedAt(v)
  12028. return nil
  12029. case creditbalance.FieldUpdatedAt:
  12030. v, ok := value.(time.Time)
  12031. if !ok {
  12032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12033. }
  12034. m.SetUpdatedAt(v)
  12035. return nil
  12036. case creditbalance.FieldDeletedAt:
  12037. v, ok := value.(time.Time)
  12038. if !ok {
  12039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12040. }
  12041. m.SetDeletedAt(v)
  12042. return nil
  12043. case creditbalance.FieldUserID:
  12044. v, ok := value.(string)
  12045. if !ok {
  12046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12047. }
  12048. m.SetUserID(v)
  12049. return nil
  12050. case creditbalance.FieldBalance:
  12051. v, ok := value.(float32)
  12052. if !ok {
  12053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12054. }
  12055. m.SetBalance(v)
  12056. return nil
  12057. case creditbalance.FieldStatus:
  12058. v, ok := value.(int)
  12059. if !ok {
  12060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12061. }
  12062. m.SetStatus(v)
  12063. return nil
  12064. case creditbalance.FieldOrganizationID:
  12065. v, ok := value.(uint64)
  12066. if !ok {
  12067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12068. }
  12069. m.SetOrganizationID(v)
  12070. return nil
  12071. }
  12072. return fmt.Errorf("unknown CreditBalance field %s", name)
  12073. }
  12074. // AddedFields returns all numeric fields that were incremented/decremented during
  12075. // this mutation.
  12076. func (m *CreditBalanceMutation) AddedFields() []string {
  12077. var fields []string
  12078. if m.addbalance != nil {
  12079. fields = append(fields, creditbalance.FieldBalance)
  12080. }
  12081. if m.addstatus != nil {
  12082. fields = append(fields, creditbalance.FieldStatus)
  12083. }
  12084. if m.addorganization_id != nil {
  12085. fields = append(fields, creditbalance.FieldOrganizationID)
  12086. }
  12087. return fields
  12088. }
  12089. // AddedField returns the numeric value that was incremented/decremented on a field
  12090. // with the given name. The second boolean return value indicates that this field
  12091. // was not set, or was not defined in the schema.
  12092. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12093. switch name {
  12094. case creditbalance.FieldBalance:
  12095. return m.AddedBalance()
  12096. case creditbalance.FieldStatus:
  12097. return m.AddedStatus()
  12098. case creditbalance.FieldOrganizationID:
  12099. return m.AddedOrganizationID()
  12100. }
  12101. return nil, false
  12102. }
  12103. // AddField adds the value to the field with the given name. It returns an error if
  12104. // the field is not defined in the schema, or if the type mismatched the field
  12105. // type.
  12106. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12107. switch name {
  12108. case creditbalance.FieldBalance:
  12109. v, ok := value.(float32)
  12110. if !ok {
  12111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12112. }
  12113. m.AddBalance(v)
  12114. return nil
  12115. case creditbalance.FieldStatus:
  12116. v, ok := value.(int)
  12117. if !ok {
  12118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12119. }
  12120. m.AddStatus(v)
  12121. return nil
  12122. case creditbalance.FieldOrganizationID:
  12123. v, ok := value.(int64)
  12124. if !ok {
  12125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12126. }
  12127. m.AddOrganizationID(v)
  12128. return nil
  12129. }
  12130. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12131. }
  12132. // ClearedFields returns all nullable fields that were cleared during this
  12133. // mutation.
  12134. func (m *CreditBalanceMutation) ClearedFields() []string {
  12135. var fields []string
  12136. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12137. fields = append(fields, creditbalance.FieldDeletedAt)
  12138. }
  12139. if m.FieldCleared(creditbalance.FieldUserID) {
  12140. fields = append(fields, creditbalance.FieldUserID)
  12141. }
  12142. if m.FieldCleared(creditbalance.FieldStatus) {
  12143. fields = append(fields, creditbalance.FieldStatus)
  12144. }
  12145. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12146. fields = append(fields, creditbalance.FieldOrganizationID)
  12147. }
  12148. return fields
  12149. }
  12150. // FieldCleared returns a boolean indicating if a field with the given name was
  12151. // cleared in this mutation.
  12152. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12153. _, ok := m.clearedFields[name]
  12154. return ok
  12155. }
  12156. // ClearField clears the value of the field with the given name. It returns an
  12157. // error if the field is not defined in the schema.
  12158. func (m *CreditBalanceMutation) ClearField(name string) error {
  12159. switch name {
  12160. case creditbalance.FieldDeletedAt:
  12161. m.ClearDeletedAt()
  12162. return nil
  12163. case creditbalance.FieldUserID:
  12164. m.ClearUserID()
  12165. return nil
  12166. case creditbalance.FieldStatus:
  12167. m.ClearStatus()
  12168. return nil
  12169. case creditbalance.FieldOrganizationID:
  12170. m.ClearOrganizationID()
  12171. return nil
  12172. }
  12173. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12174. }
  12175. // ResetField resets all changes in the mutation for the field with the given name.
  12176. // It returns an error if the field is not defined in the schema.
  12177. func (m *CreditBalanceMutation) ResetField(name string) error {
  12178. switch name {
  12179. case creditbalance.FieldCreatedAt:
  12180. m.ResetCreatedAt()
  12181. return nil
  12182. case creditbalance.FieldUpdatedAt:
  12183. m.ResetUpdatedAt()
  12184. return nil
  12185. case creditbalance.FieldDeletedAt:
  12186. m.ResetDeletedAt()
  12187. return nil
  12188. case creditbalance.FieldUserID:
  12189. m.ResetUserID()
  12190. return nil
  12191. case creditbalance.FieldBalance:
  12192. m.ResetBalance()
  12193. return nil
  12194. case creditbalance.FieldStatus:
  12195. m.ResetStatus()
  12196. return nil
  12197. case creditbalance.FieldOrganizationID:
  12198. m.ResetOrganizationID()
  12199. return nil
  12200. }
  12201. return fmt.Errorf("unknown CreditBalance field %s", name)
  12202. }
  12203. // AddedEdges returns all edge names that were set/added in this mutation.
  12204. func (m *CreditBalanceMutation) AddedEdges() []string {
  12205. edges := make([]string, 0, 0)
  12206. return edges
  12207. }
  12208. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12209. // name in this mutation.
  12210. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12211. return nil
  12212. }
  12213. // RemovedEdges returns all edge names that were removed in this mutation.
  12214. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12215. edges := make([]string, 0, 0)
  12216. return edges
  12217. }
  12218. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12219. // the given name in this mutation.
  12220. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12221. return nil
  12222. }
  12223. // ClearedEdges returns all edge names that were cleared in this mutation.
  12224. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12225. edges := make([]string, 0, 0)
  12226. return edges
  12227. }
  12228. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12229. // was cleared in this mutation.
  12230. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12231. return false
  12232. }
  12233. // ClearEdge clears the value of the edge with the given name. It returns an error
  12234. // if that edge is not defined in the schema.
  12235. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12236. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12237. }
  12238. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12239. // It returns an error if the edge is not defined in the schema.
  12240. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12241. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12242. }
  12243. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12244. type CreditUsageMutation struct {
  12245. config
  12246. op Op
  12247. typ string
  12248. id *uint64
  12249. created_at *time.Time
  12250. updated_at *time.Time
  12251. deleted_at *time.Time
  12252. user_id *string
  12253. number *float32
  12254. addnumber *float32
  12255. status *int
  12256. addstatus *int
  12257. ntype *int
  12258. addntype *int
  12259. table *string
  12260. organization_id *uint64
  12261. addorganization_id *int64
  12262. nid *uint64
  12263. addnid *int64
  12264. reason *string
  12265. operator *string
  12266. clearedFields map[string]struct{}
  12267. done bool
  12268. oldValue func(context.Context) (*CreditUsage, error)
  12269. predicates []predicate.CreditUsage
  12270. }
  12271. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12272. // creditusageOption allows management of the mutation configuration using functional options.
  12273. type creditusageOption func(*CreditUsageMutation)
  12274. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12275. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12276. m := &CreditUsageMutation{
  12277. config: c,
  12278. op: op,
  12279. typ: TypeCreditUsage,
  12280. clearedFields: make(map[string]struct{}),
  12281. }
  12282. for _, opt := range opts {
  12283. opt(m)
  12284. }
  12285. return m
  12286. }
  12287. // withCreditUsageID sets the ID field of the mutation.
  12288. func withCreditUsageID(id uint64) creditusageOption {
  12289. return func(m *CreditUsageMutation) {
  12290. var (
  12291. err error
  12292. once sync.Once
  12293. value *CreditUsage
  12294. )
  12295. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12296. once.Do(func() {
  12297. if m.done {
  12298. err = errors.New("querying old values post mutation is not allowed")
  12299. } else {
  12300. value, err = m.Client().CreditUsage.Get(ctx, id)
  12301. }
  12302. })
  12303. return value, err
  12304. }
  12305. m.id = &id
  12306. }
  12307. }
  12308. // withCreditUsage sets the old CreditUsage of the mutation.
  12309. func withCreditUsage(node *CreditUsage) creditusageOption {
  12310. return func(m *CreditUsageMutation) {
  12311. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12312. return node, nil
  12313. }
  12314. m.id = &node.ID
  12315. }
  12316. }
  12317. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12318. // executed in a transaction (ent.Tx), a transactional client is returned.
  12319. func (m CreditUsageMutation) Client() *Client {
  12320. client := &Client{config: m.config}
  12321. client.init()
  12322. return client
  12323. }
  12324. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12325. // it returns an error otherwise.
  12326. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12327. if _, ok := m.driver.(*txDriver); !ok {
  12328. return nil, errors.New("ent: mutation is not running in a transaction")
  12329. }
  12330. tx := &Tx{config: m.config}
  12331. tx.init()
  12332. return tx, nil
  12333. }
  12334. // SetID sets the value of the id field. Note that this
  12335. // operation is only accepted on creation of CreditUsage entities.
  12336. func (m *CreditUsageMutation) SetID(id uint64) {
  12337. m.id = &id
  12338. }
  12339. // ID returns the ID value in the mutation. Note that the ID is only available
  12340. // if it was provided to the builder or after it was returned from the database.
  12341. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12342. if m.id == nil {
  12343. return
  12344. }
  12345. return *m.id, true
  12346. }
  12347. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12348. // That means, if the mutation is applied within a transaction with an isolation level such
  12349. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12350. // or updated by the mutation.
  12351. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12352. switch {
  12353. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12354. id, exists := m.ID()
  12355. if exists {
  12356. return []uint64{id}, nil
  12357. }
  12358. fallthrough
  12359. case m.op.Is(OpUpdate | OpDelete):
  12360. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12361. default:
  12362. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12363. }
  12364. }
  12365. // SetCreatedAt sets the "created_at" field.
  12366. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12367. m.created_at = &t
  12368. }
  12369. // CreatedAt returns the value of the "created_at" field in the mutation.
  12370. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12371. v := m.created_at
  12372. if v == nil {
  12373. return
  12374. }
  12375. return *v, true
  12376. }
  12377. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12378. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12380. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12381. if !m.op.Is(OpUpdateOne) {
  12382. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12383. }
  12384. if m.id == nil || m.oldValue == nil {
  12385. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12386. }
  12387. oldValue, err := m.oldValue(ctx)
  12388. if err != nil {
  12389. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12390. }
  12391. return oldValue.CreatedAt, nil
  12392. }
  12393. // ResetCreatedAt resets all changes to the "created_at" field.
  12394. func (m *CreditUsageMutation) ResetCreatedAt() {
  12395. m.created_at = nil
  12396. }
  12397. // SetUpdatedAt sets the "updated_at" field.
  12398. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12399. m.updated_at = &t
  12400. }
  12401. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12402. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12403. v := m.updated_at
  12404. if v == nil {
  12405. return
  12406. }
  12407. return *v, true
  12408. }
  12409. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12410. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12412. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12413. if !m.op.Is(OpUpdateOne) {
  12414. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12415. }
  12416. if m.id == nil || m.oldValue == nil {
  12417. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12418. }
  12419. oldValue, err := m.oldValue(ctx)
  12420. if err != nil {
  12421. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12422. }
  12423. return oldValue.UpdatedAt, nil
  12424. }
  12425. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12426. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12427. m.updated_at = nil
  12428. }
  12429. // SetDeletedAt sets the "deleted_at" field.
  12430. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12431. m.deleted_at = &t
  12432. }
  12433. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12434. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12435. v := m.deleted_at
  12436. if v == nil {
  12437. return
  12438. }
  12439. return *v, true
  12440. }
  12441. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12442. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12444. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12445. if !m.op.Is(OpUpdateOne) {
  12446. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12447. }
  12448. if m.id == nil || m.oldValue == nil {
  12449. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12450. }
  12451. oldValue, err := m.oldValue(ctx)
  12452. if err != nil {
  12453. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12454. }
  12455. return oldValue.DeletedAt, nil
  12456. }
  12457. // ClearDeletedAt clears the value of the "deleted_at" field.
  12458. func (m *CreditUsageMutation) ClearDeletedAt() {
  12459. m.deleted_at = nil
  12460. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12461. }
  12462. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12463. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12464. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12465. return ok
  12466. }
  12467. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12468. func (m *CreditUsageMutation) ResetDeletedAt() {
  12469. m.deleted_at = nil
  12470. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12471. }
  12472. // SetUserID sets the "user_id" field.
  12473. func (m *CreditUsageMutation) SetUserID(s string) {
  12474. m.user_id = &s
  12475. }
  12476. // UserID returns the value of the "user_id" field in the mutation.
  12477. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12478. v := m.user_id
  12479. if v == nil {
  12480. return
  12481. }
  12482. return *v, true
  12483. }
  12484. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12485. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12487. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12488. if !m.op.Is(OpUpdateOne) {
  12489. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12490. }
  12491. if m.id == nil || m.oldValue == nil {
  12492. return v, errors.New("OldUserID requires an ID field in the mutation")
  12493. }
  12494. oldValue, err := m.oldValue(ctx)
  12495. if err != nil {
  12496. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12497. }
  12498. return oldValue.UserID, nil
  12499. }
  12500. // ClearUserID clears the value of the "user_id" field.
  12501. func (m *CreditUsageMutation) ClearUserID() {
  12502. m.user_id = nil
  12503. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12504. }
  12505. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12506. func (m *CreditUsageMutation) UserIDCleared() bool {
  12507. _, ok := m.clearedFields[creditusage.FieldUserID]
  12508. return ok
  12509. }
  12510. // ResetUserID resets all changes to the "user_id" field.
  12511. func (m *CreditUsageMutation) ResetUserID() {
  12512. m.user_id = nil
  12513. delete(m.clearedFields, creditusage.FieldUserID)
  12514. }
  12515. // SetNumber sets the "number" field.
  12516. func (m *CreditUsageMutation) SetNumber(f float32) {
  12517. m.number = &f
  12518. m.addnumber = nil
  12519. }
  12520. // Number returns the value of the "number" field in the mutation.
  12521. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12522. v := m.number
  12523. if v == nil {
  12524. return
  12525. }
  12526. return *v, true
  12527. }
  12528. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12529. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12531. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12532. if !m.op.Is(OpUpdateOne) {
  12533. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12534. }
  12535. if m.id == nil || m.oldValue == nil {
  12536. return v, errors.New("OldNumber requires an ID field in the mutation")
  12537. }
  12538. oldValue, err := m.oldValue(ctx)
  12539. if err != nil {
  12540. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12541. }
  12542. return oldValue.Number, nil
  12543. }
  12544. // AddNumber adds f to the "number" field.
  12545. func (m *CreditUsageMutation) AddNumber(f float32) {
  12546. if m.addnumber != nil {
  12547. *m.addnumber += f
  12548. } else {
  12549. m.addnumber = &f
  12550. }
  12551. }
  12552. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12553. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12554. v := m.addnumber
  12555. if v == nil {
  12556. return
  12557. }
  12558. return *v, true
  12559. }
  12560. // ResetNumber resets all changes to the "number" field.
  12561. func (m *CreditUsageMutation) ResetNumber() {
  12562. m.number = nil
  12563. m.addnumber = nil
  12564. }
  12565. // SetStatus sets the "status" field.
  12566. func (m *CreditUsageMutation) SetStatus(i int) {
  12567. m.status = &i
  12568. m.addstatus = nil
  12569. }
  12570. // Status returns the value of the "status" field in the mutation.
  12571. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12572. v := m.status
  12573. if v == nil {
  12574. return
  12575. }
  12576. return *v, true
  12577. }
  12578. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12579. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12581. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12582. if !m.op.Is(OpUpdateOne) {
  12583. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12584. }
  12585. if m.id == nil || m.oldValue == nil {
  12586. return v, errors.New("OldStatus requires an ID field in the mutation")
  12587. }
  12588. oldValue, err := m.oldValue(ctx)
  12589. if err != nil {
  12590. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12591. }
  12592. return oldValue.Status, nil
  12593. }
  12594. // AddStatus adds i to the "status" field.
  12595. func (m *CreditUsageMutation) AddStatus(i int) {
  12596. if m.addstatus != nil {
  12597. *m.addstatus += i
  12598. } else {
  12599. m.addstatus = &i
  12600. }
  12601. }
  12602. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12603. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12604. v := m.addstatus
  12605. if v == nil {
  12606. return
  12607. }
  12608. return *v, true
  12609. }
  12610. // ClearStatus clears the value of the "status" field.
  12611. func (m *CreditUsageMutation) ClearStatus() {
  12612. m.status = nil
  12613. m.addstatus = nil
  12614. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12615. }
  12616. // StatusCleared returns if the "status" field was cleared in this mutation.
  12617. func (m *CreditUsageMutation) StatusCleared() bool {
  12618. _, ok := m.clearedFields[creditusage.FieldStatus]
  12619. return ok
  12620. }
  12621. // ResetStatus resets all changes to the "status" field.
  12622. func (m *CreditUsageMutation) ResetStatus() {
  12623. m.status = nil
  12624. m.addstatus = nil
  12625. delete(m.clearedFields, creditusage.FieldStatus)
  12626. }
  12627. // SetNtype sets the "ntype" field.
  12628. func (m *CreditUsageMutation) SetNtype(i int) {
  12629. m.ntype = &i
  12630. m.addntype = nil
  12631. }
  12632. // Ntype returns the value of the "ntype" field in the mutation.
  12633. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12634. v := m.ntype
  12635. if v == nil {
  12636. return
  12637. }
  12638. return *v, true
  12639. }
  12640. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  12641. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12643. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  12644. if !m.op.Is(OpUpdateOne) {
  12645. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12646. }
  12647. if m.id == nil || m.oldValue == nil {
  12648. return v, errors.New("OldNtype requires an ID field in the mutation")
  12649. }
  12650. oldValue, err := m.oldValue(ctx)
  12651. if err != nil {
  12652. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  12653. }
  12654. return oldValue.Ntype, nil
  12655. }
  12656. // AddNtype adds i to the "ntype" field.
  12657. func (m *CreditUsageMutation) AddNtype(i int) {
  12658. if m.addntype != nil {
  12659. *m.addntype += i
  12660. } else {
  12661. m.addntype = &i
  12662. }
  12663. }
  12664. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12665. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12666. v := m.addntype
  12667. if v == nil {
  12668. return
  12669. }
  12670. return *v, true
  12671. }
  12672. // ResetNtype resets all changes to the "ntype" field.
  12673. func (m *CreditUsageMutation) ResetNtype() {
  12674. m.ntype = nil
  12675. m.addntype = nil
  12676. }
  12677. // SetTable sets the "table" field.
  12678. func (m *CreditUsageMutation) SetTable(s string) {
  12679. m.table = &s
  12680. }
  12681. // Table returns the value of the "table" field in the mutation.
  12682. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12683. v := m.table
  12684. if v == nil {
  12685. return
  12686. }
  12687. return *v, true
  12688. }
  12689. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12690. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12692. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12693. if !m.op.Is(OpUpdateOne) {
  12694. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12695. }
  12696. if m.id == nil || m.oldValue == nil {
  12697. return v, errors.New("OldTable requires an ID field in the mutation")
  12698. }
  12699. oldValue, err := m.oldValue(ctx)
  12700. if err != nil {
  12701. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12702. }
  12703. return oldValue.Table, nil
  12704. }
  12705. // ResetTable resets all changes to the "table" field.
  12706. func (m *CreditUsageMutation) ResetTable() {
  12707. m.table = nil
  12708. }
  12709. // SetOrganizationID sets the "organization_id" field.
  12710. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12711. m.organization_id = &u
  12712. m.addorganization_id = nil
  12713. }
  12714. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12715. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12716. v := m.organization_id
  12717. if v == nil {
  12718. return
  12719. }
  12720. return *v, true
  12721. }
  12722. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12723. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12725. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12726. if !m.op.Is(OpUpdateOne) {
  12727. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12728. }
  12729. if m.id == nil || m.oldValue == nil {
  12730. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12731. }
  12732. oldValue, err := m.oldValue(ctx)
  12733. if err != nil {
  12734. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12735. }
  12736. return oldValue.OrganizationID, nil
  12737. }
  12738. // AddOrganizationID adds u to the "organization_id" field.
  12739. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12740. if m.addorganization_id != nil {
  12741. *m.addorganization_id += u
  12742. } else {
  12743. m.addorganization_id = &u
  12744. }
  12745. }
  12746. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12747. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12748. v := m.addorganization_id
  12749. if v == nil {
  12750. return
  12751. }
  12752. return *v, true
  12753. }
  12754. // ClearOrganizationID clears the value of the "organization_id" field.
  12755. func (m *CreditUsageMutation) ClearOrganizationID() {
  12756. m.organization_id = nil
  12757. m.addorganization_id = nil
  12758. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12759. }
  12760. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12761. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  12762. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  12763. return ok
  12764. }
  12765. // ResetOrganizationID resets all changes to the "organization_id" field.
  12766. func (m *CreditUsageMutation) ResetOrganizationID() {
  12767. m.organization_id = nil
  12768. m.addorganization_id = nil
  12769. delete(m.clearedFields, creditusage.FieldOrganizationID)
  12770. }
  12771. // SetNid sets the "nid" field.
  12772. func (m *CreditUsageMutation) SetNid(u uint64) {
  12773. m.nid = &u
  12774. m.addnid = nil
  12775. }
  12776. // Nid returns the value of the "nid" field in the mutation.
  12777. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  12778. v := m.nid
  12779. if v == nil {
  12780. return
  12781. }
  12782. return *v, true
  12783. }
  12784. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  12785. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12787. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  12788. if !m.op.Is(OpUpdateOne) {
  12789. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  12790. }
  12791. if m.id == nil || m.oldValue == nil {
  12792. return v, errors.New("OldNid requires an ID field in the mutation")
  12793. }
  12794. oldValue, err := m.oldValue(ctx)
  12795. if err != nil {
  12796. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  12797. }
  12798. return oldValue.Nid, nil
  12799. }
  12800. // AddNid adds u to the "nid" field.
  12801. func (m *CreditUsageMutation) AddNid(u int64) {
  12802. if m.addnid != nil {
  12803. *m.addnid += u
  12804. } else {
  12805. m.addnid = &u
  12806. }
  12807. }
  12808. // AddedNid returns the value that was added to the "nid" field in this mutation.
  12809. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  12810. v := m.addnid
  12811. if v == nil {
  12812. return
  12813. }
  12814. return *v, true
  12815. }
  12816. // ResetNid resets all changes to the "nid" field.
  12817. func (m *CreditUsageMutation) ResetNid() {
  12818. m.nid = nil
  12819. m.addnid = nil
  12820. }
  12821. // SetReason sets the "reason" field.
  12822. func (m *CreditUsageMutation) SetReason(s string) {
  12823. m.reason = &s
  12824. }
  12825. // Reason returns the value of the "reason" field in the mutation.
  12826. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  12827. v := m.reason
  12828. if v == nil {
  12829. return
  12830. }
  12831. return *v, true
  12832. }
  12833. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  12834. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12836. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  12837. if !m.op.Is(OpUpdateOne) {
  12838. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  12839. }
  12840. if m.id == nil || m.oldValue == nil {
  12841. return v, errors.New("OldReason requires an ID field in the mutation")
  12842. }
  12843. oldValue, err := m.oldValue(ctx)
  12844. if err != nil {
  12845. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  12846. }
  12847. return oldValue.Reason, nil
  12848. }
  12849. // ResetReason resets all changes to the "reason" field.
  12850. func (m *CreditUsageMutation) ResetReason() {
  12851. m.reason = nil
  12852. }
  12853. // SetOperator sets the "operator" field.
  12854. func (m *CreditUsageMutation) SetOperator(s string) {
  12855. m.operator = &s
  12856. }
  12857. // Operator returns the value of the "operator" field in the mutation.
  12858. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  12859. v := m.operator
  12860. if v == nil {
  12861. return
  12862. }
  12863. return *v, true
  12864. }
  12865. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  12866. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12868. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  12869. if !m.op.Is(OpUpdateOne) {
  12870. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  12871. }
  12872. if m.id == nil || m.oldValue == nil {
  12873. return v, errors.New("OldOperator requires an ID field in the mutation")
  12874. }
  12875. oldValue, err := m.oldValue(ctx)
  12876. if err != nil {
  12877. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  12878. }
  12879. return oldValue.Operator, nil
  12880. }
  12881. // ResetOperator resets all changes to the "operator" field.
  12882. func (m *CreditUsageMutation) ResetOperator() {
  12883. m.operator = nil
  12884. }
  12885. // Where appends a list predicates to the CreditUsageMutation builder.
  12886. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  12887. m.predicates = append(m.predicates, ps...)
  12888. }
  12889. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  12890. // users can use type-assertion to append predicates that do not depend on any generated package.
  12891. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  12892. p := make([]predicate.CreditUsage, len(ps))
  12893. for i := range ps {
  12894. p[i] = ps[i]
  12895. }
  12896. m.Where(p...)
  12897. }
  12898. // Op returns the operation name.
  12899. func (m *CreditUsageMutation) Op() Op {
  12900. return m.op
  12901. }
  12902. // SetOp allows setting the mutation operation.
  12903. func (m *CreditUsageMutation) SetOp(op Op) {
  12904. m.op = op
  12905. }
  12906. // Type returns the node type of this mutation (CreditUsage).
  12907. func (m *CreditUsageMutation) Type() string {
  12908. return m.typ
  12909. }
  12910. // Fields returns all fields that were changed during this mutation. Note that in
  12911. // order to get all numeric fields that were incremented/decremented, call
  12912. // AddedFields().
  12913. func (m *CreditUsageMutation) Fields() []string {
  12914. fields := make([]string, 0, 12)
  12915. if m.created_at != nil {
  12916. fields = append(fields, creditusage.FieldCreatedAt)
  12917. }
  12918. if m.updated_at != nil {
  12919. fields = append(fields, creditusage.FieldUpdatedAt)
  12920. }
  12921. if m.deleted_at != nil {
  12922. fields = append(fields, creditusage.FieldDeletedAt)
  12923. }
  12924. if m.user_id != nil {
  12925. fields = append(fields, creditusage.FieldUserID)
  12926. }
  12927. if m.number != nil {
  12928. fields = append(fields, creditusage.FieldNumber)
  12929. }
  12930. if m.status != nil {
  12931. fields = append(fields, creditusage.FieldStatus)
  12932. }
  12933. if m.ntype != nil {
  12934. fields = append(fields, creditusage.FieldNtype)
  12935. }
  12936. if m.table != nil {
  12937. fields = append(fields, creditusage.FieldTable)
  12938. }
  12939. if m.organization_id != nil {
  12940. fields = append(fields, creditusage.FieldOrganizationID)
  12941. }
  12942. if m.nid != nil {
  12943. fields = append(fields, creditusage.FieldNid)
  12944. }
  12945. if m.reason != nil {
  12946. fields = append(fields, creditusage.FieldReason)
  12947. }
  12948. if m.operator != nil {
  12949. fields = append(fields, creditusage.FieldOperator)
  12950. }
  12951. return fields
  12952. }
  12953. // Field returns the value of a field with the given name. The second boolean
  12954. // return value indicates that this field was not set, or was not defined in the
  12955. // schema.
  12956. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  12957. switch name {
  12958. case creditusage.FieldCreatedAt:
  12959. return m.CreatedAt()
  12960. case creditusage.FieldUpdatedAt:
  12961. return m.UpdatedAt()
  12962. case creditusage.FieldDeletedAt:
  12963. return m.DeletedAt()
  12964. case creditusage.FieldUserID:
  12965. return m.UserID()
  12966. case creditusage.FieldNumber:
  12967. return m.Number()
  12968. case creditusage.FieldStatus:
  12969. return m.Status()
  12970. case creditusage.FieldNtype:
  12971. return m.Ntype()
  12972. case creditusage.FieldTable:
  12973. return m.Table()
  12974. case creditusage.FieldOrganizationID:
  12975. return m.OrganizationID()
  12976. case creditusage.FieldNid:
  12977. return m.Nid()
  12978. case creditusage.FieldReason:
  12979. return m.Reason()
  12980. case creditusage.FieldOperator:
  12981. return m.Operator()
  12982. }
  12983. return nil, false
  12984. }
  12985. // OldField returns the old value of the field from the database. An error is
  12986. // returned if the mutation operation is not UpdateOne, or the query to the
  12987. // database failed.
  12988. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12989. switch name {
  12990. case creditusage.FieldCreatedAt:
  12991. return m.OldCreatedAt(ctx)
  12992. case creditusage.FieldUpdatedAt:
  12993. return m.OldUpdatedAt(ctx)
  12994. case creditusage.FieldDeletedAt:
  12995. return m.OldDeletedAt(ctx)
  12996. case creditusage.FieldUserID:
  12997. return m.OldUserID(ctx)
  12998. case creditusage.FieldNumber:
  12999. return m.OldNumber(ctx)
  13000. case creditusage.FieldStatus:
  13001. return m.OldStatus(ctx)
  13002. case creditusage.FieldNtype:
  13003. return m.OldNtype(ctx)
  13004. case creditusage.FieldTable:
  13005. return m.OldTable(ctx)
  13006. case creditusage.FieldOrganizationID:
  13007. return m.OldOrganizationID(ctx)
  13008. case creditusage.FieldNid:
  13009. return m.OldNid(ctx)
  13010. case creditusage.FieldReason:
  13011. return m.OldReason(ctx)
  13012. case creditusage.FieldOperator:
  13013. return m.OldOperator(ctx)
  13014. }
  13015. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  13016. }
  13017. // SetField sets the value of a field with the given name. It returns an error if
  13018. // the field is not defined in the schema, or if the type mismatched the field
  13019. // type.
  13020. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  13021. switch name {
  13022. case creditusage.FieldCreatedAt:
  13023. v, ok := value.(time.Time)
  13024. if !ok {
  13025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13026. }
  13027. m.SetCreatedAt(v)
  13028. return nil
  13029. case creditusage.FieldUpdatedAt:
  13030. v, ok := value.(time.Time)
  13031. if !ok {
  13032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13033. }
  13034. m.SetUpdatedAt(v)
  13035. return nil
  13036. case creditusage.FieldDeletedAt:
  13037. v, ok := value.(time.Time)
  13038. if !ok {
  13039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13040. }
  13041. m.SetDeletedAt(v)
  13042. return nil
  13043. case creditusage.FieldUserID:
  13044. v, ok := value.(string)
  13045. if !ok {
  13046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13047. }
  13048. m.SetUserID(v)
  13049. return nil
  13050. case creditusage.FieldNumber:
  13051. v, ok := value.(float32)
  13052. if !ok {
  13053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13054. }
  13055. m.SetNumber(v)
  13056. return nil
  13057. case creditusage.FieldStatus:
  13058. v, ok := value.(int)
  13059. if !ok {
  13060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13061. }
  13062. m.SetStatus(v)
  13063. return nil
  13064. case creditusage.FieldNtype:
  13065. v, ok := value.(int)
  13066. if !ok {
  13067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13068. }
  13069. m.SetNtype(v)
  13070. return nil
  13071. case creditusage.FieldTable:
  13072. v, ok := value.(string)
  13073. if !ok {
  13074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13075. }
  13076. m.SetTable(v)
  13077. return nil
  13078. case creditusage.FieldOrganizationID:
  13079. v, ok := value.(uint64)
  13080. if !ok {
  13081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13082. }
  13083. m.SetOrganizationID(v)
  13084. return nil
  13085. case creditusage.FieldNid:
  13086. v, ok := value.(uint64)
  13087. if !ok {
  13088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13089. }
  13090. m.SetNid(v)
  13091. return nil
  13092. case creditusage.FieldReason:
  13093. v, ok := value.(string)
  13094. if !ok {
  13095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13096. }
  13097. m.SetReason(v)
  13098. return nil
  13099. case creditusage.FieldOperator:
  13100. v, ok := value.(string)
  13101. if !ok {
  13102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13103. }
  13104. m.SetOperator(v)
  13105. return nil
  13106. }
  13107. return fmt.Errorf("unknown CreditUsage field %s", name)
  13108. }
  13109. // AddedFields returns all numeric fields that were incremented/decremented during
  13110. // this mutation.
  13111. func (m *CreditUsageMutation) AddedFields() []string {
  13112. var fields []string
  13113. if m.addnumber != nil {
  13114. fields = append(fields, creditusage.FieldNumber)
  13115. }
  13116. if m.addstatus != nil {
  13117. fields = append(fields, creditusage.FieldStatus)
  13118. }
  13119. if m.addntype != nil {
  13120. fields = append(fields, creditusage.FieldNtype)
  13121. }
  13122. if m.addorganization_id != nil {
  13123. fields = append(fields, creditusage.FieldOrganizationID)
  13124. }
  13125. if m.addnid != nil {
  13126. fields = append(fields, creditusage.FieldNid)
  13127. }
  13128. return fields
  13129. }
  13130. // AddedField returns the numeric value that was incremented/decremented on a field
  13131. // with the given name. The second boolean return value indicates that this field
  13132. // was not set, or was not defined in the schema.
  13133. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13134. switch name {
  13135. case creditusage.FieldNumber:
  13136. return m.AddedNumber()
  13137. case creditusage.FieldStatus:
  13138. return m.AddedStatus()
  13139. case creditusage.FieldNtype:
  13140. return m.AddedNtype()
  13141. case creditusage.FieldOrganizationID:
  13142. return m.AddedOrganizationID()
  13143. case creditusage.FieldNid:
  13144. return m.AddedNid()
  13145. }
  13146. return nil, false
  13147. }
  13148. // AddField adds the value to the field with the given name. It returns an error if
  13149. // the field is not defined in the schema, or if the type mismatched the field
  13150. // type.
  13151. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13152. switch name {
  13153. case creditusage.FieldNumber:
  13154. v, ok := value.(float32)
  13155. if !ok {
  13156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13157. }
  13158. m.AddNumber(v)
  13159. return nil
  13160. case creditusage.FieldStatus:
  13161. v, ok := value.(int)
  13162. if !ok {
  13163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13164. }
  13165. m.AddStatus(v)
  13166. return nil
  13167. case creditusage.FieldNtype:
  13168. v, ok := value.(int)
  13169. if !ok {
  13170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13171. }
  13172. m.AddNtype(v)
  13173. return nil
  13174. case creditusage.FieldOrganizationID:
  13175. v, ok := value.(int64)
  13176. if !ok {
  13177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13178. }
  13179. m.AddOrganizationID(v)
  13180. return nil
  13181. case creditusage.FieldNid:
  13182. v, ok := value.(int64)
  13183. if !ok {
  13184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13185. }
  13186. m.AddNid(v)
  13187. return nil
  13188. }
  13189. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13190. }
  13191. // ClearedFields returns all nullable fields that were cleared during this
  13192. // mutation.
  13193. func (m *CreditUsageMutation) ClearedFields() []string {
  13194. var fields []string
  13195. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13196. fields = append(fields, creditusage.FieldDeletedAt)
  13197. }
  13198. if m.FieldCleared(creditusage.FieldUserID) {
  13199. fields = append(fields, creditusage.FieldUserID)
  13200. }
  13201. if m.FieldCleared(creditusage.FieldStatus) {
  13202. fields = append(fields, creditusage.FieldStatus)
  13203. }
  13204. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13205. fields = append(fields, creditusage.FieldOrganizationID)
  13206. }
  13207. return fields
  13208. }
  13209. // FieldCleared returns a boolean indicating if a field with the given name was
  13210. // cleared in this mutation.
  13211. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13212. _, ok := m.clearedFields[name]
  13213. return ok
  13214. }
  13215. // ClearField clears the value of the field with the given name. It returns an
  13216. // error if the field is not defined in the schema.
  13217. func (m *CreditUsageMutation) ClearField(name string) error {
  13218. switch name {
  13219. case creditusage.FieldDeletedAt:
  13220. m.ClearDeletedAt()
  13221. return nil
  13222. case creditusage.FieldUserID:
  13223. m.ClearUserID()
  13224. return nil
  13225. case creditusage.FieldStatus:
  13226. m.ClearStatus()
  13227. return nil
  13228. case creditusage.FieldOrganizationID:
  13229. m.ClearOrganizationID()
  13230. return nil
  13231. }
  13232. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13233. }
  13234. // ResetField resets all changes in the mutation for the field with the given name.
  13235. // It returns an error if the field is not defined in the schema.
  13236. func (m *CreditUsageMutation) ResetField(name string) error {
  13237. switch name {
  13238. case creditusage.FieldCreatedAt:
  13239. m.ResetCreatedAt()
  13240. return nil
  13241. case creditusage.FieldUpdatedAt:
  13242. m.ResetUpdatedAt()
  13243. return nil
  13244. case creditusage.FieldDeletedAt:
  13245. m.ResetDeletedAt()
  13246. return nil
  13247. case creditusage.FieldUserID:
  13248. m.ResetUserID()
  13249. return nil
  13250. case creditusage.FieldNumber:
  13251. m.ResetNumber()
  13252. return nil
  13253. case creditusage.FieldStatus:
  13254. m.ResetStatus()
  13255. return nil
  13256. case creditusage.FieldNtype:
  13257. m.ResetNtype()
  13258. return nil
  13259. case creditusage.FieldTable:
  13260. m.ResetTable()
  13261. return nil
  13262. case creditusage.FieldOrganizationID:
  13263. m.ResetOrganizationID()
  13264. return nil
  13265. case creditusage.FieldNid:
  13266. m.ResetNid()
  13267. return nil
  13268. case creditusage.FieldReason:
  13269. m.ResetReason()
  13270. return nil
  13271. case creditusage.FieldOperator:
  13272. m.ResetOperator()
  13273. return nil
  13274. }
  13275. return fmt.Errorf("unknown CreditUsage field %s", name)
  13276. }
  13277. // AddedEdges returns all edge names that were set/added in this mutation.
  13278. func (m *CreditUsageMutation) AddedEdges() []string {
  13279. edges := make([]string, 0, 0)
  13280. return edges
  13281. }
  13282. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13283. // name in this mutation.
  13284. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13285. return nil
  13286. }
  13287. // RemovedEdges returns all edge names that were removed in this mutation.
  13288. func (m *CreditUsageMutation) RemovedEdges() []string {
  13289. edges := make([]string, 0, 0)
  13290. return edges
  13291. }
  13292. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13293. // the given name in this mutation.
  13294. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13295. return nil
  13296. }
  13297. // ClearedEdges returns all edge names that were cleared in this mutation.
  13298. func (m *CreditUsageMutation) ClearedEdges() []string {
  13299. edges := make([]string, 0, 0)
  13300. return edges
  13301. }
  13302. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13303. // was cleared in this mutation.
  13304. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13305. return false
  13306. }
  13307. // ClearEdge clears the value of the edge with the given name. It returns an error
  13308. // if that edge is not defined in the schema.
  13309. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13310. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13311. }
  13312. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13313. // It returns an error if the edge is not defined in the schema.
  13314. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13315. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13316. }
  13317. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13318. type EmployeeMutation struct {
  13319. config
  13320. op Op
  13321. typ string
  13322. id *uint64
  13323. created_at *time.Time
  13324. updated_at *time.Time
  13325. deleted_at *time.Time
  13326. title *string
  13327. avatar *string
  13328. tags *string
  13329. hire_count *int
  13330. addhire_count *int
  13331. service_count *int
  13332. addservice_count *int
  13333. achievement_count *int
  13334. addachievement_count *int
  13335. intro *string
  13336. estimate *string
  13337. skill *string
  13338. ability_type *string
  13339. scene *string
  13340. switch_in *string
  13341. video_url *string
  13342. organization_id *uint64
  13343. addorganization_id *int64
  13344. category_id *uint64
  13345. addcategory_id *int64
  13346. api_base *string
  13347. api_key *string
  13348. ai_info *string
  13349. is_vip *int
  13350. addis_vip *int
  13351. chat_url *string
  13352. clearedFields map[string]struct{}
  13353. em_work_experiences map[uint64]struct{}
  13354. removedem_work_experiences map[uint64]struct{}
  13355. clearedem_work_experiences bool
  13356. em_tutorial map[uint64]struct{}
  13357. removedem_tutorial map[uint64]struct{}
  13358. clearedem_tutorial bool
  13359. done bool
  13360. oldValue func(context.Context) (*Employee, error)
  13361. predicates []predicate.Employee
  13362. }
  13363. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13364. // employeeOption allows management of the mutation configuration using functional options.
  13365. type employeeOption func(*EmployeeMutation)
  13366. // newEmployeeMutation creates new mutation for the Employee entity.
  13367. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13368. m := &EmployeeMutation{
  13369. config: c,
  13370. op: op,
  13371. typ: TypeEmployee,
  13372. clearedFields: make(map[string]struct{}),
  13373. }
  13374. for _, opt := range opts {
  13375. opt(m)
  13376. }
  13377. return m
  13378. }
  13379. // withEmployeeID sets the ID field of the mutation.
  13380. func withEmployeeID(id uint64) employeeOption {
  13381. return func(m *EmployeeMutation) {
  13382. var (
  13383. err error
  13384. once sync.Once
  13385. value *Employee
  13386. )
  13387. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13388. once.Do(func() {
  13389. if m.done {
  13390. err = errors.New("querying old values post mutation is not allowed")
  13391. } else {
  13392. value, err = m.Client().Employee.Get(ctx, id)
  13393. }
  13394. })
  13395. return value, err
  13396. }
  13397. m.id = &id
  13398. }
  13399. }
  13400. // withEmployee sets the old Employee of the mutation.
  13401. func withEmployee(node *Employee) employeeOption {
  13402. return func(m *EmployeeMutation) {
  13403. m.oldValue = func(context.Context) (*Employee, error) {
  13404. return node, nil
  13405. }
  13406. m.id = &node.ID
  13407. }
  13408. }
  13409. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13410. // executed in a transaction (ent.Tx), a transactional client is returned.
  13411. func (m EmployeeMutation) Client() *Client {
  13412. client := &Client{config: m.config}
  13413. client.init()
  13414. return client
  13415. }
  13416. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13417. // it returns an error otherwise.
  13418. func (m EmployeeMutation) Tx() (*Tx, error) {
  13419. if _, ok := m.driver.(*txDriver); !ok {
  13420. return nil, errors.New("ent: mutation is not running in a transaction")
  13421. }
  13422. tx := &Tx{config: m.config}
  13423. tx.init()
  13424. return tx, nil
  13425. }
  13426. // SetID sets the value of the id field. Note that this
  13427. // operation is only accepted on creation of Employee entities.
  13428. func (m *EmployeeMutation) SetID(id uint64) {
  13429. m.id = &id
  13430. }
  13431. // ID returns the ID value in the mutation. Note that the ID is only available
  13432. // if it was provided to the builder or after it was returned from the database.
  13433. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13434. if m.id == nil {
  13435. return
  13436. }
  13437. return *m.id, true
  13438. }
  13439. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13440. // That means, if the mutation is applied within a transaction with an isolation level such
  13441. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13442. // or updated by the mutation.
  13443. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13444. switch {
  13445. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13446. id, exists := m.ID()
  13447. if exists {
  13448. return []uint64{id}, nil
  13449. }
  13450. fallthrough
  13451. case m.op.Is(OpUpdate | OpDelete):
  13452. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13453. default:
  13454. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13455. }
  13456. }
  13457. // SetCreatedAt sets the "created_at" field.
  13458. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13459. m.created_at = &t
  13460. }
  13461. // CreatedAt returns the value of the "created_at" field in the mutation.
  13462. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13463. v := m.created_at
  13464. if v == nil {
  13465. return
  13466. }
  13467. return *v, true
  13468. }
  13469. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13470. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13472. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13473. if !m.op.Is(OpUpdateOne) {
  13474. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13475. }
  13476. if m.id == nil || m.oldValue == nil {
  13477. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13478. }
  13479. oldValue, err := m.oldValue(ctx)
  13480. if err != nil {
  13481. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13482. }
  13483. return oldValue.CreatedAt, nil
  13484. }
  13485. // ResetCreatedAt resets all changes to the "created_at" field.
  13486. func (m *EmployeeMutation) ResetCreatedAt() {
  13487. m.created_at = nil
  13488. }
  13489. // SetUpdatedAt sets the "updated_at" field.
  13490. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13491. m.updated_at = &t
  13492. }
  13493. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13494. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13495. v := m.updated_at
  13496. if v == nil {
  13497. return
  13498. }
  13499. return *v, true
  13500. }
  13501. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13502. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13504. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13505. if !m.op.Is(OpUpdateOne) {
  13506. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13507. }
  13508. if m.id == nil || m.oldValue == nil {
  13509. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13510. }
  13511. oldValue, err := m.oldValue(ctx)
  13512. if err != nil {
  13513. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13514. }
  13515. return oldValue.UpdatedAt, nil
  13516. }
  13517. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13518. func (m *EmployeeMutation) ResetUpdatedAt() {
  13519. m.updated_at = nil
  13520. }
  13521. // SetDeletedAt sets the "deleted_at" field.
  13522. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13523. m.deleted_at = &t
  13524. }
  13525. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13526. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13527. v := m.deleted_at
  13528. if v == nil {
  13529. return
  13530. }
  13531. return *v, true
  13532. }
  13533. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13534. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13536. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13537. if !m.op.Is(OpUpdateOne) {
  13538. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13539. }
  13540. if m.id == nil || m.oldValue == nil {
  13541. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13542. }
  13543. oldValue, err := m.oldValue(ctx)
  13544. if err != nil {
  13545. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13546. }
  13547. return oldValue.DeletedAt, nil
  13548. }
  13549. // ClearDeletedAt clears the value of the "deleted_at" field.
  13550. func (m *EmployeeMutation) ClearDeletedAt() {
  13551. m.deleted_at = nil
  13552. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13553. }
  13554. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13555. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13556. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13557. return ok
  13558. }
  13559. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13560. func (m *EmployeeMutation) ResetDeletedAt() {
  13561. m.deleted_at = nil
  13562. delete(m.clearedFields, employee.FieldDeletedAt)
  13563. }
  13564. // SetTitle sets the "title" field.
  13565. func (m *EmployeeMutation) SetTitle(s string) {
  13566. m.title = &s
  13567. }
  13568. // Title returns the value of the "title" field in the mutation.
  13569. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13570. v := m.title
  13571. if v == nil {
  13572. return
  13573. }
  13574. return *v, true
  13575. }
  13576. // OldTitle returns the old "title" field's value of the Employee entity.
  13577. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13579. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13580. if !m.op.Is(OpUpdateOne) {
  13581. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13582. }
  13583. if m.id == nil || m.oldValue == nil {
  13584. return v, errors.New("OldTitle requires an ID field in the mutation")
  13585. }
  13586. oldValue, err := m.oldValue(ctx)
  13587. if err != nil {
  13588. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13589. }
  13590. return oldValue.Title, nil
  13591. }
  13592. // ResetTitle resets all changes to the "title" field.
  13593. func (m *EmployeeMutation) ResetTitle() {
  13594. m.title = nil
  13595. }
  13596. // SetAvatar sets the "avatar" field.
  13597. func (m *EmployeeMutation) SetAvatar(s string) {
  13598. m.avatar = &s
  13599. }
  13600. // Avatar returns the value of the "avatar" field in the mutation.
  13601. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13602. v := m.avatar
  13603. if v == nil {
  13604. return
  13605. }
  13606. return *v, true
  13607. }
  13608. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13609. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13611. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13612. if !m.op.Is(OpUpdateOne) {
  13613. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13614. }
  13615. if m.id == nil || m.oldValue == nil {
  13616. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13617. }
  13618. oldValue, err := m.oldValue(ctx)
  13619. if err != nil {
  13620. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13621. }
  13622. return oldValue.Avatar, nil
  13623. }
  13624. // ResetAvatar resets all changes to the "avatar" field.
  13625. func (m *EmployeeMutation) ResetAvatar() {
  13626. m.avatar = nil
  13627. }
  13628. // SetTags sets the "tags" field.
  13629. func (m *EmployeeMutation) SetTags(s string) {
  13630. m.tags = &s
  13631. }
  13632. // Tags returns the value of the "tags" field in the mutation.
  13633. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  13634. v := m.tags
  13635. if v == nil {
  13636. return
  13637. }
  13638. return *v, true
  13639. }
  13640. // OldTags returns the old "tags" field's value of the Employee entity.
  13641. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13643. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  13644. if !m.op.Is(OpUpdateOne) {
  13645. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  13646. }
  13647. if m.id == nil || m.oldValue == nil {
  13648. return v, errors.New("OldTags requires an ID field in the mutation")
  13649. }
  13650. oldValue, err := m.oldValue(ctx)
  13651. if err != nil {
  13652. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  13653. }
  13654. return oldValue.Tags, nil
  13655. }
  13656. // ResetTags resets all changes to the "tags" field.
  13657. func (m *EmployeeMutation) ResetTags() {
  13658. m.tags = nil
  13659. }
  13660. // SetHireCount sets the "hire_count" field.
  13661. func (m *EmployeeMutation) SetHireCount(i int) {
  13662. m.hire_count = &i
  13663. m.addhire_count = nil
  13664. }
  13665. // HireCount returns the value of the "hire_count" field in the mutation.
  13666. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  13667. v := m.hire_count
  13668. if v == nil {
  13669. return
  13670. }
  13671. return *v, true
  13672. }
  13673. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  13674. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13676. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  13677. if !m.op.Is(OpUpdateOne) {
  13678. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  13679. }
  13680. if m.id == nil || m.oldValue == nil {
  13681. return v, errors.New("OldHireCount requires an ID field in the mutation")
  13682. }
  13683. oldValue, err := m.oldValue(ctx)
  13684. if err != nil {
  13685. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  13686. }
  13687. return oldValue.HireCount, nil
  13688. }
  13689. // AddHireCount adds i to the "hire_count" field.
  13690. func (m *EmployeeMutation) AddHireCount(i int) {
  13691. if m.addhire_count != nil {
  13692. *m.addhire_count += i
  13693. } else {
  13694. m.addhire_count = &i
  13695. }
  13696. }
  13697. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  13698. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  13699. v := m.addhire_count
  13700. if v == nil {
  13701. return
  13702. }
  13703. return *v, true
  13704. }
  13705. // ResetHireCount resets all changes to the "hire_count" field.
  13706. func (m *EmployeeMutation) ResetHireCount() {
  13707. m.hire_count = nil
  13708. m.addhire_count = nil
  13709. }
  13710. // SetServiceCount sets the "service_count" field.
  13711. func (m *EmployeeMutation) SetServiceCount(i int) {
  13712. m.service_count = &i
  13713. m.addservice_count = nil
  13714. }
  13715. // ServiceCount returns the value of the "service_count" field in the mutation.
  13716. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  13717. v := m.service_count
  13718. if v == nil {
  13719. return
  13720. }
  13721. return *v, true
  13722. }
  13723. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  13724. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13726. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  13727. if !m.op.Is(OpUpdateOne) {
  13728. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  13729. }
  13730. if m.id == nil || m.oldValue == nil {
  13731. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  13732. }
  13733. oldValue, err := m.oldValue(ctx)
  13734. if err != nil {
  13735. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  13736. }
  13737. return oldValue.ServiceCount, nil
  13738. }
  13739. // AddServiceCount adds i to the "service_count" field.
  13740. func (m *EmployeeMutation) AddServiceCount(i int) {
  13741. if m.addservice_count != nil {
  13742. *m.addservice_count += i
  13743. } else {
  13744. m.addservice_count = &i
  13745. }
  13746. }
  13747. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  13748. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  13749. v := m.addservice_count
  13750. if v == nil {
  13751. return
  13752. }
  13753. return *v, true
  13754. }
  13755. // ResetServiceCount resets all changes to the "service_count" field.
  13756. func (m *EmployeeMutation) ResetServiceCount() {
  13757. m.service_count = nil
  13758. m.addservice_count = nil
  13759. }
  13760. // SetAchievementCount sets the "achievement_count" field.
  13761. func (m *EmployeeMutation) SetAchievementCount(i int) {
  13762. m.achievement_count = &i
  13763. m.addachievement_count = nil
  13764. }
  13765. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  13766. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  13767. v := m.achievement_count
  13768. if v == nil {
  13769. return
  13770. }
  13771. return *v, true
  13772. }
  13773. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  13774. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13776. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  13777. if !m.op.Is(OpUpdateOne) {
  13778. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  13779. }
  13780. if m.id == nil || m.oldValue == nil {
  13781. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  13782. }
  13783. oldValue, err := m.oldValue(ctx)
  13784. if err != nil {
  13785. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  13786. }
  13787. return oldValue.AchievementCount, nil
  13788. }
  13789. // AddAchievementCount adds i to the "achievement_count" field.
  13790. func (m *EmployeeMutation) AddAchievementCount(i int) {
  13791. if m.addachievement_count != nil {
  13792. *m.addachievement_count += i
  13793. } else {
  13794. m.addachievement_count = &i
  13795. }
  13796. }
  13797. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  13798. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  13799. v := m.addachievement_count
  13800. if v == nil {
  13801. return
  13802. }
  13803. return *v, true
  13804. }
  13805. // ResetAchievementCount resets all changes to the "achievement_count" field.
  13806. func (m *EmployeeMutation) ResetAchievementCount() {
  13807. m.achievement_count = nil
  13808. m.addachievement_count = nil
  13809. }
  13810. // SetIntro sets the "intro" field.
  13811. func (m *EmployeeMutation) SetIntro(s string) {
  13812. m.intro = &s
  13813. }
  13814. // Intro returns the value of the "intro" field in the mutation.
  13815. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  13816. v := m.intro
  13817. if v == nil {
  13818. return
  13819. }
  13820. return *v, true
  13821. }
  13822. // OldIntro returns the old "intro" field's value of the Employee entity.
  13823. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13825. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  13826. if !m.op.Is(OpUpdateOne) {
  13827. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  13828. }
  13829. if m.id == nil || m.oldValue == nil {
  13830. return v, errors.New("OldIntro requires an ID field in the mutation")
  13831. }
  13832. oldValue, err := m.oldValue(ctx)
  13833. if err != nil {
  13834. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  13835. }
  13836. return oldValue.Intro, nil
  13837. }
  13838. // ResetIntro resets all changes to the "intro" field.
  13839. func (m *EmployeeMutation) ResetIntro() {
  13840. m.intro = nil
  13841. }
  13842. // SetEstimate sets the "estimate" field.
  13843. func (m *EmployeeMutation) SetEstimate(s string) {
  13844. m.estimate = &s
  13845. }
  13846. // Estimate returns the value of the "estimate" field in the mutation.
  13847. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  13848. v := m.estimate
  13849. if v == nil {
  13850. return
  13851. }
  13852. return *v, true
  13853. }
  13854. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  13855. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13857. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  13858. if !m.op.Is(OpUpdateOne) {
  13859. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  13860. }
  13861. if m.id == nil || m.oldValue == nil {
  13862. return v, errors.New("OldEstimate requires an ID field in the mutation")
  13863. }
  13864. oldValue, err := m.oldValue(ctx)
  13865. if err != nil {
  13866. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  13867. }
  13868. return oldValue.Estimate, nil
  13869. }
  13870. // ResetEstimate resets all changes to the "estimate" field.
  13871. func (m *EmployeeMutation) ResetEstimate() {
  13872. m.estimate = nil
  13873. }
  13874. // SetSkill sets the "skill" field.
  13875. func (m *EmployeeMutation) SetSkill(s string) {
  13876. m.skill = &s
  13877. }
  13878. // Skill returns the value of the "skill" field in the mutation.
  13879. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  13880. v := m.skill
  13881. if v == nil {
  13882. return
  13883. }
  13884. return *v, true
  13885. }
  13886. // OldSkill returns the old "skill" field's value of the Employee entity.
  13887. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13889. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  13890. if !m.op.Is(OpUpdateOne) {
  13891. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  13892. }
  13893. if m.id == nil || m.oldValue == nil {
  13894. return v, errors.New("OldSkill requires an ID field in the mutation")
  13895. }
  13896. oldValue, err := m.oldValue(ctx)
  13897. if err != nil {
  13898. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  13899. }
  13900. return oldValue.Skill, nil
  13901. }
  13902. // ResetSkill resets all changes to the "skill" field.
  13903. func (m *EmployeeMutation) ResetSkill() {
  13904. m.skill = nil
  13905. }
  13906. // SetAbilityType sets the "ability_type" field.
  13907. func (m *EmployeeMutation) SetAbilityType(s string) {
  13908. m.ability_type = &s
  13909. }
  13910. // AbilityType returns the value of the "ability_type" field in the mutation.
  13911. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  13912. v := m.ability_type
  13913. if v == nil {
  13914. return
  13915. }
  13916. return *v, true
  13917. }
  13918. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  13919. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13921. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  13922. if !m.op.Is(OpUpdateOne) {
  13923. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  13924. }
  13925. if m.id == nil || m.oldValue == nil {
  13926. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  13927. }
  13928. oldValue, err := m.oldValue(ctx)
  13929. if err != nil {
  13930. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  13931. }
  13932. return oldValue.AbilityType, nil
  13933. }
  13934. // ResetAbilityType resets all changes to the "ability_type" field.
  13935. func (m *EmployeeMutation) ResetAbilityType() {
  13936. m.ability_type = nil
  13937. }
  13938. // SetScene sets the "scene" field.
  13939. func (m *EmployeeMutation) SetScene(s string) {
  13940. m.scene = &s
  13941. }
  13942. // Scene returns the value of the "scene" field in the mutation.
  13943. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  13944. v := m.scene
  13945. if v == nil {
  13946. return
  13947. }
  13948. return *v, true
  13949. }
  13950. // OldScene returns the old "scene" field's value of the Employee entity.
  13951. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13953. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  13954. if !m.op.Is(OpUpdateOne) {
  13955. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  13956. }
  13957. if m.id == nil || m.oldValue == nil {
  13958. return v, errors.New("OldScene requires an ID field in the mutation")
  13959. }
  13960. oldValue, err := m.oldValue(ctx)
  13961. if err != nil {
  13962. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  13963. }
  13964. return oldValue.Scene, nil
  13965. }
  13966. // ResetScene resets all changes to the "scene" field.
  13967. func (m *EmployeeMutation) ResetScene() {
  13968. m.scene = nil
  13969. }
  13970. // SetSwitchIn sets the "switch_in" field.
  13971. func (m *EmployeeMutation) SetSwitchIn(s string) {
  13972. m.switch_in = &s
  13973. }
  13974. // SwitchIn returns the value of the "switch_in" field in the mutation.
  13975. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  13976. v := m.switch_in
  13977. if v == nil {
  13978. return
  13979. }
  13980. return *v, true
  13981. }
  13982. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  13983. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13985. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  13986. if !m.op.Is(OpUpdateOne) {
  13987. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  13988. }
  13989. if m.id == nil || m.oldValue == nil {
  13990. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  13991. }
  13992. oldValue, err := m.oldValue(ctx)
  13993. if err != nil {
  13994. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  13995. }
  13996. return oldValue.SwitchIn, nil
  13997. }
  13998. // ResetSwitchIn resets all changes to the "switch_in" field.
  13999. func (m *EmployeeMutation) ResetSwitchIn() {
  14000. m.switch_in = nil
  14001. }
  14002. // SetVideoURL sets the "video_url" field.
  14003. func (m *EmployeeMutation) SetVideoURL(s string) {
  14004. m.video_url = &s
  14005. }
  14006. // VideoURL returns the value of the "video_url" field in the mutation.
  14007. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  14008. v := m.video_url
  14009. if v == nil {
  14010. return
  14011. }
  14012. return *v, true
  14013. }
  14014. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  14015. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14017. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  14018. if !m.op.Is(OpUpdateOne) {
  14019. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  14020. }
  14021. if m.id == nil || m.oldValue == nil {
  14022. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  14023. }
  14024. oldValue, err := m.oldValue(ctx)
  14025. if err != nil {
  14026. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  14027. }
  14028. return oldValue.VideoURL, nil
  14029. }
  14030. // ResetVideoURL resets all changes to the "video_url" field.
  14031. func (m *EmployeeMutation) ResetVideoURL() {
  14032. m.video_url = nil
  14033. }
  14034. // SetOrganizationID sets the "organization_id" field.
  14035. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  14036. m.organization_id = &u
  14037. m.addorganization_id = nil
  14038. }
  14039. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14040. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  14041. v := m.organization_id
  14042. if v == nil {
  14043. return
  14044. }
  14045. return *v, true
  14046. }
  14047. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  14048. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14050. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14051. if !m.op.Is(OpUpdateOne) {
  14052. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14053. }
  14054. if m.id == nil || m.oldValue == nil {
  14055. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14056. }
  14057. oldValue, err := m.oldValue(ctx)
  14058. if err != nil {
  14059. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14060. }
  14061. return oldValue.OrganizationID, nil
  14062. }
  14063. // AddOrganizationID adds u to the "organization_id" field.
  14064. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  14065. if m.addorganization_id != nil {
  14066. *m.addorganization_id += u
  14067. } else {
  14068. m.addorganization_id = &u
  14069. }
  14070. }
  14071. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14072. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  14073. v := m.addorganization_id
  14074. if v == nil {
  14075. return
  14076. }
  14077. return *v, true
  14078. }
  14079. // ResetOrganizationID resets all changes to the "organization_id" field.
  14080. func (m *EmployeeMutation) ResetOrganizationID() {
  14081. m.organization_id = nil
  14082. m.addorganization_id = nil
  14083. }
  14084. // SetCategoryID sets the "category_id" field.
  14085. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14086. m.category_id = &u
  14087. m.addcategory_id = nil
  14088. }
  14089. // CategoryID returns the value of the "category_id" field in the mutation.
  14090. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14091. v := m.category_id
  14092. if v == nil {
  14093. return
  14094. }
  14095. return *v, true
  14096. }
  14097. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14098. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14100. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14101. if !m.op.Is(OpUpdateOne) {
  14102. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14103. }
  14104. if m.id == nil || m.oldValue == nil {
  14105. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14106. }
  14107. oldValue, err := m.oldValue(ctx)
  14108. if err != nil {
  14109. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14110. }
  14111. return oldValue.CategoryID, nil
  14112. }
  14113. // AddCategoryID adds u to the "category_id" field.
  14114. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14115. if m.addcategory_id != nil {
  14116. *m.addcategory_id += u
  14117. } else {
  14118. m.addcategory_id = &u
  14119. }
  14120. }
  14121. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14122. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14123. v := m.addcategory_id
  14124. if v == nil {
  14125. return
  14126. }
  14127. return *v, true
  14128. }
  14129. // ResetCategoryID resets all changes to the "category_id" field.
  14130. func (m *EmployeeMutation) ResetCategoryID() {
  14131. m.category_id = nil
  14132. m.addcategory_id = nil
  14133. }
  14134. // SetAPIBase sets the "api_base" field.
  14135. func (m *EmployeeMutation) SetAPIBase(s string) {
  14136. m.api_base = &s
  14137. }
  14138. // APIBase returns the value of the "api_base" field in the mutation.
  14139. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14140. v := m.api_base
  14141. if v == nil {
  14142. return
  14143. }
  14144. return *v, true
  14145. }
  14146. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14147. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14149. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14150. if !m.op.Is(OpUpdateOne) {
  14151. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14152. }
  14153. if m.id == nil || m.oldValue == nil {
  14154. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14155. }
  14156. oldValue, err := m.oldValue(ctx)
  14157. if err != nil {
  14158. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14159. }
  14160. return oldValue.APIBase, nil
  14161. }
  14162. // ResetAPIBase resets all changes to the "api_base" field.
  14163. func (m *EmployeeMutation) ResetAPIBase() {
  14164. m.api_base = nil
  14165. }
  14166. // SetAPIKey sets the "api_key" field.
  14167. func (m *EmployeeMutation) SetAPIKey(s string) {
  14168. m.api_key = &s
  14169. }
  14170. // APIKey returns the value of the "api_key" field in the mutation.
  14171. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14172. v := m.api_key
  14173. if v == nil {
  14174. return
  14175. }
  14176. return *v, true
  14177. }
  14178. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14179. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14181. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14182. if !m.op.Is(OpUpdateOne) {
  14183. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14184. }
  14185. if m.id == nil || m.oldValue == nil {
  14186. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14187. }
  14188. oldValue, err := m.oldValue(ctx)
  14189. if err != nil {
  14190. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14191. }
  14192. return oldValue.APIKey, nil
  14193. }
  14194. // ResetAPIKey resets all changes to the "api_key" field.
  14195. func (m *EmployeeMutation) ResetAPIKey() {
  14196. m.api_key = nil
  14197. }
  14198. // SetAiInfo sets the "ai_info" field.
  14199. func (m *EmployeeMutation) SetAiInfo(s string) {
  14200. m.ai_info = &s
  14201. }
  14202. // AiInfo returns the value of the "ai_info" field in the mutation.
  14203. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14204. v := m.ai_info
  14205. if v == nil {
  14206. return
  14207. }
  14208. return *v, true
  14209. }
  14210. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14211. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14213. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14214. if !m.op.Is(OpUpdateOne) {
  14215. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14216. }
  14217. if m.id == nil || m.oldValue == nil {
  14218. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14219. }
  14220. oldValue, err := m.oldValue(ctx)
  14221. if err != nil {
  14222. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14223. }
  14224. return oldValue.AiInfo, nil
  14225. }
  14226. // ClearAiInfo clears the value of the "ai_info" field.
  14227. func (m *EmployeeMutation) ClearAiInfo() {
  14228. m.ai_info = nil
  14229. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14230. }
  14231. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14232. func (m *EmployeeMutation) AiInfoCleared() bool {
  14233. _, ok := m.clearedFields[employee.FieldAiInfo]
  14234. return ok
  14235. }
  14236. // ResetAiInfo resets all changes to the "ai_info" field.
  14237. func (m *EmployeeMutation) ResetAiInfo() {
  14238. m.ai_info = nil
  14239. delete(m.clearedFields, employee.FieldAiInfo)
  14240. }
  14241. // SetIsVip sets the "is_vip" field.
  14242. func (m *EmployeeMutation) SetIsVip(i int) {
  14243. m.is_vip = &i
  14244. m.addis_vip = nil
  14245. }
  14246. // IsVip returns the value of the "is_vip" field in the mutation.
  14247. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14248. v := m.is_vip
  14249. if v == nil {
  14250. return
  14251. }
  14252. return *v, true
  14253. }
  14254. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14255. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14257. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14258. if !m.op.Is(OpUpdateOne) {
  14259. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14260. }
  14261. if m.id == nil || m.oldValue == nil {
  14262. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14263. }
  14264. oldValue, err := m.oldValue(ctx)
  14265. if err != nil {
  14266. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14267. }
  14268. return oldValue.IsVip, nil
  14269. }
  14270. // AddIsVip adds i to the "is_vip" field.
  14271. func (m *EmployeeMutation) AddIsVip(i int) {
  14272. if m.addis_vip != nil {
  14273. *m.addis_vip += i
  14274. } else {
  14275. m.addis_vip = &i
  14276. }
  14277. }
  14278. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14279. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14280. v := m.addis_vip
  14281. if v == nil {
  14282. return
  14283. }
  14284. return *v, true
  14285. }
  14286. // ResetIsVip resets all changes to the "is_vip" field.
  14287. func (m *EmployeeMutation) ResetIsVip() {
  14288. m.is_vip = nil
  14289. m.addis_vip = nil
  14290. }
  14291. // SetChatURL sets the "chat_url" field.
  14292. func (m *EmployeeMutation) SetChatURL(s string) {
  14293. m.chat_url = &s
  14294. }
  14295. // ChatURL returns the value of the "chat_url" field in the mutation.
  14296. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14297. v := m.chat_url
  14298. if v == nil {
  14299. return
  14300. }
  14301. return *v, true
  14302. }
  14303. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14304. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14306. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14307. if !m.op.Is(OpUpdateOne) {
  14308. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14309. }
  14310. if m.id == nil || m.oldValue == nil {
  14311. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14312. }
  14313. oldValue, err := m.oldValue(ctx)
  14314. if err != nil {
  14315. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14316. }
  14317. return oldValue.ChatURL, nil
  14318. }
  14319. // ResetChatURL resets all changes to the "chat_url" field.
  14320. func (m *EmployeeMutation) ResetChatURL() {
  14321. m.chat_url = nil
  14322. }
  14323. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14324. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14325. if m.em_work_experiences == nil {
  14326. m.em_work_experiences = make(map[uint64]struct{})
  14327. }
  14328. for i := range ids {
  14329. m.em_work_experiences[ids[i]] = struct{}{}
  14330. }
  14331. }
  14332. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14333. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14334. m.clearedem_work_experiences = true
  14335. }
  14336. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14337. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14338. return m.clearedem_work_experiences
  14339. }
  14340. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14341. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14342. if m.removedem_work_experiences == nil {
  14343. m.removedem_work_experiences = make(map[uint64]struct{})
  14344. }
  14345. for i := range ids {
  14346. delete(m.em_work_experiences, ids[i])
  14347. m.removedem_work_experiences[ids[i]] = struct{}{}
  14348. }
  14349. }
  14350. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14351. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14352. for id := range m.removedem_work_experiences {
  14353. ids = append(ids, id)
  14354. }
  14355. return
  14356. }
  14357. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14358. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14359. for id := range m.em_work_experiences {
  14360. ids = append(ids, id)
  14361. }
  14362. return
  14363. }
  14364. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14365. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14366. m.em_work_experiences = nil
  14367. m.clearedem_work_experiences = false
  14368. m.removedem_work_experiences = nil
  14369. }
  14370. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14371. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14372. if m.em_tutorial == nil {
  14373. m.em_tutorial = make(map[uint64]struct{})
  14374. }
  14375. for i := range ids {
  14376. m.em_tutorial[ids[i]] = struct{}{}
  14377. }
  14378. }
  14379. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14380. func (m *EmployeeMutation) ClearEmTutorial() {
  14381. m.clearedem_tutorial = true
  14382. }
  14383. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14384. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14385. return m.clearedem_tutorial
  14386. }
  14387. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14388. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14389. if m.removedem_tutorial == nil {
  14390. m.removedem_tutorial = make(map[uint64]struct{})
  14391. }
  14392. for i := range ids {
  14393. delete(m.em_tutorial, ids[i])
  14394. m.removedem_tutorial[ids[i]] = struct{}{}
  14395. }
  14396. }
  14397. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14398. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14399. for id := range m.removedem_tutorial {
  14400. ids = append(ids, id)
  14401. }
  14402. return
  14403. }
  14404. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14405. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14406. for id := range m.em_tutorial {
  14407. ids = append(ids, id)
  14408. }
  14409. return
  14410. }
  14411. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14412. func (m *EmployeeMutation) ResetEmTutorial() {
  14413. m.em_tutorial = nil
  14414. m.clearedem_tutorial = false
  14415. m.removedem_tutorial = nil
  14416. }
  14417. // Where appends a list predicates to the EmployeeMutation builder.
  14418. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14419. m.predicates = append(m.predicates, ps...)
  14420. }
  14421. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14422. // users can use type-assertion to append predicates that do not depend on any generated package.
  14423. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14424. p := make([]predicate.Employee, len(ps))
  14425. for i := range ps {
  14426. p[i] = ps[i]
  14427. }
  14428. m.Where(p...)
  14429. }
  14430. // Op returns the operation name.
  14431. func (m *EmployeeMutation) Op() Op {
  14432. return m.op
  14433. }
  14434. // SetOp allows setting the mutation operation.
  14435. func (m *EmployeeMutation) SetOp(op Op) {
  14436. m.op = op
  14437. }
  14438. // Type returns the node type of this mutation (Employee).
  14439. func (m *EmployeeMutation) Type() string {
  14440. return m.typ
  14441. }
  14442. // Fields returns all fields that were changed during this mutation. Note that in
  14443. // order to get all numeric fields that were incremented/decremented, call
  14444. // AddedFields().
  14445. func (m *EmployeeMutation) Fields() []string {
  14446. fields := make([]string, 0, 23)
  14447. if m.created_at != nil {
  14448. fields = append(fields, employee.FieldCreatedAt)
  14449. }
  14450. if m.updated_at != nil {
  14451. fields = append(fields, employee.FieldUpdatedAt)
  14452. }
  14453. if m.deleted_at != nil {
  14454. fields = append(fields, employee.FieldDeletedAt)
  14455. }
  14456. if m.title != nil {
  14457. fields = append(fields, employee.FieldTitle)
  14458. }
  14459. if m.avatar != nil {
  14460. fields = append(fields, employee.FieldAvatar)
  14461. }
  14462. if m.tags != nil {
  14463. fields = append(fields, employee.FieldTags)
  14464. }
  14465. if m.hire_count != nil {
  14466. fields = append(fields, employee.FieldHireCount)
  14467. }
  14468. if m.service_count != nil {
  14469. fields = append(fields, employee.FieldServiceCount)
  14470. }
  14471. if m.achievement_count != nil {
  14472. fields = append(fields, employee.FieldAchievementCount)
  14473. }
  14474. if m.intro != nil {
  14475. fields = append(fields, employee.FieldIntro)
  14476. }
  14477. if m.estimate != nil {
  14478. fields = append(fields, employee.FieldEstimate)
  14479. }
  14480. if m.skill != nil {
  14481. fields = append(fields, employee.FieldSkill)
  14482. }
  14483. if m.ability_type != nil {
  14484. fields = append(fields, employee.FieldAbilityType)
  14485. }
  14486. if m.scene != nil {
  14487. fields = append(fields, employee.FieldScene)
  14488. }
  14489. if m.switch_in != nil {
  14490. fields = append(fields, employee.FieldSwitchIn)
  14491. }
  14492. if m.video_url != nil {
  14493. fields = append(fields, employee.FieldVideoURL)
  14494. }
  14495. if m.organization_id != nil {
  14496. fields = append(fields, employee.FieldOrganizationID)
  14497. }
  14498. if m.category_id != nil {
  14499. fields = append(fields, employee.FieldCategoryID)
  14500. }
  14501. if m.api_base != nil {
  14502. fields = append(fields, employee.FieldAPIBase)
  14503. }
  14504. if m.api_key != nil {
  14505. fields = append(fields, employee.FieldAPIKey)
  14506. }
  14507. if m.ai_info != nil {
  14508. fields = append(fields, employee.FieldAiInfo)
  14509. }
  14510. if m.is_vip != nil {
  14511. fields = append(fields, employee.FieldIsVip)
  14512. }
  14513. if m.chat_url != nil {
  14514. fields = append(fields, employee.FieldChatURL)
  14515. }
  14516. return fields
  14517. }
  14518. // Field returns the value of a field with the given name. The second boolean
  14519. // return value indicates that this field was not set, or was not defined in the
  14520. // schema.
  14521. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14522. switch name {
  14523. case employee.FieldCreatedAt:
  14524. return m.CreatedAt()
  14525. case employee.FieldUpdatedAt:
  14526. return m.UpdatedAt()
  14527. case employee.FieldDeletedAt:
  14528. return m.DeletedAt()
  14529. case employee.FieldTitle:
  14530. return m.Title()
  14531. case employee.FieldAvatar:
  14532. return m.Avatar()
  14533. case employee.FieldTags:
  14534. return m.Tags()
  14535. case employee.FieldHireCount:
  14536. return m.HireCount()
  14537. case employee.FieldServiceCount:
  14538. return m.ServiceCount()
  14539. case employee.FieldAchievementCount:
  14540. return m.AchievementCount()
  14541. case employee.FieldIntro:
  14542. return m.Intro()
  14543. case employee.FieldEstimate:
  14544. return m.Estimate()
  14545. case employee.FieldSkill:
  14546. return m.Skill()
  14547. case employee.FieldAbilityType:
  14548. return m.AbilityType()
  14549. case employee.FieldScene:
  14550. return m.Scene()
  14551. case employee.FieldSwitchIn:
  14552. return m.SwitchIn()
  14553. case employee.FieldVideoURL:
  14554. return m.VideoURL()
  14555. case employee.FieldOrganizationID:
  14556. return m.OrganizationID()
  14557. case employee.FieldCategoryID:
  14558. return m.CategoryID()
  14559. case employee.FieldAPIBase:
  14560. return m.APIBase()
  14561. case employee.FieldAPIKey:
  14562. return m.APIKey()
  14563. case employee.FieldAiInfo:
  14564. return m.AiInfo()
  14565. case employee.FieldIsVip:
  14566. return m.IsVip()
  14567. case employee.FieldChatURL:
  14568. return m.ChatURL()
  14569. }
  14570. return nil, false
  14571. }
  14572. // OldField returns the old value of the field from the database. An error is
  14573. // returned if the mutation operation is not UpdateOne, or the query to the
  14574. // database failed.
  14575. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14576. switch name {
  14577. case employee.FieldCreatedAt:
  14578. return m.OldCreatedAt(ctx)
  14579. case employee.FieldUpdatedAt:
  14580. return m.OldUpdatedAt(ctx)
  14581. case employee.FieldDeletedAt:
  14582. return m.OldDeletedAt(ctx)
  14583. case employee.FieldTitle:
  14584. return m.OldTitle(ctx)
  14585. case employee.FieldAvatar:
  14586. return m.OldAvatar(ctx)
  14587. case employee.FieldTags:
  14588. return m.OldTags(ctx)
  14589. case employee.FieldHireCount:
  14590. return m.OldHireCount(ctx)
  14591. case employee.FieldServiceCount:
  14592. return m.OldServiceCount(ctx)
  14593. case employee.FieldAchievementCount:
  14594. return m.OldAchievementCount(ctx)
  14595. case employee.FieldIntro:
  14596. return m.OldIntro(ctx)
  14597. case employee.FieldEstimate:
  14598. return m.OldEstimate(ctx)
  14599. case employee.FieldSkill:
  14600. return m.OldSkill(ctx)
  14601. case employee.FieldAbilityType:
  14602. return m.OldAbilityType(ctx)
  14603. case employee.FieldScene:
  14604. return m.OldScene(ctx)
  14605. case employee.FieldSwitchIn:
  14606. return m.OldSwitchIn(ctx)
  14607. case employee.FieldVideoURL:
  14608. return m.OldVideoURL(ctx)
  14609. case employee.FieldOrganizationID:
  14610. return m.OldOrganizationID(ctx)
  14611. case employee.FieldCategoryID:
  14612. return m.OldCategoryID(ctx)
  14613. case employee.FieldAPIBase:
  14614. return m.OldAPIBase(ctx)
  14615. case employee.FieldAPIKey:
  14616. return m.OldAPIKey(ctx)
  14617. case employee.FieldAiInfo:
  14618. return m.OldAiInfo(ctx)
  14619. case employee.FieldIsVip:
  14620. return m.OldIsVip(ctx)
  14621. case employee.FieldChatURL:
  14622. return m.OldChatURL(ctx)
  14623. }
  14624. return nil, fmt.Errorf("unknown Employee field %s", name)
  14625. }
  14626. // SetField sets the value of a field with the given name. It returns an error if
  14627. // the field is not defined in the schema, or if the type mismatched the field
  14628. // type.
  14629. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14630. switch name {
  14631. case employee.FieldCreatedAt:
  14632. v, ok := value.(time.Time)
  14633. if !ok {
  14634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14635. }
  14636. m.SetCreatedAt(v)
  14637. return nil
  14638. case employee.FieldUpdatedAt:
  14639. v, ok := value.(time.Time)
  14640. if !ok {
  14641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14642. }
  14643. m.SetUpdatedAt(v)
  14644. return nil
  14645. case employee.FieldDeletedAt:
  14646. v, ok := value.(time.Time)
  14647. if !ok {
  14648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14649. }
  14650. m.SetDeletedAt(v)
  14651. return nil
  14652. case employee.FieldTitle:
  14653. v, ok := value.(string)
  14654. if !ok {
  14655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14656. }
  14657. m.SetTitle(v)
  14658. return nil
  14659. case employee.FieldAvatar:
  14660. v, ok := value.(string)
  14661. if !ok {
  14662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14663. }
  14664. m.SetAvatar(v)
  14665. return nil
  14666. case employee.FieldTags:
  14667. v, ok := value.(string)
  14668. if !ok {
  14669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14670. }
  14671. m.SetTags(v)
  14672. return nil
  14673. case employee.FieldHireCount:
  14674. v, ok := value.(int)
  14675. if !ok {
  14676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14677. }
  14678. m.SetHireCount(v)
  14679. return nil
  14680. case employee.FieldServiceCount:
  14681. v, ok := value.(int)
  14682. if !ok {
  14683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14684. }
  14685. m.SetServiceCount(v)
  14686. return nil
  14687. case employee.FieldAchievementCount:
  14688. v, ok := value.(int)
  14689. if !ok {
  14690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14691. }
  14692. m.SetAchievementCount(v)
  14693. return nil
  14694. case employee.FieldIntro:
  14695. v, ok := value.(string)
  14696. if !ok {
  14697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14698. }
  14699. m.SetIntro(v)
  14700. return nil
  14701. case employee.FieldEstimate:
  14702. v, ok := value.(string)
  14703. if !ok {
  14704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14705. }
  14706. m.SetEstimate(v)
  14707. return nil
  14708. case employee.FieldSkill:
  14709. v, ok := value.(string)
  14710. if !ok {
  14711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14712. }
  14713. m.SetSkill(v)
  14714. return nil
  14715. case employee.FieldAbilityType:
  14716. v, ok := value.(string)
  14717. if !ok {
  14718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14719. }
  14720. m.SetAbilityType(v)
  14721. return nil
  14722. case employee.FieldScene:
  14723. v, ok := value.(string)
  14724. if !ok {
  14725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14726. }
  14727. m.SetScene(v)
  14728. return nil
  14729. case employee.FieldSwitchIn:
  14730. v, ok := value.(string)
  14731. if !ok {
  14732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14733. }
  14734. m.SetSwitchIn(v)
  14735. return nil
  14736. case employee.FieldVideoURL:
  14737. v, ok := value.(string)
  14738. if !ok {
  14739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14740. }
  14741. m.SetVideoURL(v)
  14742. return nil
  14743. case employee.FieldOrganizationID:
  14744. v, ok := value.(uint64)
  14745. if !ok {
  14746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14747. }
  14748. m.SetOrganizationID(v)
  14749. return nil
  14750. case employee.FieldCategoryID:
  14751. v, ok := value.(uint64)
  14752. if !ok {
  14753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14754. }
  14755. m.SetCategoryID(v)
  14756. return nil
  14757. case employee.FieldAPIBase:
  14758. v, ok := value.(string)
  14759. if !ok {
  14760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14761. }
  14762. m.SetAPIBase(v)
  14763. return nil
  14764. case employee.FieldAPIKey:
  14765. v, ok := value.(string)
  14766. if !ok {
  14767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14768. }
  14769. m.SetAPIKey(v)
  14770. return nil
  14771. case employee.FieldAiInfo:
  14772. v, ok := value.(string)
  14773. if !ok {
  14774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14775. }
  14776. m.SetAiInfo(v)
  14777. return nil
  14778. case employee.FieldIsVip:
  14779. v, ok := value.(int)
  14780. if !ok {
  14781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14782. }
  14783. m.SetIsVip(v)
  14784. return nil
  14785. case employee.FieldChatURL:
  14786. v, ok := value.(string)
  14787. if !ok {
  14788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14789. }
  14790. m.SetChatURL(v)
  14791. return nil
  14792. }
  14793. return fmt.Errorf("unknown Employee field %s", name)
  14794. }
  14795. // AddedFields returns all numeric fields that were incremented/decremented during
  14796. // this mutation.
  14797. func (m *EmployeeMutation) AddedFields() []string {
  14798. var fields []string
  14799. if m.addhire_count != nil {
  14800. fields = append(fields, employee.FieldHireCount)
  14801. }
  14802. if m.addservice_count != nil {
  14803. fields = append(fields, employee.FieldServiceCount)
  14804. }
  14805. if m.addachievement_count != nil {
  14806. fields = append(fields, employee.FieldAchievementCount)
  14807. }
  14808. if m.addorganization_id != nil {
  14809. fields = append(fields, employee.FieldOrganizationID)
  14810. }
  14811. if m.addcategory_id != nil {
  14812. fields = append(fields, employee.FieldCategoryID)
  14813. }
  14814. if m.addis_vip != nil {
  14815. fields = append(fields, employee.FieldIsVip)
  14816. }
  14817. return fields
  14818. }
  14819. // AddedField returns the numeric value that was incremented/decremented on a field
  14820. // with the given name. The second boolean return value indicates that this field
  14821. // was not set, or was not defined in the schema.
  14822. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  14823. switch name {
  14824. case employee.FieldHireCount:
  14825. return m.AddedHireCount()
  14826. case employee.FieldServiceCount:
  14827. return m.AddedServiceCount()
  14828. case employee.FieldAchievementCount:
  14829. return m.AddedAchievementCount()
  14830. case employee.FieldOrganizationID:
  14831. return m.AddedOrganizationID()
  14832. case employee.FieldCategoryID:
  14833. return m.AddedCategoryID()
  14834. case employee.FieldIsVip:
  14835. return m.AddedIsVip()
  14836. }
  14837. return nil, false
  14838. }
  14839. // AddField adds the value to the field with the given name. It returns an error if
  14840. // the field is not defined in the schema, or if the type mismatched the field
  14841. // type.
  14842. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  14843. switch name {
  14844. case employee.FieldHireCount:
  14845. v, ok := value.(int)
  14846. if !ok {
  14847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14848. }
  14849. m.AddHireCount(v)
  14850. return nil
  14851. case employee.FieldServiceCount:
  14852. v, ok := value.(int)
  14853. if !ok {
  14854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14855. }
  14856. m.AddServiceCount(v)
  14857. return nil
  14858. case employee.FieldAchievementCount:
  14859. v, ok := value.(int)
  14860. if !ok {
  14861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14862. }
  14863. m.AddAchievementCount(v)
  14864. return nil
  14865. case employee.FieldOrganizationID:
  14866. v, ok := value.(int64)
  14867. if !ok {
  14868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14869. }
  14870. m.AddOrganizationID(v)
  14871. return nil
  14872. case employee.FieldCategoryID:
  14873. v, ok := value.(int64)
  14874. if !ok {
  14875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14876. }
  14877. m.AddCategoryID(v)
  14878. return nil
  14879. case employee.FieldIsVip:
  14880. v, ok := value.(int)
  14881. if !ok {
  14882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14883. }
  14884. m.AddIsVip(v)
  14885. return nil
  14886. }
  14887. return fmt.Errorf("unknown Employee numeric field %s", name)
  14888. }
  14889. // ClearedFields returns all nullable fields that were cleared during this
  14890. // mutation.
  14891. func (m *EmployeeMutation) ClearedFields() []string {
  14892. var fields []string
  14893. if m.FieldCleared(employee.FieldDeletedAt) {
  14894. fields = append(fields, employee.FieldDeletedAt)
  14895. }
  14896. if m.FieldCleared(employee.FieldAiInfo) {
  14897. fields = append(fields, employee.FieldAiInfo)
  14898. }
  14899. return fields
  14900. }
  14901. // FieldCleared returns a boolean indicating if a field with the given name was
  14902. // cleared in this mutation.
  14903. func (m *EmployeeMutation) FieldCleared(name string) bool {
  14904. _, ok := m.clearedFields[name]
  14905. return ok
  14906. }
  14907. // ClearField clears the value of the field with the given name. It returns an
  14908. // error if the field is not defined in the schema.
  14909. func (m *EmployeeMutation) ClearField(name string) error {
  14910. switch name {
  14911. case employee.FieldDeletedAt:
  14912. m.ClearDeletedAt()
  14913. return nil
  14914. case employee.FieldAiInfo:
  14915. m.ClearAiInfo()
  14916. return nil
  14917. }
  14918. return fmt.Errorf("unknown Employee nullable field %s", name)
  14919. }
  14920. // ResetField resets all changes in the mutation for the field with the given name.
  14921. // It returns an error if the field is not defined in the schema.
  14922. func (m *EmployeeMutation) ResetField(name string) error {
  14923. switch name {
  14924. case employee.FieldCreatedAt:
  14925. m.ResetCreatedAt()
  14926. return nil
  14927. case employee.FieldUpdatedAt:
  14928. m.ResetUpdatedAt()
  14929. return nil
  14930. case employee.FieldDeletedAt:
  14931. m.ResetDeletedAt()
  14932. return nil
  14933. case employee.FieldTitle:
  14934. m.ResetTitle()
  14935. return nil
  14936. case employee.FieldAvatar:
  14937. m.ResetAvatar()
  14938. return nil
  14939. case employee.FieldTags:
  14940. m.ResetTags()
  14941. return nil
  14942. case employee.FieldHireCount:
  14943. m.ResetHireCount()
  14944. return nil
  14945. case employee.FieldServiceCount:
  14946. m.ResetServiceCount()
  14947. return nil
  14948. case employee.FieldAchievementCount:
  14949. m.ResetAchievementCount()
  14950. return nil
  14951. case employee.FieldIntro:
  14952. m.ResetIntro()
  14953. return nil
  14954. case employee.FieldEstimate:
  14955. m.ResetEstimate()
  14956. return nil
  14957. case employee.FieldSkill:
  14958. m.ResetSkill()
  14959. return nil
  14960. case employee.FieldAbilityType:
  14961. m.ResetAbilityType()
  14962. return nil
  14963. case employee.FieldScene:
  14964. m.ResetScene()
  14965. return nil
  14966. case employee.FieldSwitchIn:
  14967. m.ResetSwitchIn()
  14968. return nil
  14969. case employee.FieldVideoURL:
  14970. m.ResetVideoURL()
  14971. return nil
  14972. case employee.FieldOrganizationID:
  14973. m.ResetOrganizationID()
  14974. return nil
  14975. case employee.FieldCategoryID:
  14976. m.ResetCategoryID()
  14977. return nil
  14978. case employee.FieldAPIBase:
  14979. m.ResetAPIBase()
  14980. return nil
  14981. case employee.FieldAPIKey:
  14982. m.ResetAPIKey()
  14983. return nil
  14984. case employee.FieldAiInfo:
  14985. m.ResetAiInfo()
  14986. return nil
  14987. case employee.FieldIsVip:
  14988. m.ResetIsVip()
  14989. return nil
  14990. case employee.FieldChatURL:
  14991. m.ResetChatURL()
  14992. return nil
  14993. }
  14994. return fmt.Errorf("unknown Employee field %s", name)
  14995. }
  14996. // AddedEdges returns all edge names that were set/added in this mutation.
  14997. func (m *EmployeeMutation) AddedEdges() []string {
  14998. edges := make([]string, 0, 2)
  14999. if m.em_work_experiences != nil {
  15000. edges = append(edges, employee.EdgeEmWorkExperiences)
  15001. }
  15002. if m.em_tutorial != nil {
  15003. edges = append(edges, employee.EdgeEmTutorial)
  15004. }
  15005. return edges
  15006. }
  15007. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15008. // name in this mutation.
  15009. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  15010. switch name {
  15011. case employee.EdgeEmWorkExperiences:
  15012. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  15013. for id := range m.em_work_experiences {
  15014. ids = append(ids, id)
  15015. }
  15016. return ids
  15017. case employee.EdgeEmTutorial:
  15018. ids := make([]ent.Value, 0, len(m.em_tutorial))
  15019. for id := range m.em_tutorial {
  15020. ids = append(ids, id)
  15021. }
  15022. return ids
  15023. }
  15024. return nil
  15025. }
  15026. // RemovedEdges returns all edge names that were removed in this mutation.
  15027. func (m *EmployeeMutation) RemovedEdges() []string {
  15028. edges := make([]string, 0, 2)
  15029. if m.removedem_work_experiences != nil {
  15030. edges = append(edges, employee.EdgeEmWorkExperiences)
  15031. }
  15032. if m.removedem_tutorial != nil {
  15033. edges = append(edges, employee.EdgeEmTutorial)
  15034. }
  15035. return edges
  15036. }
  15037. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15038. // the given name in this mutation.
  15039. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  15040. switch name {
  15041. case employee.EdgeEmWorkExperiences:
  15042. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  15043. for id := range m.removedem_work_experiences {
  15044. ids = append(ids, id)
  15045. }
  15046. return ids
  15047. case employee.EdgeEmTutorial:
  15048. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  15049. for id := range m.removedem_tutorial {
  15050. ids = append(ids, id)
  15051. }
  15052. return ids
  15053. }
  15054. return nil
  15055. }
  15056. // ClearedEdges returns all edge names that were cleared in this mutation.
  15057. func (m *EmployeeMutation) ClearedEdges() []string {
  15058. edges := make([]string, 0, 2)
  15059. if m.clearedem_work_experiences {
  15060. edges = append(edges, employee.EdgeEmWorkExperiences)
  15061. }
  15062. if m.clearedem_tutorial {
  15063. edges = append(edges, employee.EdgeEmTutorial)
  15064. }
  15065. return edges
  15066. }
  15067. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15068. // was cleared in this mutation.
  15069. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  15070. switch name {
  15071. case employee.EdgeEmWorkExperiences:
  15072. return m.clearedem_work_experiences
  15073. case employee.EdgeEmTutorial:
  15074. return m.clearedem_tutorial
  15075. }
  15076. return false
  15077. }
  15078. // ClearEdge clears the value of the edge with the given name. It returns an error
  15079. // if that edge is not defined in the schema.
  15080. func (m *EmployeeMutation) ClearEdge(name string) error {
  15081. switch name {
  15082. }
  15083. return fmt.Errorf("unknown Employee unique edge %s", name)
  15084. }
  15085. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15086. // It returns an error if the edge is not defined in the schema.
  15087. func (m *EmployeeMutation) ResetEdge(name string) error {
  15088. switch name {
  15089. case employee.EdgeEmWorkExperiences:
  15090. m.ResetEmWorkExperiences()
  15091. return nil
  15092. case employee.EdgeEmTutorial:
  15093. m.ResetEmTutorial()
  15094. return nil
  15095. }
  15096. return fmt.Errorf("unknown Employee edge %s", name)
  15097. }
  15098. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15099. type EmployeeConfigMutation struct {
  15100. config
  15101. op Op
  15102. typ string
  15103. id *uint64
  15104. created_at *time.Time
  15105. updated_at *time.Time
  15106. deleted_at *time.Time
  15107. stype *string
  15108. title *string
  15109. photo *string
  15110. organization_id *uint64
  15111. addorganization_id *int64
  15112. clearedFields map[string]struct{}
  15113. done bool
  15114. oldValue func(context.Context) (*EmployeeConfig, error)
  15115. predicates []predicate.EmployeeConfig
  15116. }
  15117. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15118. // employeeconfigOption allows management of the mutation configuration using functional options.
  15119. type employeeconfigOption func(*EmployeeConfigMutation)
  15120. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15121. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15122. m := &EmployeeConfigMutation{
  15123. config: c,
  15124. op: op,
  15125. typ: TypeEmployeeConfig,
  15126. clearedFields: make(map[string]struct{}),
  15127. }
  15128. for _, opt := range opts {
  15129. opt(m)
  15130. }
  15131. return m
  15132. }
  15133. // withEmployeeConfigID sets the ID field of the mutation.
  15134. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15135. return func(m *EmployeeConfigMutation) {
  15136. var (
  15137. err error
  15138. once sync.Once
  15139. value *EmployeeConfig
  15140. )
  15141. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15142. once.Do(func() {
  15143. if m.done {
  15144. err = errors.New("querying old values post mutation is not allowed")
  15145. } else {
  15146. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15147. }
  15148. })
  15149. return value, err
  15150. }
  15151. m.id = &id
  15152. }
  15153. }
  15154. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15155. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15156. return func(m *EmployeeConfigMutation) {
  15157. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15158. return node, nil
  15159. }
  15160. m.id = &node.ID
  15161. }
  15162. }
  15163. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15164. // executed in a transaction (ent.Tx), a transactional client is returned.
  15165. func (m EmployeeConfigMutation) Client() *Client {
  15166. client := &Client{config: m.config}
  15167. client.init()
  15168. return client
  15169. }
  15170. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15171. // it returns an error otherwise.
  15172. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15173. if _, ok := m.driver.(*txDriver); !ok {
  15174. return nil, errors.New("ent: mutation is not running in a transaction")
  15175. }
  15176. tx := &Tx{config: m.config}
  15177. tx.init()
  15178. return tx, nil
  15179. }
  15180. // SetID sets the value of the id field. Note that this
  15181. // operation is only accepted on creation of EmployeeConfig entities.
  15182. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15183. m.id = &id
  15184. }
  15185. // ID returns the ID value in the mutation. Note that the ID is only available
  15186. // if it was provided to the builder or after it was returned from the database.
  15187. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15188. if m.id == nil {
  15189. return
  15190. }
  15191. return *m.id, true
  15192. }
  15193. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15194. // That means, if the mutation is applied within a transaction with an isolation level such
  15195. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15196. // or updated by the mutation.
  15197. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15198. switch {
  15199. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15200. id, exists := m.ID()
  15201. if exists {
  15202. return []uint64{id}, nil
  15203. }
  15204. fallthrough
  15205. case m.op.Is(OpUpdate | OpDelete):
  15206. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15207. default:
  15208. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15209. }
  15210. }
  15211. // SetCreatedAt sets the "created_at" field.
  15212. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15213. m.created_at = &t
  15214. }
  15215. // CreatedAt returns the value of the "created_at" field in the mutation.
  15216. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15217. v := m.created_at
  15218. if v == nil {
  15219. return
  15220. }
  15221. return *v, true
  15222. }
  15223. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15224. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15226. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15227. if !m.op.Is(OpUpdateOne) {
  15228. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15229. }
  15230. if m.id == nil || m.oldValue == nil {
  15231. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15232. }
  15233. oldValue, err := m.oldValue(ctx)
  15234. if err != nil {
  15235. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15236. }
  15237. return oldValue.CreatedAt, nil
  15238. }
  15239. // ResetCreatedAt resets all changes to the "created_at" field.
  15240. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15241. m.created_at = nil
  15242. }
  15243. // SetUpdatedAt sets the "updated_at" field.
  15244. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15245. m.updated_at = &t
  15246. }
  15247. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15248. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15249. v := m.updated_at
  15250. if v == nil {
  15251. return
  15252. }
  15253. return *v, true
  15254. }
  15255. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15256. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15258. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15259. if !m.op.Is(OpUpdateOne) {
  15260. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15261. }
  15262. if m.id == nil || m.oldValue == nil {
  15263. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15264. }
  15265. oldValue, err := m.oldValue(ctx)
  15266. if err != nil {
  15267. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15268. }
  15269. return oldValue.UpdatedAt, nil
  15270. }
  15271. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15272. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15273. m.updated_at = nil
  15274. }
  15275. // SetDeletedAt sets the "deleted_at" field.
  15276. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15277. m.deleted_at = &t
  15278. }
  15279. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15280. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15281. v := m.deleted_at
  15282. if v == nil {
  15283. return
  15284. }
  15285. return *v, true
  15286. }
  15287. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15288. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15290. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15291. if !m.op.Is(OpUpdateOne) {
  15292. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15293. }
  15294. if m.id == nil || m.oldValue == nil {
  15295. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15296. }
  15297. oldValue, err := m.oldValue(ctx)
  15298. if err != nil {
  15299. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15300. }
  15301. return oldValue.DeletedAt, nil
  15302. }
  15303. // ClearDeletedAt clears the value of the "deleted_at" field.
  15304. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15305. m.deleted_at = nil
  15306. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15307. }
  15308. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15309. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15310. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15311. return ok
  15312. }
  15313. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15314. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15315. m.deleted_at = nil
  15316. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15317. }
  15318. // SetStype sets the "stype" field.
  15319. func (m *EmployeeConfigMutation) SetStype(s string) {
  15320. m.stype = &s
  15321. }
  15322. // Stype returns the value of the "stype" field in the mutation.
  15323. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15324. v := m.stype
  15325. if v == nil {
  15326. return
  15327. }
  15328. return *v, true
  15329. }
  15330. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15331. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15333. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15334. if !m.op.Is(OpUpdateOne) {
  15335. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15336. }
  15337. if m.id == nil || m.oldValue == nil {
  15338. return v, errors.New("OldStype requires an ID field in the mutation")
  15339. }
  15340. oldValue, err := m.oldValue(ctx)
  15341. if err != nil {
  15342. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15343. }
  15344. return oldValue.Stype, nil
  15345. }
  15346. // ResetStype resets all changes to the "stype" field.
  15347. func (m *EmployeeConfigMutation) ResetStype() {
  15348. m.stype = nil
  15349. }
  15350. // SetTitle sets the "title" field.
  15351. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15352. m.title = &s
  15353. }
  15354. // Title returns the value of the "title" field in the mutation.
  15355. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15356. v := m.title
  15357. if v == nil {
  15358. return
  15359. }
  15360. return *v, true
  15361. }
  15362. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15363. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15365. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15366. if !m.op.Is(OpUpdateOne) {
  15367. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15368. }
  15369. if m.id == nil || m.oldValue == nil {
  15370. return v, errors.New("OldTitle requires an ID field in the mutation")
  15371. }
  15372. oldValue, err := m.oldValue(ctx)
  15373. if err != nil {
  15374. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15375. }
  15376. return oldValue.Title, nil
  15377. }
  15378. // ResetTitle resets all changes to the "title" field.
  15379. func (m *EmployeeConfigMutation) ResetTitle() {
  15380. m.title = nil
  15381. }
  15382. // SetPhoto sets the "photo" field.
  15383. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15384. m.photo = &s
  15385. }
  15386. // Photo returns the value of the "photo" field in the mutation.
  15387. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15388. v := m.photo
  15389. if v == nil {
  15390. return
  15391. }
  15392. return *v, true
  15393. }
  15394. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15395. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15397. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15398. if !m.op.Is(OpUpdateOne) {
  15399. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15400. }
  15401. if m.id == nil || m.oldValue == nil {
  15402. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15403. }
  15404. oldValue, err := m.oldValue(ctx)
  15405. if err != nil {
  15406. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15407. }
  15408. return oldValue.Photo, nil
  15409. }
  15410. // ResetPhoto resets all changes to the "photo" field.
  15411. func (m *EmployeeConfigMutation) ResetPhoto() {
  15412. m.photo = nil
  15413. }
  15414. // SetOrganizationID sets the "organization_id" field.
  15415. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15416. m.organization_id = &u
  15417. m.addorganization_id = nil
  15418. }
  15419. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15420. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15421. v := m.organization_id
  15422. if v == nil {
  15423. return
  15424. }
  15425. return *v, true
  15426. }
  15427. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15428. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15430. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15431. if !m.op.Is(OpUpdateOne) {
  15432. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15433. }
  15434. if m.id == nil || m.oldValue == nil {
  15435. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15436. }
  15437. oldValue, err := m.oldValue(ctx)
  15438. if err != nil {
  15439. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15440. }
  15441. return oldValue.OrganizationID, nil
  15442. }
  15443. // AddOrganizationID adds u to the "organization_id" field.
  15444. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15445. if m.addorganization_id != nil {
  15446. *m.addorganization_id += u
  15447. } else {
  15448. m.addorganization_id = &u
  15449. }
  15450. }
  15451. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15452. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15453. v := m.addorganization_id
  15454. if v == nil {
  15455. return
  15456. }
  15457. return *v, true
  15458. }
  15459. // ClearOrganizationID clears the value of the "organization_id" field.
  15460. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15461. m.organization_id = nil
  15462. m.addorganization_id = nil
  15463. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15464. }
  15465. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15466. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15467. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15468. return ok
  15469. }
  15470. // ResetOrganizationID resets all changes to the "organization_id" field.
  15471. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15472. m.organization_id = nil
  15473. m.addorganization_id = nil
  15474. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15475. }
  15476. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15477. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15478. m.predicates = append(m.predicates, ps...)
  15479. }
  15480. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15481. // users can use type-assertion to append predicates that do not depend on any generated package.
  15482. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15483. p := make([]predicate.EmployeeConfig, len(ps))
  15484. for i := range ps {
  15485. p[i] = ps[i]
  15486. }
  15487. m.Where(p...)
  15488. }
  15489. // Op returns the operation name.
  15490. func (m *EmployeeConfigMutation) Op() Op {
  15491. return m.op
  15492. }
  15493. // SetOp allows setting the mutation operation.
  15494. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15495. m.op = op
  15496. }
  15497. // Type returns the node type of this mutation (EmployeeConfig).
  15498. func (m *EmployeeConfigMutation) Type() string {
  15499. return m.typ
  15500. }
  15501. // Fields returns all fields that were changed during this mutation. Note that in
  15502. // order to get all numeric fields that were incremented/decremented, call
  15503. // AddedFields().
  15504. func (m *EmployeeConfigMutation) Fields() []string {
  15505. fields := make([]string, 0, 7)
  15506. if m.created_at != nil {
  15507. fields = append(fields, employeeconfig.FieldCreatedAt)
  15508. }
  15509. if m.updated_at != nil {
  15510. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15511. }
  15512. if m.deleted_at != nil {
  15513. fields = append(fields, employeeconfig.FieldDeletedAt)
  15514. }
  15515. if m.stype != nil {
  15516. fields = append(fields, employeeconfig.FieldStype)
  15517. }
  15518. if m.title != nil {
  15519. fields = append(fields, employeeconfig.FieldTitle)
  15520. }
  15521. if m.photo != nil {
  15522. fields = append(fields, employeeconfig.FieldPhoto)
  15523. }
  15524. if m.organization_id != nil {
  15525. fields = append(fields, employeeconfig.FieldOrganizationID)
  15526. }
  15527. return fields
  15528. }
  15529. // Field returns the value of a field with the given name. The second boolean
  15530. // return value indicates that this field was not set, or was not defined in the
  15531. // schema.
  15532. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15533. switch name {
  15534. case employeeconfig.FieldCreatedAt:
  15535. return m.CreatedAt()
  15536. case employeeconfig.FieldUpdatedAt:
  15537. return m.UpdatedAt()
  15538. case employeeconfig.FieldDeletedAt:
  15539. return m.DeletedAt()
  15540. case employeeconfig.FieldStype:
  15541. return m.Stype()
  15542. case employeeconfig.FieldTitle:
  15543. return m.Title()
  15544. case employeeconfig.FieldPhoto:
  15545. return m.Photo()
  15546. case employeeconfig.FieldOrganizationID:
  15547. return m.OrganizationID()
  15548. }
  15549. return nil, false
  15550. }
  15551. // OldField returns the old value of the field from the database. An error is
  15552. // returned if the mutation operation is not UpdateOne, or the query to the
  15553. // database failed.
  15554. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15555. switch name {
  15556. case employeeconfig.FieldCreatedAt:
  15557. return m.OldCreatedAt(ctx)
  15558. case employeeconfig.FieldUpdatedAt:
  15559. return m.OldUpdatedAt(ctx)
  15560. case employeeconfig.FieldDeletedAt:
  15561. return m.OldDeletedAt(ctx)
  15562. case employeeconfig.FieldStype:
  15563. return m.OldStype(ctx)
  15564. case employeeconfig.FieldTitle:
  15565. return m.OldTitle(ctx)
  15566. case employeeconfig.FieldPhoto:
  15567. return m.OldPhoto(ctx)
  15568. case employeeconfig.FieldOrganizationID:
  15569. return m.OldOrganizationID(ctx)
  15570. }
  15571. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15572. }
  15573. // SetField sets the value of a field with the given name. It returns an error if
  15574. // the field is not defined in the schema, or if the type mismatched the field
  15575. // type.
  15576. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15577. switch name {
  15578. case employeeconfig.FieldCreatedAt:
  15579. v, ok := value.(time.Time)
  15580. if !ok {
  15581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15582. }
  15583. m.SetCreatedAt(v)
  15584. return nil
  15585. case employeeconfig.FieldUpdatedAt:
  15586. v, ok := value.(time.Time)
  15587. if !ok {
  15588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15589. }
  15590. m.SetUpdatedAt(v)
  15591. return nil
  15592. case employeeconfig.FieldDeletedAt:
  15593. v, ok := value.(time.Time)
  15594. if !ok {
  15595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15596. }
  15597. m.SetDeletedAt(v)
  15598. return nil
  15599. case employeeconfig.FieldStype:
  15600. v, ok := value.(string)
  15601. if !ok {
  15602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15603. }
  15604. m.SetStype(v)
  15605. return nil
  15606. case employeeconfig.FieldTitle:
  15607. v, ok := value.(string)
  15608. if !ok {
  15609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15610. }
  15611. m.SetTitle(v)
  15612. return nil
  15613. case employeeconfig.FieldPhoto:
  15614. v, ok := value.(string)
  15615. if !ok {
  15616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15617. }
  15618. m.SetPhoto(v)
  15619. return nil
  15620. case employeeconfig.FieldOrganizationID:
  15621. v, ok := value.(uint64)
  15622. if !ok {
  15623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15624. }
  15625. m.SetOrganizationID(v)
  15626. return nil
  15627. }
  15628. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15629. }
  15630. // AddedFields returns all numeric fields that were incremented/decremented during
  15631. // this mutation.
  15632. func (m *EmployeeConfigMutation) AddedFields() []string {
  15633. var fields []string
  15634. if m.addorganization_id != nil {
  15635. fields = append(fields, employeeconfig.FieldOrganizationID)
  15636. }
  15637. return fields
  15638. }
  15639. // AddedField returns the numeric value that was incremented/decremented on a field
  15640. // with the given name. The second boolean return value indicates that this field
  15641. // was not set, or was not defined in the schema.
  15642. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  15643. switch name {
  15644. case employeeconfig.FieldOrganizationID:
  15645. return m.AddedOrganizationID()
  15646. }
  15647. return nil, false
  15648. }
  15649. // AddField adds the value to the field with the given name. It returns an error if
  15650. // the field is not defined in the schema, or if the type mismatched the field
  15651. // type.
  15652. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  15653. switch name {
  15654. case employeeconfig.FieldOrganizationID:
  15655. v, ok := value.(int64)
  15656. if !ok {
  15657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15658. }
  15659. m.AddOrganizationID(v)
  15660. return nil
  15661. }
  15662. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  15663. }
  15664. // ClearedFields returns all nullable fields that were cleared during this
  15665. // mutation.
  15666. func (m *EmployeeConfigMutation) ClearedFields() []string {
  15667. var fields []string
  15668. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  15669. fields = append(fields, employeeconfig.FieldDeletedAt)
  15670. }
  15671. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  15672. fields = append(fields, employeeconfig.FieldOrganizationID)
  15673. }
  15674. return fields
  15675. }
  15676. // FieldCleared returns a boolean indicating if a field with the given name was
  15677. // cleared in this mutation.
  15678. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  15679. _, ok := m.clearedFields[name]
  15680. return ok
  15681. }
  15682. // ClearField clears the value of the field with the given name. It returns an
  15683. // error if the field is not defined in the schema.
  15684. func (m *EmployeeConfigMutation) ClearField(name string) error {
  15685. switch name {
  15686. case employeeconfig.FieldDeletedAt:
  15687. m.ClearDeletedAt()
  15688. return nil
  15689. case employeeconfig.FieldOrganizationID:
  15690. m.ClearOrganizationID()
  15691. return nil
  15692. }
  15693. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  15694. }
  15695. // ResetField resets all changes in the mutation for the field with the given name.
  15696. // It returns an error if the field is not defined in the schema.
  15697. func (m *EmployeeConfigMutation) ResetField(name string) error {
  15698. switch name {
  15699. case employeeconfig.FieldCreatedAt:
  15700. m.ResetCreatedAt()
  15701. return nil
  15702. case employeeconfig.FieldUpdatedAt:
  15703. m.ResetUpdatedAt()
  15704. return nil
  15705. case employeeconfig.FieldDeletedAt:
  15706. m.ResetDeletedAt()
  15707. return nil
  15708. case employeeconfig.FieldStype:
  15709. m.ResetStype()
  15710. return nil
  15711. case employeeconfig.FieldTitle:
  15712. m.ResetTitle()
  15713. return nil
  15714. case employeeconfig.FieldPhoto:
  15715. m.ResetPhoto()
  15716. return nil
  15717. case employeeconfig.FieldOrganizationID:
  15718. m.ResetOrganizationID()
  15719. return nil
  15720. }
  15721. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15722. }
  15723. // AddedEdges returns all edge names that were set/added in this mutation.
  15724. func (m *EmployeeConfigMutation) AddedEdges() []string {
  15725. edges := make([]string, 0, 0)
  15726. return edges
  15727. }
  15728. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15729. // name in this mutation.
  15730. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  15731. return nil
  15732. }
  15733. // RemovedEdges returns all edge names that were removed in this mutation.
  15734. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  15735. edges := make([]string, 0, 0)
  15736. return edges
  15737. }
  15738. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15739. // the given name in this mutation.
  15740. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  15741. return nil
  15742. }
  15743. // ClearedEdges returns all edge names that were cleared in this mutation.
  15744. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  15745. edges := make([]string, 0, 0)
  15746. return edges
  15747. }
  15748. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15749. // was cleared in this mutation.
  15750. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  15751. return false
  15752. }
  15753. // ClearEdge clears the value of the edge with the given name. It returns an error
  15754. // if that edge is not defined in the schema.
  15755. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  15756. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  15757. }
  15758. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15759. // It returns an error if the edge is not defined in the schema.
  15760. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  15761. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  15762. }
  15763. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  15764. type LabelMutation struct {
  15765. config
  15766. op Op
  15767. typ string
  15768. id *uint64
  15769. created_at *time.Time
  15770. updated_at *time.Time
  15771. status *uint8
  15772. addstatus *int8
  15773. _type *int
  15774. add_type *int
  15775. name *string
  15776. from *int
  15777. addfrom *int
  15778. mode *int
  15779. addmode *int
  15780. conditions *string
  15781. organization_id *uint64
  15782. addorganization_id *int64
  15783. clearedFields map[string]struct{}
  15784. label_relationships map[uint64]struct{}
  15785. removedlabel_relationships map[uint64]struct{}
  15786. clearedlabel_relationships bool
  15787. done bool
  15788. oldValue func(context.Context) (*Label, error)
  15789. predicates []predicate.Label
  15790. }
  15791. var _ ent.Mutation = (*LabelMutation)(nil)
  15792. // labelOption allows management of the mutation configuration using functional options.
  15793. type labelOption func(*LabelMutation)
  15794. // newLabelMutation creates new mutation for the Label entity.
  15795. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  15796. m := &LabelMutation{
  15797. config: c,
  15798. op: op,
  15799. typ: TypeLabel,
  15800. clearedFields: make(map[string]struct{}),
  15801. }
  15802. for _, opt := range opts {
  15803. opt(m)
  15804. }
  15805. return m
  15806. }
  15807. // withLabelID sets the ID field of the mutation.
  15808. func withLabelID(id uint64) labelOption {
  15809. return func(m *LabelMutation) {
  15810. var (
  15811. err error
  15812. once sync.Once
  15813. value *Label
  15814. )
  15815. m.oldValue = func(ctx context.Context) (*Label, error) {
  15816. once.Do(func() {
  15817. if m.done {
  15818. err = errors.New("querying old values post mutation is not allowed")
  15819. } else {
  15820. value, err = m.Client().Label.Get(ctx, id)
  15821. }
  15822. })
  15823. return value, err
  15824. }
  15825. m.id = &id
  15826. }
  15827. }
  15828. // withLabel sets the old Label of the mutation.
  15829. func withLabel(node *Label) labelOption {
  15830. return func(m *LabelMutation) {
  15831. m.oldValue = func(context.Context) (*Label, error) {
  15832. return node, nil
  15833. }
  15834. m.id = &node.ID
  15835. }
  15836. }
  15837. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15838. // executed in a transaction (ent.Tx), a transactional client is returned.
  15839. func (m LabelMutation) Client() *Client {
  15840. client := &Client{config: m.config}
  15841. client.init()
  15842. return client
  15843. }
  15844. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15845. // it returns an error otherwise.
  15846. func (m LabelMutation) Tx() (*Tx, error) {
  15847. if _, ok := m.driver.(*txDriver); !ok {
  15848. return nil, errors.New("ent: mutation is not running in a transaction")
  15849. }
  15850. tx := &Tx{config: m.config}
  15851. tx.init()
  15852. return tx, nil
  15853. }
  15854. // SetID sets the value of the id field. Note that this
  15855. // operation is only accepted on creation of Label entities.
  15856. func (m *LabelMutation) SetID(id uint64) {
  15857. m.id = &id
  15858. }
  15859. // ID returns the ID value in the mutation. Note that the ID is only available
  15860. // if it was provided to the builder or after it was returned from the database.
  15861. func (m *LabelMutation) ID() (id uint64, exists bool) {
  15862. if m.id == nil {
  15863. return
  15864. }
  15865. return *m.id, true
  15866. }
  15867. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15868. // That means, if the mutation is applied within a transaction with an isolation level such
  15869. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15870. // or updated by the mutation.
  15871. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  15872. switch {
  15873. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15874. id, exists := m.ID()
  15875. if exists {
  15876. return []uint64{id}, nil
  15877. }
  15878. fallthrough
  15879. case m.op.Is(OpUpdate | OpDelete):
  15880. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  15881. default:
  15882. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15883. }
  15884. }
  15885. // SetCreatedAt sets the "created_at" field.
  15886. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  15887. m.created_at = &t
  15888. }
  15889. // CreatedAt returns the value of the "created_at" field in the mutation.
  15890. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  15891. v := m.created_at
  15892. if v == nil {
  15893. return
  15894. }
  15895. return *v, true
  15896. }
  15897. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  15898. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15900. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15901. if !m.op.Is(OpUpdateOne) {
  15902. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15903. }
  15904. if m.id == nil || m.oldValue == nil {
  15905. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15906. }
  15907. oldValue, err := m.oldValue(ctx)
  15908. if err != nil {
  15909. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15910. }
  15911. return oldValue.CreatedAt, nil
  15912. }
  15913. // ResetCreatedAt resets all changes to the "created_at" field.
  15914. func (m *LabelMutation) ResetCreatedAt() {
  15915. m.created_at = nil
  15916. }
  15917. // SetUpdatedAt sets the "updated_at" field.
  15918. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  15919. m.updated_at = &t
  15920. }
  15921. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15922. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  15923. v := m.updated_at
  15924. if v == nil {
  15925. return
  15926. }
  15927. return *v, true
  15928. }
  15929. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  15930. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15932. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15933. if !m.op.Is(OpUpdateOne) {
  15934. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15935. }
  15936. if m.id == nil || m.oldValue == nil {
  15937. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15938. }
  15939. oldValue, err := m.oldValue(ctx)
  15940. if err != nil {
  15941. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15942. }
  15943. return oldValue.UpdatedAt, nil
  15944. }
  15945. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15946. func (m *LabelMutation) ResetUpdatedAt() {
  15947. m.updated_at = nil
  15948. }
  15949. // SetStatus sets the "status" field.
  15950. func (m *LabelMutation) SetStatus(u uint8) {
  15951. m.status = &u
  15952. m.addstatus = nil
  15953. }
  15954. // Status returns the value of the "status" field in the mutation.
  15955. func (m *LabelMutation) Status() (r uint8, exists bool) {
  15956. v := m.status
  15957. if v == nil {
  15958. return
  15959. }
  15960. return *v, true
  15961. }
  15962. // OldStatus returns the old "status" field's value of the Label entity.
  15963. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15965. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15966. if !m.op.Is(OpUpdateOne) {
  15967. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15968. }
  15969. if m.id == nil || m.oldValue == nil {
  15970. return v, errors.New("OldStatus requires an ID field in the mutation")
  15971. }
  15972. oldValue, err := m.oldValue(ctx)
  15973. if err != nil {
  15974. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15975. }
  15976. return oldValue.Status, nil
  15977. }
  15978. // AddStatus adds u to the "status" field.
  15979. func (m *LabelMutation) AddStatus(u int8) {
  15980. if m.addstatus != nil {
  15981. *m.addstatus += u
  15982. } else {
  15983. m.addstatus = &u
  15984. }
  15985. }
  15986. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15987. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  15988. v := m.addstatus
  15989. if v == nil {
  15990. return
  15991. }
  15992. return *v, true
  15993. }
  15994. // ClearStatus clears the value of the "status" field.
  15995. func (m *LabelMutation) ClearStatus() {
  15996. m.status = nil
  15997. m.addstatus = nil
  15998. m.clearedFields[label.FieldStatus] = struct{}{}
  15999. }
  16000. // StatusCleared returns if the "status" field was cleared in this mutation.
  16001. func (m *LabelMutation) StatusCleared() bool {
  16002. _, ok := m.clearedFields[label.FieldStatus]
  16003. return ok
  16004. }
  16005. // ResetStatus resets all changes to the "status" field.
  16006. func (m *LabelMutation) ResetStatus() {
  16007. m.status = nil
  16008. m.addstatus = nil
  16009. delete(m.clearedFields, label.FieldStatus)
  16010. }
  16011. // SetType sets the "type" field.
  16012. func (m *LabelMutation) SetType(i int) {
  16013. m._type = &i
  16014. m.add_type = nil
  16015. }
  16016. // GetType returns the value of the "type" field in the mutation.
  16017. func (m *LabelMutation) GetType() (r int, exists bool) {
  16018. v := m._type
  16019. if v == nil {
  16020. return
  16021. }
  16022. return *v, true
  16023. }
  16024. // OldType returns the old "type" field's value of the Label entity.
  16025. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16027. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  16028. if !m.op.Is(OpUpdateOne) {
  16029. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16030. }
  16031. if m.id == nil || m.oldValue == nil {
  16032. return v, errors.New("OldType requires an ID field in the mutation")
  16033. }
  16034. oldValue, err := m.oldValue(ctx)
  16035. if err != nil {
  16036. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16037. }
  16038. return oldValue.Type, nil
  16039. }
  16040. // AddType adds i to the "type" field.
  16041. func (m *LabelMutation) AddType(i int) {
  16042. if m.add_type != nil {
  16043. *m.add_type += i
  16044. } else {
  16045. m.add_type = &i
  16046. }
  16047. }
  16048. // AddedType returns the value that was added to the "type" field in this mutation.
  16049. func (m *LabelMutation) AddedType() (r int, exists bool) {
  16050. v := m.add_type
  16051. if v == nil {
  16052. return
  16053. }
  16054. return *v, true
  16055. }
  16056. // ResetType resets all changes to the "type" field.
  16057. func (m *LabelMutation) ResetType() {
  16058. m._type = nil
  16059. m.add_type = nil
  16060. }
  16061. // SetName sets the "name" field.
  16062. func (m *LabelMutation) SetName(s string) {
  16063. m.name = &s
  16064. }
  16065. // Name returns the value of the "name" field in the mutation.
  16066. func (m *LabelMutation) Name() (r string, exists bool) {
  16067. v := m.name
  16068. if v == nil {
  16069. return
  16070. }
  16071. return *v, true
  16072. }
  16073. // OldName returns the old "name" field's value of the Label entity.
  16074. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16076. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  16077. if !m.op.Is(OpUpdateOne) {
  16078. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16079. }
  16080. if m.id == nil || m.oldValue == nil {
  16081. return v, errors.New("OldName requires an ID field in the mutation")
  16082. }
  16083. oldValue, err := m.oldValue(ctx)
  16084. if err != nil {
  16085. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16086. }
  16087. return oldValue.Name, nil
  16088. }
  16089. // ResetName resets all changes to the "name" field.
  16090. func (m *LabelMutation) ResetName() {
  16091. m.name = nil
  16092. }
  16093. // SetFrom sets the "from" field.
  16094. func (m *LabelMutation) SetFrom(i int) {
  16095. m.from = &i
  16096. m.addfrom = nil
  16097. }
  16098. // From returns the value of the "from" field in the mutation.
  16099. func (m *LabelMutation) From() (r int, exists bool) {
  16100. v := m.from
  16101. if v == nil {
  16102. return
  16103. }
  16104. return *v, true
  16105. }
  16106. // OldFrom returns the old "from" field's value of the Label entity.
  16107. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16109. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16110. if !m.op.Is(OpUpdateOne) {
  16111. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16112. }
  16113. if m.id == nil || m.oldValue == nil {
  16114. return v, errors.New("OldFrom requires an ID field in the mutation")
  16115. }
  16116. oldValue, err := m.oldValue(ctx)
  16117. if err != nil {
  16118. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16119. }
  16120. return oldValue.From, nil
  16121. }
  16122. // AddFrom adds i to the "from" field.
  16123. func (m *LabelMutation) AddFrom(i int) {
  16124. if m.addfrom != nil {
  16125. *m.addfrom += i
  16126. } else {
  16127. m.addfrom = &i
  16128. }
  16129. }
  16130. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16131. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16132. v := m.addfrom
  16133. if v == nil {
  16134. return
  16135. }
  16136. return *v, true
  16137. }
  16138. // ResetFrom resets all changes to the "from" field.
  16139. func (m *LabelMutation) ResetFrom() {
  16140. m.from = nil
  16141. m.addfrom = nil
  16142. }
  16143. // SetMode sets the "mode" field.
  16144. func (m *LabelMutation) SetMode(i int) {
  16145. m.mode = &i
  16146. m.addmode = nil
  16147. }
  16148. // Mode returns the value of the "mode" field in the mutation.
  16149. func (m *LabelMutation) Mode() (r int, exists bool) {
  16150. v := m.mode
  16151. if v == nil {
  16152. return
  16153. }
  16154. return *v, true
  16155. }
  16156. // OldMode returns the old "mode" field's value of the Label entity.
  16157. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16159. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16160. if !m.op.Is(OpUpdateOne) {
  16161. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16162. }
  16163. if m.id == nil || m.oldValue == nil {
  16164. return v, errors.New("OldMode requires an ID field in the mutation")
  16165. }
  16166. oldValue, err := m.oldValue(ctx)
  16167. if err != nil {
  16168. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16169. }
  16170. return oldValue.Mode, nil
  16171. }
  16172. // AddMode adds i to the "mode" field.
  16173. func (m *LabelMutation) AddMode(i int) {
  16174. if m.addmode != nil {
  16175. *m.addmode += i
  16176. } else {
  16177. m.addmode = &i
  16178. }
  16179. }
  16180. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16181. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16182. v := m.addmode
  16183. if v == nil {
  16184. return
  16185. }
  16186. return *v, true
  16187. }
  16188. // ResetMode resets all changes to the "mode" field.
  16189. func (m *LabelMutation) ResetMode() {
  16190. m.mode = nil
  16191. m.addmode = nil
  16192. }
  16193. // SetConditions sets the "conditions" field.
  16194. func (m *LabelMutation) SetConditions(s string) {
  16195. m.conditions = &s
  16196. }
  16197. // Conditions returns the value of the "conditions" field in the mutation.
  16198. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16199. v := m.conditions
  16200. if v == nil {
  16201. return
  16202. }
  16203. return *v, true
  16204. }
  16205. // OldConditions returns the old "conditions" field's value of the Label entity.
  16206. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16208. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16209. if !m.op.Is(OpUpdateOne) {
  16210. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16211. }
  16212. if m.id == nil || m.oldValue == nil {
  16213. return v, errors.New("OldConditions requires an ID field in the mutation")
  16214. }
  16215. oldValue, err := m.oldValue(ctx)
  16216. if err != nil {
  16217. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16218. }
  16219. return oldValue.Conditions, nil
  16220. }
  16221. // ClearConditions clears the value of the "conditions" field.
  16222. func (m *LabelMutation) ClearConditions() {
  16223. m.conditions = nil
  16224. m.clearedFields[label.FieldConditions] = struct{}{}
  16225. }
  16226. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16227. func (m *LabelMutation) ConditionsCleared() bool {
  16228. _, ok := m.clearedFields[label.FieldConditions]
  16229. return ok
  16230. }
  16231. // ResetConditions resets all changes to the "conditions" field.
  16232. func (m *LabelMutation) ResetConditions() {
  16233. m.conditions = nil
  16234. delete(m.clearedFields, label.FieldConditions)
  16235. }
  16236. // SetOrganizationID sets the "organization_id" field.
  16237. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16238. m.organization_id = &u
  16239. m.addorganization_id = nil
  16240. }
  16241. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16242. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16243. v := m.organization_id
  16244. if v == nil {
  16245. return
  16246. }
  16247. return *v, true
  16248. }
  16249. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16250. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16252. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16253. if !m.op.Is(OpUpdateOne) {
  16254. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16255. }
  16256. if m.id == nil || m.oldValue == nil {
  16257. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16258. }
  16259. oldValue, err := m.oldValue(ctx)
  16260. if err != nil {
  16261. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16262. }
  16263. return oldValue.OrganizationID, nil
  16264. }
  16265. // AddOrganizationID adds u to the "organization_id" field.
  16266. func (m *LabelMutation) AddOrganizationID(u int64) {
  16267. if m.addorganization_id != nil {
  16268. *m.addorganization_id += u
  16269. } else {
  16270. m.addorganization_id = &u
  16271. }
  16272. }
  16273. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16274. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16275. v := m.addorganization_id
  16276. if v == nil {
  16277. return
  16278. }
  16279. return *v, true
  16280. }
  16281. // ClearOrganizationID clears the value of the "organization_id" field.
  16282. func (m *LabelMutation) ClearOrganizationID() {
  16283. m.organization_id = nil
  16284. m.addorganization_id = nil
  16285. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16286. }
  16287. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16288. func (m *LabelMutation) OrganizationIDCleared() bool {
  16289. _, ok := m.clearedFields[label.FieldOrganizationID]
  16290. return ok
  16291. }
  16292. // ResetOrganizationID resets all changes to the "organization_id" field.
  16293. func (m *LabelMutation) ResetOrganizationID() {
  16294. m.organization_id = nil
  16295. m.addorganization_id = nil
  16296. delete(m.clearedFields, label.FieldOrganizationID)
  16297. }
  16298. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16299. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16300. if m.label_relationships == nil {
  16301. m.label_relationships = make(map[uint64]struct{})
  16302. }
  16303. for i := range ids {
  16304. m.label_relationships[ids[i]] = struct{}{}
  16305. }
  16306. }
  16307. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16308. func (m *LabelMutation) ClearLabelRelationships() {
  16309. m.clearedlabel_relationships = true
  16310. }
  16311. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16312. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16313. return m.clearedlabel_relationships
  16314. }
  16315. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16316. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16317. if m.removedlabel_relationships == nil {
  16318. m.removedlabel_relationships = make(map[uint64]struct{})
  16319. }
  16320. for i := range ids {
  16321. delete(m.label_relationships, ids[i])
  16322. m.removedlabel_relationships[ids[i]] = struct{}{}
  16323. }
  16324. }
  16325. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16326. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16327. for id := range m.removedlabel_relationships {
  16328. ids = append(ids, id)
  16329. }
  16330. return
  16331. }
  16332. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16333. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16334. for id := range m.label_relationships {
  16335. ids = append(ids, id)
  16336. }
  16337. return
  16338. }
  16339. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16340. func (m *LabelMutation) ResetLabelRelationships() {
  16341. m.label_relationships = nil
  16342. m.clearedlabel_relationships = false
  16343. m.removedlabel_relationships = nil
  16344. }
  16345. // Where appends a list predicates to the LabelMutation builder.
  16346. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16347. m.predicates = append(m.predicates, ps...)
  16348. }
  16349. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16350. // users can use type-assertion to append predicates that do not depend on any generated package.
  16351. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16352. p := make([]predicate.Label, len(ps))
  16353. for i := range ps {
  16354. p[i] = ps[i]
  16355. }
  16356. m.Where(p...)
  16357. }
  16358. // Op returns the operation name.
  16359. func (m *LabelMutation) Op() Op {
  16360. return m.op
  16361. }
  16362. // SetOp allows setting the mutation operation.
  16363. func (m *LabelMutation) SetOp(op Op) {
  16364. m.op = op
  16365. }
  16366. // Type returns the node type of this mutation (Label).
  16367. func (m *LabelMutation) Type() string {
  16368. return m.typ
  16369. }
  16370. // Fields returns all fields that were changed during this mutation. Note that in
  16371. // order to get all numeric fields that were incremented/decremented, call
  16372. // AddedFields().
  16373. func (m *LabelMutation) Fields() []string {
  16374. fields := make([]string, 0, 9)
  16375. if m.created_at != nil {
  16376. fields = append(fields, label.FieldCreatedAt)
  16377. }
  16378. if m.updated_at != nil {
  16379. fields = append(fields, label.FieldUpdatedAt)
  16380. }
  16381. if m.status != nil {
  16382. fields = append(fields, label.FieldStatus)
  16383. }
  16384. if m._type != nil {
  16385. fields = append(fields, label.FieldType)
  16386. }
  16387. if m.name != nil {
  16388. fields = append(fields, label.FieldName)
  16389. }
  16390. if m.from != nil {
  16391. fields = append(fields, label.FieldFrom)
  16392. }
  16393. if m.mode != nil {
  16394. fields = append(fields, label.FieldMode)
  16395. }
  16396. if m.conditions != nil {
  16397. fields = append(fields, label.FieldConditions)
  16398. }
  16399. if m.organization_id != nil {
  16400. fields = append(fields, label.FieldOrganizationID)
  16401. }
  16402. return fields
  16403. }
  16404. // Field returns the value of a field with the given name. The second boolean
  16405. // return value indicates that this field was not set, or was not defined in the
  16406. // schema.
  16407. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16408. switch name {
  16409. case label.FieldCreatedAt:
  16410. return m.CreatedAt()
  16411. case label.FieldUpdatedAt:
  16412. return m.UpdatedAt()
  16413. case label.FieldStatus:
  16414. return m.Status()
  16415. case label.FieldType:
  16416. return m.GetType()
  16417. case label.FieldName:
  16418. return m.Name()
  16419. case label.FieldFrom:
  16420. return m.From()
  16421. case label.FieldMode:
  16422. return m.Mode()
  16423. case label.FieldConditions:
  16424. return m.Conditions()
  16425. case label.FieldOrganizationID:
  16426. return m.OrganizationID()
  16427. }
  16428. return nil, false
  16429. }
  16430. // OldField returns the old value of the field from the database. An error is
  16431. // returned if the mutation operation is not UpdateOne, or the query to the
  16432. // database failed.
  16433. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16434. switch name {
  16435. case label.FieldCreatedAt:
  16436. return m.OldCreatedAt(ctx)
  16437. case label.FieldUpdatedAt:
  16438. return m.OldUpdatedAt(ctx)
  16439. case label.FieldStatus:
  16440. return m.OldStatus(ctx)
  16441. case label.FieldType:
  16442. return m.OldType(ctx)
  16443. case label.FieldName:
  16444. return m.OldName(ctx)
  16445. case label.FieldFrom:
  16446. return m.OldFrom(ctx)
  16447. case label.FieldMode:
  16448. return m.OldMode(ctx)
  16449. case label.FieldConditions:
  16450. return m.OldConditions(ctx)
  16451. case label.FieldOrganizationID:
  16452. return m.OldOrganizationID(ctx)
  16453. }
  16454. return nil, fmt.Errorf("unknown Label field %s", name)
  16455. }
  16456. // SetField sets the value of a field with the given name. It returns an error if
  16457. // the field is not defined in the schema, or if the type mismatched the field
  16458. // type.
  16459. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16460. switch name {
  16461. case label.FieldCreatedAt:
  16462. v, ok := value.(time.Time)
  16463. if !ok {
  16464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16465. }
  16466. m.SetCreatedAt(v)
  16467. return nil
  16468. case label.FieldUpdatedAt:
  16469. v, ok := value.(time.Time)
  16470. if !ok {
  16471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16472. }
  16473. m.SetUpdatedAt(v)
  16474. return nil
  16475. case label.FieldStatus:
  16476. v, ok := value.(uint8)
  16477. if !ok {
  16478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16479. }
  16480. m.SetStatus(v)
  16481. return nil
  16482. case label.FieldType:
  16483. v, ok := value.(int)
  16484. if !ok {
  16485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16486. }
  16487. m.SetType(v)
  16488. return nil
  16489. case label.FieldName:
  16490. v, ok := value.(string)
  16491. if !ok {
  16492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16493. }
  16494. m.SetName(v)
  16495. return nil
  16496. case label.FieldFrom:
  16497. v, ok := value.(int)
  16498. if !ok {
  16499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16500. }
  16501. m.SetFrom(v)
  16502. return nil
  16503. case label.FieldMode:
  16504. v, ok := value.(int)
  16505. if !ok {
  16506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16507. }
  16508. m.SetMode(v)
  16509. return nil
  16510. case label.FieldConditions:
  16511. v, ok := value.(string)
  16512. if !ok {
  16513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16514. }
  16515. m.SetConditions(v)
  16516. return nil
  16517. case label.FieldOrganizationID:
  16518. v, ok := value.(uint64)
  16519. if !ok {
  16520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16521. }
  16522. m.SetOrganizationID(v)
  16523. return nil
  16524. }
  16525. return fmt.Errorf("unknown Label field %s", name)
  16526. }
  16527. // AddedFields returns all numeric fields that were incremented/decremented during
  16528. // this mutation.
  16529. func (m *LabelMutation) AddedFields() []string {
  16530. var fields []string
  16531. if m.addstatus != nil {
  16532. fields = append(fields, label.FieldStatus)
  16533. }
  16534. if m.add_type != nil {
  16535. fields = append(fields, label.FieldType)
  16536. }
  16537. if m.addfrom != nil {
  16538. fields = append(fields, label.FieldFrom)
  16539. }
  16540. if m.addmode != nil {
  16541. fields = append(fields, label.FieldMode)
  16542. }
  16543. if m.addorganization_id != nil {
  16544. fields = append(fields, label.FieldOrganizationID)
  16545. }
  16546. return fields
  16547. }
  16548. // AddedField returns the numeric value that was incremented/decremented on a field
  16549. // with the given name. The second boolean return value indicates that this field
  16550. // was not set, or was not defined in the schema.
  16551. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16552. switch name {
  16553. case label.FieldStatus:
  16554. return m.AddedStatus()
  16555. case label.FieldType:
  16556. return m.AddedType()
  16557. case label.FieldFrom:
  16558. return m.AddedFrom()
  16559. case label.FieldMode:
  16560. return m.AddedMode()
  16561. case label.FieldOrganizationID:
  16562. return m.AddedOrganizationID()
  16563. }
  16564. return nil, false
  16565. }
  16566. // AddField adds the value to the field with the given name. It returns an error if
  16567. // the field is not defined in the schema, or if the type mismatched the field
  16568. // type.
  16569. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16570. switch name {
  16571. case label.FieldStatus:
  16572. v, ok := value.(int8)
  16573. if !ok {
  16574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16575. }
  16576. m.AddStatus(v)
  16577. return nil
  16578. case label.FieldType:
  16579. v, ok := value.(int)
  16580. if !ok {
  16581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16582. }
  16583. m.AddType(v)
  16584. return nil
  16585. case label.FieldFrom:
  16586. v, ok := value.(int)
  16587. if !ok {
  16588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16589. }
  16590. m.AddFrom(v)
  16591. return nil
  16592. case label.FieldMode:
  16593. v, ok := value.(int)
  16594. if !ok {
  16595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16596. }
  16597. m.AddMode(v)
  16598. return nil
  16599. case label.FieldOrganizationID:
  16600. v, ok := value.(int64)
  16601. if !ok {
  16602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16603. }
  16604. m.AddOrganizationID(v)
  16605. return nil
  16606. }
  16607. return fmt.Errorf("unknown Label numeric field %s", name)
  16608. }
  16609. // ClearedFields returns all nullable fields that were cleared during this
  16610. // mutation.
  16611. func (m *LabelMutation) ClearedFields() []string {
  16612. var fields []string
  16613. if m.FieldCleared(label.FieldStatus) {
  16614. fields = append(fields, label.FieldStatus)
  16615. }
  16616. if m.FieldCleared(label.FieldConditions) {
  16617. fields = append(fields, label.FieldConditions)
  16618. }
  16619. if m.FieldCleared(label.FieldOrganizationID) {
  16620. fields = append(fields, label.FieldOrganizationID)
  16621. }
  16622. return fields
  16623. }
  16624. // FieldCleared returns a boolean indicating if a field with the given name was
  16625. // cleared in this mutation.
  16626. func (m *LabelMutation) FieldCleared(name string) bool {
  16627. _, ok := m.clearedFields[name]
  16628. return ok
  16629. }
  16630. // ClearField clears the value of the field with the given name. It returns an
  16631. // error if the field is not defined in the schema.
  16632. func (m *LabelMutation) ClearField(name string) error {
  16633. switch name {
  16634. case label.FieldStatus:
  16635. m.ClearStatus()
  16636. return nil
  16637. case label.FieldConditions:
  16638. m.ClearConditions()
  16639. return nil
  16640. case label.FieldOrganizationID:
  16641. m.ClearOrganizationID()
  16642. return nil
  16643. }
  16644. return fmt.Errorf("unknown Label nullable field %s", name)
  16645. }
  16646. // ResetField resets all changes in the mutation for the field with the given name.
  16647. // It returns an error if the field is not defined in the schema.
  16648. func (m *LabelMutation) ResetField(name string) error {
  16649. switch name {
  16650. case label.FieldCreatedAt:
  16651. m.ResetCreatedAt()
  16652. return nil
  16653. case label.FieldUpdatedAt:
  16654. m.ResetUpdatedAt()
  16655. return nil
  16656. case label.FieldStatus:
  16657. m.ResetStatus()
  16658. return nil
  16659. case label.FieldType:
  16660. m.ResetType()
  16661. return nil
  16662. case label.FieldName:
  16663. m.ResetName()
  16664. return nil
  16665. case label.FieldFrom:
  16666. m.ResetFrom()
  16667. return nil
  16668. case label.FieldMode:
  16669. m.ResetMode()
  16670. return nil
  16671. case label.FieldConditions:
  16672. m.ResetConditions()
  16673. return nil
  16674. case label.FieldOrganizationID:
  16675. m.ResetOrganizationID()
  16676. return nil
  16677. }
  16678. return fmt.Errorf("unknown Label field %s", name)
  16679. }
  16680. // AddedEdges returns all edge names that were set/added in this mutation.
  16681. func (m *LabelMutation) AddedEdges() []string {
  16682. edges := make([]string, 0, 1)
  16683. if m.label_relationships != nil {
  16684. edges = append(edges, label.EdgeLabelRelationships)
  16685. }
  16686. return edges
  16687. }
  16688. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16689. // name in this mutation.
  16690. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  16691. switch name {
  16692. case label.EdgeLabelRelationships:
  16693. ids := make([]ent.Value, 0, len(m.label_relationships))
  16694. for id := range m.label_relationships {
  16695. ids = append(ids, id)
  16696. }
  16697. return ids
  16698. }
  16699. return nil
  16700. }
  16701. // RemovedEdges returns all edge names that were removed in this mutation.
  16702. func (m *LabelMutation) RemovedEdges() []string {
  16703. edges := make([]string, 0, 1)
  16704. if m.removedlabel_relationships != nil {
  16705. edges = append(edges, label.EdgeLabelRelationships)
  16706. }
  16707. return edges
  16708. }
  16709. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16710. // the given name in this mutation.
  16711. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  16712. switch name {
  16713. case label.EdgeLabelRelationships:
  16714. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  16715. for id := range m.removedlabel_relationships {
  16716. ids = append(ids, id)
  16717. }
  16718. return ids
  16719. }
  16720. return nil
  16721. }
  16722. // ClearedEdges returns all edge names that were cleared in this mutation.
  16723. func (m *LabelMutation) ClearedEdges() []string {
  16724. edges := make([]string, 0, 1)
  16725. if m.clearedlabel_relationships {
  16726. edges = append(edges, label.EdgeLabelRelationships)
  16727. }
  16728. return edges
  16729. }
  16730. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16731. // was cleared in this mutation.
  16732. func (m *LabelMutation) EdgeCleared(name string) bool {
  16733. switch name {
  16734. case label.EdgeLabelRelationships:
  16735. return m.clearedlabel_relationships
  16736. }
  16737. return false
  16738. }
  16739. // ClearEdge clears the value of the edge with the given name. It returns an error
  16740. // if that edge is not defined in the schema.
  16741. func (m *LabelMutation) ClearEdge(name string) error {
  16742. switch name {
  16743. }
  16744. return fmt.Errorf("unknown Label unique edge %s", name)
  16745. }
  16746. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16747. // It returns an error if the edge is not defined in the schema.
  16748. func (m *LabelMutation) ResetEdge(name string) error {
  16749. switch name {
  16750. case label.EdgeLabelRelationships:
  16751. m.ResetLabelRelationships()
  16752. return nil
  16753. }
  16754. return fmt.Errorf("unknown Label edge %s", name)
  16755. }
  16756. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  16757. type LabelRelationshipMutation struct {
  16758. config
  16759. op Op
  16760. typ string
  16761. id *uint64
  16762. created_at *time.Time
  16763. updated_at *time.Time
  16764. status *uint8
  16765. addstatus *int8
  16766. organization_id *uint64
  16767. addorganization_id *int64
  16768. clearedFields map[string]struct{}
  16769. contacts *uint64
  16770. clearedcontacts bool
  16771. labels *uint64
  16772. clearedlabels bool
  16773. done bool
  16774. oldValue func(context.Context) (*LabelRelationship, error)
  16775. predicates []predicate.LabelRelationship
  16776. }
  16777. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  16778. // labelrelationshipOption allows management of the mutation configuration using functional options.
  16779. type labelrelationshipOption func(*LabelRelationshipMutation)
  16780. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  16781. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  16782. m := &LabelRelationshipMutation{
  16783. config: c,
  16784. op: op,
  16785. typ: TypeLabelRelationship,
  16786. clearedFields: make(map[string]struct{}),
  16787. }
  16788. for _, opt := range opts {
  16789. opt(m)
  16790. }
  16791. return m
  16792. }
  16793. // withLabelRelationshipID sets the ID field of the mutation.
  16794. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  16795. return func(m *LabelRelationshipMutation) {
  16796. var (
  16797. err error
  16798. once sync.Once
  16799. value *LabelRelationship
  16800. )
  16801. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  16802. once.Do(func() {
  16803. if m.done {
  16804. err = errors.New("querying old values post mutation is not allowed")
  16805. } else {
  16806. value, err = m.Client().LabelRelationship.Get(ctx, id)
  16807. }
  16808. })
  16809. return value, err
  16810. }
  16811. m.id = &id
  16812. }
  16813. }
  16814. // withLabelRelationship sets the old LabelRelationship of the mutation.
  16815. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  16816. return func(m *LabelRelationshipMutation) {
  16817. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  16818. return node, nil
  16819. }
  16820. m.id = &node.ID
  16821. }
  16822. }
  16823. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16824. // executed in a transaction (ent.Tx), a transactional client is returned.
  16825. func (m LabelRelationshipMutation) Client() *Client {
  16826. client := &Client{config: m.config}
  16827. client.init()
  16828. return client
  16829. }
  16830. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16831. // it returns an error otherwise.
  16832. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  16833. if _, ok := m.driver.(*txDriver); !ok {
  16834. return nil, errors.New("ent: mutation is not running in a transaction")
  16835. }
  16836. tx := &Tx{config: m.config}
  16837. tx.init()
  16838. return tx, nil
  16839. }
  16840. // SetID sets the value of the id field. Note that this
  16841. // operation is only accepted on creation of LabelRelationship entities.
  16842. func (m *LabelRelationshipMutation) SetID(id uint64) {
  16843. m.id = &id
  16844. }
  16845. // ID returns the ID value in the mutation. Note that the ID is only available
  16846. // if it was provided to the builder or after it was returned from the database.
  16847. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  16848. if m.id == nil {
  16849. return
  16850. }
  16851. return *m.id, true
  16852. }
  16853. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16854. // That means, if the mutation is applied within a transaction with an isolation level such
  16855. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16856. // or updated by the mutation.
  16857. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  16858. switch {
  16859. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16860. id, exists := m.ID()
  16861. if exists {
  16862. return []uint64{id}, nil
  16863. }
  16864. fallthrough
  16865. case m.op.Is(OpUpdate | OpDelete):
  16866. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  16867. default:
  16868. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16869. }
  16870. }
  16871. // SetCreatedAt sets the "created_at" field.
  16872. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  16873. m.created_at = &t
  16874. }
  16875. // CreatedAt returns the value of the "created_at" field in the mutation.
  16876. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  16877. v := m.created_at
  16878. if v == nil {
  16879. return
  16880. }
  16881. return *v, true
  16882. }
  16883. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  16884. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16886. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16887. if !m.op.Is(OpUpdateOne) {
  16888. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16889. }
  16890. if m.id == nil || m.oldValue == nil {
  16891. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16892. }
  16893. oldValue, err := m.oldValue(ctx)
  16894. if err != nil {
  16895. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16896. }
  16897. return oldValue.CreatedAt, nil
  16898. }
  16899. // ResetCreatedAt resets all changes to the "created_at" field.
  16900. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  16901. m.created_at = nil
  16902. }
  16903. // SetUpdatedAt sets the "updated_at" field.
  16904. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  16905. m.updated_at = &t
  16906. }
  16907. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16908. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  16909. v := m.updated_at
  16910. if v == nil {
  16911. return
  16912. }
  16913. return *v, true
  16914. }
  16915. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  16916. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16918. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16919. if !m.op.Is(OpUpdateOne) {
  16920. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16921. }
  16922. if m.id == nil || m.oldValue == nil {
  16923. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16924. }
  16925. oldValue, err := m.oldValue(ctx)
  16926. if err != nil {
  16927. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16928. }
  16929. return oldValue.UpdatedAt, nil
  16930. }
  16931. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16932. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  16933. m.updated_at = nil
  16934. }
  16935. // SetStatus sets the "status" field.
  16936. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  16937. m.status = &u
  16938. m.addstatus = nil
  16939. }
  16940. // Status returns the value of the "status" field in the mutation.
  16941. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  16942. v := m.status
  16943. if v == nil {
  16944. return
  16945. }
  16946. return *v, true
  16947. }
  16948. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  16949. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16951. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16952. if !m.op.Is(OpUpdateOne) {
  16953. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16954. }
  16955. if m.id == nil || m.oldValue == nil {
  16956. return v, errors.New("OldStatus requires an ID field in the mutation")
  16957. }
  16958. oldValue, err := m.oldValue(ctx)
  16959. if err != nil {
  16960. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16961. }
  16962. return oldValue.Status, nil
  16963. }
  16964. // AddStatus adds u to the "status" field.
  16965. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  16966. if m.addstatus != nil {
  16967. *m.addstatus += u
  16968. } else {
  16969. m.addstatus = &u
  16970. }
  16971. }
  16972. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16973. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  16974. v := m.addstatus
  16975. if v == nil {
  16976. return
  16977. }
  16978. return *v, true
  16979. }
  16980. // ClearStatus clears the value of the "status" field.
  16981. func (m *LabelRelationshipMutation) ClearStatus() {
  16982. m.status = nil
  16983. m.addstatus = nil
  16984. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  16985. }
  16986. // StatusCleared returns if the "status" field was cleared in this mutation.
  16987. func (m *LabelRelationshipMutation) StatusCleared() bool {
  16988. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  16989. return ok
  16990. }
  16991. // ResetStatus resets all changes to the "status" field.
  16992. func (m *LabelRelationshipMutation) ResetStatus() {
  16993. m.status = nil
  16994. m.addstatus = nil
  16995. delete(m.clearedFields, labelrelationship.FieldStatus)
  16996. }
  16997. // SetLabelID sets the "label_id" field.
  16998. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  16999. m.labels = &u
  17000. }
  17001. // LabelID returns the value of the "label_id" field in the mutation.
  17002. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  17003. v := m.labels
  17004. if v == nil {
  17005. return
  17006. }
  17007. return *v, true
  17008. }
  17009. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  17010. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17012. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  17013. if !m.op.Is(OpUpdateOne) {
  17014. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  17015. }
  17016. if m.id == nil || m.oldValue == nil {
  17017. return v, errors.New("OldLabelID requires an ID field in the mutation")
  17018. }
  17019. oldValue, err := m.oldValue(ctx)
  17020. if err != nil {
  17021. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  17022. }
  17023. return oldValue.LabelID, nil
  17024. }
  17025. // ResetLabelID resets all changes to the "label_id" field.
  17026. func (m *LabelRelationshipMutation) ResetLabelID() {
  17027. m.labels = nil
  17028. }
  17029. // SetContactID sets the "contact_id" field.
  17030. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  17031. m.contacts = &u
  17032. }
  17033. // ContactID returns the value of the "contact_id" field in the mutation.
  17034. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  17035. v := m.contacts
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  17042. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17044. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17045. if !m.op.Is(OpUpdateOne) {
  17046. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17047. }
  17048. if m.id == nil || m.oldValue == nil {
  17049. return v, errors.New("OldContactID requires an ID field in the mutation")
  17050. }
  17051. oldValue, err := m.oldValue(ctx)
  17052. if err != nil {
  17053. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17054. }
  17055. return oldValue.ContactID, nil
  17056. }
  17057. // ResetContactID resets all changes to the "contact_id" field.
  17058. func (m *LabelRelationshipMutation) ResetContactID() {
  17059. m.contacts = nil
  17060. }
  17061. // SetOrganizationID sets the "organization_id" field.
  17062. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  17063. m.organization_id = &u
  17064. m.addorganization_id = nil
  17065. }
  17066. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17067. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  17068. v := m.organization_id
  17069. if v == nil {
  17070. return
  17071. }
  17072. return *v, true
  17073. }
  17074. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  17075. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17077. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17078. if !m.op.Is(OpUpdateOne) {
  17079. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17080. }
  17081. if m.id == nil || m.oldValue == nil {
  17082. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17083. }
  17084. oldValue, err := m.oldValue(ctx)
  17085. if err != nil {
  17086. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17087. }
  17088. return oldValue.OrganizationID, nil
  17089. }
  17090. // AddOrganizationID adds u to the "organization_id" field.
  17091. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17092. if m.addorganization_id != nil {
  17093. *m.addorganization_id += u
  17094. } else {
  17095. m.addorganization_id = &u
  17096. }
  17097. }
  17098. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17099. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17100. v := m.addorganization_id
  17101. if v == nil {
  17102. return
  17103. }
  17104. return *v, true
  17105. }
  17106. // ClearOrganizationID clears the value of the "organization_id" field.
  17107. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17108. m.organization_id = nil
  17109. m.addorganization_id = nil
  17110. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17111. }
  17112. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17113. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17114. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17115. return ok
  17116. }
  17117. // ResetOrganizationID resets all changes to the "organization_id" field.
  17118. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17119. m.organization_id = nil
  17120. m.addorganization_id = nil
  17121. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17122. }
  17123. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17124. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17125. m.contacts = &id
  17126. }
  17127. // ClearContacts clears the "contacts" edge to the Contact entity.
  17128. func (m *LabelRelationshipMutation) ClearContacts() {
  17129. m.clearedcontacts = true
  17130. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17131. }
  17132. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17133. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17134. return m.clearedcontacts
  17135. }
  17136. // ContactsID returns the "contacts" edge ID in the mutation.
  17137. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17138. if m.contacts != nil {
  17139. return *m.contacts, true
  17140. }
  17141. return
  17142. }
  17143. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17144. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17145. // ContactsID instead. It exists only for internal usage by the builders.
  17146. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17147. if id := m.contacts; id != nil {
  17148. ids = append(ids, *id)
  17149. }
  17150. return
  17151. }
  17152. // ResetContacts resets all changes to the "contacts" edge.
  17153. func (m *LabelRelationshipMutation) ResetContacts() {
  17154. m.contacts = nil
  17155. m.clearedcontacts = false
  17156. }
  17157. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17158. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17159. m.labels = &id
  17160. }
  17161. // ClearLabels clears the "labels" edge to the Label entity.
  17162. func (m *LabelRelationshipMutation) ClearLabels() {
  17163. m.clearedlabels = true
  17164. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17165. }
  17166. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17167. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17168. return m.clearedlabels
  17169. }
  17170. // LabelsID returns the "labels" edge ID in the mutation.
  17171. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17172. if m.labels != nil {
  17173. return *m.labels, true
  17174. }
  17175. return
  17176. }
  17177. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17178. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17179. // LabelsID instead. It exists only for internal usage by the builders.
  17180. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17181. if id := m.labels; id != nil {
  17182. ids = append(ids, *id)
  17183. }
  17184. return
  17185. }
  17186. // ResetLabels resets all changes to the "labels" edge.
  17187. func (m *LabelRelationshipMutation) ResetLabels() {
  17188. m.labels = nil
  17189. m.clearedlabels = false
  17190. }
  17191. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17192. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17193. m.predicates = append(m.predicates, ps...)
  17194. }
  17195. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17196. // users can use type-assertion to append predicates that do not depend on any generated package.
  17197. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17198. p := make([]predicate.LabelRelationship, len(ps))
  17199. for i := range ps {
  17200. p[i] = ps[i]
  17201. }
  17202. m.Where(p...)
  17203. }
  17204. // Op returns the operation name.
  17205. func (m *LabelRelationshipMutation) Op() Op {
  17206. return m.op
  17207. }
  17208. // SetOp allows setting the mutation operation.
  17209. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17210. m.op = op
  17211. }
  17212. // Type returns the node type of this mutation (LabelRelationship).
  17213. func (m *LabelRelationshipMutation) Type() string {
  17214. return m.typ
  17215. }
  17216. // Fields returns all fields that were changed during this mutation. Note that in
  17217. // order to get all numeric fields that were incremented/decremented, call
  17218. // AddedFields().
  17219. func (m *LabelRelationshipMutation) Fields() []string {
  17220. fields := make([]string, 0, 6)
  17221. if m.created_at != nil {
  17222. fields = append(fields, labelrelationship.FieldCreatedAt)
  17223. }
  17224. if m.updated_at != nil {
  17225. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17226. }
  17227. if m.status != nil {
  17228. fields = append(fields, labelrelationship.FieldStatus)
  17229. }
  17230. if m.labels != nil {
  17231. fields = append(fields, labelrelationship.FieldLabelID)
  17232. }
  17233. if m.contacts != nil {
  17234. fields = append(fields, labelrelationship.FieldContactID)
  17235. }
  17236. if m.organization_id != nil {
  17237. fields = append(fields, labelrelationship.FieldOrganizationID)
  17238. }
  17239. return fields
  17240. }
  17241. // Field returns the value of a field with the given name. The second boolean
  17242. // return value indicates that this field was not set, or was not defined in the
  17243. // schema.
  17244. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17245. switch name {
  17246. case labelrelationship.FieldCreatedAt:
  17247. return m.CreatedAt()
  17248. case labelrelationship.FieldUpdatedAt:
  17249. return m.UpdatedAt()
  17250. case labelrelationship.FieldStatus:
  17251. return m.Status()
  17252. case labelrelationship.FieldLabelID:
  17253. return m.LabelID()
  17254. case labelrelationship.FieldContactID:
  17255. return m.ContactID()
  17256. case labelrelationship.FieldOrganizationID:
  17257. return m.OrganizationID()
  17258. }
  17259. return nil, false
  17260. }
  17261. // OldField returns the old value of the field from the database. An error is
  17262. // returned if the mutation operation is not UpdateOne, or the query to the
  17263. // database failed.
  17264. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17265. switch name {
  17266. case labelrelationship.FieldCreatedAt:
  17267. return m.OldCreatedAt(ctx)
  17268. case labelrelationship.FieldUpdatedAt:
  17269. return m.OldUpdatedAt(ctx)
  17270. case labelrelationship.FieldStatus:
  17271. return m.OldStatus(ctx)
  17272. case labelrelationship.FieldLabelID:
  17273. return m.OldLabelID(ctx)
  17274. case labelrelationship.FieldContactID:
  17275. return m.OldContactID(ctx)
  17276. case labelrelationship.FieldOrganizationID:
  17277. return m.OldOrganizationID(ctx)
  17278. }
  17279. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17280. }
  17281. // SetField sets the value of a field with the given name. It returns an error if
  17282. // the field is not defined in the schema, or if the type mismatched the field
  17283. // type.
  17284. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17285. switch name {
  17286. case labelrelationship.FieldCreatedAt:
  17287. v, ok := value.(time.Time)
  17288. if !ok {
  17289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17290. }
  17291. m.SetCreatedAt(v)
  17292. return nil
  17293. case labelrelationship.FieldUpdatedAt:
  17294. v, ok := value.(time.Time)
  17295. if !ok {
  17296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17297. }
  17298. m.SetUpdatedAt(v)
  17299. return nil
  17300. case labelrelationship.FieldStatus:
  17301. v, ok := value.(uint8)
  17302. if !ok {
  17303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17304. }
  17305. m.SetStatus(v)
  17306. return nil
  17307. case labelrelationship.FieldLabelID:
  17308. v, ok := value.(uint64)
  17309. if !ok {
  17310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17311. }
  17312. m.SetLabelID(v)
  17313. return nil
  17314. case labelrelationship.FieldContactID:
  17315. v, ok := value.(uint64)
  17316. if !ok {
  17317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17318. }
  17319. m.SetContactID(v)
  17320. return nil
  17321. case labelrelationship.FieldOrganizationID:
  17322. v, ok := value.(uint64)
  17323. if !ok {
  17324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17325. }
  17326. m.SetOrganizationID(v)
  17327. return nil
  17328. }
  17329. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17330. }
  17331. // AddedFields returns all numeric fields that were incremented/decremented during
  17332. // this mutation.
  17333. func (m *LabelRelationshipMutation) AddedFields() []string {
  17334. var fields []string
  17335. if m.addstatus != nil {
  17336. fields = append(fields, labelrelationship.FieldStatus)
  17337. }
  17338. if m.addorganization_id != nil {
  17339. fields = append(fields, labelrelationship.FieldOrganizationID)
  17340. }
  17341. return fields
  17342. }
  17343. // AddedField returns the numeric value that was incremented/decremented on a field
  17344. // with the given name. The second boolean return value indicates that this field
  17345. // was not set, or was not defined in the schema.
  17346. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17347. switch name {
  17348. case labelrelationship.FieldStatus:
  17349. return m.AddedStatus()
  17350. case labelrelationship.FieldOrganizationID:
  17351. return m.AddedOrganizationID()
  17352. }
  17353. return nil, false
  17354. }
  17355. // AddField adds the value to the field with the given name. It returns an error if
  17356. // the field is not defined in the schema, or if the type mismatched the field
  17357. // type.
  17358. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17359. switch name {
  17360. case labelrelationship.FieldStatus:
  17361. v, ok := value.(int8)
  17362. if !ok {
  17363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17364. }
  17365. m.AddStatus(v)
  17366. return nil
  17367. case labelrelationship.FieldOrganizationID:
  17368. v, ok := value.(int64)
  17369. if !ok {
  17370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17371. }
  17372. m.AddOrganizationID(v)
  17373. return nil
  17374. }
  17375. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17376. }
  17377. // ClearedFields returns all nullable fields that were cleared during this
  17378. // mutation.
  17379. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17380. var fields []string
  17381. if m.FieldCleared(labelrelationship.FieldStatus) {
  17382. fields = append(fields, labelrelationship.FieldStatus)
  17383. }
  17384. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17385. fields = append(fields, labelrelationship.FieldOrganizationID)
  17386. }
  17387. return fields
  17388. }
  17389. // FieldCleared returns a boolean indicating if a field with the given name was
  17390. // cleared in this mutation.
  17391. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17392. _, ok := m.clearedFields[name]
  17393. return ok
  17394. }
  17395. // ClearField clears the value of the field with the given name. It returns an
  17396. // error if the field is not defined in the schema.
  17397. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17398. switch name {
  17399. case labelrelationship.FieldStatus:
  17400. m.ClearStatus()
  17401. return nil
  17402. case labelrelationship.FieldOrganizationID:
  17403. m.ClearOrganizationID()
  17404. return nil
  17405. }
  17406. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17407. }
  17408. // ResetField resets all changes in the mutation for the field with the given name.
  17409. // It returns an error if the field is not defined in the schema.
  17410. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17411. switch name {
  17412. case labelrelationship.FieldCreatedAt:
  17413. m.ResetCreatedAt()
  17414. return nil
  17415. case labelrelationship.FieldUpdatedAt:
  17416. m.ResetUpdatedAt()
  17417. return nil
  17418. case labelrelationship.FieldStatus:
  17419. m.ResetStatus()
  17420. return nil
  17421. case labelrelationship.FieldLabelID:
  17422. m.ResetLabelID()
  17423. return nil
  17424. case labelrelationship.FieldContactID:
  17425. m.ResetContactID()
  17426. return nil
  17427. case labelrelationship.FieldOrganizationID:
  17428. m.ResetOrganizationID()
  17429. return nil
  17430. }
  17431. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17432. }
  17433. // AddedEdges returns all edge names that were set/added in this mutation.
  17434. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17435. edges := make([]string, 0, 2)
  17436. if m.contacts != nil {
  17437. edges = append(edges, labelrelationship.EdgeContacts)
  17438. }
  17439. if m.labels != nil {
  17440. edges = append(edges, labelrelationship.EdgeLabels)
  17441. }
  17442. return edges
  17443. }
  17444. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17445. // name in this mutation.
  17446. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17447. switch name {
  17448. case labelrelationship.EdgeContacts:
  17449. if id := m.contacts; id != nil {
  17450. return []ent.Value{*id}
  17451. }
  17452. case labelrelationship.EdgeLabels:
  17453. if id := m.labels; id != nil {
  17454. return []ent.Value{*id}
  17455. }
  17456. }
  17457. return nil
  17458. }
  17459. // RemovedEdges returns all edge names that were removed in this mutation.
  17460. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17461. edges := make([]string, 0, 2)
  17462. return edges
  17463. }
  17464. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17465. // the given name in this mutation.
  17466. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17467. return nil
  17468. }
  17469. // ClearedEdges returns all edge names that were cleared in this mutation.
  17470. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17471. edges := make([]string, 0, 2)
  17472. if m.clearedcontacts {
  17473. edges = append(edges, labelrelationship.EdgeContacts)
  17474. }
  17475. if m.clearedlabels {
  17476. edges = append(edges, labelrelationship.EdgeLabels)
  17477. }
  17478. return edges
  17479. }
  17480. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17481. // was cleared in this mutation.
  17482. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17483. switch name {
  17484. case labelrelationship.EdgeContacts:
  17485. return m.clearedcontacts
  17486. case labelrelationship.EdgeLabels:
  17487. return m.clearedlabels
  17488. }
  17489. return false
  17490. }
  17491. // ClearEdge clears the value of the edge with the given name. It returns an error
  17492. // if that edge is not defined in the schema.
  17493. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17494. switch name {
  17495. case labelrelationship.EdgeContacts:
  17496. m.ClearContacts()
  17497. return nil
  17498. case labelrelationship.EdgeLabels:
  17499. m.ClearLabels()
  17500. return nil
  17501. }
  17502. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17503. }
  17504. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17505. // It returns an error if the edge is not defined in the schema.
  17506. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17507. switch name {
  17508. case labelrelationship.EdgeContacts:
  17509. m.ResetContacts()
  17510. return nil
  17511. case labelrelationship.EdgeLabels:
  17512. m.ResetLabels()
  17513. return nil
  17514. }
  17515. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17516. }
  17517. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17518. type LabelTaggingMutation struct {
  17519. config
  17520. op Op
  17521. typ string
  17522. id *uint64
  17523. created_at *time.Time
  17524. updated_at *time.Time
  17525. status *uint8
  17526. addstatus *int8
  17527. deleted_at *time.Time
  17528. organization_id *uint64
  17529. addorganization_id *int64
  17530. _type *int
  17531. add_type *int
  17532. conditions *string
  17533. action_label_add *[]uint64
  17534. appendaction_label_add []uint64
  17535. action_label_del *[]uint64
  17536. appendaction_label_del []uint64
  17537. clearedFields map[string]struct{}
  17538. done bool
  17539. oldValue func(context.Context) (*LabelTagging, error)
  17540. predicates []predicate.LabelTagging
  17541. }
  17542. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17543. // labeltaggingOption allows management of the mutation configuration using functional options.
  17544. type labeltaggingOption func(*LabelTaggingMutation)
  17545. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17546. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17547. m := &LabelTaggingMutation{
  17548. config: c,
  17549. op: op,
  17550. typ: TypeLabelTagging,
  17551. clearedFields: make(map[string]struct{}),
  17552. }
  17553. for _, opt := range opts {
  17554. opt(m)
  17555. }
  17556. return m
  17557. }
  17558. // withLabelTaggingID sets the ID field of the mutation.
  17559. func withLabelTaggingID(id uint64) labeltaggingOption {
  17560. return func(m *LabelTaggingMutation) {
  17561. var (
  17562. err error
  17563. once sync.Once
  17564. value *LabelTagging
  17565. )
  17566. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17567. once.Do(func() {
  17568. if m.done {
  17569. err = errors.New("querying old values post mutation is not allowed")
  17570. } else {
  17571. value, err = m.Client().LabelTagging.Get(ctx, id)
  17572. }
  17573. })
  17574. return value, err
  17575. }
  17576. m.id = &id
  17577. }
  17578. }
  17579. // withLabelTagging sets the old LabelTagging of the mutation.
  17580. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17581. return func(m *LabelTaggingMutation) {
  17582. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17583. return node, nil
  17584. }
  17585. m.id = &node.ID
  17586. }
  17587. }
  17588. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17589. // executed in a transaction (ent.Tx), a transactional client is returned.
  17590. func (m LabelTaggingMutation) Client() *Client {
  17591. client := &Client{config: m.config}
  17592. client.init()
  17593. return client
  17594. }
  17595. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17596. // it returns an error otherwise.
  17597. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17598. if _, ok := m.driver.(*txDriver); !ok {
  17599. return nil, errors.New("ent: mutation is not running in a transaction")
  17600. }
  17601. tx := &Tx{config: m.config}
  17602. tx.init()
  17603. return tx, nil
  17604. }
  17605. // SetID sets the value of the id field. Note that this
  17606. // operation is only accepted on creation of LabelTagging entities.
  17607. func (m *LabelTaggingMutation) SetID(id uint64) {
  17608. m.id = &id
  17609. }
  17610. // ID returns the ID value in the mutation. Note that the ID is only available
  17611. // if it was provided to the builder or after it was returned from the database.
  17612. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17613. if m.id == nil {
  17614. return
  17615. }
  17616. return *m.id, true
  17617. }
  17618. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17619. // That means, if the mutation is applied within a transaction with an isolation level such
  17620. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17621. // or updated by the mutation.
  17622. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17623. switch {
  17624. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17625. id, exists := m.ID()
  17626. if exists {
  17627. return []uint64{id}, nil
  17628. }
  17629. fallthrough
  17630. case m.op.Is(OpUpdate | OpDelete):
  17631. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17632. default:
  17633. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17634. }
  17635. }
  17636. // SetCreatedAt sets the "created_at" field.
  17637. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  17638. m.created_at = &t
  17639. }
  17640. // CreatedAt returns the value of the "created_at" field in the mutation.
  17641. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  17642. v := m.created_at
  17643. if v == nil {
  17644. return
  17645. }
  17646. return *v, true
  17647. }
  17648. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  17649. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17651. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17652. if !m.op.Is(OpUpdateOne) {
  17653. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17654. }
  17655. if m.id == nil || m.oldValue == nil {
  17656. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17657. }
  17658. oldValue, err := m.oldValue(ctx)
  17659. if err != nil {
  17660. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17661. }
  17662. return oldValue.CreatedAt, nil
  17663. }
  17664. // ResetCreatedAt resets all changes to the "created_at" field.
  17665. func (m *LabelTaggingMutation) ResetCreatedAt() {
  17666. m.created_at = nil
  17667. }
  17668. // SetUpdatedAt sets the "updated_at" field.
  17669. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  17670. m.updated_at = &t
  17671. }
  17672. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17673. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  17674. v := m.updated_at
  17675. if v == nil {
  17676. return
  17677. }
  17678. return *v, true
  17679. }
  17680. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  17681. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17683. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17684. if !m.op.Is(OpUpdateOne) {
  17685. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17686. }
  17687. if m.id == nil || m.oldValue == nil {
  17688. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17689. }
  17690. oldValue, err := m.oldValue(ctx)
  17691. if err != nil {
  17692. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17693. }
  17694. return oldValue.UpdatedAt, nil
  17695. }
  17696. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17697. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  17698. m.updated_at = nil
  17699. }
  17700. // SetStatus sets the "status" field.
  17701. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  17702. m.status = &u
  17703. m.addstatus = nil
  17704. }
  17705. // Status returns the value of the "status" field in the mutation.
  17706. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  17707. v := m.status
  17708. if v == nil {
  17709. return
  17710. }
  17711. return *v, true
  17712. }
  17713. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  17714. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17716. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17717. if !m.op.Is(OpUpdateOne) {
  17718. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17719. }
  17720. if m.id == nil || m.oldValue == nil {
  17721. return v, errors.New("OldStatus requires an ID field in the mutation")
  17722. }
  17723. oldValue, err := m.oldValue(ctx)
  17724. if err != nil {
  17725. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17726. }
  17727. return oldValue.Status, nil
  17728. }
  17729. // AddStatus adds u to the "status" field.
  17730. func (m *LabelTaggingMutation) AddStatus(u int8) {
  17731. if m.addstatus != nil {
  17732. *m.addstatus += u
  17733. } else {
  17734. m.addstatus = &u
  17735. }
  17736. }
  17737. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17738. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  17739. v := m.addstatus
  17740. if v == nil {
  17741. return
  17742. }
  17743. return *v, true
  17744. }
  17745. // ClearStatus clears the value of the "status" field.
  17746. func (m *LabelTaggingMutation) ClearStatus() {
  17747. m.status = nil
  17748. m.addstatus = nil
  17749. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  17750. }
  17751. // StatusCleared returns if the "status" field was cleared in this mutation.
  17752. func (m *LabelTaggingMutation) StatusCleared() bool {
  17753. _, ok := m.clearedFields[labeltagging.FieldStatus]
  17754. return ok
  17755. }
  17756. // ResetStatus resets all changes to the "status" field.
  17757. func (m *LabelTaggingMutation) ResetStatus() {
  17758. m.status = nil
  17759. m.addstatus = nil
  17760. delete(m.clearedFields, labeltagging.FieldStatus)
  17761. }
  17762. // SetDeletedAt sets the "deleted_at" field.
  17763. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  17764. m.deleted_at = &t
  17765. }
  17766. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17767. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  17768. v := m.deleted_at
  17769. if v == nil {
  17770. return
  17771. }
  17772. return *v, true
  17773. }
  17774. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  17775. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17777. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17778. if !m.op.Is(OpUpdateOne) {
  17779. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17780. }
  17781. if m.id == nil || m.oldValue == nil {
  17782. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17783. }
  17784. oldValue, err := m.oldValue(ctx)
  17785. if err != nil {
  17786. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17787. }
  17788. return oldValue.DeletedAt, nil
  17789. }
  17790. // ClearDeletedAt clears the value of the "deleted_at" field.
  17791. func (m *LabelTaggingMutation) ClearDeletedAt() {
  17792. m.deleted_at = nil
  17793. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  17794. }
  17795. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17796. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  17797. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  17798. return ok
  17799. }
  17800. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17801. func (m *LabelTaggingMutation) ResetDeletedAt() {
  17802. m.deleted_at = nil
  17803. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  17804. }
  17805. // SetOrganizationID sets the "organization_id" field.
  17806. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  17807. m.organization_id = &u
  17808. m.addorganization_id = nil
  17809. }
  17810. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17811. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  17812. v := m.organization_id
  17813. if v == nil {
  17814. return
  17815. }
  17816. return *v, true
  17817. }
  17818. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  17819. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17821. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17822. if !m.op.Is(OpUpdateOne) {
  17823. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17824. }
  17825. if m.id == nil || m.oldValue == nil {
  17826. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17827. }
  17828. oldValue, err := m.oldValue(ctx)
  17829. if err != nil {
  17830. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17831. }
  17832. return oldValue.OrganizationID, nil
  17833. }
  17834. // AddOrganizationID adds u to the "organization_id" field.
  17835. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  17836. if m.addorganization_id != nil {
  17837. *m.addorganization_id += u
  17838. } else {
  17839. m.addorganization_id = &u
  17840. }
  17841. }
  17842. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17843. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  17844. v := m.addorganization_id
  17845. if v == nil {
  17846. return
  17847. }
  17848. return *v, true
  17849. }
  17850. // ResetOrganizationID resets all changes to the "organization_id" field.
  17851. func (m *LabelTaggingMutation) ResetOrganizationID() {
  17852. m.organization_id = nil
  17853. m.addorganization_id = nil
  17854. }
  17855. // SetType sets the "type" field.
  17856. func (m *LabelTaggingMutation) SetType(i int) {
  17857. m._type = &i
  17858. m.add_type = nil
  17859. }
  17860. // GetType returns the value of the "type" field in the mutation.
  17861. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  17862. v := m._type
  17863. if v == nil {
  17864. return
  17865. }
  17866. return *v, true
  17867. }
  17868. // OldType returns the old "type" field's value of the LabelTagging entity.
  17869. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17871. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  17872. if !m.op.Is(OpUpdateOne) {
  17873. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17874. }
  17875. if m.id == nil || m.oldValue == nil {
  17876. return v, errors.New("OldType requires an ID field in the mutation")
  17877. }
  17878. oldValue, err := m.oldValue(ctx)
  17879. if err != nil {
  17880. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17881. }
  17882. return oldValue.Type, nil
  17883. }
  17884. // AddType adds i to the "type" field.
  17885. func (m *LabelTaggingMutation) AddType(i int) {
  17886. if m.add_type != nil {
  17887. *m.add_type += i
  17888. } else {
  17889. m.add_type = &i
  17890. }
  17891. }
  17892. // AddedType returns the value that was added to the "type" field in this mutation.
  17893. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  17894. v := m.add_type
  17895. if v == nil {
  17896. return
  17897. }
  17898. return *v, true
  17899. }
  17900. // ResetType resets all changes to the "type" field.
  17901. func (m *LabelTaggingMutation) ResetType() {
  17902. m._type = nil
  17903. m.add_type = nil
  17904. }
  17905. // SetConditions sets the "conditions" field.
  17906. func (m *LabelTaggingMutation) SetConditions(s string) {
  17907. m.conditions = &s
  17908. }
  17909. // Conditions returns the value of the "conditions" field in the mutation.
  17910. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  17911. v := m.conditions
  17912. if v == nil {
  17913. return
  17914. }
  17915. return *v, true
  17916. }
  17917. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  17918. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17920. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  17921. if !m.op.Is(OpUpdateOne) {
  17922. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17923. }
  17924. if m.id == nil || m.oldValue == nil {
  17925. return v, errors.New("OldConditions requires an ID field in the mutation")
  17926. }
  17927. oldValue, err := m.oldValue(ctx)
  17928. if err != nil {
  17929. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17930. }
  17931. return oldValue.Conditions, nil
  17932. }
  17933. // ResetConditions resets all changes to the "conditions" field.
  17934. func (m *LabelTaggingMutation) ResetConditions() {
  17935. m.conditions = nil
  17936. }
  17937. // SetActionLabelAdd sets the "action_label_add" field.
  17938. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  17939. m.action_label_add = &u
  17940. m.appendaction_label_add = nil
  17941. }
  17942. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17943. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17944. v := m.action_label_add
  17945. if v == nil {
  17946. return
  17947. }
  17948. return *v, true
  17949. }
  17950. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  17951. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17953. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17954. if !m.op.Is(OpUpdateOne) {
  17955. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17956. }
  17957. if m.id == nil || m.oldValue == nil {
  17958. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17959. }
  17960. oldValue, err := m.oldValue(ctx)
  17961. if err != nil {
  17962. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17963. }
  17964. return oldValue.ActionLabelAdd, nil
  17965. }
  17966. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17967. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  17968. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17969. }
  17970. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17971. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17972. if len(m.appendaction_label_add) == 0 {
  17973. return nil, false
  17974. }
  17975. return m.appendaction_label_add, true
  17976. }
  17977. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17978. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  17979. m.action_label_add = nil
  17980. m.appendaction_label_add = nil
  17981. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  17982. }
  17983. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17984. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  17985. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  17986. return ok
  17987. }
  17988. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17989. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  17990. m.action_label_add = nil
  17991. m.appendaction_label_add = nil
  17992. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  17993. }
  17994. // SetActionLabelDel sets the "action_label_del" field.
  17995. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  17996. m.action_label_del = &u
  17997. m.appendaction_label_del = nil
  17998. }
  17999. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18000. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  18001. v := m.action_label_del
  18002. if v == nil {
  18003. return
  18004. }
  18005. return *v, true
  18006. }
  18007. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  18008. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18010. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18011. if !m.op.Is(OpUpdateOne) {
  18012. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18013. }
  18014. if m.id == nil || m.oldValue == nil {
  18015. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18016. }
  18017. oldValue, err := m.oldValue(ctx)
  18018. if err != nil {
  18019. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18020. }
  18021. return oldValue.ActionLabelDel, nil
  18022. }
  18023. // AppendActionLabelDel adds u to the "action_label_del" field.
  18024. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  18025. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18026. }
  18027. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18028. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18029. if len(m.appendaction_label_del) == 0 {
  18030. return nil, false
  18031. }
  18032. return m.appendaction_label_del, true
  18033. }
  18034. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18035. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  18036. m.action_label_del = nil
  18037. m.appendaction_label_del = nil
  18038. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  18039. }
  18040. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18041. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  18042. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  18043. return ok
  18044. }
  18045. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18046. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  18047. m.action_label_del = nil
  18048. m.appendaction_label_del = nil
  18049. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  18050. }
  18051. // Where appends a list predicates to the LabelTaggingMutation builder.
  18052. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  18053. m.predicates = append(m.predicates, ps...)
  18054. }
  18055. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  18056. // users can use type-assertion to append predicates that do not depend on any generated package.
  18057. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  18058. p := make([]predicate.LabelTagging, len(ps))
  18059. for i := range ps {
  18060. p[i] = ps[i]
  18061. }
  18062. m.Where(p...)
  18063. }
  18064. // Op returns the operation name.
  18065. func (m *LabelTaggingMutation) Op() Op {
  18066. return m.op
  18067. }
  18068. // SetOp allows setting the mutation operation.
  18069. func (m *LabelTaggingMutation) SetOp(op Op) {
  18070. m.op = op
  18071. }
  18072. // Type returns the node type of this mutation (LabelTagging).
  18073. func (m *LabelTaggingMutation) Type() string {
  18074. return m.typ
  18075. }
  18076. // Fields returns all fields that were changed during this mutation. Note that in
  18077. // order to get all numeric fields that were incremented/decremented, call
  18078. // AddedFields().
  18079. func (m *LabelTaggingMutation) Fields() []string {
  18080. fields := make([]string, 0, 9)
  18081. if m.created_at != nil {
  18082. fields = append(fields, labeltagging.FieldCreatedAt)
  18083. }
  18084. if m.updated_at != nil {
  18085. fields = append(fields, labeltagging.FieldUpdatedAt)
  18086. }
  18087. if m.status != nil {
  18088. fields = append(fields, labeltagging.FieldStatus)
  18089. }
  18090. if m.deleted_at != nil {
  18091. fields = append(fields, labeltagging.FieldDeletedAt)
  18092. }
  18093. if m.organization_id != nil {
  18094. fields = append(fields, labeltagging.FieldOrganizationID)
  18095. }
  18096. if m._type != nil {
  18097. fields = append(fields, labeltagging.FieldType)
  18098. }
  18099. if m.conditions != nil {
  18100. fields = append(fields, labeltagging.FieldConditions)
  18101. }
  18102. if m.action_label_add != nil {
  18103. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18104. }
  18105. if m.action_label_del != nil {
  18106. fields = append(fields, labeltagging.FieldActionLabelDel)
  18107. }
  18108. return fields
  18109. }
  18110. // Field returns the value of a field with the given name. The second boolean
  18111. // return value indicates that this field was not set, or was not defined in the
  18112. // schema.
  18113. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18114. switch name {
  18115. case labeltagging.FieldCreatedAt:
  18116. return m.CreatedAt()
  18117. case labeltagging.FieldUpdatedAt:
  18118. return m.UpdatedAt()
  18119. case labeltagging.FieldStatus:
  18120. return m.Status()
  18121. case labeltagging.FieldDeletedAt:
  18122. return m.DeletedAt()
  18123. case labeltagging.FieldOrganizationID:
  18124. return m.OrganizationID()
  18125. case labeltagging.FieldType:
  18126. return m.GetType()
  18127. case labeltagging.FieldConditions:
  18128. return m.Conditions()
  18129. case labeltagging.FieldActionLabelAdd:
  18130. return m.ActionLabelAdd()
  18131. case labeltagging.FieldActionLabelDel:
  18132. return m.ActionLabelDel()
  18133. }
  18134. return nil, false
  18135. }
  18136. // OldField returns the old value of the field from the database. An error is
  18137. // returned if the mutation operation is not UpdateOne, or the query to the
  18138. // database failed.
  18139. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18140. switch name {
  18141. case labeltagging.FieldCreatedAt:
  18142. return m.OldCreatedAt(ctx)
  18143. case labeltagging.FieldUpdatedAt:
  18144. return m.OldUpdatedAt(ctx)
  18145. case labeltagging.FieldStatus:
  18146. return m.OldStatus(ctx)
  18147. case labeltagging.FieldDeletedAt:
  18148. return m.OldDeletedAt(ctx)
  18149. case labeltagging.FieldOrganizationID:
  18150. return m.OldOrganizationID(ctx)
  18151. case labeltagging.FieldType:
  18152. return m.OldType(ctx)
  18153. case labeltagging.FieldConditions:
  18154. return m.OldConditions(ctx)
  18155. case labeltagging.FieldActionLabelAdd:
  18156. return m.OldActionLabelAdd(ctx)
  18157. case labeltagging.FieldActionLabelDel:
  18158. return m.OldActionLabelDel(ctx)
  18159. }
  18160. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18161. }
  18162. // SetField sets the value of a field with the given name. It returns an error if
  18163. // the field is not defined in the schema, or if the type mismatched the field
  18164. // type.
  18165. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18166. switch name {
  18167. case labeltagging.FieldCreatedAt:
  18168. v, ok := value.(time.Time)
  18169. if !ok {
  18170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18171. }
  18172. m.SetCreatedAt(v)
  18173. return nil
  18174. case labeltagging.FieldUpdatedAt:
  18175. v, ok := value.(time.Time)
  18176. if !ok {
  18177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18178. }
  18179. m.SetUpdatedAt(v)
  18180. return nil
  18181. case labeltagging.FieldStatus:
  18182. v, ok := value.(uint8)
  18183. if !ok {
  18184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18185. }
  18186. m.SetStatus(v)
  18187. return nil
  18188. case labeltagging.FieldDeletedAt:
  18189. v, ok := value.(time.Time)
  18190. if !ok {
  18191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18192. }
  18193. m.SetDeletedAt(v)
  18194. return nil
  18195. case labeltagging.FieldOrganizationID:
  18196. v, ok := value.(uint64)
  18197. if !ok {
  18198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18199. }
  18200. m.SetOrganizationID(v)
  18201. return nil
  18202. case labeltagging.FieldType:
  18203. v, ok := value.(int)
  18204. if !ok {
  18205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18206. }
  18207. m.SetType(v)
  18208. return nil
  18209. case labeltagging.FieldConditions:
  18210. v, ok := value.(string)
  18211. if !ok {
  18212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18213. }
  18214. m.SetConditions(v)
  18215. return nil
  18216. case labeltagging.FieldActionLabelAdd:
  18217. v, ok := value.([]uint64)
  18218. if !ok {
  18219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18220. }
  18221. m.SetActionLabelAdd(v)
  18222. return nil
  18223. case labeltagging.FieldActionLabelDel:
  18224. v, ok := value.([]uint64)
  18225. if !ok {
  18226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18227. }
  18228. m.SetActionLabelDel(v)
  18229. return nil
  18230. }
  18231. return fmt.Errorf("unknown LabelTagging field %s", name)
  18232. }
  18233. // AddedFields returns all numeric fields that were incremented/decremented during
  18234. // this mutation.
  18235. func (m *LabelTaggingMutation) AddedFields() []string {
  18236. var fields []string
  18237. if m.addstatus != nil {
  18238. fields = append(fields, labeltagging.FieldStatus)
  18239. }
  18240. if m.addorganization_id != nil {
  18241. fields = append(fields, labeltagging.FieldOrganizationID)
  18242. }
  18243. if m.add_type != nil {
  18244. fields = append(fields, labeltagging.FieldType)
  18245. }
  18246. return fields
  18247. }
  18248. // AddedField returns the numeric value that was incremented/decremented on a field
  18249. // with the given name. The second boolean return value indicates that this field
  18250. // was not set, or was not defined in the schema.
  18251. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18252. switch name {
  18253. case labeltagging.FieldStatus:
  18254. return m.AddedStatus()
  18255. case labeltagging.FieldOrganizationID:
  18256. return m.AddedOrganizationID()
  18257. case labeltagging.FieldType:
  18258. return m.AddedType()
  18259. }
  18260. return nil, false
  18261. }
  18262. // AddField adds the value to the field with the given name. It returns an error if
  18263. // the field is not defined in the schema, or if the type mismatched the field
  18264. // type.
  18265. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18266. switch name {
  18267. case labeltagging.FieldStatus:
  18268. v, ok := value.(int8)
  18269. if !ok {
  18270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18271. }
  18272. m.AddStatus(v)
  18273. return nil
  18274. case labeltagging.FieldOrganizationID:
  18275. v, ok := value.(int64)
  18276. if !ok {
  18277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18278. }
  18279. m.AddOrganizationID(v)
  18280. return nil
  18281. case labeltagging.FieldType:
  18282. v, ok := value.(int)
  18283. if !ok {
  18284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18285. }
  18286. m.AddType(v)
  18287. return nil
  18288. }
  18289. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18290. }
  18291. // ClearedFields returns all nullable fields that were cleared during this
  18292. // mutation.
  18293. func (m *LabelTaggingMutation) ClearedFields() []string {
  18294. var fields []string
  18295. if m.FieldCleared(labeltagging.FieldStatus) {
  18296. fields = append(fields, labeltagging.FieldStatus)
  18297. }
  18298. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18299. fields = append(fields, labeltagging.FieldDeletedAt)
  18300. }
  18301. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18302. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18303. }
  18304. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18305. fields = append(fields, labeltagging.FieldActionLabelDel)
  18306. }
  18307. return fields
  18308. }
  18309. // FieldCleared returns a boolean indicating if a field with the given name was
  18310. // cleared in this mutation.
  18311. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18312. _, ok := m.clearedFields[name]
  18313. return ok
  18314. }
  18315. // ClearField clears the value of the field with the given name. It returns an
  18316. // error if the field is not defined in the schema.
  18317. func (m *LabelTaggingMutation) ClearField(name string) error {
  18318. switch name {
  18319. case labeltagging.FieldStatus:
  18320. m.ClearStatus()
  18321. return nil
  18322. case labeltagging.FieldDeletedAt:
  18323. m.ClearDeletedAt()
  18324. return nil
  18325. case labeltagging.FieldActionLabelAdd:
  18326. m.ClearActionLabelAdd()
  18327. return nil
  18328. case labeltagging.FieldActionLabelDel:
  18329. m.ClearActionLabelDel()
  18330. return nil
  18331. }
  18332. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18333. }
  18334. // ResetField resets all changes in the mutation for the field with the given name.
  18335. // It returns an error if the field is not defined in the schema.
  18336. func (m *LabelTaggingMutation) ResetField(name string) error {
  18337. switch name {
  18338. case labeltagging.FieldCreatedAt:
  18339. m.ResetCreatedAt()
  18340. return nil
  18341. case labeltagging.FieldUpdatedAt:
  18342. m.ResetUpdatedAt()
  18343. return nil
  18344. case labeltagging.FieldStatus:
  18345. m.ResetStatus()
  18346. return nil
  18347. case labeltagging.FieldDeletedAt:
  18348. m.ResetDeletedAt()
  18349. return nil
  18350. case labeltagging.FieldOrganizationID:
  18351. m.ResetOrganizationID()
  18352. return nil
  18353. case labeltagging.FieldType:
  18354. m.ResetType()
  18355. return nil
  18356. case labeltagging.FieldConditions:
  18357. m.ResetConditions()
  18358. return nil
  18359. case labeltagging.FieldActionLabelAdd:
  18360. m.ResetActionLabelAdd()
  18361. return nil
  18362. case labeltagging.FieldActionLabelDel:
  18363. m.ResetActionLabelDel()
  18364. return nil
  18365. }
  18366. return fmt.Errorf("unknown LabelTagging field %s", name)
  18367. }
  18368. // AddedEdges returns all edge names that were set/added in this mutation.
  18369. func (m *LabelTaggingMutation) AddedEdges() []string {
  18370. edges := make([]string, 0, 0)
  18371. return edges
  18372. }
  18373. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18374. // name in this mutation.
  18375. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18376. return nil
  18377. }
  18378. // RemovedEdges returns all edge names that were removed in this mutation.
  18379. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18380. edges := make([]string, 0, 0)
  18381. return edges
  18382. }
  18383. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18384. // the given name in this mutation.
  18385. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18386. return nil
  18387. }
  18388. // ClearedEdges returns all edge names that were cleared in this mutation.
  18389. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18390. edges := make([]string, 0, 0)
  18391. return edges
  18392. }
  18393. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18394. // was cleared in this mutation.
  18395. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18396. return false
  18397. }
  18398. // ClearEdge clears the value of the edge with the given name. It returns an error
  18399. // if that edge is not defined in the schema.
  18400. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18401. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18402. }
  18403. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18404. // It returns an error if the edge is not defined in the schema.
  18405. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18406. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18407. }
  18408. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18409. type MessageMutation struct {
  18410. config
  18411. op Op
  18412. typ string
  18413. id *int
  18414. wx_wxid *string
  18415. wxid *string
  18416. content *string
  18417. clearedFields map[string]struct{}
  18418. done bool
  18419. oldValue func(context.Context) (*Message, error)
  18420. predicates []predicate.Message
  18421. }
  18422. var _ ent.Mutation = (*MessageMutation)(nil)
  18423. // messageOption allows management of the mutation configuration using functional options.
  18424. type messageOption func(*MessageMutation)
  18425. // newMessageMutation creates new mutation for the Message entity.
  18426. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18427. m := &MessageMutation{
  18428. config: c,
  18429. op: op,
  18430. typ: TypeMessage,
  18431. clearedFields: make(map[string]struct{}),
  18432. }
  18433. for _, opt := range opts {
  18434. opt(m)
  18435. }
  18436. return m
  18437. }
  18438. // withMessageID sets the ID field of the mutation.
  18439. func withMessageID(id int) messageOption {
  18440. return func(m *MessageMutation) {
  18441. var (
  18442. err error
  18443. once sync.Once
  18444. value *Message
  18445. )
  18446. m.oldValue = func(ctx context.Context) (*Message, error) {
  18447. once.Do(func() {
  18448. if m.done {
  18449. err = errors.New("querying old values post mutation is not allowed")
  18450. } else {
  18451. value, err = m.Client().Message.Get(ctx, id)
  18452. }
  18453. })
  18454. return value, err
  18455. }
  18456. m.id = &id
  18457. }
  18458. }
  18459. // withMessage sets the old Message of the mutation.
  18460. func withMessage(node *Message) messageOption {
  18461. return func(m *MessageMutation) {
  18462. m.oldValue = func(context.Context) (*Message, error) {
  18463. return node, nil
  18464. }
  18465. m.id = &node.ID
  18466. }
  18467. }
  18468. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18469. // executed in a transaction (ent.Tx), a transactional client is returned.
  18470. func (m MessageMutation) Client() *Client {
  18471. client := &Client{config: m.config}
  18472. client.init()
  18473. return client
  18474. }
  18475. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18476. // it returns an error otherwise.
  18477. func (m MessageMutation) Tx() (*Tx, error) {
  18478. if _, ok := m.driver.(*txDriver); !ok {
  18479. return nil, errors.New("ent: mutation is not running in a transaction")
  18480. }
  18481. tx := &Tx{config: m.config}
  18482. tx.init()
  18483. return tx, nil
  18484. }
  18485. // ID returns the ID value in the mutation. Note that the ID is only available
  18486. // if it was provided to the builder or after it was returned from the database.
  18487. func (m *MessageMutation) ID() (id int, exists bool) {
  18488. if m.id == nil {
  18489. return
  18490. }
  18491. return *m.id, true
  18492. }
  18493. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18494. // That means, if the mutation is applied within a transaction with an isolation level such
  18495. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18496. // or updated by the mutation.
  18497. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18498. switch {
  18499. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18500. id, exists := m.ID()
  18501. if exists {
  18502. return []int{id}, nil
  18503. }
  18504. fallthrough
  18505. case m.op.Is(OpUpdate | OpDelete):
  18506. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18507. default:
  18508. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18509. }
  18510. }
  18511. // SetWxWxid sets the "wx_wxid" field.
  18512. func (m *MessageMutation) SetWxWxid(s string) {
  18513. m.wx_wxid = &s
  18514. }
  18515. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18516. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18517. v := m.wx_wxid
  18518. if v == nil {
  18519. return
  18520. }
  18521. return *v, true
  18522. }
  18523. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18524. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18526. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18527. if !m.op.Is(OpUpdateOne) {
  18528. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18529. }
  18530. if m.id == nil || m.oldValue == nil {
  18531. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18532. }
  18533. oldValue, err := m.oldValue(ctx)
  18534. if err != nil {
  18535. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18536. }
  18537. return oldValue.WxWxid, nil
  18538. }
  18539. // ClearWxWxid clears the value of the "wx_wxid" field.
  18540. func (m *MessageMutation) ClearWxWxid() {
  18541. m.wx_wxid = nil
  18542. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18543. }
  18544. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18545. func (m *MessageMutation) WxWxidCleared() bool {
  18546. _, ok := m.clearedFields[message.FieldWxWxid]
  18547. return ok
  18548. }
  18549. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18550. func (m *MessageMutation) ResetWxWxid() {
  18551. m.wx_wxid = nil
  18552. delete(m.clearedFields, message.FieldWxWxid)
  18553. }
  18554. // SetWxid sets the "wxid" field.
  18555. func (m *MessageMutation) SetWxid(s string) {
  18556. m.wxid = &s
  18557. }
  18558. // Wxid returns the value of the "wxid" field in the mutation.
  18559. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18560. v := m.wxid
  18561. if v == nil {
  18562. return
  18563. }
  18564. return *v, true
  18565. }
  18566. // OldWxid returns the old "wxid" field's value of the Message entity.
  18567. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18569. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18570. if !m.op.Is(OpUpdateOne) {
  18571. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18572. }
  18573. if m.id == nil || m.oldValue == nil {
  18574. return v, errors.New("OldWxid requires an ID field in the mutation")
  18575. }
  18576. oldValue, err := m.oldValue(ctx)
  18577. if err != nil {
  18578. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18579. }
  18580. return oldValue.Wxid, nil
  18581. }
  18582. // ResetWxid resets all changes to the "wxid" field.
  18583. func (m *MessageMutation) ResetWxid() {
  18584. m.wxid = nil
  18585. }
  18586. // SetContent sets the "content" field.
  18587. func (m *MessageMutation) SetContent(s string) {
  18588. m.content = &s
  18589. }
  18590. // Content returns the value of the "content" field in the mutation.
  18591. func (m *MessageMutation) Content() (r string, exists bool) {
  18592. v := m.content
  18593. if v == nil {
  18594. return
  18595. }
  18596. return *v, true
  18597. }
  18598. // OldContent returns the old "content" field's value of the Message entity.
  18599. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18601. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18602. if !m.op.Is(OpUpdateOne) {
  18603. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18604. }
  18605. if m.id == nil || m.oldValue == nil {
  18606. return v, errors.New("OldContent requires an ID field in the mutation")
  18607. }
  18608. oldValue, err := m.oldValue(ctx)
  18609. if err != nil {
  18610. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18611. }
  18612. return oldValue.Content, nil
  18613. }
  18614. // ResetContent resets all changes to the "content" field.
  18615. func (m *MessageMutation) ResetContent() {
  18616. m.content = nil
  18617. }
  18618. // Where appends a list predicates to the MessageMutation builder.
  18619. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18620. m.predicates = append(m.predicates, ps...)
  18621. }
  18622. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18623. // users can use type-assertion to append predicates that do not depend on any generated package.
  18624. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18625. p := make([]predicate.Message, len(ps))
  18626. for i := range ps {
  18627. p[i] = ps[i]
  18628. }
  18629. m.Where(p...)
  18630. }
  18631. // Op returns the operation name.
  18632. func (m *MessageMutation) Op() Op {
  18633. return m.op
  18634. }
  18635. // SetOp allows setting the mutation operation.
  18636. func (m *MessageMutation) SetOp(op Op) {
  18637. m.op = op
  18638. }
  18639. // Type returns the node type of this mutation (Message).
  18640. func (m *MessageMutation) Type() string {
  18641. return m.typ
  18642. }
  18643. // Fields returns all fields that were changed during this mutation. Note that in
  18644. // order to get all numeric fields that were incremented/decremented, call
  18645. // AddedFields().
  18646. func (m *MessageMutation) Fields() []string {
  18647. fields := make([]string, 0, 3)
  18648. if m.wx_wxid != nil {
  18649. fields = append(fields, message.FieldWxWxid)
  18650. }
  18651. if m.wxid != nil {
  18652. fields = append(fields, message.FieldWxid)
  18653. }
  18654. if m.content != nil {
  18655. fields = append(fields, message.FieldContent)
  18656. }
  18657. return fields
  18658. }
  18659. // Field returns the value of a field with the given name. The second boolean
  18660. // return value indicates that this field was not set, or was not defined in the
  18661. // schema.
  18662. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  18663. switch name {
  18664. case message.FieldWxWxid:
  18665. return m.WxWxid()
  18666. case message.FieldWxid:
  18667. return m.Wxid()
  18668. case message.FieldContent:
  18669. return m.Content()
  18670. }
  18671. return nil, false
  18672. }
  18673. // OldField returns the old value of the field from the database. An error is
  18674. // returned if the mutation operation is not UpdateOne, or the query to the
  18675. // database failed.
  18676. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18677. switch name {
  18678. case message.FieldWxWxid:
  18679. return m.OldWxWxid(ctx)
  18680. case message.FieldWxid:
  18681. return m.OldWxid(ctx)
  18682. case message.FieldContent:
  18683. return m.OldContent(ctx)
  18684. }
  18685. return nil, fmt.Errorf("unknown Message field %s", name)
  18686. }
  18687. // SetField sets the value of a field with the given name. It returns an error if
  18688. // the field is not defined in the schema, or if the type mismatched the field
  18689. // type.
  18690. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  18691. switch name {
  18692. case message.FieldWxWxid:
  18693. v, ok := value.(string)
  18694. if !ok {
  18695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18696. }
  18697. m.SetWxWxid(v)
  18698. return nil
  18699. case message.FieldWxid:
  18700. v, ok := value.(string)
  18701. if !ok {
  18702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18703. }
  18704. m.SetWxid(v)
  18705. return nil
  18706. case message.FieldContent:
  18707. v, ok := value.(string)
  18708. if !ok {
  18709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18710. }
  18711. m.SetContent(v)
  18712. return nil
  18713. }
  18714. return fmt.Errorf("unknown Message field %s", name)
  18715. }
  18716. // AddedFields returns all numeric fields that were incremented/decremented during
  18717. // this mutation.
  18718. func (m *MessageMutation) AddedFields() []string {
  18719. return nil
  18720. }
  18721. // AddedField returns the numeric value that was incremented/decremented on a field
  18722. // with the given name. The second boolean return value indicates that this field
  18723. // was not set, or was not defined in the schema.
  18724. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  18725. return nil, false
  18726. }
  18727. // AddField adds the value to the field with the given name. It returns an error if
  18728. // the field is not defined in the schema, or if the type mismatched the field
  18729. // type.
  18730. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  18731. switch name {
  18732. }
  18733. return fmt.Errorf("unknown Message numeric field %s", name)
  18734. }
  18735. // ClearedFields returns all nullable fields that were cleared during this
  18736. // mutation.
  18737. func (m *MessageMutation) ClearedFields() []string {
  18738. var fields []string
  18739. if m.FieldCleared(message.FieldWxWxid) {
  18740. fields = append(fields, message.FieldWxWxid)
  18741. }
  18742. return fields
  18743. }
  18744. // FieldCleared returns a boolean indicating if a field with the given name was
  18745. // cleared in this mutation.
  18746. func (m *MessageMutation) FieldCleared(name string) bool {
  18747. _, ok := m.clearedFields[name]
  18748. return ok
  18749. }
  18750. // ClearField clears the value of the field with the given name. It returns an
  18751. // error if the field is not defined in the schema.
  18752. func (m *MessageMutation) ClearField(name string) error {
  18753. switch name {
  18754. case message.FieldWxWxid:
  18755. m.ClearWxWxid()
  18756. return nil
  18757. }
  18758. return fmt.Errorf("unknown Message nullable field %s", name)
  18759. }
  18760. // ResetField resets all changes in the mutation for the field with the given name.
  18761. // It returns an error if the field is not defined in the schema.
  18762. func (m *MessageMutation) ResetField(name string) error {
  18763. switch name {
  18764. case message.FieldWxWxid:
  18765. m.ResetWxWxid()
  18766. return nil
  18767. case message.FieldWxid:
  18768. m.ResetWxid()
  18769. return nil
  18770. case message.FieldContent:
  18771. m.ResetContent()
  18772. return nil
  18773. }
  18774. return fmt.Errorf("unknown Message field %s", name)
  18775. }
  18776. // AddedEdges returns all edge names that were set/added in this mutation.
  18777. func (m *MessageMutation) AddedEdges() []string {
  18778. edges := make([]string, 0, 0)
  18779. return edges
  18780. }
  18781. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18782. // name in this mutation.
  18783. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  18784. return nil
  18785. }
  18786. // RemovedEdges returns all edge names that were removed in this mutation.
  18787. func (m *MessageMutation) RemovedEdges() []string {
  18788. edges := make([]string, 0, 0)
  18789. return edges
  18790. }
  18791. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18792. // the given name in this mutation.
  18793. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  18794. return nil
  18795. }
  18796. // ClearedEdges returns all edge names that were cleared in this mutation.
  18797. func (m *MessageMutation) ClearedEdges() []string {
  18798. edges := make([]string, 0, 0)
  18799. return edges
  18800. }
  18801. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18802. // was cleared in this mutation.
  18803. func (m *MessageMutation) EdgeCleared(name string) bool {
  18804. return false
  18805. }
  18806. // ClearEdge clears the value of the edge with the given name. It returns an error
  18807. // if that edge is not defined in the schema.
  18808. func (m *MessageMutation) ClearEdge(name string) error {
  18809. return fmt.Errorf("unknown Message unique edge %s", name)
  18810. }
  18811. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18812. // It returns an error if the edge is not defined in the schema.
  18813. func (m *MessageMutation) ResetEdge(name string) error {
  18814. return fmt.Errorf("unknown Message edge %s", name)
  18815. }
  18816. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  18817. type MessageRecordsMutation struct {
  18818. config
  18819. op Op
  18820. typ string
  18821. id *uint64
  18822. created_at *time.Time
  18823. updated_at *time.Time
  18824. status *uint8
  18825. addstatus *int8
  18826. bot_wxid *string
  18827. contact_type *int
  18828. addcontact_type *int
  18829. contact_wxid *string
  18830. content_type *int
  18831. addcontent_type *int
  18832. content *string
  18833. meta *custom_types.Meta
  18834. error_detail *string
  18835. send_time *time.Time
  18836. source_type *int
  18837. addsource_type *int
  18838. organization_id *uint64
  18839. addorganization_id *int64
  18840. clearedFields map[string]struct{}
  18841. sop_stage *uint64
  18842. clearedsop_stage bool
  18843. sop_node *uint64
  18844. clearedsop_node bool
  18845. message_contact *uint64
  18846. clearedmessage_contact bool
  18847. done bool
  18848. oldValue func(context.Context) (*MessageRecords, error)
  18849. predicates []predicate.MessageRecords
  18850. }
  18851. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  18852. // messagerecordsOption allows management of the mutation configuration using functional options.
  18853. type messagerecordsOption func(*MessageRecordsMutation)
  18854. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  18855. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  18856. m := &MessageRecordsMutation{
  18857. config: c,
  18858. op: op,
  18859. typ: TypeMessageRecords,
  18860. clearedFields: make(map[string]struct{}),
  18861. }
  18862. for _, opt := range opts {
  18863. opt(m)
  18864. }
  18865. return m
  18866. }
  18867. // withMessageRecordsID sets the ID field of the mutation.
  18868. func withMessageRecordsID(id uint64) messagerecordsOption {
  18869. return func(m *MessageRecordsMutation) {
  18870. var (
  18871. err error
  18872. once sync.Once
  18873. value *MessageRecords
  18874. )
  18875. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  18876. once.Do(func() {
  18877. if m.done {
  18878. err = errors.New("querying old values post mutation is not allowed")
  18879. } else {
  18880. value, err = m.Client().MessageRecords.Get(ctx, id)
  18881. }
  18882. })
  18883. return value, err
  18884. }
  18885. m.id = &id
  18886. }
  18887. }
  18888. // withMessageRecords sets the old MessageRecords of the mutation.
  18889. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  18890. return func(m *MessageRecordsMutation) {
  18891. m.oldValue = func(context.Context) (*MessageRecords, error) {
  18892. return node, nil
  18893. }
  18894. m.id = &node.ID
  18895. }
  18896. }
  18897. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18898. // executed in a transaction (ent.Tx), a transactional client is returned.
  18899. func (m MessageRecordsMutation) Client() *Client {
  18900. client := &Client{config: m.config}
  18901. client.init()
  18902. return client
  18903. }
  18904. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18905. // it returns an error otherwise.
  18906. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  18907. if _, ok := m.driver.(*txDriver); !ok {
  18908. return nil, errors.New("ent: mutation is not running in a transaction")
  18909. }
  18910. tx := &Tx{config: m.config}
  18911. tx.init()
  18912. return tx, nil
  18913. }
  18914. // SetID sets the value of the id field. Note that this
  18915. // operation is only accepted on creation of MessageRecords entities.
  18916. func (m *MessageRecordsMutation) SetID(id uint64) {
  18917. m.id = &id
  18918. }
  18919. // ID returns the ID value in the mutation. Note that the ID is only available
  18920. // if it was provided to the builder or after it was returned from the database.
  18921. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  18922. if m.id == nil {
  18923. return
  18924. }
  18925. return *m.id, true
  18926. }
  18927. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18928. // That means, if the mutation is applied within a transaction with an isolation level such
  18929. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18930. // or updated by the mutation.
  18931. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  18932. switch {
  18933. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18934. id, exists := m.ID()
  18935. if exists {
  18936. return []uint64{id}, nil
  18937. }
  18938. fallthrough
  18939. case m.op.Is(OpUpdate | OpDelete):
  18940. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  18941. default:
  18942. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18943. }
  18944. }
  18945. // SetCreatedAt sets the "created_at" field.
  18946. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  18947. m.created_at = &t
  18948. }
  18949. // CreatedAt returns the value of the "created_at" field in the mutation.
  18950. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  18951. v := m.created_at
  18952. if v == nil {
  18953. return
  18954. }
  18955. return *v, true
  18956. }
  18957. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  18958. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18960. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18961. if !m.op.Is(OpUpdateOne) {
  18962. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18963. }
  18964. if m.id == nil || m.oldValue == nil {
  18965. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18966. }
  18967. oldValue, err := m.oldValue(ctx)
  18968. if err != nil {
  18969. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18970. }
  18971. return oldValue.CreatedAt, nil
  18972. }
  18973. // ResetCreatedAt resets all changes to the "created_at" field.
  18974. func (m *MessageRecordsMutation) ResetCreatedAt() {
  18975. m.created_at = nil
  18976. }
  18977. // SetUpdatedAt sets the "updated_at" field.
  18978. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  18979. m.updated_at = &t
  18980. }
  18981. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18982. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  18983. v := m.updated_at
  18984. if v == nil {
  18985. return
  18986. }
  18987. return *v, true
  18988. }
  18989. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  18990. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18992. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18993. if !m.op.Is(OpUpdateOne) {
  18994. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18995. }
  18996. if m.id == nil || m.oldValue == nil {
  18997. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18998. }
  18999. oldValue, err := m.oldValue(ctx)
  19000. if err != nil {
  19001. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19002. }
  19003. return oldValue.UpdatedAt, nil
  19004. }
  19005. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19006. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  19007. m.updated_at = nil
  19008. }
  19009. // SetStatus sets the "status" field.
  19010. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  19011. m.status = &u
  19012. m.addstatus = nil
  19013. }
  19014. // Status returns the value of the "status" field in the mutation.
  19015. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  19016. v := m.status
  19017. if v == nil {
  19018. return
  19019. }
  19020. return *v, true
  19021. }
  19022. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  19023. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19025. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19026. if !m.op.Is(OpUpdateOne) {
  19027. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19028. }
  19029. if m.id == nil || m.oldValue == nil {
  19030. return v, errors.New("OldStatus requires an ID field in the mutation")
  19031. }
  19032. oldValue, err := m.oldValue(ctx)
  19033. if err != nil {
  19034. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19035. }
  19036. return oldValue.Status, nil
  19037. }
  19038. // AddStatus adds u to the "status" field.
  19039. func (m *MessageRecordsMutation) AddStatus(u int8) {
  19040. if m.addstatus != nil {
  19041. *m.addstatus += u
  19042. } else {
  19043. m.addstatus = &u
  19044. }
  19045. }
  19046. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19047. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  19048. v := m.addstatus
  19049. if v == nil {
  19050. return
  19051. }
  19052. return *v, true
  19053. }
  19054. // ClearStatus clears the value of the "status" field.
  19055. func (m *MessageRecordsMutation) ClearStatus() {
  19056. m.status = nil
  19057. m.addstatus = nil
  19058. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  19059. }
  19060. // StatusCleared returns if the "status" field was cleared in this mutation.
  19061. func (m *MessageRecordsMutation) StatusCleared() bool {
  19062. _, ok := m.clearedFields[messagerecords.FieldStatus]
  19063. return ok
  19064. }
  19065. // ResetStatus resets all changes to the "status" field.
  19066. func (m *MessageRecordsMutation) ResetStatus() {
  19067. m.status = nil
  19068. m.addstatus = nil
  19069. delete(m.clearedFields, messagerecords.FieldStatus)
  19070. }
  19071. // SetBotWxid sets the "bot_wxid" field.
  19072. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  19073. m.bot_wxid = &s
  19074. }
  19075. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  19076. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  19077. v := m.bot_wxid
  19078. if v == nil {
  19079. return
  19080. }
  19081. return *v, true
  19082. }
  19083. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19084. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19086. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19087. if !m.op.Is(OpUpdateOne) {
  19088. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19089. }
  19090. if m.id == nil || m.oldValue == nil {
  19091. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19092. }
  19093. oldValue, err := m.oldValue(ctx)
  19094. if err != nil {
  19095. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19096. }
  19097. return oldValue.BotWxid, nil
  19098. }
  19099. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19100. func (m *MessageRecordsMutation) ResetBotWxid() {
  19101. m.bot_wxid = nil
  19102. }
  19103. // SetContactID sets the "contact_id" field.
  19104. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19105. m.message_contact = &u
  19106. }
  19107. // ContactID returns the value of the "contact_id" field in the mutation.
  19108. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19109. v := m.message_contact
  19110. if v == nil {
  19111. return
  19112. }
  19113. return *v, true
  19114. }
  19115. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19116. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19118. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19119. if !m.op.Is(OpUpdateOne) {
  19120. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19121. }
  19122. if m.id == nil || m.oldValue == nil {
  19123. return v, errors.New("OldContactID requires an ID field in the mutation")
  19124. }
  19125. oldValue, err := m.oldValue(ctx)
  19126. if err != nil {
  19127. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19128. }
  19129. return oldValue.ContactID, nil
  19130. }
  19131. // ClearContactID clears the value of the "contact_id" field.
  19132. func (m *MessageRecordsMutation) ClearContactID() {
  19133. m.message_contact = nil
  19134. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19135. }
  19136. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19137. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19138. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19139. return ok
  19140. }
  19141. // ResetContactID resets all changes to the "contact_id" field.
  19142. func (m *MessageRecordsMutation) ResetContactID() {
  19143. m.message_contact = nil
  19144. delete(m.clearedFields, messagerecords.FieldContactID)
  19145. }
  19146. // SetContactType sets the "contact_type" field.
  19147. func (m *MessageRecordsMutation) SetContactType(i int) {
  19148. m.contact_type = &i
  19149. m.addcontact_type = nil
  19150. }
  19151. // ContactType returns the value of the "contact_type" field in the mutation.
  19152. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19153. v := m.contact_type
  19154. if v == nil {
  19155. return
  19156. }
  19157. return *v, true
  19158. }
  19159. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19160. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19162. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19163. if !m.op.Is(OpUpdateOne) {
  19164. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19165. }
  19166. if m.id == nil || m.oldValue == nil {
  19167. return v, errors.New("OldContactType requires an ID field in the mutation")
  19168. }
  19169. oldValue, err := m.oldValue(ctx)
  19170. if err != nil {
  19171. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19172. }
  19173. return oldValue.ContactType, nil
  19174. }
  19175. // AddContactType adds i to the "contact_type" field.
  19176. func (m *MessageRecordsMutation) AddContactType(i int) {
  19177. if m.addcontact_type != nil {
  19178. *m.addcontact_type += i
  19179. } else {
  19180. m.addcontact_type = &i
  19181. }
  19182. }
  19183. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19184. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19185. v := m.addcontact_type
  19186. if v == nil {
  19187. return
  19188. }
  19189. return *v, true
  19190. }
  19191. // ResetContactType resets all changes to the "contact_type" field.
  19192. func (m *MessageRecordsMutation) ResetContactType() {
  19193. m.contact_type = nil
  19194. m.addcontact_type = nil
  19195. }
  19196. // SetContactWxid sets the "contact_wxid" field.
  19197. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19198. m.contact_wxid = &s
  19199. }
  19200. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19201. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19202. v := m.contact_wxid
  19203. if v == nil {
  19204. return
  19205. }
  19206. return *v, true
  19207. }
  19208. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19209. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19211. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19212. if !m.op.Is(OpUpdateOne) {
  19213. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19214. }
  19215. if m.id == nil || m.oldValue == nil {
  19216. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19217. }
  19218. oldValue, err := m.oldValue(ctx)
  19219. if err != nil {
  19220. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19221. }
  19222. return oldValue.ContactWxid, nil
  19223. }
  19224. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19225. func (m *MessageRecordsMutation) ResetContactWxid() {
  19226. m.contact_wxid = nil
  19227. }
  19228. // SetContentType sets the "content_type" field.
  19229. func (m *MessageRecordsMutation) SetContentType(i int) {
  19230. m.content_type = &i
  19231. m.addcontent_type = nil
  19232. }
  19233. // ContentType returns the value of the "content_type" field in the mutation.
  19234. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19235. v := m.content_type
  19236. if v == nil {
  19237. return
  19238. }
  19239. return *v, true
  19240. }
  19241. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19242. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19244. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19245. if !m.op.Is(OpUpdateOne) {
  19246. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19247. }
  19248. if m.id == nil || m.oldValue == nil {
  19249. return v, errors.New("OldContentType requires an ID field in the mutation")
  19250. }
  19251. oldValue, err := m.oldValue(ctx)
  19252. if err != nil {
  19253. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19254. }
  19255. return oldValue.ContentType, nil
  19256. }
  19257. // AddContentType adds i to the "content_type" field.
  19258. func (m *MessageRecordsMutation) AddContentType(i int) {
  19259. if m.addcontent_type != nil {
  19260. *m.addcontent_type += i
  19261. } else {
  19262. m.addcontent_type = &i
  19263. }
  19264. }
  19265. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19266. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19267. v := m.addcontent_type
  19268. if v == nil {
  19269. return
  19270. }
  19271. return *v, true
  19272. }
  19273. // ResetContentType resets all changes to the "content_type" field.
  19274. func (m *MessageRecordsMutation) ResetContentType() {
  19275. m.content_type = nil
  19276. m.addcontent_type = nil
  19277. }
  19278. // SetContent sets the "content" field.
  19279. func (m *MessageRecordsMutation) SetContent(s string) {
  19280. m.content = &s
  19281. }
  19282. // Content returns the value of the "content" field in the mutation.
  19283. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19284. v := m.content
  19285. if v == nil {
  19286. return
  19287. }
  19288. return *v, true
  19289. }
  19290. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19291. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19293. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19294. if !m.op.Is(OpUpdateOne) {
  19295. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19296. }
  19297. if m.id == nil || m.oldValue == nil {
  19298. return v, errors.New("OldContent requires an ID field in the mutation")
  19299. }
  19300. oldValue, err := m.oldValue(ctx)
  19301. if err != nil {
  19302. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19303. }
  19304. return oldValue.Content, nil
  19305. }
  19306. // ResetContent resets all changes to the "content" field.
  19307. func (m *MessageRecordsMutation) ResetContent() {
  19308. m.content = nil
  19309. }
  19310. // SetMeta sets the "meta" field.
  19311. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19312. m.meta = &ct
  19313. }
  19314. // Meta returns the value of the "meta" field in the mutation.
  19315. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19316. v := m.meta
  19317. if v == nil {
  19318. return
  19319. }
  19320. return *v, true
  19321. }
  19322. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19323. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19325. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19326. if !m.op.Is(OpUpdateOne) {
  19327. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19328. }
  19329. if m.id == nil || m.oldValue == nil {
  19330. return v, errors.New("OldMeta requires an ID field in the mutation")
  19331. }
  19332. oldValue, err := m.oldValue(ctx)
  19333. if err != nil {
  19334. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19335. }
  19336. return oldValue.Meta, nil
  19337. }
  19338. // ClearMeta clears the value of the "meta" field.
  19339. func (m *MessageRecordsMutation) ClearMeta() {
  19340. m.meta = nil
  19341. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19342. }
  19343. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19344. func (m *MessageRecordsMutation) MetaCleared() bool {
  19345. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19346. return ok
  19347. }
  19348. // ResetMeta resets all changes to the "meta" field.
  19349. func (m *MessageRecordsMutation) ResetMeta() {
  19350. m.meta = nil
  19351. delete(m.clearedFields, messagerecords.FieldMeta)
  19352. }
  19353. // SetErrorDetail sets the "error_detail" field.
  19354. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19355. m.error_detail = &s
  19356. }
  19357. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19358. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19359. v := m.error_detail
  19360. if v == nil {
  19361. return
  19362. }
  19363. return *v, true
  19364. }
  19365. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19366. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19368. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19369. if !m.op.Is(OpUpdateOne) {
  19370. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19371. }
  19372. if m.id == nil || m.oldValue == nil {
  19373. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19374. }
  19375. oldValue, err := m.oldValue(ctx)
  19376. if err != nil {
  19377. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19378. }
  19379. return oldValue.ErrorDetail, nil
  19380. }
  19381. // ResetErrorDetail resets all changes to the "error_detail" field.
  19382. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19383. m.error_detail = nil
  19384. }
  19385. // SetSendTime sets the "send_time" field.
  19386. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19387. m.send_time = &t
  19388. }
  19389. // SendTime returns the value of the "send_time" field in the mutation.
  19390. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19391. v := m.send_time
  19392. if v == nil {
  19393. return
  19394. }
  19395. return *v, true
  19396. }
  19397. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  19398. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19400. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19401. if !m.op.Is(OpUpdateOne) {
  19402. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19403. }
  19404. if m.id == nil || m.oldValue == nil {
  19405. return v, errors.New("OldSendTime requires an ID field in the mutation")
  19406. }
  19407. oldValue, err := m.oldValue(ctx)
  19408. if err != nil {
  19409. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  19410. }
  19411. return oldValue.SendTime, nil
  19412. }
  19413. // ClearSendTime clears the value of the "send_time" field.
  19414. func (m *MessageRecordsMutation) ClearSendTime() {
  19415. m.send_time = nil
  19416. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19417. }
  19418. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19419. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19420. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19421. return ok
  19422. }
  19423. // ResetSendTime resets all changes to the "send_time" field.
  19424. func (m *MessageRecordsMutation) ResetSendTime() {
  19425. m.send_time = nil
  19426. delete(m.clearedFields, messagerecords.FieldSendTime)
  19427. }
  19428. // SetSourceType sets the "source_type" field.
  19429. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19430. m.source_type = &i
  19431. m.addsource_type = nil
  19432. }
  19433. // SourceType returns the value of the "source_type" field in the mutation.
  19434. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19435. v := m.source_type
  19436. if v == nil {
  19437. return
  19438. }
  19439. return *v, true
  19440. }
  19441. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19442. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19444. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19445. if !m.op.Is(OpUpdateOne) {
  19446. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19447. }
  19448. if m.id == nil || m.oldValue == nil {
  19449. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19450. }
  19451. oldValue, err := m.oldValue(ctx)
  19452. if err != nil {
  19453. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19454. }
  19455. return oldValue.SourceType, nil
  19456. }
  19457. // AddSourceType adds i to the "source_type" field.
  19458. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19459. if m.addsource_type != nil {
  19460. *m.addsource_type += i
  19461. } else {
  19462. m.addsource_type = &i
  19463. }
  19464. }
  19465. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19466. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19467. v := m.addsource_type
  19468. if v == nil {
  19469. return
  19470. }
  19471. return *v, true
  19472. }
  19473. // ResetSourceType resets all changes to the "source_type" field.
  19474. func (m *MessageRecordsMutation) ResetSourceType() {
  19475. m.source_type = nil
  19476. m.addsource_type = nil
  19477. }
  19478. // SetSourceID sets the "source_id" field.
  19479. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19480. m.sop_stage = &u
  19481. }
  19482. // SourceID returns the value of the "source_id" field in the mutation.
  19483. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19484. v := m.sop_stage
  19485. if v == nil {
  19486. return
  19487. }
  19488. return *v, true
  19489. }
  19490. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19491. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19493. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19494. if !m.op.Is(OpUpdateOne) {
  19495. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19496. }
  19497. if m.id == nil || m.oldValue == nil {
  19498. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19499. }
  19500. oldValue, err := m.oldValue(ctx)
  19501. if err != nil {
  19502. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19503. }
  19504. return oldValue.SourceID, nil
  19505. }
  19506. // ClearSourceID clears the value of the "source_id" field.
  19507. func (m *MessageRecordsMutation) ClearSourceID() {
  19508. m.sop_stage = nil
  19509. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19510. }
  19511. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19512. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19513. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19514. return ok
  19515. }
  19516. // ResetSourceID resets all changes to the "source_id" field.
  19517. func (m *MessageRecordsMutation) ResetSourceID() {
  19518. m.sop_stage = nil
  19519. delete(m.clearedFields, messagerecords.FieldSourceID)
  19520. }
  19521. // SetSubSourceID sets the "sub_source_id" field.
  19522. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19523. m.sop_node = &u
  19524. }
  19525. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19526. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19527. v := m.sop_node
  19528. if v == nil {
  19529. return
  19530. }
  19531. return *v, true
  19532. }
  19533. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19534. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19536. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19537. if !m.op.Is(OpUpdateOne) {
  19538. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19539. }
  19540. if m.id == nil || m.oldValue == nil {
  19541. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19542. }
  19543. oldValue, err := m.oldValue(ctx)
  19544. if err != nil {
  19545. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19546. }
  19547. return oldValue.SubSourceID, nil
  19548. }
  19549. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19550. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19551. m.sop_node = nil
  19552. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19553. }
  19554. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19555. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19556. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19557. return ok
  19558. }
  19559. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19560. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19561. m.sop_node = nil
  19562. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19563. }
  19564. // SetOrganizationID sets the "organization_id" field.
  19565. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19566. m.organization_id = &u
  19567. m.addorganization_id = nil
  19568. }
  19569. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19570. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19571. v := m.organization_id
  19572. if v == nil {
  19573. return
  19574. }
  19575. return *v, true
  19576. }
  19577. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19578. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19580. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19581. if !m.op.Is(OpUpdateOne) {
  19582. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19583. }
  19584. if m.id == nil || m.oldValue == nil {
  19585. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19586. }
  19587. oldValue, err := m.oldValue(ctx)
  19588. if err != nil {
  19589. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19590. }
  19591. return oldValue.OrganizationID, nil
  19592. }
  19593. // AddOrganizationID adds u to the "organization_id" field.
  19594. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19595. if m.addorganization_id != nil {
  19596. *m.addorganization_id += u
  19597. } else {
  19598. m.addorganization_id = &u
  19599. }
  19600. }
  19601. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19602. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19603. v := m.addorganization_id
  19604. if v == nil {
  19605. return
  19606. }
  19607. return *v, true
  19608. }
  19609. // ClearOrganizationID clears the value of the "organization_id" field.
  19610. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19611. m.organization_id = nil
  19612. m.addorganization_id = nil
  19613. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19614. }
  19615. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19616. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19617. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19618. return ok
  19619. }
  19620. // ResetOrganizationID resets all changes to the "organization_id" field.
  19621. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19622. m.organization_id = nil
  19623. m.addorganization_id = nil
  19624. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19625. }
  19626. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19627. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19628. m.sop_stage = &id
  19629. }
  19630. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19631. func (m *MessageRecordsMutation) ClearSopStage() {
  19632. m.clearedsop_stage = true
  19633. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19634. }
  19635. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  19636. func (m *MessageRecordsMutation) SopStageCleared() bool {
  19637. return m.SourceIDCleared() || m.clearedsop_stage
  19638. }
  19639. // SopStageID returns the "sop_stage" edge ID in the mutation.
  19640. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  19641. if m.sop_stage != nil {
  19642. return *m.sop_stage, true
  19643. }
  19644. return
  19645. }
  19646. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  19647. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19648. // SopStageID instead. It exists only for internal usage by the builders.
  19649. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  19650. if id := m.sop_stage; id != nil {
  19651. ids = append(ids, *id)
  19652. }
  19653. return
  19654. }
  19655. // ResetSopStage resets all changes to the "sop_stage" edge.
  19656. func (m *MessageRecordsMutation) ResetSopStage() {
  19657. m.sop_stage = nil
  19658. m.clearedsop_stage = false
  19659. }
  19660. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  19661. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  19662. m.sop_node = &id
  19663. }
  19664. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  19665. func (m *MessageRecordsMutation) ClearSopNode() {
  19666. m.clearedsop_node = true
  19667. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19668. }
  19669. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  19670. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  19671. return m.SubSourceIDCleared() || m.clearedsop_node
  19672. }
  19673. // SopNodeID returns the "sop_node" edge ID in the mutation.
  19674. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  19675. if m.sop_node != nil {
  19676. return *m.sop_node, true
  19677. }
  19678. return
  19679. }
  19680. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  19681. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19682. // SopNodeID instead. It exists only for internal usage by the builders.
  19683. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  19684. if id := m.sop_node; id != nil {
  19685. ids = append(ids, *id)
  19686. }
  19687. return
  19688. }
  19689. // ResetSopNode resets all changes to the "sop_node" edge.
  19690. func (m *MessageRecordsMutation) ResetSopNode() {
  19691. m.sop_node = nil
  19692. m.clearedsop_node = false
  19693. }
  19694. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  19695. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  19696. m.message_contact = &id
  19697. }
  19698. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  19699. func (m *MessageRecordsMutation) ClearMessageContact() {
  19700. m.clearedmessage_contact = true
  19701. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19702. }
  19703. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  19704. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  19705. return m.ContactIDCleared() || m.clearedmessage_contact
  19706. }
  19707. // MessageContactID returns the "message_contact" edge ID in the mutation.
  19708. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  19709. if m.message_contact != nil {
  19710. return *m.message_contact, true
  19711. }
  19712. return
  19713. }
  19714. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  19715. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19716. // MessageContactID instead. It exists only for internal usage by the builders.
  19717. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  19718. if id := m.message_contact; id != nil {
  19719. ids = append(ids, *id)
  19720. }
  19721. return
  19722. }
  19723. // ResetMessageContact resets all changes to the "message_contact" edge.
  19724. func (m *MessageRecordsMutation) ResetMessageContact() {
  19725. m.message_contact = nil
  19726. m.clearedmessage_contact = false
  19727. }
  19728. // Where appends a list predicates to the MessageRecordsMutation builder.
  19729. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  19730. m.predicates = append(m.predicates, ps...)
  19731. }
  19732. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  19733. // users can use type-assertion to append predicates that do not depend on any generated package.
  19734. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  19735. p := make([]predicate.MessageRecords, len(ps))
  19736. for i := range ps {
  19737. p[i] = ps[i]
  19738. }
  19739. m.Where(p...)
  19740. }
  19741. // Op returns the operation name.
  19742. func (m *MessageRecordsMutation) Op() Op {
  19743. return m.op
  19744. }
  19745. // SetOp allows setting the mutation operation.
  19746. func (m *MessageRecordsMutation) SetOp(op Op) {
  19747. m.op = op
  19748. }
  19749. // Type returns the node type of this mutation (MessageRecords).
  19750. func (m *MessageRecordsMutation) Type() string {
  19751. return m.typ
  19752. }
  19753. // Fields returns all fields that were changed during this mutation. Note that in
  19754. // order to get all numeric fields that were incremented/decremented, call
  19755. // AddedFields().
  19756. func (m *MessageRecordsMutation) Fields() []string {
  19757. fields := make([]string, 0, 16)
  19758. if m.created_at != nil {
  19759. fields = append(fields, messagerecords.FieldCreatedAt)
  19760. }
  19761. if m.updated_at != nil {
  19762. fields = append(fields, messagerecords.FieldUpdatedAt)
  19763. }
  19764. if m.status != nil {
  19765. fields = append(fields, messagerecords.FieldStatus)
  19766. }
  19767. if m.bot_wxid != nil {
  19768. fields = append(fields, messagerecords.FieldBotWxid)
  19769. }
  19770. if m.message_contact != nil {
  19771. fields = append(fields, messagerecords.FieldContactID)
  19772. }
  19773. if m.contact_type != nil {
  19774. fields = append(fields, messagerecords.FieldContactType)
  19775. }
  19776. if m.contact_wxid != nil {
  19777. fields = append(fields, messagerecords.FieldContactWxid)
  19778. }
  19779. if m.content_type != nil {
  19780. fields = append(fields, messagerecords.FieldContentType)
  19781. }
  19782. if m.content != nil {
  19783. fields = append(fields, messagerecords.FieldContent)
  19784. }
  19785. if m.meta != nil {
  19786. fields = append(fields, messagerecords.FieldMeta)
  19787. }
  19788. if m.error_detail != nil {
  19789. fields = append(fields, messagerecords.FieldErrorDetail)
  19790. }
  19791. if m.send_time != nil {
  19792. fields = append(fields, messagerecords.FieldSendTime)
  19793. }
  19794. if m.source_type != nil {
  19795. fields = append(fields, messagerecords.FieldSourceType)
  19796. }
  19797. if m.sop_stage != nil {
  19798. fields = append(fields, messagerecords.FieldSourceID)
  19799. }
  19800. if m.sop_node != nil {
  19801. fields = append(fields, messagerecords.FieldSubSourceID)
  19802. }
  19803. if m.organization_id != nil {
  19804. fields = append(fields, messagerecords.FieldOrganizationID)
  19805. }
  19806. return fields
  19807. }
  19808. // Field returns the value of a field with the given name. The second boolean
  19809. // return value indicates that this field was not set, or was not defined in the
  19810. // schema.
  19811. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  19812. switch name {
  19813. case messagerecords.FieldCreatedAt:
  19814. return m.CreatedAt()
  19815. case messagerecords.FieldUpdatedAt:
  19816. return m.UpdatedAt()
  19817. case messagerecords.FieldStatus:
  19818. return m.Status()
  19819. case messagerecords.FieldBotWxid:
  19820. return m.BotWxid()
  19821. case messagerecords.FieldContactID:
  19822. return m.ContactID()
  19823. case messagerecords.FieldContactType:
  19824. return m.ContactType()
  19825. case messagerecords.FieldContactWxid:
  19826. return m.ContactWxid()
  19827. case messagerecords.FieldContentType:
  19828. return m.ContentType()
  19829. case messagerecords.FieldContent:
  19830. return m.Content()
  19831. case messagerecords.FieldMeta:
  19832. return m.Meta()
  19833. case messagerecords.FieldErrorDetail:
  19834. return m.ErrorDetail()
  19835. case messagerecords.FieldSendTime:
  19836. return m.SendTime()
  19837. case messagerecords.FieldSourceType:
  19838. return m.SourceType()
  19839. case messagerecords.FieldSourceID:
  19840. return m.SourceID()
  19841. case messagerecords.FieldSubSourceID:
  19842. return m.SubSourceID()
  19843. case messagerecords.FieldOrganizationID:
  19844. return m.OrganizationID()
  19845. }
  19846. return nil, false
  19847. }
  19848. // OldField returns the old value of the field from the database. An error is
  19849. // returned if the mutation operation is not UpdateOne, or the query to the
  19850. // database failed.
  19851. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19852. switch name {
  19853. case messagerecords.FieldCreatedAt:
  19854. return m.OldCreatedAt(ctx)
  19855. case messagerecords.FieldUpdatedAt:
  19856. return m.OldUpdatedAt(ctx)
  19857. case messagerecords.FieldStatus:
  19858. return m.OldStatus(ctx)
  19859. case messagerecords.FieldBotWxid:
  19860. return m.OldBotWxid(ctx)
  19861. case messagerecords.FieldContactID:
  19862. return m.OldContactID(ctx)
  19863. case messagerecords.FieldContactType:
  19864. return m.OldContactType(ctx)
  19865. case messagerecords.FieldContactWxid:
  19866. return m.OldContactWxid(ctx)
  19867. case messagerecords.FieldContentType:
  19868. return m.OldContentType(ctx)
  19869. case messagerecords.FieldContent:
  19870. return m.OldContent(ctx)
  19871. case messagerecords.FieldMeta:
  19872. return m.OldMeta(ctx)
  19873. case messagerecords.FieldErrorDetail:
  19874. return m.OldErrorDetail(ctx)
  19875. case messagerecords.FieldSendTime:
  19876. return m.OldSendTime(ctx)
  19877. case messagerecords.FieldSourceType:
  19878. return m.OldSourceType(ctx)
  19879. case messagerecords.FieldSourceID:
  19880. return m.OldSourceID(ctx)
  19881. case messagerecords.FieldSubSourceID:
  19882. return m.OldSubSourceID(ctx)
  19883. case messagerecords.FieldOrganizationID:
  19884. return m.OldOrganizationID(ctx)
  19885. }
  19886. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  19887. }
  19888. // SetField sets the value of a field with the given name. It returns an error if
  19889. // the field is not defined in the schema, or if the type mismatched the field
  19890. // type.
  19891. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  19892. switch name {
  19893. case messagerecords.FieldCreatedAt:
  19894. v, ok := value.(time.Time)
  19895. if !ok {
  19896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19897. }
  19898. m.SetCreatedAt(v)
  19899. return nil
  19900. case messagerecords.FieldUpdatedAt:
  19901. v, ok := value.(time.Time)
  19902. if !ok {
  19903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19904. }
  19905. m.SetUpdatedAt(v)
  19906. return nil
  19907. case messagerecords.FieldStatus:
  19908. v, ok := value.(uint8)
  19909. if !ok {
  19910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19911. }
  19912. m.SetStatus(v)
  19913. return nil
  19914. case messagerecords.FieldBotWxid:
  19915. v, ok := value.(string)
  19916. if !ok {
  19917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19918. }
  19919. m.SetBotWxid(v)
  19920. return nil
  19921. case messagerecords.FieldContactID:
  19922. v, ok := value.(uint64)
  19923. if !ok {
  19924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19925. }
  19926. m.SetContactID(v)
  19927. return nil
  19928. case messagerecords.FieldContactType:
  19929. v, ok := value.(int)
  19930. if !ok {
  19931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19932. }
  19933. m.SetContactType(v)
  19934. return nil
  19935. case messagerecords.FieldContactWxid:
  19936. v, ok := value.(string)
  19937. if !ok {
  19938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19939. }
  19940. m.SetContactWxid(v)
  19941. return nil
  19942. case messagerecords.FieldContentType:
  19943. v, ok := value.(int)
  19944. if !ok {
  19945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19946. }
  19947. m.SetContentType(v)
  19948. return nil
  19949. case messagerecords.FieldContent:
  19950. v, ok := value.(string)
  19951. if !ok {
  19952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19953. }
  19954. m.SetContent(v)
  19955. return nil
  19956. case messagerecords.FieldMeta:
  19957. v, ok := value.(custom_types.Meta)
  19958. if !ok {
  19959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19960. }
  19961. m.SetMeta(v)
  19962. return nil
  19963. case messagerecords.FieldErrorDetail:
  19964. v, ok := value.(string)
  19965. if !ok {
  19966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19967. }
  19968. m.SetErrorDetail(v)
  19969. return nil
  19970. case messagerecords.FieldSendTime:
  19971. v, ok := value.(time.Time)
  19972. if !ok {
  19973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19974. }
  19975. m.SetSendTime(v)
  19976. return nil
  19977. case messagerecords.FieldSourceType:
  19978. v, ok := value.(int)
  19979. if !ok {
  19980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19981. }
  19982. m.SetSourceType(v)
  19983. return nil
  19984. case messagerecords.FieldSourceID:
  19985. v, ok := value.(uint64)
  19986. if !ok {
  19987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19988. }
  19989. m.SetSourceID(v)
  19990. return nil
  19991. case messagerecords.FieldSubSourceID:
  19992. v, ok := value.(uint64)
  19993. if !ok {
  19994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19995. }
  19996. m.SetSubSourceID(v)
  19997. return nil
  19998. case messagerecords.FieldOrganizationID:
  19999. v, ok := value.(uint64)
  20000. if !ok {
  20001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20002. }
  20003. m.SetOrganizationID(v)
  20004. return nil
  20005. }
  20006. return fmt.Errorf("unknown MessageRecords field %s", name)
  20007. }
  20008. // AddedFields returns all numeric fields that were incremented/decremented during
  20009. // this mutation.
  20010. func (m *MessageRecordsMutation) AddedFields() []string {
  20011. var fields []string
  20012. if m.addstatus != nil {
  20013. fields = append(fields, messagerecords.FieldStatus)
  20014. }
  20015. if m.addcontact_type != nil {
  20016. fields = append(fields, messagerecords.FieldContactType)
  20017. }
  20018. if m.addcontent_type != nil {
  20019. fields = append(fields, messagerecords.FieldContentType)
  20020. }
  20021. if m.addsource_type != nil {
  20022. fields = append(fields, messagerecords.FieldSourceType)
  20023. }
  20024. if m.addorganization_id != nil {
  20025. fields = append(fields, messagerecords.FieldOrganizationID)
  20026. }
  20027. return fields
  20028. }
  20029. // AddedField returns the numeric value that was incremented/decremented on a field
  20030. // with the given name. The second boolean return value indicates that this field
  20031. // was not set, or was not defined in the schema.
  20032. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  20033. switch name {
  20034. case messagerecords.FieldStatus:
  20035. return m.AddedStatus()
  20036. case messagerecords.FieldContactType:
  20037. return m.AddedContactType()
  20038. case messagerecords.FieldContentType:
  20039. return m.AddedContentType()
  20040. case messagerecords.FieldSourceType:
  20041. return m.AddedSourceType()
  20042. case messagerecords.FieldOrganizationID:
  20043. return m.AddedOrganizationID()
  20044. }
  20045. return nil, false
  20046. }
  20047. // AddField adds the value to the field with the given name. It returns an error if
  20048. // the field is not defined in the schema, or if the type mismatched the field
  20049. // type.
  20050. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  20051. switch name {
  20052. case messagerecords.FieldStatus:
  20053. v, ok := value.(int8)
  20054. if !ok {
  20055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20056. }
  20057. m.AddStatus(v)
  20058. return nil
  20059. case messagerecords.FieldContactType:
  20060. v, ok := value.(int)
  20061. if !ok {
  20062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20063. }
  20064. m.AddContactType(v)
  20065. return nil
  20066. case messagerecords.FieldContentType:
  20067. v, ok := value.(int)
  20068. if !ok {
  20069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20070. }
  20071. m.AddContentType(v)
  20072. return nil
  20073. case messagerecords.FieldSourceType:
  20074. v, ok := value.(int)
  20075. if !ok {
  20076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20077. }
  20078. m.AddSourceType(v)
  20079. return nil
  20080. case messagerecords.FieldOrganizationID:
  20081. v, ok := value.(int64)
  20082. if !ok {
  20083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20084. }
  20085. m.AddOrganizationID(v)
  20086. return nil
  20087. }
  20088. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20089. }
  20090. // ClearedFields returns all nullable fields that were cleared during this
  20091. // mutation.
  20092. func (m *MessageRecordsMutation) ClearedFields() []string {
  20093. var fields []string
  20094. if m.FieldCleared(messagerecords.FieldStatus) {
  20095. fields = append(fields, messagerecords.FieldStatus)
  20096. }
  20097. if m.FieldCleared(messagerecords.FieldContactID) {
  20098. fields = append(fields, messagerecords.FieldContactID)
  20099. }
  20100. if m.FieldCleared(messagerecords.FieldMeta) {
  20101. fields = append(fields, messagerecords.FieldMeta)
  20102. }
  20103. if m.FieldCleared(messagerecords.FieldSendTime) {
  20104. fields = append(fields, messagerecords.FieldSendTime)
  20105. }
  20106. if m.FieldCleared(messagerecords.FieldSourceID) {
  20107. fields = append(fields, messagerecords.FieldSourceID)
  20108. }
  20109. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20110. fields = append(fields, messagerecords.FieldSubSourceID)
  20111. }
  20112. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20113. fields = append(fields, messagerecords.FieldOrganizationID)
  20114. }
  20115. return fields
  20116. }
  20117. // FieldCleared returns a boolean indicating if a field with the given name was
  20118. // cleared in this mutation.
  20119. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20120. _, ok := m.clearedFields[name]
  20121. return ok
  20122. }
  20123. // ClearField clears the value of the field with the given name. It returns an
  20124. // error if the field is not defined in the schema.
  20125. func (m *MessageRecordsMutation) ClearField(name string) error {
  20126. switch name {
  20127. case messagerecords.FieldStatus:
  20128. m.ClearStatus()
  20129. return nil
  20130. case messagerecords.FieldContactID:
  20131. m.ClearContactID()
  20132. return nil
  20133. case messagerecords.FieldMeta:
  20134. m.ClearMeta()
  20135. return nil
  20136. case messagerecords.FieldSendTime:
  20137. m.ClearSendTime()
  20138. return nil
  20139. case messagerecords.FieldSourceID:
  20140. m.ClearSourceID()
  20141. return nil
  20142. case messagerecords.FieldSubSourceID:
  20143. m.ClearSubSourceID()
  20144. return nil
  20145. case messagerecords.FieldOrganizationID:
  20146. m.ClearOrganizationID()
  20147. return nil
  20148. }
  20149. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20150. }
  20151. // ResetField resets all changes in the mutation for the field with the given name.
  20152. // It returns an error if the field is not defined in the schema.
  20153. func (m *MessageRecordsMutation) ResetField(name string) error {
  20154. switch name {
  20155. case messagerecords.FieldCreatedAt:
  20156. m.ResetCreatedAt()
  20157. return nil
  20158. case messagerecords.FieldUpdatedAt:
  20159. m.ResetUpdatedAt()
  20160. return nil
  20161. case messagerecords.FieldStatus:
  20162. m.ResetStatus()
  20163. return nil
  20164. case messagerecords.FieldBotWxid:
  20165. m.ResetBotWxid()
  20166. return nil
  20167. case messagerecords.FieldContactID:
  20168. m.ResetContactID()
  20169. return nil
  20170. case messagerecords.FieldContactType:
  20171. m.ResetContactType()
  20172. return nil
  20173. case messagerecords.FieldContactWxid:
  20174. m.ResetContactWxid()
  20175. return nil
  20176. case messagerecords.FieldContentType:
  20177. m.ResetContentType()
  20178. return nil
  20179. case messagerecords.FieldContent:
  20180. m.ResetContent()
  20181. return nil
  20182. case messagerecords.FieldMeta:
  20183. m.ResetMeta()
  20184. return nil
  20185. case messagerecords.FieldErrorDetail:
  20186. m.ResetErrorDetail()
  20187. return nil
  20188. case messagerecords.FieldSendTime:
  20189. m.ResetSendTime()
  20190. return nil
  20191. case messagerecords.FieldSourceType:
  20192. m.ResetSourceType()
  20193. return nil
  20194. case messagerecords.FieldSourceID:
  20195. m.ResetSourceID()
  20196. return nil
  20197. case messagerecords.FieldSubSourceID:
  20198. m.ResetSubSourceID()
  20199. return nil
  20200. case messagerecords.FieldOrganizationID:
  20201. m.ResetOrganizationID()
  20202. return nil
  20203. }
  20204. return fmt.Errorf("unknown MessageRecords field %s", name)
  20205. }
  20206. // AddedEdges returns all edge names that were set/added in this mutation.
  20207. func (m *MessageRecordsMutation) AddedEdges() []string {
  20208. edges := make([]string, 0, 3)
  20209. if m.sop_stage != nil {
  20210. edges = append(edges, messagerecords.EdgeSopStage)
  20211. }
  20212. if m.sop_node != nil {
  20213. edges = append(edges, messagerecords.EdgeSopNode)
  20214. }
  20215. if m.message_contact != nil {
  20216. edges = append(edges, messagerecords.EdgeMessageContact)
  20217. }
  20218. return edges
  20219. }
  20220. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20221. // name in this mutation.
  20222. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20223. switch name {
  20224. case messagerecords.EdgeSopStage:
  20225. if id := m.sop_stage; id != nil {
  20226. return []ent.Value{*id}
  20227. }
  20228. case messagerecords.EdgeSopNode:
  20229. if id := m.sop_node; id != nil {
  20230. return []ent.Value{*id}
  20231. }
  20232. case messagerecords.EdgeMessageContact:
  20233. if id := m.message_contact; id != nil {
  20234. return []ent.Value{*id}
  20235. }
  20236. }
  20237. return nil
  20238. }
  20239. // RemovedEdges returns all edge names that were removed in this mutation.
  20240. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20241. edges := make([]string, 0, 3)
  20242. return edges
  20243. }
  20244. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20245. // the given name in this mutation.
  20246. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20247. return nil
  20248. }
  20249. // ClearedEdges returns all edge names that were cleared in this mutation.
  20250. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20251. edges := make([]string, 0, 3)
  20252. if m.clearedsop_stage {
  20253. edges = append(edges, messagerecords.EdgeSopStage)
  20254. }
  20255. if m.clearedsop_node {
  20256. edges = append(edges, messagerecords.EdgeSopNode)
  20257. }
  20258. if m.clearedmessage_contact {
  20259. edges = append(edges, messagerecords.EdgeMessageContact)
  20260. }
  20261. return edges
  20262. }
  20263. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20264. // was cleared in this mutation.
  20265. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20266. switch name {
  20267. case messagerecords.EdgeSopStage:
  20268. return m.clearedsop_stage
  20269. case messagerecords.EdgeSopNode:
  20270. return m.clearedsop_node
  20271. case messagerecords.EdgeMessageContact:
  20272. return m.clearedmessage_contact
  20273. }
  20274. return false
  20275. }
  20276. // ClearEdge clears the value of the edge with the given name. It returns an error
  20277. // if that edge is not defined in the schema.
  20278. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20279. switch name {
  20280. case messagerecords.EdgeSopStage:
  20281. m.ClearSopStage()
  20282. return nil
  20283. case messagerecords.EdgeSopNode:
  20284. m.ClearSopNode()
  20285. return nil
  20286. case messagerecords.EdgeMessageContact:
  20287. m.ClearMessageContact()
  20288. return nil
  20289. }
  20290. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20291. }
  20292. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20293. // It returns an error if the edge is not defined in the schema.
  20294. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20295. switch name {
  20296. case messagerecords.EdgeSopStage:
  20297. m.ResetSopStage()
  20298. return nil
  20299. case messagerecords.EdgeSopNode:
  20300. m.ResetSopNode()
  20301. return nil
  20302. case messagerecords.EdgeMessageContact:
  20303. m.ResetMessageContact()
  20304. return nil
  20305. }
  20306. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20307. }
  20308. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20309. type MsgMutation struct {
  20310. config
  20311. op Op
  20312. typ string
  20313. id *uint64
  20314. created_at *time.Time
  20315. updated_at *time.Time
  20316. deleted_at *time.Time
  20317. status *uint8
  20318. addstatus *int8
  20319. fromwxid *string
  20320. toid *string
  20321. msgtype *int32
  20322. addmsgtype *int32
  20323. msg *string
  20324. batch_no *string
  20325. cc *string
  20326. phone *string
  20327. clearedFields map[string]struct{}
  20328. done bool
  20329. oldValue func(context.Context) (*Msg, error)
  20330. predicates []predicate.Msg
  20331. }
  20332. var _ ent.Mutation = (*MsgMutation)(nil)
  20333. // msgOption allows management of the mutation configuration using functional options.
  20334. type msgOption func(*MsgMutation)
  20335. // newMsgMutation creates new mutation for the Msg entity.
  20336. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20337. m := &MsgMutation{
  20338. config: c,
  20339. op: op,
  20340. typ: TypeMsg,
  20341. clearedFields: make(map[string]struct{}),
  20342. }
  20343. for _, opt := range opts {
  20344. opt(m)
  20345. }
  20346. return m
  20347. }
  20348. // withMsgID sets the ID field of the mutation.
  20349. func withMsgID(id uint64) msgOption {
  20350. return func(m *MsgMutation) {
  20351. var (
  20352. err error
  20353. once sync.Once
  20354. value *Msg
  20355. )
  20356. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20357. once.Do(func() {
  20358. if m.done {
  20359. err = errors.New("querying old values post mutation is not allowed")
  20360. } else {
  20361. value, err = m.Client().Msg.Get(ctx, id)
  20362. }
  20363. })
  20364. return value, err
  20365. }
  20366. m.id = &id
  20367. }
  20368. }
  20369. // withMsg sets the old Msg of the mutation.
  20370. func withMsg(node *Msg) msgOption {
  20371. return func(m *MsgMutation) {
  20372. m.oldValue = func(context.Context) (*Msg, error) {
  20373. return node, nil
  20374. }
  20375. m.id = &node.ID
  20376. }
  20377. }
  20378. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20379. // executed in a transaction (ent.Tx), a transactional client is returned.
  20380. func (m MsgMutation) Client() *Client {
  20381. client := &Client{config: m.config}
  20382. client.init()
  20383. return client
  20384. }
  20385. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20386. // it returns an error otherwise.
  20387. func (m MsgMutation) Tx() (*Tx, error) {
  20388. if _, ok := m.driver.(*txDriver); !ok {
  20389. return nil, errors.New("ent: mutation is not running in a transaction")
  20390. }
  20391. tx := &Tx{config: m.config}
  20392. tx.init()
  20393. return tx, nil
  20394. }
  20395. // SetID sets the value of the id field. Note that this
  20396. // operation is only accepted on creation of Msg entities.
  20397. func (m *MsgMutation) SetID(id uint64) {
  20398. m.id = &id
  20399. }
  20400. // ID returns the ID value in the mutation. Note that the ID is only available
  20401. // if it was provided to the builder or after it was returned from the database.
  20402. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20403. if m.id == nil {
  20404. return
  20405. }
  20406. return *m.id, true
  20407. }
  20408. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20409. // That means, if the mutation is applied within a transaction with an isolation level such
  20410. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20411. // or updated by the mutation.
  20412. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20413. switch {
  20414. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20415. id, exists := m.ID()
  20416. if exists {
  20417. return []uint64{id}, nil
  20418. }
  20419. fallthrough
  20420. case m.op.Is(OpUpdate | OpDelete):
  20421. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20422. default:
  20423. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20424. }
  20425. }
  20426. // SetCreatedAt sets the "created_at" field.
  20427. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20428. m.created_at = &t
  20429. }
  20430. // CreatedAt returns the value of the "created_at" field in the mutation.
  20431. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20432. v := m.created_at
  20433. if v == nil {
  20434. return
  20435. }
  20436. return *v, true
  20437. }
  20438. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20439. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20441. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20442. if !m.op.Is(OpUpdateOne) {
  20443. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20444. }
  20445. if m.id == nil || m.oldValue == nil {
  20446. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20447. }
  20448. oldValue, err := m.oldValue(ctx)
  20449. if err != nil {
  20450. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20451. }
  20452. return oldValue.CreatedAt, nil
  20453. }
  20454. // ResetCreatedAt resets all changes to the "created_at" field.
  20455. func (m *MsgMutation) ResetCreatedAt() {
  20456. m.created_at = nil
  20457. }
  20458. // SetUpdatedAt sets the "updated_at" field.
  20459. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20460. m.updated_at = &t
  20461. }
  20462. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20463. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20464. v := m.updated_at
  20465. if v == nil {
  20466. return
  20467. }
  20468. return *v, true
  20469. }
  20470. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20471. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20473. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20474. if !m.op.Is(OpUpdateOne) {
  20475. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20476. }
  20477. if m.id == nil || m.oldValue == nil {
  20478. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20479. }
  20480. oldValue, err := m.oldValue(ctx)
  20481. if err != nil {
  20482. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20483. }
  20484. return oldValue.UpdatedAt, nil
  20485. }
  20486. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20487. func (m *MsgMutation) ResetUpdatedAt() {
  20488. m.updated_at = nil
  20489. }
  20490. // SetDeletedAt sets the "deleted_at" field.
  20491. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20492. m.deleted_at = &t
  20493. }
  20494. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20495. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20496. v := m.deleted_at
  20497. if v == nil {
  20498. return
  20499. }
  20500. return *v, true
  20501. }
  20502. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20503. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20505. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20506. if !m.op.Is(OpUpdateOne) {
  20507. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20508. }
  20509. if m.id == nil || m.oldValue == nil {
  20510. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20511. }
  20512. oldValue, err := m.oldValue(ctx)
  20513. if err != nil {
  20514. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20515. }
  20516. return oldValue.DeletedAt, nil
  20517. }
  20518. // ClearDeletedAt clears the value of the "deleted_at" field.
  20519. func (m *MsgMutation) ClearDeletedAt() {
  20520. m.deleted_at = nil
  20521. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20522. }
  20523. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20524. func (m *MsgMutation) DeletedAtCleared() bool {
  20525. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20526. return ok
  20527. }
  20528. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20529. func (m *MsgMutation) ResetDeletedAt() {
  20530. m.deleted_at = nil
  20531. delete(m.clearedFields, msg.FieldDeletedAt)
  20532. }
  20533. // SetStatus sets the "status" field.
  20534. func (m *MsgMutation) SetStatus(u uint8) {
  20535. m.status = &u
  20536. m.addstatus = nil
  20537. }
  20538. // Status returns the value of the "status" field in the mutation.
  20539. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20540. v := m.status
  20541. if v == nil {
  20542. return
  20543. }
  20544. return *v, true
  20545. }
  20546. // OldStatus returns the old "status" field's value of the Msg entity.
  20547. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20549. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20550. if !m.op.Is(OpUpdateOne) {
  20551. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20552. }
  20553. if m.id == nil || m.oldValue == nil {
  20554. return v, errors.New("OldStatus requires an ID field in the mutation")
  20555. }
  20556. oldValue, err := m.oldValue(ctx)
  20557. if err != nil {
  20558. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20559. }
  20560. return oldValue.Status, nil
  20561. }
  20562. // AddStatus adds u to the "status" field.
  20563. func (m *MsgMutation) AddStatus(u int8) {
  20564. if m.addstatus != nil {
  20565. *m.addstatus += u
  20566. } else {
  20567. m.addstatus = &u
  20568. }
  20569. }
  20570. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20571. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20572. v := m.addstatus
  20573. if v == nil {
  20574. return
  20575. }
  20576. return *v, true
  20577. }
  20578. // ClearStatus clears the value of the "status" field.
  20579. func (m *MsgMutation) ClearStatus() {
  20580. m.status = nil
  20581. m.addstatus = nil
  20582. m.clearedFields[msg.FieldStatus] = struct{}{}
  20583. }
  20584. // StatusCleared returns if the "status" field was cleared in this mutation.
  20585. func (m *MsgMutation) StatusCleared() bool {
  20586. _, ok := m.clearedFields[msg.FieldStatus]
  20587. return ok
  20588. }
  20589. // ResetStatus resets all changes to the "status" field.
  20590. func (m *MsgMutation) ResetStatus() {
  20591. m.status = nil
  20592. m.addstatus = nil
  20593. delete(m.clearedFields, msg.FieldStatus)
  20594. }
  20595. // SetFromwxid sets the "fromwxid" field.
  20596. func (m *MsgMutation) SetFromwxid(s string) {
  20597. m.fromwxid = &s
  20598. }
  20599. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20600. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20601. v := m.fromwxid
  20602. if v == nil {
  20603. return
  20604. }
  20605. return *v, true
  20606. }
  20607. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20608. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20610. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20611. if !m.op.Is(OpUpdateOne) {
  20612. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20613. }
  20614. if m.id == nil || m.oldValue == nil {
  20615. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20616. }
  20617. oldValue, err := m.oldValue(ctx)
  20618. if err != nil {
  20619. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20620. }
  20621. return oldValue.Fromwxid, nil
  20622. }
  20623. // ClearFromwxid clears the value of the "fromwxid" field.
  20624. func (m *MsgMutation) ClearFromwxid() {
  20625. m.fromwxid = nil
  20626. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20627. }
  20628. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20629. func (m *MsgMutation) FromwxidCleared() bool {
  20630. _, ok := m.clearedFields[msg.FieldFromwxid]
  20631. return ok
  20632. }
  20633. // ResetFromwxid resets all changes to the "fromwxid" field.
  20634. func (m *MsgMutation) ResetFromwxid() {
  20635. m.fromwxid = nil
  20636. delete(m.clearedFields, msg.FieldFromwxid)
  20637. }
  20638. // SetToid sets the "toid" field.
  20639. func (m *MsgMutation) SetToid(s string) {
  20640. m.toid = &s
  20641. }
  20642. // Toid returns the value of the "toid" field in the mutation.
  20643. func (m *MsgMutation) Toid() (r string, exists bool) {
  20644. v := m.toid
  20645. if v == nil {
  20646. return
  20647. }
  20648. return *v, true
  20649. }
  20650. // OldToid returns the old "toid" field's value of the Msg entity.
  20651. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20653. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  20654. if !m.op.Is(OpUpdateOne) {
  20655. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  20656. }
  20657. if m.id == nil || m.oldValue == nil {
  20658. return v, errors.New("OldToid requires an ID field in the mutation")
  20659. }
  20660. oldValue, err := m.oldValue(ctx)
  20661. if err != nil {
  20662. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  20663. }
  20664. return oldValue.Toid, nil
  20665. }
  20666. // ClearToid clears the value of the "toid" field.
  20667. func (m *MsgMutation) ClearToid() {
  20668. m.toid = nil
  20669. m.clearedFields[msg.FieldToid] = struct{}{}
  20670. }
  20671. // ToidCleared returns if the "toid" field was cleared in this mutation.
  20672. func (m *MsgMutation) ToidCleared() bool {
  20673. _, ok := m.clearedFields[msg.FieldToid]
  20674. return ok
  20675. }
  20676. // ResetToid resets all changes to the "toid" field.
  20677. func (m *MsgMutation) ResetToid() {
  20678. m.toid = nil
  20679. delete(m.clearedFields, msg.FieldToid)
  20680. }
  20681. // SetMsgtype sets the "msgtype" field.
  20682. func (m *MsgMutation) SetMsgtype(i int32) {
  20683. m.msgtype = &i
  20684. m.addmsgtype = nil
  20685. }
  20686. // Msgtype returns the value of the "msgtype" field in the mutation.
  20687. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  20688. v := m.msgtype
  20689. if v == nil {
  20690. return
  20691. }
  20692. return *v, true
  20693. }
  20694. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  20695. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20697. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  20698. if !m.op.Is(OpUpdateOne) {
  20699. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  20700. }
  20701. if m.id == nil || m.oldValue == nil {
  20702. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  20703. }
  20704. oldValue, err := m.oldValue(ctx)
  20705. if err != nil {
  20706. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  20707. }
  20708. return oldValue.Msgtype, nil
  20709. }
  20710. // AddMsgtype adds i to the "msgtype" field.
  20711. func (m *MsgMutation) AddMsgtype(i int32) {
  20712. if m.addmsgtype != nil {
  20713. *m.addmsgtype += i
  20714. } else {
  20715. m.addmsgtype = &i
  20716. }
  20717. }
  20718. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  20719. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  20720. v := m.addmsgtype
  20721. if v == nil {
  20722. return
  20723. }
  20724. return *v, true
  20725. }
  20726. // ClearMsgtype clears the value of the "msgtype" field.
  20727. func (m *MsgMutation) ClearMsgtype() {
  20728. m.msgtype = nil
  20729. m.addmsgtype = nil
  20730. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  20731. }
  20732. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  20733. func (m *MsgMutation) MsgtypeCleared() bool {
  20734. _, ok := m.clearedFields[msg.FieldMsgtype]
  20735. return ok
  20736. }
  20737. // ResetMsgtype resets all changes to the "msgtype" field.
  20738. func (m *MsgMutation) ResetMsgtype() {
  20739. m.msgtype = nil
  20740. m.addmsgtype = nil
  20741. delete(m.clearedFields, msg.FieldMsgtype)
  20742. }
  20743. // SetMsg sets the "msg" field.
  20744. func (m *MsgMutation) SetMsg(s string) {
  20745. m.msg = &s
  20746. }
  20747. // Msg returns the value of the "msg" field in the mutation.
  20748. func (m *MsgMutation) Msg() (r string, exists bool) {
  20749. v := m.msg
  20750. if v == nil {
  20751. return
  20752. }
  20753. return *v, true
  20754. }
  20755. // OldMsg returns the old "msg" field's value of the Msg entity.
  20756. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20758. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  20759. if !m.op.Is(OpUpdateOne) {
  20760. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  20761. }
  20762. if m.id == nil || m.oldValue == nil {
  20763. return v, errors.New("OldMsg requires an ID field in the mutation")
  20764. }
  20765. oldValue, err := m.oldValue(ctx)
  20766. if err != nil {
  20767. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  20768. }
  20769. return oldValue.Msg, nil
  20770. }
  20771. // ClearMsg clears the value of the "msg" field.
  20772. func (m *MsgMutation) ClearMsg() {
  20773. m.msg = nil
  20774. m.clearedFields[msg.FieldMsg] = struct{}{}
  20775. }
  20776. // MsgCleared returns if the "msg" field was cleared in this mutation.
  20777. func (m *MsgMutation) MsgCleared() bool {
  20778. _, ok := m.clearedFields[msg.FieldMsg]
  20779. return ok
  20780. }
  20781. // ResetMsg resets all changes to the "msg" field.
  20782. func (m *MsgMutation) ResetMsg() {
  20783. m.msg = nil
  20784. delete(m.clearedFields, msg.FieldMsg)
  20785. }
  20786. // SetBatchNo sets the "batch_no" field.
  20787. func (m *MsgMutation) SetBatchNo(s string) {
  20788. m.batch_no = &s
  20789. }
  20790. // BatchNo returns the value of the "batch_no" field in the mutation.
  20791. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  20792. v := m.batch_no
  20793. if v == nil {
  20794. return
  20795. }
  20796. return *v, true
  20797. }
  20798. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  20799. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20801. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  20802. if !m.op.Is(OpUpdateOne) {
  20803. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  20804. }
  20805. if m.id == nil || m.oldValue == nil {
  20806. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  20807. }
  20808. oldValue, err := m.oldValue(ctx)
  20809. if err != nil {
  20810. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  20811. }
  20812. return oldValue.BatchNo, nil
  20813. }
  20814. // ClearBatchNo clears the value of the "batch_no" field.
  20815. func (m *MsgMutation) ClearBatchNo() {
  20816. m.batch_no = nil
  20817. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  20818. }
  20819. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  20820. func (m *MsgMutation) BatchNoCleared() bool {
  20821. _, ok := m.clearedFields[msg.FieldBatchNo]
  20822. return ok
  20823. }
  20824. // ResetBatchNo resets all changes to the "batch_no" field.
  20825. func (m *MsgMutation) ResetBatchNo() {
  20826. m.batch_no = nil
  20827. delete(m.clearedFields, msg.FieldBatchNo)
  20828. }
  20829. // SetCc sets the "cc" field.
  20830. func (m *MsgMutation) SetCc(s string) {
  20831. m.cc = &s
  20832. }
  20833. // Cc returns the value of the "cc" field in the mutation.
  20834. func (m *MsgMutation) Cc() (r string, exists bool) {
  20835. v := m.cc
  20836. if v == nil {
  20837. return
  20838. }
  20839. return *v, true
  20840. }
  20841. // OldCc returns the old "cc" field's value of the Msg entity.
  20842. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20844. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  20845. if !m.op.Is(OpUpdateOne) {
  20846. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  20847. }
  20848. if m.id == nil || m.oldValue == nil {
  20849. return v, errors.New("OldCc requires an ID field in the mutation")
  20850. }
  20851. oldValue, err := m.oldValue(ctx)
  20852. if err != nil {
  20853. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  20854. }
  20855. return oldValue.Cc, nil
  20856. }
  20857. // ResetCc resets all changes to the "cc" field.
  20858. func (m *MsgMutation) ResetCc() {
  20859. m.cc = nil
  20860. }
  20861. // SetPhone sets the "phone" field.
  20862. func (m *MsgMutation) SetPhone(s string) {
  20863. m.phone = &s
  20864. }
  20865. // Phone returns the value of the "phone" field in the mutation.
  20866. func (m *MsgMutation) Phone() (r string, exists bool) {
  20867. v := m.phone
  20868. if v == nil {
  20869. return
  20870. }
  20871. return *v, true
  20872. }
  20873. // OldPhone returns the old "phone" field's value of the Msg entity.
  20874. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20876. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  20877. if !m.op.Is(OpUpdateOne) {
  20878. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  20879. }
  20880. if m.id == nil || m.oldValue == nil {
  20881. return v, errors.New("OldPhone requires an ID field in the mutation")
  20882. }
  20883. oldValue, err := m.oldValue(ctx)
  20884. if err != nil {
  20885. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  20886. }
  20887. return oldValue.Phone, nil
  20888. }
  20889. // ResetPhone resets all changes to the "phone" field.
  20890. func (m *MsgMutation) ResetPhone() {
  20891. m.phone = nil
  20892. }
  20893. // Where appends a list predicates to the MsgMutation builder.
  20894. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  20895. m.predicates = append(m.predicates, ps...)
  20896. }
  20897. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  20898. // users can use type-assertion to append predicates that do not depend on any generated package.
  20899. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  20900. p := make([]predicate.Msg, len(ps))
  20901. for i := range ps {
  20902. p[i] = ps[i]
  20903. }
  20904. m.Where(p...)
  20905. }
  20906. // Op returns the operation name.
  20907. func (m *MsgMutation) Op() Op {
  20908. return m.op
  20909. }
  20910. // SetOp allows setting the mutation operation.
  20911. func (m *MsgMutation) SetOp(op Op) {
  20912. m.op = op
  20913. }
  20914. // Type returns the node type of this mutation (Msg).
  20915. func (m *MsgMutation) Type() string {
  20916. return m.typ
  20917. }
  20918. // Fields returns all fields that were changed during this mutation. Note that in
  20919. // order to get all numeric fields that were incremented/decremented, call
  20920. // AddedFields().
  20921. func (m *MsgMutation) Fields() []string {
  20922. fields := make([]string, 0, 11)
  20923. if m.created_at != nil {
  20924. fields = append(fields, msg.FieldCreatedAt)
  20925. }
  20926. if m.updated_at != nil {
  20927. fields = append(fields, msg.FieldUpdatedAt)
  20928. }
  20929. if m.deleted_at != nil {
  20930. fields = append(fields, msg.FieldDeletedAt)
  20931. }
  20932. if m.status != nil {
  20933. fields = append(fields, msg.FieldStatus)
  20934. }
  20935. if m.fromwxid != nil {
  20936. fields = append(fields, msg.FieldFromwxid)
  20937. }
  20938. if m.toid != nil {
  20939. fields = append(fields, msg.FieldToid)
  20940. }
  20941. if m.msgtype != nil {
  20942. fields = append(fields, msg.FieldMsgtype)
  20943. }
  20944. if m.msg != nil {
  20945. fields = append(fields, msg.FieldMsg)
  20946. }
  20947. if m.batch_no != nil {
  20948. fields = append(fields, msg.FieldBatchNo)
  20949. }
  20950. if m.cc != nil {
  20951. fields = append(fields, msg.FieldCc)
  20952. }
  20953. if m.phone != nil {
  20954. fields = append(fields, msg.FieldPhone)
  20955. }
  20956. return fields
  20957. }
  20958. // Field returns the value of a field with the given name. The second boolean
  20959. // return value indicates that this field was not set, or was not defined in the
  20960. // schema.
  20961. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  20962. switch name {
  20963. case msg.FieldCreatedAt:
  20964. return m.CreatedAt()
  20965. case msg.FieldUpdatedAt:
  20966. return m.UpdatedAt()
  20967. case msg.FieldDeletedAt:
  20968. return m.DeletedAt()
  20969. case msg.FieldStatus:
  20970. return m.Status()
  20971. case msg.FieldFromwxid:
  20972. return m.Fromwxid()
  20973. case msg.FieldToid:
  20974. return m.Toid()
  20975. case msg.FieldMsgtype:
  20976. return m.Msgtype()
  20977. case msg.FieldMsg:
  20978. return m.Msg()
  20979. case msg.FieldBatchNo:
  20980. return m.BatchNo()
  20981. case msg.FieldCc:
  20982. return m.Cc()
  20983. case msg.FieldPhone:
  20984. return m.Phone()
  20985. }
  20986. return nil, false
  20987. }
  20988. // OldField returns the old value of the field from the database. An error is
  20989. // returned if the mutation operation is not UpdateOne, or the query to the
  20990. // database failed.
  20991. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20992. switch name {
  20993. case msg.FieldCreatedAt:
  20994. return m.OldCreatedAt(ctx)
  20995. case msg.FieldUpdatedAt:
  20996. return m.OldUpdatedAt(ctx)
  20997. case msg.FieldDeletedAt:
  20998. return m.OldDeletedAt(ctx)
  20999. case msg.FieldStatus:
  21000. return m.OldStatus(ctx)
  21001. case msg.FieldFromwxid:
  21002. return m.OldFromwxid(ctx)
  21003. case msg.FieldToid:
  21004. return m.OldToid(ctx)
  21005. case msg.FieldMsgtype:
  21006. return m.OldMsgtype(ctx)
  21007. case msg.FieldMsg:
  21008. return m.OldMsg(ctx)
  21009. case msg.FieldBatchNo:
  21010. return m.OldBatchNo(ctx)
  21011. case msg.FieldCc:
  21012. return m.OldCc(ctx)
  21013. case msg.FieldPhone:
  21014. return m.OldPhone(ctx)
  21015. }
  21016. return nil, fmt.Errorf("unknown Msg field %s", name)
  21017. }
  21018. // SetField sets the value of a field with the given name. It returns an error if
  21019. // the field is not defined in the schema, or if the type mismatched the field
  21020. // type.
  21021. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  21022. switch name {
  21023. case msg.FieldCreatedAt:
  21024. v, ok := value.(time.Time)
  21025. if !ok {
  21026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21027. }
  21028. m.SetCreatedAt(v)
  21029. return nil
  21030. case msg.FieldUpdatedAt:
  21031. v, ok := value.(time.Time)
  21032. if !ok {
  21033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21034. }
  21035. m.SetUpdatedAt(v)
  21036. return nil
  21037. case msg.FieldDeletedAt:
  21038. v, ok := value.(time.Time)
  21039. if !ok {
  21040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21041. }
  21042. m.SetDeletedAt(v)
  21043. return nil
  21044. case msg.FieldStatus:
  21045. v, ok := value.(uint8)
  21046. if !ok {
  21047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21048. }
  21049. m.SetStatus(v)
  21050. return nil
  21051. case msg.FieldFromwxid:
  21052. v, ok := value.(string)
  21053. if !ok {
  21054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21055. }
  21056. m.SetFromwxid(v)
  21057. return nil
  21058. case msg.FieldToid:
  21059. v, ok := value.(string)
  21060. if !ok {
  21061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21062. }
  21063. m.SetToid(v)
  21064. return nil
  21065. case msg.FieldMsgtype:
  21066. v, ok := value.(int32)
  21067. if !ok {
  21068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21069. }
  21070. m.SetMsgtype(v)
  21071. return nil
  21072. case msg.FieldMsg:
  21073. v, ok := value.(string)
  21074. if !ok {
  21075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21076. }
  21077. m.SetMsg(v)
  21078. return nil
  21079. case msg.FieldBatchNo:
  21080. v, ok := value.(string)
  21081. if !ok {
  21082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21083. }
  21084. m.SetBatchNo(v)
  21085. return nil
  21086. case msg.FieldCc:
  21087. v, ok := value.(string)
  21088. if !ok {
  21089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21090. }
  21091. m.SetCc(v)
  21092. return nil
  21093. case msg.FieldPhone:
  21094. v, ok := value.(string)
  21095. if !ok {
  21096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21097. }
  21098. m.SetPhone(v)
  21099. return nil
  21100. }
  21101. return fmt.Errorf("unknown Msg field %s", name)
  21102. }
  21103. // AddedFields returns all numeric fields that were incremented/decremented during
  21104. // this mutation.
  21105. func (m *MsgMutation) AddedFields() []string {
  21106. var fields []string
  21107. if m.addstatus != nil {
  21108. fields = append(fields, msg.FieldStatus)
  21109. }
  21110. if m.addmsgtype != nil {
  21111. fields = append(fields, msg.FieldMsgtype)
  21112. }
  21113. return fields
  21114. }
  21115. // AddedField returns the numeric value that was incremented/decremented on a field
  21116. // with the given name. The second boolean return value indicates that this field
  21117. // was not set, or was not defined in the schema.
  21118. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21119. switch name {
  21120. case msg.FieldStatus:
  21121. return m.AddedStatus()
  21122. case msg.FieldMsgtype:
  21123. return m.AddedMsgtype()
  21124. }
  21125. return nil, false
  21126. }
  21127. // AddField adds the value to the field with the given name. It returns an error if
  21128. // the field is not defined in the schema, or if the type mismatched the field
  21129. // type.
  21130. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21131. switch name {
  21132. case msg.FieldStatus:
  21133. v, ok := value.(int8)
  21134. if !ok {
  21135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21136. }
  21137. m.AddStatus(v)
  21138. return nil
  21139. case msg.FieldMsgtype:
  21140. v, ok := value.(int32)
  21141. if !ok {
  21142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21143. }
  21144. m.AddMsgtype(v)
  21145. return nil
  21146. }
  21147. return fmt.Errorf("unknown Msg numeric field %s", name)
  21148. }
  21149. // ClearedFields returns all nullable fields that were cleared during this
  21150. // mutation.
  21151. func (m *MsgMutation) ClearedFields() []string {
  21152. var fields []string
  21153. if m.FieldCleared(msg.FieldDeletedAt) {
  21154. fields = append(fields, msg.FieldDeletedAt)
  21155. }
  21156. if m.FieldCleared(msg.FieldStatus) {
  21157. fields = append(fields, msg.FieldStatus)
  21158. }
  21159. if m.FieldCleared(msg.FieldFromwxid) {
  21160. fields = append(fields, msg.FieldFromwxid)
  21161. }
  21162. if m.FieldCleared(msg.FieldToid) {
  21163. fields = append(fields, msg.FieldToid)
  21164. }
  21165. if m.FieldCleared(msg.FieldMsgtype) {
  21166. fields = append(fields, msg.FieldMsgtype)
  21167. }
  21168. if m.FieldCleared(msg.FieldMsg) {
  21169. fields = append(fields, msg.FieldMsg)
  21170. }
  21171. if m.FieldCleared(msg.FieldBatchNo) {
  21172. fields = append(fields, msg.FieldBatchNo)
  21173. }
  21174. return fields
  21175. }
  21176. // FieldCleared returns a boolean indicating if a field with the given name was
  21177. // cleared in this mutation.
  21178. func (m *MsgMutation) FieldCleared(name string) bool {
  21179. _, ok := m.clearedFields[name]
  21180. return ok
  21181. }
  21182. // ClearField clears the value of the field with the given name. It returns an
  21183. // error if the field is not defined in the schema.
  21184. func (m *MsgMutation) ClearField(name string) error {
  21185. switch name {
  21186. case msg.FieldDeletedAt:
  21187. m.ClearDeletedAt()
  21188. return nil
  21189. case msg.FieldStatus:
  21190. m.ClearStatus()
  21191. return nil
  21192. case msg.FieldFromwxid:
  21193. m.ClearFromwxid()
  21194. return nil
  21195. case msg.FieldToid:
  21196. m.ClearToid()
  21197. return nil
  21198. case msg.FieldMsgtype:
  21199. m.ClearMsgtype()
  21200. return nil
  21201. case msg.FieldMsg:
  21202. m.ClearMsg()
  21203. return nil
  21204. case msg.FieldBatchNo:
  21205. m.ClearBatchNo()
  21206. return nil
  21207. }
  21208. return fmt.Errorf("unknown Msg nullable field %s", name)
  21209. }
  21210. // ResetField resets all changes in the mutation for the field with the given name.
  21211. // It returns an error if the field is not defined in the schema.
  21212. func (m *MsgMutation) ResetField(name string) error {
  21213. switch name {
  21214. case msg.FieldCreatedAt:
  21215. m.ResetCreatedAt()
  21216. return nil
  21217. case msg.FieldUpdatedAt:
  21218. m.ResetUpdatedAt()
  21219. return nil
  21220. case msg.FieldDeletedAt:
  21221. m.ResetDeletedAt()
  21222. return nil
  21223. case msg.FieldStatus:
  21224. m.ResetStatus()
  21225. return nil
  21226. case msg.FieldFromwxid:
  21227. m.ResetFromwxid()
  21228. return nil
  21229. case msg.FieldToid:
  21230. m.ResetToid()
  21231. return nil
  21232. case msg.FieldMsgtype:
  21233. m.ResetMsgtype()
  21234. return nil
  21235. case msg.FieldMsg:
  21236. m.ResetMsg()
  21237. return nil
  21238. case msg.FieldBatchNo:
  21239. m.ResetBatchNo()
  21240. return nil
  21241. case msg.FieldCc:
  21242. m.ResetCc()
  21243. return nil
  21244. case msg.FieldPhone:
  21245. m.ResetPhone()
  21246. return nil
  21247. }
  21248. return fmt.Errorf("unknown Msg field %s", name)
  21249. }
  21250. // AddedEdges returns all edge names that were set/added in this mutation.
  21251. func (m *MsgMutation) AddedEdges() []string {
  21252. edges := make([]string, 0, 0)
  21253. return edges
  21254. }
  21255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21256. // name in this mutation.
  21257. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21258. return nil
  21259. }
  21260. // RemovedEdges returns all edge names that were removed in this mutation.
  21261. func (m *MsgMutation) RemovedEdges() []string {
  21262. edges := make([]string, 0, 0)
  21263. return edges
  21264. }
  21265. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21266. // the given name in this mutation.
  21267. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21268. return nil
  21269. }
  21270. // ClearedEdges returns all edge names that were cleared in this mutation.
  21271. func (m *MsgMutation) ClearedEdges() []string {
  21272. edges := make([]string, 0, 0)
  21273. return edges
  21274. }
  21275. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21276. // was cleared in this mutation.
  21277. func (m *MsgMutation) EdgeCleared(name string) bool {
  21278. return false
  21279. }
  21280. // ClearEdge clears the value of the edge with the given name. It returns an error
  21281. // if that edge is not defined in the schema.
  21282. func (m *MsgMutation) ClearEdge(name string) error {
  21283. return fmt.Errorf("unknown Msg unique edge %s", name)
  21284. }
  21285. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21286. // It returns an error if the edge is not defined in the schema.
  21287. func (m *MsgMutation) ResetEdge(name string) error {
  21288. return fmt.Errorf("unknown Msg edge %s", name)
  21289. }
  21290. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21291. type PayRechargeMutation struct {
  21292. config
  21293. op Op
  21294. typ string
  21295. id *uint64
  21296. created_at *time.Time
  21297. updated_at *time.Time
  21298. deleted_at *time.Time
  21299. user_id *string
  21300. number *float32
  21301. addnumber *float32
  21302. status *int
  21303. addstatus *int
  21304. money *float32
  21305. addmoney *float32
  21306. out_trade_no *string
  21307. organization_id *uint64
  21308. addorganization_id *int64
  21309. clearedFields map[string]struct{}
  21310. done bool
  21311. oldValue func(context.Context) (*PayRecharge, error)
  21312. predicates []predicate.PayRecharge
  21313. }
  21314. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21315. // payrechargeOption allows management of the mutation configuration using functional options.
  21316. type payrechargeOption func(*PayRechargeMutation)
  21317. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21318. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21319. m := &PayRechargeMutation{
  21320. config: c,
  21321. op: op,
  21322. typ: TypePayRecharge,
  21323. clearedFields: make(map[string]struct{}),
  21324. }
  21325. for _, opt := range opts {
  21326. opt(m)
  21327. }
  21328. return m
  21329. }
  21330. // withPayRechargeID sets the ID field of the mutation.
  21331. func withPayRechargeID(id uint64) payrechargeOption {
  21332. return func(m *PayRechargeMutation) {
  21333. var (
  21334. err error
  21335. once sync.Once
  21336. value *PayRecharge
  21337. )
  21338. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21339. once.Do(func() {
  21340. if m.done {
  21341. err = errors.New("querying old values post mutation is not allowed")
  21342. } else {
  21343. value, err = m.Client().PayRecharge.Get(ctx, id)
  21344. }
  21345. })
  21346. return value, err
  21347. }
  21348. m.id = &id
  21349. }
  21350. }
  21351. // withPayRecharge sets the old PayRecharge of the mutation.
  21352. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21353. return func(m *PayRechargeMutation) {
  21354. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21355. return node, nil
  21356. }
  21357. m.id = &node.ID
  21358. }
  21359. }
  21360. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21361. // executed in a transaction (ent.Tx), a transactional client is returned.
  21362. func (m PayRechargeMutation) Client() *Client {
  21363. client := &Client{config: m.config}
  21364. client.init()
  21365. return client
  21366. }
  21367. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21368. // it returns an error otherwise.
  21369. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21370. if _, ok := m.driver.(*txDriver); !ok {
  21371. return nil, errors.New("ent: mutation is not running in a transaction")
  21372. }
  21373. tx := &Tx{config: m.config}
  21374. tx.init()
  21375. return tx, nil
  21376. }
  21377. // SetID sets the value of the id field. Note that this
  21378. // operation is only accepted on creation of PayRecharge entities.
  21379. func (m *PayRechargeMutation) SetID(id uint64) {
  21380. m.id = &id
  21381. }
  21382. // ID returns the ID value in the mutation. Note that the ID is only available
  21383. // if it was provided to the builder or after it was returned from the database.
  21384. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21385. if m.id == nil {
  21386. return
  21387. }
  21388. return *m.id, true
  21389. }
  21390. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21391. // That means, if the mutation is applied within a transaction with an isolation level such
  21392. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21393. // or updated by the mutation.
  21394. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21395. switch {
  21396. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21397. id, exists := m.ID()
  21398. if exists {
  21399. return []uint64{id}, nil
  21400. }
  21401. fallthrough
  21402. case m.op.Is(OpUpdate | OpDelete):
  21403. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21404. default:
  21405. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21406. }
  21407. }
  21408. // SetCreatedAt sets the "created_at" field.
  21409. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21410. m.created_at = &t
  21411. }
  21412. // CreatedAt returns the value of the "created_at" field in the mutation.
  21413. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21414. v := m.created_at
  21415. if v == nil {
  21416. return
  21417. }
  21418. return *v, true
  21419. }
  21420. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21421. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21423. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21424. if !m.op.Is(OpUpdateOne) {
  21425. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21426. }
  21427. if m.id == nil || m.oldValue == nil {
  21428. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21429. }
  21430. oldValue, err := m.oldValue(ctx)
  21431. if err != nil {
  21432. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21433. }
  21434. return oldValue.CreatedAt, nil
  21435. }
  21436. // ResetCreatedAt resets all changes to the "created_at" field.
  21437. func (m *PayRechargeMutation) ResetCreatedAt() {
  21438. m.created_at = nil
  21439. }
  21440. // SetUpdatedAt sets the "updated_at" field.
  21441. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21442. m.updated_at = &t
  21443. }
  21444. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21445. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21446. v := m.updated_at
  21447. if v == nil {
  21448. return
  21449. }
  21450. return *v, true
  21451. }
  21452. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21453. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21455. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21456. if !m.op.Is(OpUpdateOne) {
  21457. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21458. }
  21459. if m.id == nil || m.oldValue == nil {
  21460. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21461. }
  21462. oldValue, err := m.oldValue(ctx)
  21463. if err != nil {
  21464. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21465. }
  21466. return oldValue.UpdatedAt, nil
  21467. }
  21468. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21469. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21470. m.updated_at = nil
  21471. }
  21472. // SetDeletedAt sets the "deleted_at" field.
  21473. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21474. m.deleted_at = &t
  21475. }
  21476. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21477. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21478. v := m.deleted_at
  21479. if v == nil {
  21480. return
  21481. }
  21482. return *v, true
  21483. }
  21484. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21485. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21487. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21488. if !m.op.Is(OpUpdateOne) {
  21489. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21490. }
  21491. if m.id == nil || m.oldValue == nil {
  21492. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21493. }
  21494. oldValue, err := m.oldValue(ctx)
  21495. if err != nil {
  21496. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21497. }
  21498. return oldValue.DeletedAt, nil
  21499. }
  21500. // ClearDeletedAt clears the value of the "deleted_at" field.
  21501. func (m *PayRechargeMutation) ClearDeletedAt() {
  21502. m.deleted_at = nil
  21503. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21504. }
  21505. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21506. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21507. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21508. return ok
  21509. }
  21510. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21511. func (m *PayRechargeMutation) ResetDeletedAt() {
  21512. m.deleted_at = nil
  21513. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21514. }
  21515. // SetUserID sets the "user_id" field.
  21516. func (m *PayRechargeMutation) SetUserID(s string) {
  21517. m.user_id = &s
  21518. }
  21519. // UserID returns the value of the "user_id" field in the mutation.
  21520. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21521. v := m.user_id
  21522. if v == nil {
  21523. return
  21524. }
  21525. return *v, true
  21526. }
  21527. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21528. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21530. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21531. if !m.op.Is(OpUpdateOne) {
  21532. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21533. }
  21534. if m.id == nil || m.oldValue == nil {
  21535. return v, errors.New("OldUserID requires an ID field in the mutation")
  21536. }
  21537. oldValue, err := m.oldValue(ctx)
  21538. if err != nil {
  21539. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21540. }
  21541. return oldValue.UserID, nil
  21542. }
  21543. // ResetUserID resets all changes to the "user_id" field.
  21544. func (m *PayRechargeMutation) ResetUserID() {
  21545. m.user_id = nil
  21546. }
  21547. // SetNumber sets the "number" field.
  21548. func (m *PayRechargeMutation) SetNumber(f float32) {
  21549. m.number = &f
  21550. m.addnumber = nil
  21551. }
  21552. // Number returns the value of the "number" field in the mutation.
  21553. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21554. v := m.number
  21555. if v == nil {
  21556. return
  21557. }
  21558. return *v, true
  21559. }
  21560. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21561. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21563. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21564. if !m.op.Is(OpUpdateOne) {
  21565. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21566. }
  21567. if m.id == nil || m.oldValue == nil {
  21568. return v, errors.New("OldNumber requires an ID field in the mutation")
  21569. }
  21570. oldValue, err := m.oldValue(ctx)
  21571. if err != nil {
  21572. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21573. }
  21574. return oldValue.Number, nil
  21575. }
  21576. // AddNumber adds f to the "number" field.
  21577. func (m *PayRechargeMutation) AddNumber(f float32) {
  21578. if m.addnumber != nil {
  21579. *m.addnumber += f
  21580. } else {
  21581. m.addnumber = &f
  21582. }
  21583. }
  21584. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21585. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21586. v := m.addnumber
  21587. if v == nil {
  21588. return
  21589. }
  21590. return *v, true
  21591. }
  21592. // ResetNumber resets all changes to the "number" field.
  21593. func (m *PayRechargeMutation) ResetNumber() {
  21594. m.number = nil
  21595. m.addnumber = nil
  21596. }
  21597. // SetStatus sets the "status" field.
  21598. func (m *PayRechargeMutation) SetStatus(i int) {
  21599. m.status = &i
  21600. m.addstatus = nil
  21601. }
  21602. // Status returns the value of the "status" field in the mutation.
  21603. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21604. v := m.status
  21605. if v == nil {
  21606. return
  21607. }
  21608. return *v, true
  21609. }
  21610. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21611. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21613. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21614. if !m.op.Is(OpUpdateOne) {
  21615. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21616. }
  21617. if m.id == nil || m.oldValue == nil {
  21618. return v, errors.New("OldStatus requires an ID field in the mutation")
  21619. }
  21620. oldValue, err := m.oldValue(ctx)
  21621. if err != nil {
  21622. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21623. }
  21624. return oldValue.Status, nil
  21625. }
  21626. // AddStatus adds i to the "status" field.
  21627. func (m *PayRechargeMutation) AddStatus(i int) {
  21628. if m.addstatus != nil {
  21629. *m.addstatus += i
  21630. } else {
  21631. m.addstatus = &i
  21632. }
  21633. }
  21634. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21635. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  21636. v := m.addstatus
  21637. if v == nil {
  21638. return
  21639. }
  21640. return *v, true
  21641. }
  21642. // ClearStatus clears the value of the "status" field.
  21643. func (m *PayRechargeMutation) ClearStatus() {
  21644. m.status = nil
  21645. m.addstatus = nil
  21646. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  21647. }
  21648. // StatusCleared returns if the "status" field was cleared in this mutation.
  21649. func (m *PayRechargeMutation) StatusCleared() bool {
  21650. _, ok := m.clearedFields[payrecharge.FieldStatus]
  21651. return ok
  21652. }
  21653. // ResetStatus resets all changes to the "status" field.
  21654. func (m *PayRechargeMutation) ResetStatus() {
  21655. m.status = nil
  21656. m.addstatus = nil
  21657. delete(m.clearedFields, payrecharge.FieldStatus)
  21658. }
  21659. // SetMoney sets the "money" field.
  21660. func (m *PayRechargeMutation) SetMoney(f float32) {
  21661. m.money = &f
  21662. m.addmoney = nil
  21663. }
  21664. // Money returns the value of the "money" field in the mutation.
  21665. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  21666. v := m.money
  21667. if v == nil {
  21668. return
  21669. }
  21670. return *v, true
  21671. }
  21672. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  21673. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21675. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  21676. if !m.op.Is(OpUpdateOne) {
  21677. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  21678. }
  21679. if m.id == nil || m.oldValue == nil {
  21680. return v, errors.New("OldMoney requires an ID field in the mutation")
  21681. }
  21682. oldValue, err := m.oldValue(ctx)
  21683. if err != nil {
  21684. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  21685. }
  21686. return oldValue.Money, nil
  21687. }
  21688. // AddMoney adds f to the "money" field.
  21689. func (m *PayRechargeMutation) AddMoney(f float32) {
  21690. if m.addmoney != nil {
  21691. *m.addmoney += f
  21692. } else {
  21693. m.addmoney = &f
  21694. }
  21695. }
  21696. // AddedMoney returns the value that was added to the "money" field in this mutation.
  21697. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  21698. v := m.addmoney
  21699. if v == nil {
  21700. return
  21701. }
  21702. return *v, true
  21703. }
  21704. // ClearMoney clears the value of the "money" field.
  21705. func (m *PayRechargeMutation) ClearMoney() {
  21706. m.money = nil
  21707. m.addmoney = nil
  21708. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  21709. }
  21710. // MoneyCleared returns if the "money" field was cleared in this mutation.
  21711. func (m *PayRechargeMutation) MoneyCleared() bool {
  21712. _, ok := m.clearedFields[payrecharge.FieldMoney]
  21713. return ok
  21714. }
  21715. // ResetMoney resets all changes to the "money" field.
  21716. func (m *PayRechargeMutation) ResetMoney() {
  21717. m.money = nil
  21718. m.addmoney = nil
  21719. delete(m.clearedFields, payrecharge.FieldMoney)
  21720. }
  21721. // SetOutTradeNo sets the "out_trade_no" field.
  21722. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  21723. m.out_trade_no = &s
  21724. }
  21725. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  21726. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  21727. v := m.out_trade_no
  21728. if v == nil {
  21729. return
  21730. }
  21731. return *v, true
  21732. }
  21733. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  21734. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21736. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  21737. if !m.op.Is(OpUpdateOne) {
  21738. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  21739. }
  21740. if m.id == nil || m.oldValue == nil {
  21741. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  21742. }
  21743. oldValue, err := m.oldValue(ctx)
  21744. if err != nil {
  21745. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  21746. }
  21747. return oldValue.OutTradeNo, nil
  21748. }
  21749. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  21750. func (m *PayRechargeMutation) ClearOutTradeNo() {
  21751. m.out_trade_no = nil
  21752. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  21753. }
  21754. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  21755. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  21756. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  21757. return ok
  21758. }
  21759. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  21760. func (m *PayRechargeMutation) ResetOutTradeNo() {
  21761. m.out_trade_no = nil
  21762. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  21763. }
  21764. // SetOrganizationID sets the "organization_id" field.
  21765. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  21766. m.organization_id = &u
  21767. m.addorganization_id = nil
  21768. }
  21769. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21770. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  21771. v := m.organization_id
  21772. if v == nil {
  21773. return
  21774. }
  21775. return *v, true
  21776. }
  21777. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  21778. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21780. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21781. if !m.op.Is(OpUpdateOne) {
  21782. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21783. }
  21784. if m.id == nil || m.oldValue == nil {
  21785. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21786. }
  21787. oldValue, err := m.oldValue(ctx)
  21788. if err != nil {
  21789. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21790. }
  21791. return oldValue.OrganizationID, nil
  21792. }
  21793. // AddOrganizationID adds u to the "organization_id" field.
  21794. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  21795. if m.addorganization_id != nil {
  21796. *m.addorganization_id += u
  21797. } else {
  21798. m.addorganization_id = &u
  21799. }
  21800. }
  21801. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21802. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  21803. v := m.addorganization_id
  21804. if v == nil {
  21805. return
  21806. }
  21807. return *v, true
  21808. }
  21809. // ResetOrganizationID resets all changes to the "organization_id" field.
  21810. func (m *PayRechargeMutation) ResetOrganizationID() {
  21811. m.organization_id = nil
  21812. m.addorganization_id = nil
  21813. }
  21814. // Where appends a list predicates to the PayRechargeMutation builder.
  21815. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  21816. m.predicates = append(m.predicates, ps...)
  21817. }
  21818. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  21819. // users can use type-assertion to append predicates that do not depend on any generated package.
  21820. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  21821. p := make([]predicate.PayRecharge, len(ps))
  21822. for i := range ps {
  21823. p[i] = ps[i]
  21824. }
  21825. m.Where(p...)
  21826. }
  21827. // Op returns the operation name.
  21828. func (m *PayRechargeMutation) Op() Op {
  21829. return m.op
  21830. }
  21831. // SetOp allows setting the mutation operation.
  21832. func (m *PayRechargeMutation) SetOp(op Op) {
  21833. m.op = op
  21834. }
  21835. // Type returns the node type of this mutation (PayRecharge).
  21836. func (m *PayRechargeMutation) Type() string {
  21837. return m.typ
  21838. }
  21839. // Fields returns all fields that were changed during this mutation. Note that in
  21840. // order to get all numeric fields that were incremented/decremented, call
  21841. // AddedFields().
  21842. func (m *PayRechargeMutation) Fields() []string {
  21843. fields := make([]string, 0, 9)
  21844. if m.created_at != nil {
  21845. fields = append(fields, payrecharge.FieldCreatedAt)
  21846. }
  21847. if m.updated_at != nil {
  21848. fields = append(fields, payrecharge.FieldUpdatedAt)
  21849. }
  21850. if m.deleted_at != nil {
  21851. fields = append(fields, payrecharge.FieldDeletedAt)
  21852. }
  21853. if m.user_id != nil {
  21854. fields = append(fields, payrecharge.FieldUserID)
  21855. }
  21856. if m.number != nil {
  21857. fields = append(fields, payrecharge.FieldNumber)
  21858. }
  21859. if m.status != nil {
  21860. fields = append(fields, payrecharge.FieldStatus)
  21861. }
  21862. if m.money != nil {
  21863. fields = append(fields, payrecharge.FieldMoney)
  21864. }
  21865. if m.out_trade_no != nil {
  21866. fields = append(fields, payrecharge.FieldOutTradeNo)
  21867. }
  21868. if m.organization_id != nil {
  21869. fields = append(fields, payrecharge.FieldOrganizationID)
  21870. }
  21871. return fields
  21872. }
  21873. // Field returns the value of a field with the given name. The second boolean
  21874. // return value indicates that this field was not set, or was not defined in the
  21875. // schema.
  21876. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  21877. switch name {
  21878. case payrecharge.FieldCreatedAt:
  21879. return m.CreatedAt()
  21880. case payrecharge.FieldUpdatedAt:
  21881. return m.UpdatedAt()
  21882. case payrecharge.FieldDeletedAt:
  21883. return m.DeletedAt()
  21884. case payrecharge.FieldUserID:
  21885. return m.UserID()
  21886. case payrecharge.FieldNumber:
  21887. return m.Number()
  21888. case payrecharge.FieldStatus:
  21889. return m.Status()
  21890. case payrecharge.FieldMoney:
  21891. return m.Money()
  21892. case payrecharge.FieldOutTradeNo:
  21893. return m.OutTradeNo()
  21894. case payrecharge.FieldOrganizationID:
  21895. return m.OrganizationID()
  21896. }
  21897. return nil, false
  21898. }
  21899. // OldField returns the old value of the field from the database. An error is
  21900. // returned if the mutation operation is not UpdateOne, or the query to the
  21901. // database failed.
  21902. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21903. switch name {
  21904. case payrecharge.FieldCreatedAt:
  21905. return m.OldCreatedAt(ctx)
  21906. case payrecharge.FieldUpdatedAt:
  21907. return m.OldUpdatedAt(ctx)
  21908. case payrecharge.FieldDeletedAt:
  21909. return m.OldDeletedAt(ctx)
  21910. case payrecharge.FieldUserID:
  21911. return m.OldUserID(ctx)
  21912. case payrecharge.FieldNumber:
  21913. return m.OldNumber(ctx)
  21914. case payrecharge.FieldStatus:
  21915. return m.OldStatus(ctx)
  21916. case payrecharge.FieldMoney:
  21917. return m.OldMoney(ctx)
  21918. case payrecharge.FieldOutTradeNo:
  21919. return m.OldOutTradeNo(ctx)
  21920. case payrecharge.FieldOrganizationID:
  21921. return m.OldOrganizationID(ctx)
  21922. }
  21923. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  21924. }
  21925. // SetField sets the value of a field with the given name. It returns an error if
  21926. // the field is not defined in the schema, or if the type mismatched the field
  21927. // type.
  21928. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  21929. switch name {
  21930. case payrecharge.FieldCreatedAt:
  21931. v, ok := value.(time.Time)
  21932. if !ok {
  21933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21934. }
  21935. m.SetCreatedAt(v)
  21936. return nil
  21937. case payrecharge.FieldUpdatedAt:
  21938. v, ok := value.(time.Time)
  21939. if !ok {
  21940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21941. }
  21942. m.SetUpdatedAt(v)
  21943. return nil
  21944. case payrecharge.FieldDeletedAt:
  21945. v, ok := value.(time.Time)
  21946. if !ok {
  21947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21948. }
  21949. m.SetDeletedAt(v)
  21950. return nil
  21951. case payrecharge.FieldUserID:
  21952. v, ok := value.(string)
  21953. if !ok {
  21954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21955. }
  21956. m.SetUserID(v)
  21957. return nil
  21958. case payrecharge.FieldNumber:
  21959. v, ok := value.(float32)
  21960. if !ok {
  21961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21962. }
  21963. m.SetNumber(v)
  21964. return nil
  21965. case payrecharge.FieldStatus:
  21966. v, ok := value.(int)
  21967. if !ok {
  21968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21969. }
  21970. m.SetStatus(v)
  21971. return nil
  21972. case payrecharge.FieldMoney:
  21973. v, ok := value.(float32)
  21974. if !ok {
  21975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21976. }
  21977. m.SetMoney(v)
  21978. return nil
  21979. case payrecharge.FieldOutTradeNo:
  21980. v, ok := value.(string)
  21981. if !ok {
  21982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21983. }
  21984. m.SetOutTradeNo(v)
  21985. return nil
  21986. case payrecharge.FieldOrganizationID:
  21987. v, ok := value.(uint64)
  21988. if !ok {
  21989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21990. }
  21991. m.SetOrganizationID(v)
  21992. return nil
  21993. }
  21994. return fmt.Errorf("unknown PayRecharge field %s", name)
  21995. }
  21996. // AddedFields returns all numeric fields that were incremented/decremented during
  21997. // this mutation.
  21998. func (m *PayRechargeMutation) AddedFields() []string {
  21999. var fields []string
  22000. if m.addnumber != nil {
  22001. fields = append(fields, payrecharge.FieldNumber)
  22002. }
  22003. if m.addstatus != nil {
  22004. fields = append(fields, payrecharge.FieldStatus)
  22005. }
  22006. if m.addmoney != nil {
  22007. fields = append(fields, payrecharge.FieldMoney)
  22008. }
  22009. if m.addorganization_id != nil {
  22010. fields = append(fields, payrecharge.FieldOrganizationID)
  22011. }
  22012. return fields
  22013. }
  22014. // AddedField returns the numeric value that was incremented/decremented on a field
  22015. // with the given name. The second boolean return value indicates that this field
  22016. // was not set, or was not defined in the schema.
  22017. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  22018. switch name {
  22019. case payrecharge.FieldNumber:
  22020. return m.AddedNumber()
  22021. case payrecharge.FieldStatus:
  22022. return m.AddedStatus()
  22023. case payrecharge.FieldMoney:
  22024. return m.AddedMoney()
  22025. case payrecharge.FieldOrganizationID:
  22026. return m.AddedOrganizationID()
  22027. }
  22028. return nil, false
  22029. }
  22030. // AddField adds the value to the field with the given name. It returns an error if
  22031. // the field is not defined in the schema, or if the type mismatched the field
  22032. // type.
  22033. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  22034. switch name {
  22035. case payrecharge.FieldNumber:
  22036. v, ok := value.(float32)
  22037. if !ok {
  22038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22039. }
  22040. m.AddNumber(v)
  22041. return nil
  22042. case payrecharge.FieldStatus:
  22043. v, ok := value.(int)
  22044. if !ok {
  22045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22046. }
  22047. m.AddStatus(v)
  22048. return nil
  22049. case payrecharge.FieldMoney:
  22050. v, ok := value.(float32)
  22051. if !ok {
  22052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22053. }
  22054. m.AddMoney(v)
  22055. return nil
  22056. case payrecharge.FieldOrganizationID:
  22057. v, ok := value.(int64)
  22058. if !ok {
  22059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22060. }
  22061. m.AddOrganizationID(v)
  22062. return nil
  22063. }
  22064. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  22065. }
  22066. // ClearedFields returns all nullable fields that were cleared during this
  22067. // mutation.
  22068. func (m *PayRechargeMutation) ClearedFields() []string {
  22069. var fields []string
  22070. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  22071. fields = append(fields, payrecharge.FieldDeletedAt)
  22072. }
  22073. if m.FieldCleared(payrecharge.FieldStatus) {
  22074. fields = append(fields, payrecharge.FieldStatus)
  22075. }
  22076. if m.FieldCleared(payrecharge.FieldMoney) {
  22077. fields = append(fields, payrecharge.FieldMoney)
  22078. }
  22079. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22080. fields = append(fields, payrecharge.FieldOutTradeNo)
  22081. }
  22082. return fields
  22083. }
  22084. // FieldCleared returns a boolean indicating if a field with the given name was
  22085. // cleared in this mutation.
  22086. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22087. _, ok := m.clearedFields[name]
  22088. return ok
  22089. }
  22090. // ClearField clears the value of the field with the given name. It returns an
  22091. // error if the field is not defined in the schema.
  22092. func (m *PayRechargeMutation) ClearField(name string) error {
  22093. switch name {
  22094. case payrecharge.FieldDeletedAt:
  22095. m.ClearDeletedAt()
  22096. return nil
  22097. case payrecharge.FieldStatus:
  22098. m.ClearStatus()
  22099. return nil
  22100. case payrecharge.FieldMoney:
  22101. m.ClearMoney()
  22102. return nil
  22103. case payrecharge.FieldOutTradeNo:
  22104. m.ClearOutTradeNo()
  22105. return nil
  22106. }
  22107. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22108. }
  22109. // ResetField resets all changes in the mutation for the field with the given name.
  22110. // It returns an error if the field is not defined in the schema.
  22111. func (m *PayRechargeMutation) ResetField(name string) error {
  22112. switch name {
  22113. case payrecharge.FieldCreatedAt:
  22114. m.ResetCreatedAt()
  22115. return nil
  22116. case payrecharge.FieldUpdatedAt:
  22117. m.ResetUpdatedAt()
  22118. return nil
  22119. case payrecharge.FieldDeletedAt:
  22120. m.ResetDeletedAt()
  22121. return nil
  22122. case payrecharge.FieldUserID:
  22123. m.ResetUserID()
  22124. return nil
  22125. case payrecharge.FieldNumber:
  22126. m.ResetNumber()
  22127. return nil
  22128. case payrecharge.FieldStatus:
  22129. m.ResetStatus()
  22130. return nil
  22131. case payrecharge.FieldMoney:
  22132. m.ResetMoney()
  22133. return nil
  22134. case payrecharge.FieldOutTradeNo:
  22135. m.ResetOutTradeNo()
  22136. return nil
  22137. case payrecharge.FieldOrganizationID:
  22138. m.ResetOrganizationID()
  22139. return nil
  22140. }
  22141. return fmt.Errorf("unknown PayRecharge field %s", name)
  22142. }
  22143. // AddedEdges returns all edge names that were set/added in this mutation.
  22144. func (m *PayRechargeMutation) AddedEdges() []string {
  22145. edges := make([]string, 0, 0)
  22146. return edges
  22147. }
  22148. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22149. // name in this mutation.
  22150. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22151. return nil
  22152. }
  22153. // RemovedEdges returns all edge names that were removed in this mutation.
  22154. func (m *PayRechargeMutation) RemovedEdges() []string {
  22155. edges := make([]string, 0, 0)
  22156. return edges
  22157. }
  22158. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22159. // the given name in this mutation.
  22160. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22161. return nil
  22162. }
  22163. // ClearedEdges returns all edge names that were cleared in this mutation.
  22164. func (m *PayRechargeMutation) ClearedEdges() []string {
  22165. edges := make([]string, 0, 0)
  22166. return edges
  22167. }
  22168. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22169. // was cleared in this mutation.
  22170. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22171. return false
  22172. }
  22173. // ClearEdge clears the value of the edge with the given name. It returns an error
  22174. // if that edge is not defined in the schema.
  22175. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22176. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  22177. }
  22178. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22179. // It returns an error if the edge is not defined in the schema.
  22180. func (m *PayRechargeMutation) ResetEdge(name string) error {
  22181. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22182. }
  22183. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22184. type ServerMutation struct {
  22185. config
  22186. op Op
  22187. typ string
  22188. id *uint64
  22189. created_at *time.Time
  22190. updated_at *time.Time
  22191. status *uint8
  22192. addstatus *int8
  22193. deleted_at *time.Time
  22194. name *string
  22195. public_ip *string
  22196. private_ip *string
  22197. admin_port *string
  22198. clearedFields map[string]struct{}
  22199. wxs map[uint64]struct{}
  22200. removedwxs map[uint64]struct{}
  22201. clearedwxs bool
  22202. done bool
  22203. oldValue func(context.Context) (*Server, error)
  22204. predicates []predicate.Server
  22205. }
  22206. var _ ent.Mutation = (*ServerMutation)(nil)
  22207. // serverOption allows management of the mutation configuration using functional options.
  22208. type serverOption func(*ServerMutation)
  22209. // newServerMutation creates new mutation for the Server entity.
  22210. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22211. m := &ServerMutation{
  22212. config: c,
  22213. op: op,
  22214. typ: TypeServer,
  22215. clearedFields: make(map[string]struct{}),
  22216. }
  22217. for _, opt := range opts {
  22218. opt(m)
  22219. }
  22220. return m
  22221. }
  22222. // withServerID sets the ID field of the mutation.
  22223. func withServerID(id uint64) serverOption {
  22224. return func(m *ServerMutation) {
  22225. var (
  22226. err error
  22227. once sync.Once
  22228. value *Server
  22229. )
  22230. m.oldValue = func(ctx context.Context) (*Server, error) {
  22231. once.Do(func() {
  22232. if m.done {
  22233. err = errors.New("querying old values post mutation is not allowed")
  22234. } else {
  22235. value, err = m.Client().Server.Get(ctx, id)
  22236. }
  22237. })
  22238. return value, err
  22239. }
  22240. m.id = &id
  22241. }
  22242. }
  22243. // withServer sets the old Server of the mutation.
  22244. func withServer(node *Server) serverOption {
  22245. return func(m *ServerMutation) {
  22246. m.oldValue = func(context.Context) (*Server, error) {
  22247. return node, nil
  22248. }
  22249. m.id = &node.ID
  22250. }
  22251. }
  22252. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22253. // executed in a transaction (ent.Tx), a transactional client is returned.
  22254. func (m ServerMutation) Client() *Client {
  22255. client := &Client{config: m.config}
  22256. client.init()
  22257. return client
  22258. }
  22259. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22260. // it returns an error otherwise.
  22261. func (m ServerMutation) Tx() (*Tx, error) {
  22262. if _, ok := m.driver.(*txDriver); !ok {
  22263. return nil, errors.New("ent: mutation is not running in a transaction")
  22264. }
  22265. tx := &Tx{config: m.config}
  22266. tx.init()
  22267. return tx, nil
  22268. }
  22269. // SetID sets the value of the id field. Note that this
  22270. // operation is only accepted on creation of Server entities.
  22271. func (m *ServerMutation) SetID(id uint64) {
  22272. m.id = &id
  22273. }
  22274. // ID returns the ID value in the mutation. Note that the ID is only available
  22275. // if it was provided to the builder or after it was returned from the database.
  22276. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22277. if m.id == nil {
  22278. return
  22279. }
  22280. return *m.id, true
  22281. }
  22282. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22283. // That means, if the mutation is applied within a transaction with an isolation level such
  22284. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22285. // or updated by the mutation.
  22286. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22287. switch {
  22288. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22289. id, exists := m.ID()
  22290. if exists {
  22291. return []uint64{id}, nil
  22292. }
  22293. fallthrough
  22294. case m.op.Is(OpUpdate | OpDelete):
  22295. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22296. default:
  22297. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22298. }
  22299. }
  22300. // SetCreatedAt sets the "created_at" field.
  22301. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22302. m.created_at = &t
  22303. }
  22304. // CreatedAt returns the value of the "created_at" field in the mutation.
  22305. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22306. v := m.created_at
  22307. if v == nil {
  22308. return
  22309. }
  22310. return *v, true
  22311. }
  22312. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22313. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22315. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22316. if !m.op.Is(OpUpdateOne) {
  22317. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22318. }
  22319. if m.id == nil || m.oldValue == nil {
  22320. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22321. }
  22322. oldValue, err := m.oldValue(ctx)
  22323. if err != nil {
  22324. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22325. }
  22326. return oldValue.CreatedAt, nil
  22327. }
  22328. // ResetCreatedAt resets all changes to the "created_at" field.
  22329. func (m *ServerMutation) ResetCreatedAt() {
  22330. m.created_at = nil
  22331. }
  22332. // SetUpdatedAt sets the "updated_at" field.
  22333. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22334. m.updated_at = &t
  22335. }
  22336. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22337. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22338. v := m.updated_at
  22339. if v == nil {
  22340. return
  22341. }
  22342. return *v, true
  22343. }
  22344. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22345. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22347. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22348. if !m.op.Is(OpUpdateOne) {
  22349. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22350. }
  22351. if m.id == nil || m.oldValue == nil {
  22352. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22353. }
  22354. oldValue, err := m.oldValue(ctx)
  22355. if err != nil {
  22356. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22357. }
  22358. return oldValue.UpdatedAt, nil
  22359. }
  22360. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22361. func (m *ServerMutation) ResetUpdatedAt() {
  22362. m.updated_at = nil
  22363. }
  22364. // SetStatus sets the "status" field.
  22365. func (m *ServerMutation) SetStatus(u uint8) {
  22366. m.status = &u
  22367. m.addstatus = nil
  22368. }
  22369. // Status returns the value of the "status" field in the mutation.
  22370. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22371. v := m.status
  22372. if v == nil {
  22373. return
  22374. }
  22375. return *v, true
  22376. }
  22377. // OldStatus returns the old "status" field's value of the Server entity.
  22378. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22380. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22381. if !m.op.Is(OpUpdateOne) {
  22382. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22383. }
  22384. if m.id == nil || m.oldValue == nil {
  22385. return v, errors.New("OldStatus requires an ID field in the mutation")
  22386. }
  22387. oldValue, err := m.oldValue(ctx)
  22388. if err != nil {
  22389. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22390. }
  22391. return oldValue.Status, nil
  22392. }
  22393. // AddStatus adds u to the "status" field.
  22394. func (m *ServerMutation) AddStatus(u int8) {
  22395. if m.addstatus != nil {
  22396. *m.addstatus += u
  22397. } else {
  22398. m.addstatus = &u
  22399. }
  22400. }
  22401. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22402. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22403. v := m.addstatus
  22404. if v == nil {
  22405. return
  22406. }
  22407. return *v, true
  22408. }
  22409. // ClearStatus clears the value of the "status" field.
  22410. func (m *ServerMutation) ClearStatus() {
  22411. m.status = nil
  22412. m.addstatus = nil
  22413. m.clearedFields[server.FieldStatus] = struct{}{}
  22414. }
  22415. // StatusCleared returns if the "status" field was cleared in this mutation.
  22416. func (m *ServerMutation) StatusCleared() bool {
  22417. _, ok := m.clearedFields[server.FieldStatus]
  22418. return ok
  22419. }
  22420. // ResetStatus resets all changes to the "status" field.
  22421. func (m *ServerMutation) ResetStatus() {
  22422. m.status = nil
  22423. m.addstatus = nil
  22424. delete(m.clearedFields, server.FieldStatus)
  22425. }
  22426. // SetDeletedAt sets the "deleted_at" field.
  22427. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22428. m.deleted_at = &t
  22429. }
  22430. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22431. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22432. v := m.deleted_at
  22433. if v == nil {
  22434. return
  22435. }
  22436. return *v, true
  22437. }
  22438. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22439. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22441. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22442. if !m.op.Is(OpUpdateOne) {
  22443. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22444. }
  22445. if m.id == nil || m.oldValue == nil {
  22446. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22447. }
  22448. oldValue, err := m.oldValue(ctx)
  22449. if err != nil {
  22450. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22451. }
  22452. return oldValue.DeletedAt, nil
  22453. }
  22454. // ClearDeletedAt clears the value of the "deleted_at" field.
  22455. func (m *ServerMutation) ClearDeletedAt() {
  22456. m.deleted_at = nil
  22457. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22458. }
  22459. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22460. func (m *ServerMutation) DeletedAtCleared() bool {
  22461. _, ok := m.clearedFields[server.FieldDeletedAt]
  22462. return ok
  22463. }
  22464. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22465. func (m *ServerMutation) ResetDeletedAt() {
  22466. m.deleted_at = nil
  22467. delete(m.clearedFields, server.FieldDeletedAt)
  22468. }
  22469. // SetName sets the "name" field.
  22470. func (m *ServerMutation) SetName(s string) {
  22471. m.name = &s
  22472. }
  22473. // Name returns the value of the "name" field in the mutation.
  22474. func (m *ServerMutation) Name() (r string, exists bool) {
  22475. v := m.name
  22476. if v == nil {
  22477. return
  22478. }
  22479. return *v, true
  22480. }
  22481. // OldName returns the old "name" field's value of the Server entity.
  22482. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22484. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22485. if !m.op.Is(OpUpdateOne) {
  22486. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22487. }
  22488. if m.id == nil || m.oldValue == nil {
  22489. return v, errors.New("OldName requires an ID field in the mutation")
  22490. }
  22491. oldValue, err := m.oldValue(ctx)
  22492. if err != nil {
  22493. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22494. }
  22495. return oldValue.Name, nil
  22496. }
  22497. // ResetName resets all changes to the "name" field.
  22498. func (m *ServerMutation) ResetName() {
  22499. m.name = nil
  22500. }
  22501. // SetPublicIP sets the "public_ip" field.
  22502. func (m *ServerMutation) SetPublicIP(s string) {
  22503. m.public_ip = &s
  22504. }
  22505. // PublicIP returns the value of the "public_ip" field in the mutation.
  22506. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22507. v := m.public_ip
  22508. if v == nil {
  22509. return
  22510. }
  22511. return *v, true
  22512. }
  22513. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22514. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22516. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22517. if !m.op.Is(OpUpdateOne) {
  22518. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22519. }
  22520. if m.id == nil || m.oldValue == nil {
  22521. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22522. }
  22523. oldValue, err := m.oldValue(ctx)
  22524. if err != nil {
  22525. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22526. }
  22527. return oldValue.PublicIP, nil
  22528. }
  22529. // ResetPublicIP resets all changes to the "public_ip" field.
  22530. func (m *ServerMutation) ResetPublicIP() {
  22531. m.public_ip = nil
  22532. }
  22533. // SetPrivateIP sets the "private_ip" field.
  22534. func (m *ServerMutation) SetPrivateIP(s string) {
  22535. m.private_ip = &s
  22536. }
  22537. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22538. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22539. v := m.private_ip
  22540. if v == nil {
  22541. return
  22542. }
  22543. return *v, true
  22544. }
  22545. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22546. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22548. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22549. if !m.op.Is(OpUpdateOne) {
  22550. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22551. }
  22552. if m.id == nil || m.oldValue == nil {
  22553. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22554. }
  22555. oldValue, err := m.oldValue(ctx)
  22556. if err != nil {
  22557. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22558. }
  22559. return oldValue.PrivateIP, nil
  22560. }
  22561. // ResetPrivateIP resets all changes to the "private_ip" field.
  22562. func (m *ServerMutation) ResetPrivateIP() {
  22563. m.private_ip = nil
  22564. }
  22565. // SetAdminPort sets the "admin_port" field.
  22566. func (m *ServerMutation) SetAdminPort(s string) {
  22567. m.admin_port = &s
  22568. }
  22569. // AdminPort returns the value of the "admin_port" field in the mutation.
  22570. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22571. v := m.admin_port
  22572. if v == nil {
  22573. return
  22574. }
  22575. return *v, true
  22576. }
  22577. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22578. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22580. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22581. if !m.op.Is(OpUpdateOne) {
  22582. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22583. }
  22584. if m.id == nil || m.oldValue == nil {
  22585. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22586. }
  22587. oldValue, err := m.oldValue(ctx)
  22588. if err != nil {
  22589. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22590. }
  22591. return oldValue.AdminPort, nil
  22592. }
  22593. // ResetAdminPort resets all changes to the "admin_port" field.
  22594. func (m *ServerMutation) ResetAdminPort() {
  22595. m.admin_port = nil
  22596. }
  22597. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22598. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22599. if m.wxs == nil {
  22600. m.wxs = make(map[uint64]struct{})
  22601. }
  22602. for i := range ids {
  22603. m.wxs[ids[i]] = struct{}{}
  22604. }
  22605. }
  22606. // ClearWxs clears the "wxs" edge to the Wx entity.
  22607. func (m *ServerMutation) ClearWxs() {
  22608. m.clearedwxs = true
  22609. }
  22610. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22611. func (m *ServerMutation) WxsCleared() bool {
  22612. return m.clearedwxs
  22613. }
  22614. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22615. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22616. if m.removedwxs == nil {
  22617. m.removedwxs = make(map[uint64]struct{})
  22618. }
  22619. for i := range ids {
  22620. delete(m.wxs, ids[i])
  22621. m.removedwxs[ids[i]] = struct{}{}
  22622. }
  22623. }
  22624. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22625. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22626. for id := range m.removedwxs {
  22627. ids = append(ids, id)
  22628. }
  22629. return
  22630. }
  22631. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22632. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22633. for id := range m.wxs {
  22634. ids = append(ids, id)
  22635. }
  22636. return
  22637. }
  22638. // ResetWxs resets all changes to the "wxs" edge.
  22639. func (m *ServerMutation) ResetWxs() {
  22640. m.wxs = nil
  22641. m.clearedwxs = false
  22642. m.removedwxs = nil
  22643. }
  22644. // Where appends a list predicates to the ServerMutation builder.
  22645. func (m *ServerMutation) Where(ps ...predicate.Server) {
  22646. m.predicates = append(m.predicates, ps...)
  22647. }
  22648. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  22649. // users can use type-assertion to append predicates that do not depend on any generated package.
  22650. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  22651. p := make([]predicate.Server, len(ps))
  22652. for i := range ps {
  22653. p[i] = ps[i]
  22654. }
  22655. m.Where(p...)
  22656. }
  22657. // Op returns the operation name.
  22658. func (m *ServerMutation) Op() Op {
  22659. return m.op
  22660. }
  22661. // SetOp allows setting the mutation operation.
  22662. func (m *ServerMutation) SetOp(op Op) {
  22663. m.op = op
  22664. }
  22665. // Type returns the node type of this mutation (Server).
  22666. func (m *ServerMutation) Type() string {
  22667. return m.typ
  22668. }
  22669. // Fields returns all fields that were changed during this mutation. Note that in
  22670. // order to get all numeric fields that were incremented/decremented, call
  22671. // AddedFields().
  22672. func (m *ServerMutation) Fields() []string {
  22673. fields := make([]string, 0, 8)
  22674. if m.created_at != nil {
  22675. fields = append(fields, server.FieldCreatedAt)
  22676. }
  22677. if m.updated_at != nil {
  22678. fields = append(fields, server.FieldUpdatedAt)
  22679. }
  22680. if m.status != nil {
  22681. fields = append(fields, server.FieldStatus)
  22682. }
  22683. if m.deleted_at != nil {
  22684. fields = append(fields, server.FieldDeletedAt)
  22685. }
  22686. if m.name != nil {
  22687. fields = append(fields, server.FieldName)
  22688. }
  22689. if m.public_ip != nil {
  22690. fields = append(fields, server.FieldPublicIP)
  22691. }
  22692. if m.private_ip != nil {
  22693. fields = append(fields, server.FieldPrivateIP)
  22694. }
  22695. if m.admin_port != nil {
  22696. fields = append(fields, server.FieldAdminPort)
  22697. }
  22698. return fields
  22699. }
  22700. // Field returns the value of a field with the given name. The second boolean
  22701. // return value indicates that this field was not set, or was not defined in the
  22702. // schema.
  22703. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  22704. switch name {
  22705. case server.FieldCreatedAt:
  22706. return m.CreatedAt()
  22707. case server.FieldUpdatedAt:
  22708. return m.UpdatedAt()
  22709. case server.FieldStatus:
  22710. return m.Status()
  22711. case server.FieldDeletedAt:
  22712. return m.DeletedAt()
  22713. case server.FieldName:
  22714. return m.Name()
  22715. case server.FieldPublicIP:
  22716. return m.PublicIP()
  22717. case server.FieldPrivateIP:
  22718. return m.PrivateIP()
  22719. case server.FieldAdminPort:
  22720. return m.AdminPort()
  22721. }
  22722. return nil, false
  22723. }
  22724. // OldField returns the old value of the field from the database. An error is
  22725. // returned if the mutation operation is not UpdateOne, or the query to the
  22726. // database failed.
  22727. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22728. switch name {
  22729. case server.FieldCreatedAt:
  22730. return m.OldCreatedAt(ctx)
  22731. case server.FieldUpdatedAt:
  22732. return m.OldUpdatedAt(ctx)
  22733. case server.FieldStatus:
  22734. return m.OldStatus(ctx)
  22735. case server.FieldDeletedAt:
  22736. return m.OldDeletedAt(ctx)
  22737. case server.FieldName:
  22738. return m.OldName(ctx)
  22739. case server.FieldPublicIP:
  22740. return m.OldPublicIP(ctx)
  22741. case server.FieldPrivateIP:
  22742. return m.OldPrivateIP(ctx)
  22743. case server.FieldAdminPort:
  22744. return m.OldAdminPort(ctx)
  22745. }
  22746. return nil, fmt.Errorf("unknown Server field %s", name)
  22747. }
  22748. // SetField sets the value of a field with the given name. It returns an error if
  22749. // the field is not defined in the schema, or if the type mismatched the field
  22750. // type.
  22751. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  22752. switch name {
  22753. case server.FieldCreatedAt:
  22754. v, ok := value.(time.Time)
  22755. if !ok {
  22756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22757. }
  22758. m.SetCreatedAt(v)
  22759. return nil
  22760. case server.FieldUpdatedAt:
  22761. v, ok := value.(time.Time)
  22762. if !ok {
  22763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22764. }
  22765. m.SetUpdatedAt(v)
  22766. return nil
  22767. case server.FieldStatus:
  22768. v, ok := value.(uint8)
  22769. if !ok {
  22770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22771. }
  22772. m.SetStatus(v)
  22773. return nil
  22774. case server.FieldDeletedAt:
  22775. v, ok := value.(time.Time)
  22776. if !ok {
  22777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22778. }
  22779. m.SetDeletedAt(v)
  22780. return nil
  22781. case server.FieldName:
  22782. v, ok := value.(string)
  22783. if !ok {
  22784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22785. }
  22786. m.SetName(v)
  22787. return nil
  22788. case server.FieldPublicIP:
  22789. v, ok := value.(string)
  22790. if !ok {
  22791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22792. }
  22793. m.SetPublicIP(v)
  22794. return nil
  22795. case server.FieldPrivateIP:
  22796. v, ok := value.(string)
  22797. if !ok {
  22798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22799. }
  22800. m.SetPrivateIP(v)
  22801. return nil
  22802. case server.FieldAdminPort:
  22803. v, ok := value.(string)
  22804. if !ok {
  22805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22806. }
  22807. m.SetAdminPort(v)
  22808. return nil
  22809. }
  22810. return fmt.Errorf("unknown Server field %s", name)
  22811. }
  22812. // AddedFields returns all numeric fields that were incremented/decremented during
  22813. // this mutation.
  22814. func (m *ServerMutation) AddedFields() []string {
  22815. var fields []string
  22816. if m.addstatus != nil {
  22817. fields = append(fields, server.FieldStatus)
  22818. }
  22819. return fields
  22820. }
  22821. // AddedField returns the numeric value that was incremented/decremented on a field
  22822. // with the given name. The second boolean return value indicates that this field
  22823. // was not set, or was not defined in the schema.
  22824. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  22825. switch name {
  22826. case server.FieldStatus:
  22827. return m.AddedStatus()
  22828. }
  22829. return nil, false
  22830. }
  22831. // AddField adds the value to the field with the given name. It returns an error if
  22832. // the field is not defined in the schema, or if the type mismatched the field
  22833. // type.
  22834. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  22835. switch name {
  22836. case server.FieldStatus:
  22837. v, ok := value.(int8)
  22838. if !ok {
  22839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22840. }
  22841. m.AddStatus(v)
  22842. return nil
  22843. }
  22844. return fmt.Errorf("unknown Server numeric field %s", name)
  22845. }
  22846. // ClearedFields returns all nullable fields that were cleared during this
  22847. // mutation.
  22848. func (m *ServerMutation) ClearedFields() []string {
  22849. var fields []string
  22850. if m.FieldCleared(server.FieldStatus) {
  22851. fields = append(fields, server.FieldStatus)
  22852. }
  22853. if m.FieldCleared(server.FieldDeletedAt) {
  22854. fields = append(fields, server.FieldDeletedAt)
  22855. }
  22856. return fields
  22857. }
  22858. // FieldCleared returns a boolean indicating if a field with the given name was
  22859. // cleared in this mutation.
  22860. func (m *ServerMutation) FieldCleared(name string) bool {
  22861. _, ok := m.clearedFields[name]
  22862. return ok
  22863. }
  22864. // ClearField clears the value of the field with the given name. It returns an
  22865. // error if the field is not defined in the schema.
  22866. func (m *ServerMutation) ClearField(name string) error {
  22867. switch name {
  22868. case server.FieldStatus:
  22869. m.ClearStatus()
  22870. return nil
  22871. case server.FieldDeletedAt:
  22872. m.ClearDeletedAt()
  22873. return nil
  22874. }
  22875. return fmt.Errorf("unknown Server nullable field %s", name)
  22876. }
  22877. // ResetField resets all changes in the mutation for the field with the given name.
  22878. // It returns an error if the field is not defined in the schema.
  22879. func (m *ServerMutation) ResetField(name string) error {
  22880. switch name {
  22881. case server.FieldCreatedAt:
  22882. m.ResetCreatedAt()
  22883. return nil
  22884. case server.FieldUpdatedAt:
  22885. m.ResetUpdatedAt()
  22886. return nil
  22887. case server.FieldStatus:
  22888. m.ResetStatus()
  22889. return nil
  22890. case server.FieldDeletedAt:
  22891. m.ResetDeletedAt()
  22892. return nil
  22893. case server.FieldName:
  22894. m.ResetName()
  22895. return nil
  22896. case server.FieldPublicIP:
  22897. m.ResetPublicIP()
  22898. return nil
  22899. case server.FieldPrivateIP:
  22900. m.ResetPrivateIP()
  22901. return nil
  22902. case server.FieldAdminPort:
  22903. m.ResetAdminPort()
  22904. return nil
  22905. }
  22906. return fmt.Errorf("unknown Server field %s", name)
  22907. }
  22908. // AddedEdges returns all edge names that were set/added in this mutation.
  22909. func (m *ServerMutation) AddedEdges() []string {
  22910. edges := make([]string, 0, 1)
  22911. if m.wxs != nil {
  22912. edges = append(edges, server.EdgeWxs)
  22913. }
  22914. return edges
  22915. }
  22916. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22917. // name in this mutation.
  22918. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  22919. switch name {
  22920. case server.EdgeWxs:
  22921. ids := make([]ent.Value, 0, len(m.wxs))
  22922. for id := range m.wxs {
  22923. ids = append(ids, id)
  22924. }
  22925. return ids
  22926. }
  22927. return nil
  22928. }
  22929. // RemovedEdges returns all edge names that were removed in this mutation.
  22930. func (m *ServerMutation) RemovedEdges() []string {
  22931. edges := make([]string, 0, 1)
  22932. if m.removedwxs != nil {
  22933. edges = append(edges, server.EdgeWxs)
  22934. }
  22935. return edges
  22936. }
  22937. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22938. // the given name in this mutation.
  22939. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  22940. switch name {
  22941. case server.EdgeWxs:
  22942. ids := make([]ent.Value, 0, len(m.removedwxs))
  22943. for id := range m.removedwxs {
  22944. ids = append(ids, id)
  22945. }
  22946. return ids
  22947. }
  22948. return nil
  22949. }
  22950. // ClearedEdges returns all edge names that were cleared in this mutation.
  22951. func (m *ServerMutation) ClearedEdges() []string {
  22952. edges := make([]string, 0, 1)
  22953. if m.clearedwxs {
  22954. edges = append(edges, server.EdgeWxs)
  22955. }
  22956. return edges
  22957. }
  22958. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22959. // was cleared in this mutation.
  22960. func (m *ServerMutation) EdgeCleared(name string) bool {
  22961. switch name {
  22962. case server.EdgeWxs:
  22963. return m.clearedwxs
  22964. }
  22965. return false
  22966. }
  22967. // ClearEdge clears the value of the edge with the given name. It returns an error
  22968. // if that edge is not defined in the schema.
  22969. func (m *ServerMutation) ClearEdge(name string) error {
  22970. switch name {
  22971. }
  22972. return fmt.Errorf("unknown Server unique edge %s", name)
  22973. }
  22974. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22975. // It returns an error if the edge is not defined in the schema.
  22976. func (m *ServerMutation) ResetEdge(name string) error {
  22977. switch name {
  22978. case server.EdgeWxs:
  22979. m.ResetWxs()
  22980. return nil
  22981. }
  22982. return fmt.Errorf("unknown Server edge %s", name)
  22983. }
  22984. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  22985. type SopNodeMutation struct {
  22986. config
  22987. op Op
  22988. typ string
  22989. id *uint64
  22990. created_at *time.Time
  22991. updated_at *time.Time
  22992. status *uint8
  22993. addstatus *int8
  22994. deleted_at *time.Time
  22995. parent_id *uint64
  22996. addparent_id *int64
  22997. name *string
  22998. condition_type *int
  22999. addcondition_type *int
  23000. condition_list *[]string
  23001. appendcondition_list []string
  23002. no_reply_condition *uint64
  23003. addno_reply_condition *int64
  23004. no_reply_unit *string
  23005. action_message *[]custom_types.Action
  23006. appendaction_message []custom_types.Action
  23007. action_label_add *[]uint64
  23008. appendaction_label_add []uint64
  23009. action_label_del *[]uint64
  23010. appendaction_label_del []uint64
  23011. action_forward **custom_types.ActionForward
  23012. clearedFields map[string]struct{}
  23013. sop_stage *uint64
  23014. clearedsop_stage bool
  23015. node_messages map[uint64]struct{}
  23016. removednode_messages map[uint64]struct{}
  23017. clearednode_messages bool
  23018. done bool
  23019. oldValue func(context.Context) (*SopNode, error)
  23020. predicates []predicate.SopNode
  23021. }
  23022. var _ ent.Mutation = (*SopNodeMutation)(nil)
  23023. // sopnodeOption allows management of the mutation configuration using functional options.
  23024. type sopnodeOption func(*SopNodeMutation)
  23025. // newSopNodeMutation creates new mutation for the SopNode entity.
  23026. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  23027. m := &SopNodeMutation{
  23028. config: c,
  23029. op: op,
  23030. typ: TypeSopNode,
  23031. clearedFields: make(map[string]struct{}),
  23032. }
  23033. for _, opt := range opts {
  23034. opt(m)
  23035. }
  23036. return m
  23037. }
  23038. // withSopNodeID sets the ID field of the mutation.
  23039. func withSopNodeID(id uint64) sopnodeOption {
  23040. return func(m *SopNodeMutation) {
  23041. var (
  23042. err error
  23043. once sync.Once
  23044. value *SopNode
  23045. )
  23046. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  23047. once.Do(func() {
  23048. if m.done {
  23049. err = errors.New("querying old values post mutation is not allowed")
  23050. } else {
  23051. value, err = m.Client().SopNode.Get(ctx, id)
  23052. }
  23053. })
  23054. return value, err
  23055. }
  23056. m.id = &id
  23057. }
  23058. }
  23059. // withSopNode sets the old SopNode of the mutation.
  23060. func withSopNode(node *SopNode) sopnodeOption {
  23061. return func(m *SopNodeMutation) {
  23062. m.oldValue = func(context.Context) (*SopNode, error) {
  23063. return node, nil
  23064. }
  23065. m.id = &node.ID
  23066. }
  23067. }
  23068. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23069. // executed in a transaction (ent.Tx), a transactional client is returned.
  23070. func (m SopNodeMutation) Client() *Client {
  23071. client := &Client{config: m.config}
  23072. client.init()
  23073. return client
  23074. }
  23075. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23076. // it returns an error otherwise.
  23077. func (m SopNodeMutation) Tx() (*Tx, error) {
  23078. if _, ok := m.driver.(*txDriver); !ok {
  23079. return nil, errors.New("ent: mutation is not running in a transaction")
  23080. }
  23081. tx := &Tx{config: m.config}
  23082. tx.init()
  23083. return tx, nil
  23084. }
  23085. // SetID sets the value of the id field. Note that this
  23086. // operation is only accepted on creation of SopNode entities.
  23087. func (m *SopNodeMutation) SetID(id uint64) {
  23088. m.id = &id
  23089. }
  23090. // ID returns the ID value in the mutation. Note that the ID is only available
  23091. // if it was provided to the builder or after it was returned from the database.
  23092. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23093. if m.id == nil {
  23094. return
  23095. }
  23096. return *m.id, true
  23097. }
  23098. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23099. // That means, if the mutation is applied within a transaction with an isolation level such
  23100. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23101. // or updated by the mutation.
  23102. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23103. switch {
  23104. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23105. id, exists := m.ID()
  23106. if exists {
  23107. return []uint64{id}, nil
  23108. }
  23109. fallthrough
  23110. case m.op.Is(OpUpdate | OpDelete):
  23111. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23112. default:
  23113. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23114. }
  23115. }
  23116. // SetCreatedAt sets the "created_at" field.
  23117. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23118. m.created_at = &t
  23119. }
  23120. // CreatedAt returns the value of the "created_at" field in the mutation.
  23121. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23122. v := m.created_at
  23123. if v == nil {
  23124. return
  23125. }
  23126. return *v, true
  23127. }
  23128. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23129. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23131. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23132. if !m.op.Is(OpUpdateOne) {
  23133. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23134. }
  23135. if m.id == nil || m.oldValue == nil {
  23136. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23137. }
  23138. oldValue, err := m.oldValue(ctx)
  23139. if err != nil {
  23140. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23141. }
  23142. return oldValue.CreatedAt, nil
  23143. }
  23144. // ResetCreatedAt resets all changes to the "created_at" field.
  23145. func (m *SopNodeMutation) ResetCreatedAt() {
  23146. m.created_at = nil
  23147. }
  23148. // SetUpdatedAt sets the "updated_at" field.
  23149. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23150. m.updated_at = &t
  23151. }
  23152. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23153. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23154. v := m.updated_at
  23155. if v == nil {
  23156. return
  23157. }
  23158. return *v, true
  23159. }
  23160. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23161. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23163. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23164. if !m.op.Is(OpUpdateOne) {
  23165. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23166. }
  23167. if m.id == nil || m.oldValue == nil {
  23168. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23169. }
  23170. oldValue, err := m.oldValue(ctx)
  23171. if err != nil {
  23172. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23173. }
  23174. return oldValue.UpdatedAt, nil
  23175. }
  23176. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23177. func (m *SopNodeMutation) ResetUpdatedAt() {
  23178. m.updated_at = nil
  23179. }
  23180. // SetStatus sets the "status" field.
  23181. func (m *SopNodeMutation) SetStatus(u uint8) {
  23182. m.status = &u
  23183. m.addstatus = nil
  23184. }
  23185. // Status returns the value of the "status" field in the mutation.
  23186. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23187. v := m.status
  23188. if v == nil {
  23189. return
  23190. }
  23191. return *v, true
  23192. }
  23193. // OldStatus returns the old "status" field's value of the SopNode entity.
  23194. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23196. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23197. if !m.op.Is(OpUpdateOne) {
  23198. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23199. }
  23200. if m.id == nil || m.oldValue == nil {
  23201. return v, errors.New("OldStatus requires an ID field in the mutation")
  23202. }
  23203. oldValue, err := m.oldValue(ctx)
  23204. if err != nil {
  23205. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23206. }
  23207. return oldValue.Status, nil
  23208. }
  23209. // AddStatus adds u to the "status" field.
  23210. func (m *SopNodeMutation) AddStatus(u int8) {
  23211. if m.addstatus != nil {
  23212. *m.addstatus += u
  23213. } else {
  23214. m.addstatus = &u
  23215. }
  23216. }
  23217. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23218. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23219. v := m.addstatus
  23220. if v == nil {
  23221. return
  23222. }
  23223. return *v, true
  23224. }
  23225. // ClearStatus clears the value of the "status" field.
  23226. func (m *SopNodeMutation) ClearStatus() {
  23227. m.status = nil
  23228. m.addstatus = nil
  23229. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23230. }
  23231. // StatusCleared returns if the "status" field was cleared in this mutation.
  23232. func (m *SopNodeMutation) StatusCleared() bool {
  23233. _, ok := m.clearedFields[sopnode.FieldStatus]
  23234. return ok
  23235. }
  23236. // ResetStatus resets all changes to the "status" field.
  23237. func (m *SopNodeMutation) ResetStatus() {
  23238. m.status = nil
  23239. m.addstatus = nil
  23240. delete(m.clearedFields, sopnode.FieldStatus)
  23241. }
  23242. // SetDeletedAt sets the "deleted_at" field.
  23243. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23244. m.deleted_at = &t
  23245. }
  23246. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23247. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23248. v := m.deleted_at
  23249. if v == nil {
  23250. return
  23251. }
  23252. return *v, true
  23253. }
  23254. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23255. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23257. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23258. if !m.op.Is(OpUpdateOne) {
  23259. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23260. }
  23261. if m.id == nil || m.oldValue == nil {
  23262. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23263. }
  23264. oldValue, err := m.oldValue(ctx)
  23265. if err != nil {
  23266. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23267. }
  23268. return oldValue.DeletedAt, nil
  23269. }
  23270. // ClearDeletedAt clears the value of the "deleted_at" field.
  23271. func (m *SopNodeMutation) ClearDeletedAt() {
  23272. m.deleted_at = nil
  23273. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23274. }
  23275. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23276. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23277. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23278. return ok
  23279. }
  23280. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23281. func (m *SopNodeMutation) ResetDeletedAt() {
  23282. m.deleted_at = nil
  23283. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23284. }
  23285. // SetStageID sets the "stage_id" field.
  23286. func (m *SopNodeMutation) SetStageID(u uint64) {
  23287. m.sop_stage = &u
  23288. }
  23289. // StageID returns the value of the "stage_id" field in the mutation.
  23290. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23291. v := m.sop_stage
  23292. if v == nil {
  23293. return
  23294. }
  23295. return *v, true
  23296. }
  23297. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23298. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23300. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23301. if !m.op.Is(OpUpdateOne) {
  23302. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23303. }
  23304. if m.id == nil || m.oldValue == nil {
  23305. return v, errors.New("OldStageID requires an ID field in the mutation")
  23306. }
  23307. oldValue, err := m.oldValue(ctx)
  23308. if err != nil {
  23309. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23310. }
  23311. return oldValue.StageID, nil
  23312. }
  23313. // ResetStageID resets all changes to the "stage_id" field.
  23314. func (m *SopNodeMutation) ResetStageID() {
  23315. m.sop_stage = nil
  23316. }
  23317. // SetParentID sets the "parent_id" field.
  23318. func (m *SopNodeMutation) SetParentID(u uint64) {
  23319. m.parent_id = &u
  23320. m.addparent_id = nil
  23321. }
  23322. // ParentID returns the value of the "parent_id" field in the mutation.
  23323. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23324. v := m.parent_id
  23325. if v == nil {
  23326. return
  23327. }
  23328. return *v, true
  23329. }
  23330. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23331. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23333. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23334. if !m.op.Is(OpUpdateOne) {
  23335. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23336. }
  23337. if m.id == nil || m.oldValue == nil {
  23338. return v, errors.New("OldParentID requires an ID field in the mutation")
  23339. }
  23340. oldValue, err := m.oldValue(ctx)
  23341. if err != nil {
  23342. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23343. }
  23344. return oldValue.ParentID, nil
  23345. }
  23346. // AddParentID adds u to the "parent_id" field.
  23347. func (m *SopNodeMutation) AddParentID(u int64) {
  23348. if m.addparent_id != nil {
  23349. *m.addparent_id += u
  23350. } else {
  23351. m.addparent_id = &u
  23352. }
  23353. }
  23354. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23355. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23356. v := m.addparent_id
  23357. if v == nil {
  23358. return
  23359. }
  23360. return *v, true
  23361. }
  23362. // ResetParentID resets all changes to the "parent_id" field.
  23363. func (m *SopNodeMutation) ResetParentID() {
  23364. m.parent_id = nil
  23365. m.addparent_id = nil
  23366. }
  23367. // SetName sets the "name" field.
  23368. func (m *SopNodeMutation) SetName(s string) {
  23369. m.name = &s
  23370. }
  23371. // Name returns the value of the "name" field in the mutation.
  23372. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23373. v := m.name
  23374. if v == nil {
  23375. return
  23376. }
  23377. return *v, true
  23378. }
  23379. // OldName returns the old "name" field's value of the SopNode entity.
  23380. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23382. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23383. if !m.op.Is(OpUpdateOne) {
  23384. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23385. }
  23386. if m.id == nil || m.oldValue == nil {
  23387. return v, errors.New("OldName requires an ID field in the mutation")
  23388. }
  23389. oldValue, err := m.oldValue(ctx)
  23390. if err != nil {
  23391. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23392. }
  23393. return oldValue.Name, nil
  23394. }
  23395. // ResetName resets all changes to the "name" field.
  23396. func (m *SopNodeMutation) ResetName() {
  23397. m.name = nil
  23398. }
  23399. // SetConditionType sets the "condition_type" field.
  23400. func (m *SopNodeMutation) SetConditionType(i int) {
  23401. m.condition_type = &i
  23402. m.addcondition_type = nil
  23403. }
  23404. // ConditionType returns the value of the "condition_type" field in the mutation.
  23405. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23406. v := m.condition_type
  23407. if v == nil {
  23408. return
  23409. }
  23410. return *v, true
  23411. }
  23412. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23413. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23415. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23416. if !m.op.Is(OpUpdateOne) {
  23417. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23418. }
  23419. if m.id == nil || m.oldValue == nil {
  23420. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23421. }
  23422. oldValue, err := m.oldValue(ctx)
  23423. if err != nil {
  23424. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23425. }
  23426. return oldValue.ConditionType, nil
  23427. }
  23428. // AddConditionType adds i to the "condition_type" field.
  23429. func (m *SopNodeMutation) AddConditionType(i int) {
  23430. if m.addcondition_type != nil {
  23431. *m.addcondition_type += i
  23432. } else {
  23433. m.addcondition_type = &i
  23434. }
  23435. }
  23436. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23437. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23438. v := m.addcondition_type
  23439. if v == nil {
  23440. return
  23441. }
  23442. return *v, true
  23443. }
  23444. // ResetConditionType resets all changes to the "condition_type" field.
  23445. func (m *SopNodeMutation) ResetConditionType() {
  23446. m.condition_type = nil
  23447. m.addcondition_type = nil
  23448. }
  23449. // SetConditionList sets the "condition_list" field.
  23450. func (m *SopNodeMutation) SetConditionList(s []string) {
  23451. m.condition_list = &s
  23452. m.appendcondition_list = nil
  23453. }
  23454. // ConditionList returns the value of the "condition_list" field in the mutation.
  23455. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23456. v := m.condition_list
  23457. if v == nil {
  23458. return
  23459. }
  23460. return *v, true
  23461. }
  23462. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23463. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23465. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23466. if !m.op.Is(OpUpdateOne) {
  23467. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23468. }
  23469. if m.id == nil || m.oldValue == nil {
  23470. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23471. }
  23472. oldValue, err := m.oldValue(ctx)
  23473. if err != nil {
  23474. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23475. }
  23476. return oldValue.ConditionList, nil
  23477. }
  23478. // AppendConditionList adds s to the "condition_list" field.
  23479. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23480. m.appendcondition_list = append(m.appendcondition_list, s...)
  23481. }
  23482. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23483. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23484. if len(m.appendcondition_list) == 0 {
  23485. return nil, false
  23486. }
  23487. return m.appendcondition_list, true
  23488. }
  23489. // ClearConditionList clears the value of the "condition_list" field.
  23490. func (m *SopNodeMutation) ClearConditionList() {
  23491. m.condition_list = nil
  23492. m.appendcondition_list = nil
  23493. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23494. }
  23495. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23496. func (m *SopNodeMutation) ConditionListCleared() bool {
  23497. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23498. return ok
  23499. }
  23500. // ResetConditionList resets all changes to the "condition_list" field.
  23501. func (m *SopNodeMutation) ResetConditionList() {
  23502. m.condition_list = nil
  23503. m.appendcondition_list = nil
  23504. delete(m.clearedFields, sopnode.FieldConditionList)
  23505. }
  23506. // SetNoReplyCondition sets the "no_reply_condition" field.
  23507. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23508. m.no_reply_condition = &u
  23509. m.addno_reply_condition = nil
  23510. }
  23511. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23512. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23513. v := m.no_reply_condition
  23514. if v == nil {
  23515. return
  23516. }
  23517. return *v, true
  23518. }
  23519. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23520. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23522. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23523. if !m.op.Is(OpUpdateOne) {
  23524. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23525. }
  23526. if m.id == nil || m.oldValue == nil {
  23527. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23528. }
  23529. oldValue, err := m.oldValue(ctx)
  23530. if err != nil {
  23531. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23532. }
  23533. return oldValue.NoReplyCondition, nil
  23534. }
  23535. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23536. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23537. if m.addno_reply_condition != nil {
  23538. *m.addno_reply_condition += u
  23539. } else {
  23540. m.addno_reply_condition = &u
  23541. }
  23542. }
  23543. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23544. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23545. v := m.addno_reply_condition
  23546. if v == nil {
  23547. return
  23548. }
  23549. return *v, true
  23550. }
  23551. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23552. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23553. m.no_reply_condition = nil
  23554. m.addno_reply_condition = nil
  23555. }
  23556. // SetNoReplyUnit sets the "no_reply_unit" field.
  23557. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23558. m.no_reply_unit = &s
  23559. }
  23560. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23561. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23562. v := m.no_reply_unit
  23563. if v == nil {
  23564. return
  23565. }
  23566. return *v, true
  23567. }
  23568. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  23569. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23571. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23572. if !m.op.Is(OpUpdateOne) {
  23573. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23574. }
  23575. if m.id == nil || m.oldValue == nil {
  23576. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  23577. }
  23578. oldValue, err := m.oldValue(ctx)
  23579. if err != nil {
  23580. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  23581. }
  23582. return oldValue.NoReplyUnit, nil
  23583. }
  23584. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23585. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23586. m.no_reply_unit = nil
  23587. }
  23588. // SetActionMessage sets the "action_message" field.
  23589. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23590. m.action_message = &ct
  23591. m.appendaction_message = nil
  23592. }
  23593. // ActionMessage returns the value of the "action_message" field in the mutation.
  23594. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23595. v := m.action_message
  23596. if v == nil {
  23597. return
  23598. }
  23599. return *v, true
  23600. }
  23601. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23602. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23604. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23605. if !m.op.Is(OpUpdateOne) {
  23606. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23607. }
  23608. if m.id == nil || m.oldValue == nil {
  23609. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23610. }
  23611. oldValue, err := m.oldValue(ctx)
  23612. if err != nil {
  23613. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23614. }
  23615. return oldValue.ActionMessage, nil
  23616. }
  23617. // AppendActionMessage adds ct to the "action_message" field.
  23618. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23619. m.appendaction_message = append(m.appendaction_message, ct...)
  23620. }
  23621. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23622. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23623. if len(m.appendaction_message) == 0 {
  23624. return nil, false
  23625. }
  23626. return m.appendaction_message, true
  23627. }
  23628. // ClearActionMessage clears the value of the "action_message" field.
  23629. func (m *SopNodeMutation) ClearActionMessage() {
  23630. m.action_message = nil
  23631. m.appendaction_message = nil
  23632. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23633. }
  23634. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23635. func (m *SopNodeMutation) ActionMessageCleared() bool {
  23636. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  23637. return ok
  23638. }
  23639. // ResetActionMessage resets all changes to the "action_message" field.
  23640. func (m *SopNodeMutation) ResetActionMessage() {
  23641. m.action_message = nil
  23642. m.appendaction_message = nil
  23643. delete(m.clearedFields, sopnode.FieldActionMessage)
  23644. }
  23645. // SetActionLabelAdd sets the "action_label_add" field.
  23646. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  23647. m.action_label_add = &u
  23648. m.appendaction_label_add = nil
  23649. }
  23650. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23651. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23652. v := m.action_label_add
  23653. if v == nil {
  23654. return
  23655. }
  23656. return *v, true
  23657. }
  23658. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  23659. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23661. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23662. if !m.op.Is(OpUpdateOne) {
  23663. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23664. }
  23665. if m.id == nil || m.oldValue == nil {
  23666. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23667. }
  23668. oldValue, err := m.oldValue(ctx)
  23669. if err != nil {
  23670. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23671. }
  23672. return oldValue.ActionLabelAdd, nil
  23673. }
  23674. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23675. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  23676. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23677. }
  23678. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23679. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23680. if len(m.appendaction_label_add) == 0 {
  23681. return nil, false
  23682. }
  23683. return m.appendaction_label_add, true
  23684. }
  23685. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23686. func (m *SopNodeMutation) ClearActionLabelAdd() {
  23687. m.action_label_add = nil
  23688. m.appendaction_label_add = nil
  23689. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  23690. }
  23691. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23692. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  23693. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  23694. return ok
  23695. }
  23696. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23697. func (m *SopNodeMutation) ResetActionLabelAdd() {
  23698. m.action_label_add = nil
  23699. m.appendaction_label_add = nil
  23700. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  23701. }
  23702. // SetActionLabelDel sets the "action_label_del" field.
  23703. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  23704. m.action_label_del = &u
  23705. m.appendaction_label_del = nil
  23706. }
  23707. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23708. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  23709. v := m.action_label_del
  23710. if v == nil {
  23711. return
  23712. }
  23713. return *v, true
  23714. }
  23715. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  23716. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23718. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23719. if !m.op.Is(OpUpdateOne) {
  23720. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23721. }
  23722. if m.id == nil || m.oldValue == nil {
  23723. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23724. }
  23725. oldValue, err := m.oldValue(ctx)
  23726. if err != nil {
  23727. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23728. }
  23729. return oldValue.ActionLabelDel, nil
  23730. }
  23731. // AppendActionLabelDel adds u to the "action_label_del" field.
  23732. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  23733. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23734. }
  23735. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23736. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23737. if len(m.appendaction_label_del) == 0 {
  23738. return nil, false
  23739. }
  23740. return m.appendaction_label_del, true
  23741. }
  23742. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23743. func (m *SopNodeMutation) ClearActionLabelDel() {
  23744. m.action_label_del = nil
  23745. m.appendaction_label_del = nil
  23746. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  23747. }
  23748. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23749. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  23750. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  23751. return ok
  23752. }
  23753. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23754. func (m *SopNodeMutation) ResetActionLabelDel() {
  23755. m.action_label_del = nil
  23756. m.appendaction_label_del = nil
  23757. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  23758. }
  23759. // SetActionForward sets the "action_forward" field.
  23760. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23761. m.action_forward = &ctf
  23762. }
  23763. // ActionForward returns the value of the "action_forward" field in the mutation.
  23764. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23765. v := m.action_forward
  23766. if v == nil {
  23767. return
  23768. }
  23769. return *v, true
  23770. }
  23771. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  23772. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23774. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23775. if !m.op.Is(OpUpdateOne) {
  23776. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23777. }
  23778. if m.id == nil || m.oldValue == nil {
  23779. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23780. }
  23781. oldValue, err := m.oldValue(ctx)
  23782. if err != nil {
  23783. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23784. }
  23785. return oldValue.ActionForward, nil
  23786. }
  23787. // ClearActionForward clears the value of the "action_forward" field.
  23788. func (m *SopNodeMutation) ClearActionForward() {
  23789. m.action_forward = nil
  23790. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  23791. }
  23792. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23793. func (m *SopNodeMutation) ActionForwardCleared() bool {
  23794. _, ok := m.clearedFields[sopnode.FieldActionForward]
  23795. return ok
  23796. }
  23797. // ResetActionForward resets all changes to the "action_forward" field.
  23798. func (m *SopNodeMutation) ResetActionForward() {
  23799. m.action_forward = nil
  23800. delete(m.clearedFields, sopnode.FieldActionForward)
  23801. }
  23802. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23803. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  23804. m.sop_stage = &id
  23805. }
  23806. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23807. func (m *SopNodeMutation) ClearSopStage() {
  23808. m.clearedsop_stage = true
  23809. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  23810. }
  23811. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23812. func (m *SopNodeMutation) SopStageCleared() bool {
  23813. return m.clearedsop_stage
  23814. }
  23815. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23816. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  23817. if m.sop_stage != nil {
  23818. return *m.sop_stage, true
  23819. }
  23820. return
  23821. }
  23822. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23823. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23824. // SopStageID instead. It exists only for internal usage by the builders.
  23825. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  23826. if id := m.sop_stage; id != nil {
  23827. ids = append(ids, *id)
  23828. }
  23829. return
  23830. }
  23831. // ResetSopStage resets all changes to the "sop_stage" edge.
  23832. func (m *SopNodeMutation) ResetSopStage() {
  23833. m.sop_stage = nil
  23834. m.clearedsop_stage = false
  23835. }
  23836. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  23837. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  23838. if m.node_messages == nil {
  23839. m.node_messages = make(map[uint64]struct{})
  23840. }
  23841. for i := range ids {
  23842. m.node_messages[ids[i]] = struct{}{}
  23843. }
  23844. }
  23845. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  23846. func (m *SopNodeMutation) ClearNodeMessages() {
  23847. m.clearednode_messages = true
  23848. }
  23849. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  23850. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  23851. return m.clearednode_messages
  23852. }
  23853. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  23854. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  23855. if m.removednode_messages == nil {
  23856. m.removednode_messages = make(map[uint64]struct{})
  23857. }
  23858. for i := range ids {
  23859. delete(m.node_messages, ids[i])
  23860. m.removednode_messages[ids[i]] = struct{}{}
  23861. }
  23862. }
  23863. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  23864. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  23865. for id := range m.removednode_messages {
  23866. ids = append(ids, id)
  23867. }
  23868. return
  23869. }
  23870. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  23871. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  23872. for id := range m.node_messages {
  23873. ids = append(ids, id)
  23874. }
  23875. return
  23876. }
  23877. // ResetNodeMessages resets all changes to the "node_messages" edge.
  23878. func (m *SopNodeMutation) ResetNodeMessages() {
  23879. m.node_messages = nil
  23880. m.clearednode_messages = false
  23881. m.removednode_messages = nil
  23882. }
  23883. // Where appends a list predicates to the SopNodeMutation builder.
  23884. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  23885. m.predicates = append(m.predicates, ps...)
  23886. }
  23887. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  23888. // users can use type-assertion to append predicates that do not depend on any generated package.
  23889. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  23890. p := make([]predicate.SopNode, len(ps))
  23891. for i := range ps {
  23892. p[i] = ps[i]
  23893. }
  23894. m.Where(p...)
  23895. }
  23896. // Op returns the operation name.
  23897. func (m *SopNodeMutation) Op() Op {
  23898. return m.op
  23899. }
  23900. // SetOp allows setting the mutation operation.
  23901. func (m *SopNodeMutation) SetOp(op Op) {
  23902. m.op = op
  23903. }
  23904. // Type returns the node type of this mutation (SopNode).
  23905. func (m *SopNodeMutation) Type() string {
  23906. return m.typ
  23907. }
  23908. // Fields returns all fields that were changed during this mutation. Note that in
  23909. // order to get all numeric fields that were incremented/decremented, call
  23910. // AddedFields().
  23911. func (m *SopNodeMutation) Fields() []string {
  23912. fields := make([]string, 0, 15)
  23913. if m.created_at != nil {
  23914. fields = append(fields, sopnode.FieldCreatedAt)
  23915. }
  23916. if m.updated_at != nil {
  23917. fields = append(fields, sopnode.FieldUpdatedAt)
  23918. }
  23919. if m.status != nil {
  23920. fields = append(fields, sopnode.FieldStatus)
  23921. }
  23922. if m.deleted_at != nil {
  23923. fields = append(fields, sopnode.FieldDeletedAt)
  23924. }
  23925. if m.sop_stage != nil {
  23926. fields = append(fields, sopnode.FieldStageID)
  23927. }
  23928. if m.parent_id != nil {
  23929. fields = append(fields, sopnode.FieldParentID)
  23930. }
  23931. if m.name != nil {
  23932. fields = append(fields, sopnode.FieldName)
  23933. }
  23934. if m.condition_type != nil {
  23935. fields = append(fields, sopnode.FieldConditionType)
  23936. }
  23937. if m.condition_list != nil {
  23938. fields = append(fields, sopnode.FieldConditionList)
  23939. }
  23940. if m.no_reply_condition != nil {
  23941. fields = append(fields, sopnode.FieldNoReplyCondition)
  23942. }
  23943. if m.no_reply_unit != nil {
  23944. fields = append(fields, sopnode.FieldNoReplyUnit)
  23945. }
  23946. if m.action_message != nil {
  23947. fields = append(fields, sopnode.FieldActionMessage)
  23948. }
  23949. if m.action_label_add != nil {
  23950. fields = append(fields, sopnode.FieldActionLabelAdd)
  23951. }
  23952. if m.action_label_del != nil {
  23953. fields = append(fields, sopnode.FieldActionLabelDel)
  23954. }
  23955. if m.action_forward != nil {
  23956. fields = append(fields, sopnode.FieldActionForward)
  23957. }
  23958. return fields
  23959. }
  23960. // Field returns the value of a field with the given name. The second boolean
  23961. // return value indicates that this field was not set, or was not defined in the
  23962. // schema.
  23963. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  23964. switch name {
  23965. case sopnode.FieldCreatedAt:
  23966. return m.CreatedAt()
  23967. case sopnode.FieldUpdatedAt:
  23968. return m.UpdatedAt()
  23969. case sopnode.FieldStatus:
  23970. return m.Status()
  23971. case sopnode.FieldDeletedAt:
  23972. return m.DeletedAt()
  23973. case sopnode.FieldStageID:
  23974. return m.StageID()
  23975. case sopnode.FieldParentID:
  23976. return m.ParentID()
  23977. case sopnode.FieldName:
  23978. return m.Name()
  23979. case sopnode.FieldConditionType:
  23980. return m.ConditionType()
  23981. case sopnode.FieldConditionList:
  23982. return m.ConditionList()
  23983. case sopnode.FieldNoReplyCondition:
  23984. return m.NoReplyCondition()
  23985. case sopnode.FieldNoReplyUnit:
  23986. return m.NoReplyUnit()
  23987. case sopnode.FieldActionMessage:
  23988. return m.ActionMessage()
  23989. case sopnode.FieldActionLabelAdd:
  23990. return m.ActionLabelAdd()
  23991. case sopnode.FieldActionLabelDel:
  23992. return m.ActionLabelDel()
  23993. case sopnode.FieldActionForward:
  23994. return m.ActionForward()
  23995. }
  23996. return nil, false
  23997. }
  23998. // OldField returns the old value of the field from the database. An error is
  23999. // returned if the mutation operation is not UpdateOne, or the query to the
  24000. // database failed.
  24001. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24002. switch name {
  24003. case sopnode.FieldCreatedAt:
  24004. return m.OldCreatedAt(ctx)
  24005. case sopnode.FieldUpdatedAt:
  24006. return m.OldUpdatedAt(ctx)
  24007. case sopnode.FieldStatus:
  24008. return m.OldStatus(ctx)
  24009. case sopnode.FieldDeletedAt:
  24010. return m.OldDeletedAt(ctx)
  24011. case sopnode.FieldStageID:
  24012. return m.OldStageID(ctx)
  24013. case sopnode.FieldParentID:
  24014. return m.OldParentID(ctx)
  24015. case sopnode.FieldName:
  24016. return m.OldName(ctx)
  24017. case sopnode.FieldConditionType:
  24018. return m.OldConditionType(ctx)
  24019. case sopnode.FieldConditionList:
  24020. return m.OldConditionList(ctx)
  24021. case sopnode.FieldNoReplyCondition:
  24022. return m.OldNoReplyCondition(ctx)
  24023. case sopnode.FieldNoReplyUnit:
  24024. return m.OldNoReplyUnit(ctx)
  24025. case sopnode.FieldActionMessage:
  24026. return m.OldActionMessage(ctx)
  24027. case sopnode.FieldActionLabelAdd:
  24028. return m.OldActionLabelAdd(ctx)
  24029. case sopnode.FieldActionLabelDel:
  24030. return m.OldActionLabelDel(ctx)
  24031. case sopnode.FieldActionForward:
  24032. return m.OldActionForward(ctx)
  24033. }
  24034. return nil, fmt.Errorf("unknown SopNode field %s", name)
  24035. }
  24036. // SetField sets the value of a field with the given name. It returns an error if
  24037. // the field is not defined in the schema, or if the type mismatched the field
  24038. // type.
  24039. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  24040. switch name {
  24041. case sopnode.FieldCreatedAt:
  24042. v, ok := value.(time.Time)
  24043. if !ok {
  24044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24045. }
  24046. m.SetCreatedAt(v)
  24047. return nil
  24048. case sopnode.FieldUpdatedAt:
  24049. v, ok := value.(time.Time)
  24050. if !ok {
  24051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24052. }
  24053. m.SetUpdatedAt(v)
  24054. return nil
  24055. case sopnode.FieldStatus:
  24056. v, ok := value.(uint8)
  24057. if !ok {
  24058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24059. }
  24060. m.SetStatus(v)
  24061. return nil
  24062. case sopnode.FieldDeletedAt:
  24063. v, ok := value.(time.Time)
  24064. if !ok {
  24065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24066. }
  24067. m.SetDeletedAt(v)
  24068. return nil
  24069. case sopnode.FieldStageID:
  24070. v, ok := value.(uint64)
  24071. if !ok {
  24072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24073. }
  24074. m.SetStageID(v)
  24075. return nil
  24076. case sopnode.FieldParentID:
  24077. v, ok := value.(uint64)
  24078. if !ok {
  24079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24080. }
  24081. m.SetParentID(v)
  24082. return nil
  24083. case sopnode.FieldName:
  24084. v, ok := value.(string)
  24085. if !ok {
  24086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24087. }
  24088. m.SetName(v)
  24089. return nil
  24090. case sopnode.FieldConditionType:
  24091. v, ok := value.(int)
  24092. if !ok {
  24093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24094. }
  24095. m.SetConditionType(v)
  24096. return nil
  24097. case sopnode.FieldConditionList:
  24098. v, ok := value.([]string)
  24099. if !ok {
  24100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24101. }
  24102. m.SetConditionList(v)
  24103. return nil
  24104. case sopnode.FieldNoReplyCondition:
  24105. v, ok := value.(uint64)
  24106. if !ok {
  24107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24108. }
  24109. m.SetNoReplyCondition(v)
  24110. return nil
  24111. case sopnode.FieldNoReplyUnit:
  24112. v, ok := value.(string)
  24113. if !ok {
  24114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24115. }
  24116. m.SetNoReplyUnit(v)
  24117. return nil
  24118. case sopnode.FieldActionMessage:
  24119. v, ok := value.([]custom_types.Action)
  24120. if !ok {
  24121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24122. }
  24123. m.SetActionMessage(v)
  24124. return nil
  24125. case sopnode.FieldActionLabelAdd:
  24126. v, ok := value.([]uint64)
  24127. if !ok {
  24128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24129. }
  24130. m.SetActionLabelAdd(v)
  24131. return nil
  24132. case sopnode.FieldActionLabelDel:
  24133. v, ok := value.([]uint64)
  24134. if !ok {
  24135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24136. }
  24137. m.SetActionLabelDel(v)
  24138. return nil
  24139. case sopnode.FieldActionForward:
  24140. v, ok := value.(*custom_types.ActionForward)
  24141. if !ok {
  24142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24143. }
  24144. m.SetActionForward(v)
  24145. return nil
  24146. }
  24147. return fmt.Errorf("unknown SopNode field %s", name)
  24148. }
  24149. // AddedFields returns all numeric fields that were incremented/decremented during
  24150. // this mutation.
  24151. func (m *SopNodeMutation) AddedFields() []string {
  24152. var fields []string
  24153. if m.addstatus != nil {
  24154. fields = append(fields, sopnode.FieldStatus)
  24155. }
  24156. if m.addparent_id != nil {
  24157. fields = append(fields, sopnode.FieldParentID)
  24158. }
  24159. if m.addcondition_type != nil {
  24160. fields = append(fields, sopnode.FieldConditionType)
  24161. }
  24162. if m.addno_reply_condition != nil {
  24163. fields = append(fields, sopnode.FieldNoReplyCondition)
  24164. }
  24165. return fields
  24166. }
  24167. // AddedField returns the numeric value that was incremented/decremented on a field
  24168. // with the given name. The second boolean return value indicates that this field
  24169. // was not set, or was not defined in the schema.
  24170. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24171. switch name {
  24172. case sopnode.FieldStatus:
  24173. return m.AddedStatus()
  24174. case sopnode.FieldParentID:
  24175. return m.AddedParentID()
  24176. case sopnode.FieldConditionType:
  24177. return m.AddedConditionType()
  24178. case sopnode.FieldNoReplyCondition:
  24179. return m.AddedNoReplyCondition()
  24180. }
  24181. return nil, false
  24182. }
  24183. // AddField adds the value to the field with the given name. It returns an error if
  24184. // the field is not defined in the schema, or if the type mismatched the field
  24185. // type.
  24186. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24187. switch name {
  24188. case sopnode.FieldStatus:
  24189. v, ok := value.(int8)
  24190. if !ok {
  24191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24192. }
  24193. m.AddStatus(v)
  24194. return nil
  24195. case sopnode.FieldParentID:
  24196. v, ok := value.(int64)
  24197. if !ok {
  24198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24199. }
  24200. m.AddParentID(v)
  24201. return nil
  24202. case sopnode.FieldConditionType:
  24203. v, ok := value.(int)
  24204. if !ok {
  24205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24206. }
  24207. m.AddConditionType(v)
  24208. return nil
  24209. case sopnode.FieldNoReplyCondition:
  24210. v, ok := value.(int64)
  24211. if !ok {
  24212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24213. }
  24214. m.AddNoReplyCondition(v)
  24215. return nil
  24216. }
  24217. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24218. }
  24219. // ClearedFields returns all nullable fields that were cleared during this
  24220. // mutation.
  24221. func (m *SopNodeMutation) ClearedFields() []string {
  24222. var fields []string
  24223. if m.FieldCleared(sopnode.FieldStatus) {
  24224. fields = append(fields, sopnode.FieldStatus)
  24225. }
  24226. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24227. fields = append(fields, sopnode.FieldDeletedAt)
  24228. }
  24229. if m.FieldCleared(sopnode.FieldConditionList) {
  24230. fields = append(fields, sopnode.FieldConditionList)
  24231. }
  24232. if m.FieldCleared(sopnode.FieldActionMessage) {
  24233. fields = append(fields, sopnode.FieldActionMessage)
  24234. }
  24235. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24236. fields = append(fields, sopnode.FieldActionLabelAdd)
  24237. }
  24238. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24239. fields = append(fields, sopnode.FieldActionLabelDel)
  24240. }
  24241. if m.FieldCleared(sopnode.FieldActionForward) {
  24242. fields = append(fields, sopnode.FieldActionForward)
  24243. }
  24244. return fields
  24245. }
  24246. // FieldCleared returns a boolean indicating if a field with the given name was
  24247. // cleared in this mutation.
  24248. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24249. _, ok := m.clearedFields[name]
  24250. return ok
  24251. }
  24252. // ClearField clears the value of the field with the given name. It returns an
  24253. // error if the field is not defined in the schema.
  24254. func (m *SopNodeMutation) ClearField(name string) error {
  24255. switch name {
  24256. case sopnode.FieldStatus:
  24257. m.ClearStatus()
  24258. return nil
  24259. case sopnode.FieldDeletedAt:
  24260. m.ClearDeletedAt()
  24261. return nil
  24262. case sopnode.FieldConditionList:
  24263. m.ClearConditionList()
  24264. return nil
  24265. case sopnode.FieldActionMessage:
  24266. m.ClearActionMessage()
  24267. return nil
  24268. case sopnode.FieldActionLabelAdd:
  24269. m.ClearActionLabelAdd()
  24270. return nil
  24271. case sopnode.FieldActionLabelDel:
  24272. m.ClearActionLabelDel()
  24273. return nil
  24274. case sopnode.FieldActionForward:
  24275. m.ClearActionForward()
  24276. return nil
  24277. }
  24278. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24279. }
  24280. // ResetField resets all changes in the mutation for the field with the given name.
  24281. // It returns an error if the field is not defined in the schema.
  24282. func (m *SopNodeMutation) ResetField(name string) error {
  24283. switch name {
  24284. case sopnode.FieldCreatedAt:
  24285. m.ResetCreatedAt()
  24286. return nil
  24287. case sopnode.FieldUpdatedAt:
  24288. m.ResetUpdatedAt()
  24289. return nil
  24290. case sopnode.FieldStatus:
  24291. m.ResetStatus()
  24292. return nil
  24293. case sopnode.FieldDeletedAt:
  24294. m.ResetDeletedAt()
  24295. return nil
  24296. case sopnode.FieldStageID:
  24297. m.ResetStageID()
  24298. return nil
  24299. case sopnode.FieldParentID:
  24300. m.ResetParentID()
  24301. return nil
  24302. case sopnode.FieldName:
  24303. m.ResetName()
  24304. return nil
  24305. case sopnode.FieldConditionType:
  24306. m.ResetConditionType()
  24307. return nil
  24308. case sopnode.FieldConditionList:
  24309. m.ResetConditionList()
  24310. return nil
  24311. case sopnode.FieldNoReplyCondition:
  24312. m.ResetNoReplyCondition()
  24313. return nil
  24314. case sopnode.FieldNoReplyUnit:
  24315. m.ResetNoReplyUnit()
  24316. return nil
  24317. case sopnode.FieldActionMessage:
  24318. m.ResetActionMessage()
  24319. return nil
  24320. case sopnode.FieldActionLabelAdd:
  24321. m.ResetActionLabelAdd()
  24322. return nil
  24323. case sopnode.FieldActionLabelDel:
  24324. m.ResetActionLabelDel()
  24325. return nil
  24326. case sopnode.FieldActionForward:
  24327. m.ResetActionForward()
  24328. return nil
  24329. }
  24330. return fmt.Errorf("unknown SopNode field %s", name)
  24331. }
  24332. // AddedEdges returns all edge names that were set/added in this mutation.
  24333. func (m *SopNodeMutation) AddedEdges() []string {
  24334. edges := make([]string, 0, 2)
  24335. if m.sop_stage != nil {
  24336. edges = append(edges, sopnode.EdgeSopStage)
  24337. }
  24338. if m.node_messages != nil {
  24339. edges = append(edges, sopnode.EdgeNodeMessages)
  24340. }
  24341. return edges
  24342. }
  24343. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24344. // name in this mutation.
  24345. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24346. switch name {
  24347. case sopnode.EdgeSopStage:
  24348. if id := m.sop_stage; id != nil {
  24349. return []ent.Value{*id}
  24350. }
  24351. case sopnode.EdgeNodeMessages:
  24352. ids := make([]ent.Value, 0, len(m.node_messages))
  24353. for id := range m.node_messages {
  24354. ids = append(ids, id)
  24355. }
  24356. return ids
  24357. }
  24358. return nil
  24359. }
  24360. // RemovedEdges returns all edge names that were removed in this mutation.
  24361. func (m *SopNodeMutation) RemovedEdges() []string {
  24362. edges := make([]string, 0, 2)
  24363. if m.removednode_messages != nil {
  24364. edges = append(edges, sopnode.EdgeNodeMessages)
  24365. }
  24366. return edges
  24367. }
  24368. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24369. // the given name in this mutation.
  24370. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24371. switch name {
  24372. case sopnode.EdgeNodeMessages:
  24373. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24374. for id := range m.removednode_messages {
  24375. ids = append(ids, id)
  24376. }
  24377. return ids
  24378. }
  24379. return nil
  24380. }
  24381. // ClearedEdges returns all edge names that were cleared in this mutation.
  24382. func (m *SopNodeMutation) ClearedEdges() []string {
  24383. edges := make([]string, 0, 2)
  24384. if m.clearedsop_stage {
  24385. edges = append(edges, sopnode.EdgeSopStage)
  24386. }
  24387. if m.clearednode_messages {
  24388. edges = append(edges, sopnode.EdgeNodeMessages)
  24389. }
  24390. return edges
  24391. }
  24392. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24393. // was cleared in this mutation.
  24394. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24395. switch name {
  24396. case sopnode.EdgeSopStage:
  24397. return m.clearedsop_stage
  24398. case sopnode.EdgeNodeMessages:
  24399. return m.clearednode_messages
  24400. }
  24401. return false
  24402. }
  24403. // ClearEdge clears the value of the edge with the given name. It returns an error
  24404. // if that edge is not defined in the schema.
  24405. func (m *SopNodeMutation) ClearEdge(name string) error {
  24406. switch name {
  24407. case sopnode.EdgeSopStage:
  24408. m.ClearSopStage()
  24409. return nil
  24410. }
  24411. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24412. }
  24413. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24414. // It returns an error if the edge is not defined in the schema.
  24415. func (m *SopNodeMutation) ResetEdge(name string) error {
  24416. switch name {
  24417. case sopnode.EdgeSopStage:
  24418. m.ResetSopStage()
  24419. return nil
  24420. case sopnode.EdgeNodeMessages:
  24421. m.ResetNodeMessages()
  24422. return nil
  24423. }
  24424. return fmt.Errorf("unknown SopNode edge %s", name)
  24425. }
  24426. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24427. type SopStageMutation struct {
  24428. config
  24429. op Op
  24430. typ string
  24431. id *uint64
  24432. created_at *time.Time
  24433. updated_at *time.Time
  24434. status *uint8
  24435. addstatus *int8
  24436. deleted_at *time.Time
  24437. name *string
  24438. condition_type *int
  24439. addcondition_type *int
  24440. condition_operator *int
  24441. addcondition_operator *int
  24442. condition_list *[]custom_types.Condition
  24443. appendcondition_list []custom_types.Condition
  24444. action_message *[]custom_types.Action
  24445. appendaction_message []custom_types.Action
  24446. action_label_add *[]uint64
  24447. appendaction_label_add []uint64
  24448. action_label_del *[]uint64
  24449. appendaction_label_del []uint64
  24450. action_forward **custom_types.ActionForward
  24451. index_sort *int
  24452. addindex_sort *int
  24453. clearedFields map[string]struct{}
  24454. sop_task *uint64
  24455. clearedsop_task bool
  24456. stage_nodes map[uint64]struct{}
  24457. removedstage_nodes map[uint64]struct{}
  24458. clearedstage_nodes bool
  24459. stage_messages map[uint64]struct{}
  24460. removedstage_messages map[uint64]struct{}
  24461. clearedstage_messages bool
  24462. done bool
  24463. oldValue func(context.Context) (*SopStage, error)
  24464. predicates []predicate.SopStage
  24465. }
  24466. var _ ent.Mutation = (*SopStageMutation)(nil)
  24467. // sopstageOption allows management of the mutation configuration using functional options.
  24468. type sopstageOption func(*SopStageMutation)
  24469. // newSopStageMutation creates new mutation for the SopStage entity.
  24470. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24471. m := &SopStageMutation{
  24472. config: c,
  24473. op: op,
  24474. typ: TypeSopStage,
  24475. clearedFields: make(map[string]struct{}),
  24476. }
  24477. for _, opt := range opts {
  24478. opt(m)
  24479. }
  24480. return m
  24481. }
  24482. // withSopStageID sets the ID field of the mutation.
  24483. func withSopStageID(id uint64) sopstageOption {
  24484. return func(m *SopStageMutation) {
  24485. var (
  24486. err error
  24487. once sync.Once
  24488. value *SopStage
  24489. )
  24490. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24491. once.Do(func() {
  24492. if m.done {
  24493. err = errors.New("querying old values post mutation is not allowed")
  24494. } else {
  24495. value, err = m.Client().SopStage.Get(ctx, id)
  24496. }
  24497. })
  24498. return value, err
  24499. }
  24500. m.id = &id
  24501. }
  24502. }
  24503. // withSopStage sets the old SopStage of the mutation.
  24504. func withSopStage(node *SopStage) sopstageOption {
  24505. return func(m *SopStageMutation) {
  24506. m.oldValue = func(context.Context) (*SopStage, error) {
  24507. return node, nil
  24508. }
  24509. m.id = &node.ID
  24510. }
  24511. }
  24512. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24513. // executed in a transaction (ent.Tx), a transactional client is returned.
  24514. func (m SopStageMutation) Client() *Client {
  24515. client := &Client{config: m.config}
  24516. client.init()
  24517. return client
  24518. }
  24519. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24520. // it returns an error otherwise.
  24521. func (m SopStageMutation) Tx() (*Tx, error) {
  24522. if _, ok := m.driver.(*txDriver); !ok {
  24523. return nil, errors.New("ent: mutation is not running in a transaction")
  24524. }
  24525. tx := &Tx{config: m.config}
  24526. tx.init()
  24527. return tx, nil
  24528. }
  24529. // SetID sets the value of the id field. Note that this
  24530. // operation is only accepted on creation of SopStage entities.
  24531. func (m *SopStageMutation) SetID(id uint64) {
  24532. m.id = &id
  24533. }
  24534. // ID returns the ID value in the mutation. Note that the ID is only available
  24535. // if it was provided to the builder or after it was returned from the database.
  24536. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24537. if m.id == nil {
  24538. return
  24539. }
  24540. return *m.id, true
  24541. }
  24542. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24543. // That means, if the mutation is applied within a transaction with an isolation level such
  24544. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24545. // or updated by the mutation.
  24546. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24547. switch {
  24548. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24549. id, exists := m.ID()
  24550. if exists {
  24551. return []uint64{id}, nil
  24552. }
  24553. fallthrough
  24554. case m.op.Is(OpUpdate | OpDelete):
  24555. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24556. default:
  24557. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24558. }
  24559. }
  24560. // SetCreatedAt sets the "created_at" field.
  24561. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24562. m.created_at = &t
  24563. }
  24564. // CreatedAt returns the value of the "created_at" field in the mutation.
  24565. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24566. v := m.created_at
  24567. if v == nil {
  24568. return
  24569. }
  24570. return *v, true
  24571. }
  24572. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24573. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24575. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24576. if !m.op.Is(OpUpdateOne) {
  24577. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24578. }
  24579. if m.id == nil || m.oldValue == nil {
  24580. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24581. }
  24582. oldValue, err := m.oldValue(ctx)
  24583. if err != nil {
  24584. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24585. }
  24586. return oldValue.CreatedAt, nil
  24587. }
  24588. // ResetCreatedAt resets all changes to the "created_at" field.
  24589. func (m *SopStageMutation) ResetCreatedAt() {
  24590. m.created_at = nil
  24591. }
  24592. // SetUpdatedAt sets the "updated_at" field.
  24593. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24594. m.updated_at = &t
  24595. }
  24596. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24597. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24598. v := m.updated_at
  24599. if v == nil {
  24600. return
  24601. }
  24602. return *v, true
  24603. }
  24604. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24605. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24607. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24608. if !m.op.Is(OpUpdateOne) {
  24609. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24610. }
  24611. if m.id == nil || m.oldValue == nil {
  24612. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24613. }
  24614. oldValue, err := m.oldValue(ctx)
  24615. if err != nil {
  24616. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24617. }
  24618. return oldValue.UpdatedAt, nil
  24619. }
  24620. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24621. func (m *SopStageMutation) ResetUpdatedAt() {
  24622. m.updated_at = nil
  24623. }
  24624. // SetStatus sets the "status" field.
  24625. func (m *SopStageMutation) SetStatus(u uint8) {
  24626. m.status = &u
  24627. m.addstatus = nil
  24628. }
  24629. // Status returns the value of the "status" field in the mutation.
  24630. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24631. v := m.status
  24632. if v == nil {
  24633. return
  24634. }
  24635. return *v, true
  24636. }
  24637. // OldStatus returns the old "status" field's value of the SopStage entity.
  24638. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24640. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24641. if !m.op.Is(OpUpdateOne) {
  24642. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24643. }
  24644. if m.id == nil || m.oldValue == nil {
  24645. return v, errors.New("OldStatus requires an ID field in the mutation")
  24646. }
  24647. oldValue, err := m.oldValue(ctx)
  24648. if err != nil {
  24649. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24650. }
  24651. return oldValue.Status, nil
  24652. }
  24653. // AddStatus adds u to the "status" field.
  24654. func (m *SopStageMutation) AddStatus(u int8) {
  24655. if m.addstatus != nil {
  24656. *m.addstatus += u
  24657. } else {
  24658. m.addstatus = &u
  24659. }
  24660. }
  24661. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24662. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  24663. v := m.addstatus
  24664. if v == nil {
  24665. return
  24666. }
  24667. return *v, true
  24668. }
  24669. // ClearStatus clears the value of the "status" field.
  24670. func (m *SopStageMutation) ClearStatus() {
  24671. m.status = nil
  24672. m.addstatus = nil
  24673. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  24674. }
  24675. // StatusCleared returns if the "status" field was cleared in this mutation.
  24676. func (m *SopStageMutation) StatusCleared() bool {
  24677. _, ok := m.clearedFields[sopstage.FieldStatus]
  24678. return ok
  24679. }
  24680. // ResetStatus resets all changes to the "status" field.
  24681. func (m *SopStageMutation) ResetStatus() {
  24682. m.status = nil
  24683. m.addstatus = nil
  24684. delete(m.clearedFields, sopstage.FieldStatus)
  24685. }
  24686. // SetDeletedAt sets the "deleted_at" field.
  24687. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  24688. m.deleted_at = &t
  24689. }
  24690. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24691. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  24692. v := m.deleted_at
  24693. if v == nil {
  24694. return
  24695. }
  24696. return *v, true
  24697. }
  24698. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  24699. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24701. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24702. if !m.op.Is(OpUpdateOne) {
  24703. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24704. }
  24705. if m.id == nil || m.oldValue == nil {
  24706. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24707. }
  24708. oldValue, err := m.oldValue(ctx)
  24709. if err != nil {
  24710. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24711. }
  24712. return oldValue.DeletedAt, nil
  24713. }
  24714. // ClearDeletedAt clears the value of the "deleted_at" field.
  24715. func (m *SopStageMutation) ClearDeletedAt() {
  24716. m.deleted_at = nil
  24717. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  24718. }
  24719. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24720. func (m *SopStageMutation) DeletedAtCleared() bool {
  24721. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  24722. return ok
  24723. }
  24724. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24725. func (m *SopStageMutation) ResetDeletedAt() {
  24726. m.deleted_at = nil
  24727. delete(m.clearedFields, sopstage.FieldDeletedAt)
  24728. }
  24729. // SetTaskID sets the "task_id" field.
  24730. func (m *SopStageMutation) SetTaskID(u uint64) {
  24731. m.sop_task = &u
  24732. }
  24733. // TaskID returns the value of the "task_id" field in the mutation.
  24734. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  24735. v := m.sop_task
  24736. if v == nil {
  24737. return
  24738. }
  24739. return *v, true
  24740. }
  24741. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  24742. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24744. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  24745. if !m.op.Is(OpUpdateOne) {
  24746. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  24747. }
  24748. if m.id == nil || m.oldValue == nil {
  24749. return v, errors.New("OldTaskID requires an ID field in the mutation")
  24750. }
  24751. oldValue, err := m.oldValue(ctx)
  24752. if err != nil {
  24753. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  24754. }
  24755. return oldValue.TaskID, nil
  24756. }
  24757. // ResetTaskID resets all changes to the "task_id" field.
  24758. func (m *SopStageMutation) ResetTaskID() {
  24759. m.sop_task = nil
  24760. }
  24761. // SetName sets the "name" field.
  24762. func (m *SopStageMutation) SetName(s string) {
  24763. m.name = &s
  24764. }
  24765. // Name returns the value of the "name" field in the mutation.
  24766. func (m *SopStageMutation) Name() (r string, exists bool) {
  24767. v := m.name
  24768. if v == nil {
  24769. return
  24770. }
  24771. return *v, true
  24772. }
  24773. // OldName returns the old "name" field's value of the SopStage entity.
  24774. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24776. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  24777. if !m.op.Is(OpUpdateOne) {
  24778. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24779. }
  24780. if m.id == nil || m.oldValue == nil {
  24781. return v, errors.New("OldName requires an ID field in the mutation")
  24782. }
  24783. oldValue, err := m.oldValue(ctx)
  24784. if err != nil {
  24785. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24786. }
  24787. return oldValue.Name, nil
  24788. }
  24789. // ResetName resets all changes to the "name" field.
  24790. func (m *SopStageMutation) ResetName() {
  24791. m.name = nil
  24792. }
  24793. // SetConditionType sets the "condition_type" field.
  24794. func (m *SopStageMutation) SetConditionType(i int) {
  24795. m.condition_type = &i
  24796. m.addcondition_type = nil
  24797. }
  24798. // ConditionType returns the value of the "condition_type" field in the mutation.
  24799. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  24800. v := m.condition_type
  24801. if v == nil {
  24802. return
  24803. }
  24804. return *v, true
  24805. }
  24806. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  24807. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24809. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24810. if !m.op.Is(OpUpdateOne) {
  24811. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24812. }
  24813. if m.id == nil || m.oldValue == nil {
  24814. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24815. }
  24816. oldValue, err := m.oldValue(ctx)
  24817. if err != nil {
  24818. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24819. }
  24820. return oldValue.ConditionType, nil
  24821. }
  24822. // AddConditionType adds i to the "condition_type" field.
  24823. func (m *SopStageMutation) AddConditionType(i int) {
  24824. if m.addcondition_type != nil {
  24825. *m.addcondition_type += i
  24826. } else {
  24827. m.addcondition_type = &i
  24828. }
  24829. }
  24830. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24831. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  24832. v := m.addcondition_type
  24833. if v == nil {
  24834. return
  24835. }
  24836. return *v, true
  24837. }
  24838. // ResetConditionType resets all changes to the "condition_type" field.
  24839. func (m *SopStageMutation) ResetConditionType() {
  24840. m.condition_type = nil
  24841. m.addcondition_type = nil
  24842. }
  24843. // SetConditionOperator sets the "condition_operator" field.
  24844. func (m *SopStageMutation) SetConditionOperator(i int) {
  24845. m.condition_operator = &i
  24846. m.addcondition_operator = nil
  24847. }
  24848. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  24849. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  24850. v := m.condition_operator
  24851. if v == nil {
  24852. return
  24853. }
  24854. return *v, true
  24855. }
  24856. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  24857. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24859. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  24860. if !m.op.Is(OpUpdateOne) {
  24861. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  24862. }
  24863. if m.id == nil || m.oldValue == nil {
  24864. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  24865. }
  24866. oldValue, err := m.oldValue(ctx)
  24867. if err != nil {
  24868. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  24869. }
  24870. return oldValue.ConditionOperator, nil
  24871. }
  24872. // AddConditionOperator adds i to the "condition_operator" field.
  24873. func (m *SopStageMutation) AddConditionOperator(i int) {
  24874. if m.addcondition_operator != nil {
  24875. *m.addcondition_operator += i
  24876. } else {
  24877. m.addcondition_operator = &i
  24878. }
  24879. }
  24880. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  24881. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  24882. v := m.addcondition_operator
  24883. if v == nil {
  24884. return
  24885. }
  24886. return *v, true
  24887. }
  24888. // ResetConditionOperator resets all changes to the "condition_operator" field.
  24889. func (m *SopStageMutation) ResetConditionOperator() {
  24890. m.condition_operator = nil
  24891. m.addcondition_operator = nil
  24892. }
  24893. // SetConditionList sets the "condition_list" field.
  24894. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  24895. m.condition_list = &ct
  24896. m.appendcondition_list = nil
  24897. }
  24898. // ConditionList returns the value of the "condition_list" field in the mutation.
  24899. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  24900. v := m.condition_list
  24901. if v == nil {
  24902. return
  24903. }
  24904. return *v, true
  24905. }
  24906. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  24907. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24909. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  24910. if !m.op.Is(OpUpdateOne) {
  24911. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24912. }
  24913. if m.id == nil || m.oldValue == nil {
  24914. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24915. }
  24916. oldValue, err := m.oldValue(ctx)
  24917. if err != nil {
  24918. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24919. }
  24920. return oldValue.ConditionList, nil
  24921. }
  24922. // AppendConditionList adds ct to the "condition_list" field.
  24923. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  24924. m.appendcondition_list = append(m.appendcondition_list, ct...)
  24925. }
  24926. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  24927. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  24928. if len(m.appendcondition_list) == 0 {
  24929. return nil, false
  24930. }
  24931. return m.appendcondition_list, true
  24932. }
  24933. // ResetConditionList resets all changes to the "condition_list" field.
  24934. func (m *SopStageMutation) ResetConditionList() {
  24935. m.condition_list = nil
  24936. m.appendcondition_list = nil
  24937. }
  24938. // SetActionMessage sets the "action_message" field.
  24939. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  24940. m.action_message = &ct
  24941. m.appendaction_message = nil
  24942. }
  24943. // ActionMessage returns the value of the "action_message" field in the mutation.
  24944. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  24945. v := m.action_message
  24946. if v == nil {
  24947. return
  24948. }
  24949. return *v, true
  24950. }
  24951. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  24952. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24954. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  24955. if !m.op.Is(OpUpdateOne) {
  24956. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  24957. }
  24958. if m.id == nil || m.oldValue == nil {
  24959. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  24960. }
  24961. oldValue, err := m.oldValue(ctx)
  24962. if err != nil {
  24963. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  24964. }
  24965. return oldValue.ActionMessage, nil
  24966. }
  24967. // AppendActionMessage adds ct to the "action_message" field.
  24968. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  24969. m.appendaction_message = append(m.appendaction_message, ct...)
  24970. }
  24971. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  24972. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  24973. if len(m.appendaction_message) == 0 {
  24974. return nil, false
  24975. }
  24976. return m.appendaction_message, true
  24977. }
  24978. // ClearActionMessage clears the value of the "action_message" field.
  24979. func (m *SopStageMutation) ClearActionMessage() {
  24980. m.action_message = nil
  24981. m.appendaction_message = nil
  24982. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  24983. }
  24984. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24985. func (m *SopStageMutation) ActionMessageCleared() bool {
  24986. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  24987. return ok
  24988. }
  24989. // ResetActionMessage resets all changes to the "action_message" field.
  24990. func (m *SopStageMutation) ResetActionMessage() {
  24991. m.action_message = nil
  24992. m.appendaction_message = nil
  24993. delete(m.clearedFields, sopstage.FieldActionMessage)
  24994. }
  24995. // SetActionLabelAdd sets the "action_label_add" field.
  24996. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  24997. m.action_label_add = &u
  24998. m.appendaction_label_add = nil
  24999. }
  25000. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25001. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25002. v := m.action_label_add
  25003. if v == nil {
  25004. return
  25005. }
  25006. return *v, true
  25007. }
  25008. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  25009. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25011. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25012. if !m.op.Is(OpUpdateOne) {
  25013. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25014. }
  25015. if m.id == nil || m.oldValue == nil {
  25016. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25017. }
  25018. oldValue, err := m.oldValue(ctx)
  25019. if err != nil {
  25020. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25021. }
  25022. return oldValue.ActionLabelAdd, nil
  25023. }
  25024. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25025. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  25026. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25027. }
  25028. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25029. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25030. if len(m.appendaction_label_add) == 0 {
  25031. return nil, false
  25032. }
  25033. return m.appendaction_label_add, true
  25034. }
  25035. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25036. func (m *SopStageMutation) ClearActionLabelAdd() {
  25037. m.action_label_add = nil
  25038. m.appendaction_label_add = nil
  25039. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  25040. }
  25041. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25042. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  25043. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  25044. return ok
  25045. }
  25046. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25047. func (m *SopStageMutation) ResetActionLabelAdd() {
  25048. m.action_label_add = nil
  25049. m.appendaction_label_add = nil
  25050. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  25051. }
  25052. // SetActionLabelDel sets the "action_label_del" field.
  25053. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  25054. m.action_label_del = &u
  25055. m.appendaction_label_del = nil
  25056. }
  25057. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25058. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  25059. v := m.action_label_del
  25060. if v == nil {
  25061. return
  25062. }
  25063. return *v, true
  25064. }
  25065. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  25066. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25068. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25069. if !m.op.Is(OpUpdateOne) {
  25070. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25071. }
  25072. if m.id == nil || m.oldValue == nil {
  25073. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25074. }
  25075. oldValue, err := m.oldValue(ctx)
  25076. if err != nil {
  25077. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25078. }
  25079. return oldValue.ActionLabelDel, nil
  25080. }
  25081. // AppendActionLabelDel adds u to the "action_label_del" field.
  25082. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25083. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25084. }
  25085. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25086. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25087. if len(m.appendaction_label_del) == 0 {
  25088. return nil, false
  25089. }
  25090. return m.appendaction_label_del, true
  25091. }
  25092. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25093. func (m *SopStageMutation) ClearActionLabelDel() {
  25094. m.action_label_del = nil
  25095. m.appendaction_label_del = nil
  25096. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25097. }
  25098. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25099. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25100. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25101. return ok
  25102. }
  25103. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25104. func (m *SopStageMutation) ResetActionLabelDel() {
  25105. m.action_label_del = nil
  25106. m.appendaction_label_del = nil
  25107. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25108. }
  25109. // SetActionForward sets the "action_forward" field.
  25110. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25111. m.action_forward = &ctf
  25112. }
  25113. // ActionForward returns the value of the "action_forward" field in the mutation.
  25114. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25115. v := m.action_forward
  25116. if v == nil {
  25117. return
  25118. }
  25119. return *v, true
  25120. }
  25121. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25122. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25124. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25125. if !m.op.Is(OpUpdateOne) {
  25126. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25127. }
  25128. if m.id == nil || m.oldValue == nil {
  25129. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25130. }
  25131. oldValue, err := m.oldValue(ctx)
  25132. if err != nil {
  25133. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25134. }
  25135. return oldValue.ActionForward, nil
  25136. }
  25137. // ClearActionForward clears the value of the "action_forward" field.
  25138. func (m *SopStageMutation) ClearActionForward() {
  25139. m.action_forward = nil
  25140. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25141. }
  25142. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25143. func (m *SopStageMutation) ActionForwardCleared() bool {
  25144. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25145. return ok
  25146. }
  25147. // ResetActionForward resets all changes to the "action_forward" field.
  25148. func (m *SopStageMutation) ResetActionForward() {
  25149. m.action_forward = nil
  25150. delete(m.clearedFields, sopstage.FieldActionForward)
  25151. }
  25152. // SetIndexSort sets the "index_sort" field.
  25153. func (m *SopStageMutation) SetIndexSort(i int) {
  25154. m.index_sort = &i
  25155. m.addindex_sort = nil
  25156. }
  25157. // IndexSort returns the value of the "index_sort" field in the mutation.
  25158. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25159. v := m.index_sort
  25160. if v == nil {
  25161. return
  25162. }
  25163. return *v, true
  25164. }
  25165. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25166. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25168. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25169. if !m.op.Is(OpUpdateOne) {
  25170. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25171. }
  25172. if m.id == nil || m.oldValue == nil {
  25173. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25174. }
  25175. oldValue, err := m.oldValue(ctx)
  25176. if err != nil {
  25177. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25178. }
  25179. return oldValue.IndexSort, nil
  25180. }
  25181. // AddIndexSort adds i to the "index_sort" field.
  25182. func (m *SopStageMutation) AddIndexSort(i int) {
  25183. if m.addindex_sort != nil {
  25184. *m.addindex_sort += i
  25185. } else {
  25186. m.addindex_sort = &i
  25187. }
  25188. }
  25189. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25190. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25191. v := m.addindex_sort
  25192. if v == nil {
  25193. return
  25194. }
  25195. return *v, true
  25196. }
  25197. // ClearIndexSort clears the value of the "index_sort" field.
  25198. func (m *SopStageMutation) ClearIndexSort() {
  25199. m.index_sort = nil
  25200. m.addindex_sort = nil
  25201. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25202. }
  25203. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25204. func (m *SopStageMutation) IndexSortCleared() bool {
  25205. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25206. return ok
  25207. }
  25208. // ResetIndexSort resets all changes to the "index_sort" field.
  25209. func (m *SopStageMutation) ResetIndexSort() {
  25210. m.index_sort = nil
  25211. m.addindex_sort = nil
  25212. delete(m.clearedFields, sopstage.FieldIndexSort)
  25213. }
  25214. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25215. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25216. m.sop_task = &id
  25217. }
  25218. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25219. func (m *SopStageMutation) ClearSopTask() {
  25220. m.clearedsop_task = true
  25221. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25222. }
  25223. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25224. func (m *SopStageMutation) SopTaskCleared() bool {
  25225. return m.clearedsop_task
  25226. }
  25227. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25228. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25229. if m.sop_task != nil {
  25230. return *m.sop_task, true
  25231. }
  25232. return
  25233. }
  25234. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25235. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25236. // SopTaskID instead. It exists only for internal usage by the builders.
  25237. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25238. if id := m.sop_task; id != nil {
  25239. ids = append(ids, *id)
  25240. }
  25241. return
  25242. }
  25243. // ResetSopTask resets all changes to the "sop_task" edge.
  25244. func (m *SopStageMutation) ResetSopTask() {
  25245. m.sop_task = nil
  25246. m.clearedsop_task = false
  25247. }
  25248. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25249. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25250. if m.stage_nodes == nil {
  25251. m.stage_nodes = make(map[uint64]struct{})
  25252. }
  25253. for i := range ids {
  25254. m.stage_nodes[ids[i]] = struct{}{}
  25255. }
  25256. }
  25257. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25258. func (m *SopStageMutation) ClearStageNodes() {
  25259. m.clearedstage_nodes = true
  25260. }
  25261. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25262. func (m *SopStageMutation) StageNodesCleared() bool {
  25263. return m.clearedstage_nodes
  25264. }
  25265. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25266. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25267. if m.removedstage_nodes == nil {
  25268. m.removedstage_nodes = make(map[uint64]struct{})
  25269. }
  25270. for i := range ids {
  25271. delete(m.stage_nodes, ids[i])
  25272. m.removedstage_nodes[ids[i]] = struct{}{}
  25273. }
  25274. }
  25275. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25276. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25277. for id := range m.removedstage_nodes {
  25278. ids = append(ids, id)
  25279. }
  25280. return
  25281. }
  25282. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25283. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25284. for id := range m.stage_nodes {
  25285. ids = append(ids, id)
  25286. }
  25287. return
  25288. }
  25289. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25290. func (m *SopStageMutation) ResetStageNodes() {
  25291. m.stage_nodes = nil
  25292. m.clearedstage_nodes = false
  25293. m.removedstage_nodes = nil
  25294. }
  25295. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25296. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25297. if m.stage_messages == nil {
  25298. m.stage_messages = make(map[uint64]struct{})
  25299. }
  25300. for i := range ids {
  25301. m.stage_messages[ids[i]] = struct{}{}
  25302. }
  25303. }
  25304. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25305. func (m *SopStageMutation) ClearStageMessages() {
  25306. m.clearedstage_messages = true
  25307. }
  25308. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25309. func (m *SopStageMutation) StageMessagesCleared() bool {
  25310. return m.clearedstage_messages
  25311. }
  25312. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25313. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25314. if m.removedstage_messages == nil {
  25315. m.removedstage_messages = make(map[uint64]struct{})
  25316. }
  25317. for i := range ids {
  25318. delete(m.stage_messages, ids[i])
  25319. m.removedstage_messages[ids[i]] = struct{}{}
  25320. }
  25321. }
  25322. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25323. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25324. for id := range m.removedstage_messages {
  25325. ids = append(ids, id)
  25326. }
  25327. return
  25328. }
  25329. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25330. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25331. for id := range m.stage_messages {
  25332. ids = append(ids, id)
  25333. }
  25334. return
  25335. }
  25336. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25337. func (m *SopStageMutation) ResetStageMessages() {
  25338. m.stage_messages = nil
  25339. m.clearedstage_messages = false
  25340. m.removedstage_messages = nil
  25341. }
  25342. // Where appends a list predicates to the SopStageMutation builder.
  25343. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25344. m.predicates = append(m.predicates, ps...)
  25345. }
  25346. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25347. // users can use type-assertion to append predicates that do not depend on any generated package.
  25348. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25349. p := make([]predicate.SopStage, len(ps))
  25350. for i := range ps {
  25351. p[i] = ps[i]
  25352. }
  25353. m.Where(p...)
  25354. }
  25355. // Op returns the operation name.
  25356. func (m *SopStageMutation) Op() Op {
  25357. return m.op
  25358. }
  25359. // SetOp allows setting the mutation operation.
  25360. func (m *SopStageMutation) SetOp(op Op) {
  25361. m.op = op
  25362. }
  25363. // Type returns the node type of this mutation (SopStage).
  25364. func (m *SopStageMutation) Type() string {
  25365. return m.typ
  25366. }
  25367. // Fields returns all fields that were changed during this mutation. Note that in
  25368. // order to get all numeric fields that were incremented/decremented, call
  25369. // AddedFields().
  25370. func (m *SopStageMutation) Fields() []string {
  25371. fields := make([]string, 0, 14)
  25372. if m.created_at != nil {
  25373. fields = append(fields, sopstage.FieldCreatedAt)
  25374. }
  25375. if m.updated_at != nil {
  25376. fields = append(fields, sopstage.FieldUpdatedAt)
  25377. }
  25378. if m.status != nil {
  25379. fields = append(fields, sopstage.FieldStatus)
  25380. }
  25381. if m.deleted_at != nil {
  25382. fields = append(fields, sopstage.FieldDeletedAt)
  25383. }
  25384. if m.sop_task != nil {
  25385. fields = append(fields, sopstage.FieldTaskID)
  25386. }
  25387. if m.name != nil {
  25388. fields = append(fields, sopstage.FieldName)
  25389. }
  25390. if m.condition_type != nil {
  25391. fields = append(fields, sopstage.FieldConditionType)
  25392. }
  25393. if m.condition_operator != nil {
  25394. fields = append(fields, sopstage.FieldConditionOperator)
  25395. }
  25396. if m.condition_list != nil {
  25397. fields = append(fields, sopstage.FieldConditionList)
  25398. }
  25399. if m.action_message != nil {
  25400. fields = append(fields, sopstage.FieldActionMessage)
  25401. }
  25402. if m.action_label_add != nil {
  25403. fields = append(fields, sopstage.FieldActionLabelAdd)
  25404. }
  25405. if m.action_label_del != nil {
  25406. fields = append(fields, sopstage.FieldActionLabelDel)
  25407. }
  25408. if m.action_forward != nil {
  25409. fields = append(fields, sopstage.FieldActionForward)
  25410. }
  25411. if m.index_sort != nil {
  25412. fields = append(fields, sopstage.FieldIndexSort)
  25413. }
  25414. return fields
  25415. }
  25416. // Field returns the value of a field with the given name. The second boolean
  25417. // return value indicates that this field was not set, or was not defined in the
  25418. // schema.
  25419. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25420. switch name {
  25421. case sopstage.FieldCreatedAt:
  25422. return m.CreatedAt()
  25423. case sopstage.FieldUpdatedAt:
  25424. return m.UpdatedAt()
  25425. case sopstage.FieldStatus:
  25426. return m.Status()
  25427. case sopstage.FieldDeletedAt:
  25428. return m.DeletedAt()
  25429. case sopstage.FieldTaskID:
  25430. return m.TaskID()
  25431. case sopstage.FieldName:
  25432. return m.Name()
  25433. case sopstage.FieldConditionType:
  25434. return m.ConditionType()
  25435. case sopstage.FieldConditionOperator:
  25436. return m.ConditionOperator()
  25437. case sopstage.FieldConditionList:
  25438. return m.ConditionList()
  25439. case sopstage.FieldActionMessage:
  25440. return m.ActionMessage()
  25441. case sopstage.FieldActionLabelAdd:
  25442. return m.ActionLabelAdd()
  25443. case sopstage.FieldActionLabelDel:
  25444. return m.ActionLabelDel()
  25445. case sopstage.FieldActionForward:
  25446. return m.ActionForward()
  25447. case sopstage.FieldIndexSort:
  25448. return m.IndexSort()
  25449. }
  25450. return nil, false
  25451. }
  25452. // OldField returns the old value of the field from the database. An error is
  25453. // returned if the mutation operation is not UpdateOne, or the query to the
  25454. // database failed.
  25455. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25456. switch name {
  25457. case sopstage.FieldCreatedAt:
  25458. return m.OldCreatedAt(ctx)
  25459. case sopstage.FieldUpdatedAt:
  25460. return m.OldUpdatedAt(ctx)
  25461. case sopstage.FieldStatus:
  25462. return m.OldStatus(ctx)
  25463. case sopstage.FieldDeletedAt:
  25464. return m.OldDeletedAt(ctx)
  25465. case sopstage.FieldTaskID:
  25466. return m.OldTaskID(ctx)
  25467. case sopstage.FieldName:
  25468. return m.OldName(ctx)
  25469. case sopstage.FieldConditionType:
  25470. return m.OldConditionType(ctx)
  25471. case sopstage.FieldConditionOperator:
  25472. return m.OldConditionOperator(ctx)
  25473. case sopstage.FieldConditionList:
  25474. return m.OldConditionList(ctx)
  25475. case sopstage.FieldActionMessage:
  25476. return m.OldActionMessage(ctx)
  25477. case sopstage.FieldActionLabelAdd:
  25478. return m.OldActionLabelAdd(ctx)
  25479. case sopstage.FieldActionLabelDel:
  25480. return m.OldActionLabelDel(ctx)
  25481. case sopstage.FieldActionForward:
  25482. return m.OldActionForward(ctx)
  25483. case sopstage.FieldIndexSort:
  25484. return m.OldIndexSort(ctx)
  25485. }
  25486. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25487. }
  25488. // SetField sets the value of a field with the given name. It returns an error if
  25489. // the field is not defined in the schema, or if the type mismatched the field
  25490. // type.
  25491. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25492. switch name {
  25493. case sopstage.FieldCreatedAt:
  25494. v, ok := value.(time.Time)
  25495. if !ok {
  25496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25497. }
  25498. m.SetCreatedAt(v)
  25499. return nil
  25500. case sopstage.FieldUpdatedAt:
  25501. v, ok := value.(time.Time)
  25502. if !ok {
  25503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25504. }
  25505. m.SetUpdatedAt(v)
  25506. return nil
  25507. case sopstage.FieldStatus:
  25508. v, ok := value.(uint8)
  25509. if !ok {
  25510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25511. }
  25512. m.SetStatus(v)
  25513. return nil
  25514. case sopstage.FieldDeletedAt:
  25515. v, ok := value.(time.Time)
  25516. if !ok {
  25517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25518. }
  25519. m.SetDeletedAt(v)
  25520. return nil
  25521. case sopstage.FieldTaskID:
  25522. v, ok := value.(uint64)
  25523. if !ok {
  25524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25525. }
  25526. m.SetTaskID(v)
  25527. return nil
  25528. case sopstage.FieldName:
  25529. v, ok := value.(string)
  25530. if !ok {
  25531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25532. }
  25533. m.SetName(v)
  25534. return nil
  25535. case sopstage.FieldConditionType:
  25536. v, ok := value.(int)
  25537. if !ok {
  25538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25539. }
  25540. m.SetConditionType(v)
  25541. return nil
  25542. case sopstage.FieldConditionOperator:
  25543. v, ok := value.(int)
  25544. if !ok {
  25545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25546. }
  25547. m.SetConditionOperator(v)
  25548. return nil
  25549. case sopstage.FieldConditionList:
  25550. v, ok := value.([]custom_types.Condition)
  25551. if !ok {
  25552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25553. }
  25554. m.SetConditionList(v)
  25555. return nil
  25556. case sopstage.FieldActionMessage:
  25557. v, ok := value.([]custom_types.Action)
  25558. if !ok {
  25559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25560. }
  25561. m.SetActionMessage(v)
  25562. return nil
  25563. case sopstage.FieldActionLabelAdd:
  25564. v, ok := value.([]uint64)
  25565. if !ok {
  25566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25567. }
  25568. m.SetActionLabelAdd(v)
  25569. return nil
  25570. case sopstage.FieldActionLabelDel:
  25571. v, ok := value.([]uint64)
  25572. if !ok {
  25573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25574. }
  25575. m.SetActionLabelDel(v)
  25576. return nil
  25577. case sopstage.FieldActionForward:
  25578. v, ok := value.(*custom_types.ActionForward)
  25579. if !ok {
  25580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25581. }
  25582. m.SetActionForward(v)
  25583. return nil
  25584. case sopstage.FieldIndexSort:
  25585. v, ok := value.(int)
  25586. if !ok {
  25587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25588. }
  25589. m.SetIndexSort(v)
  25590. return nil
  25591. }
  25592. return fmt.Errorf("unknown SopStage field %s", name)
  25593. }
  25594. // AddedFields returns all numeric fields that were incremented/decremented during
  25595. // this mutation.
  25596. func (m *SopStageMutation) AddedFields() []string {
  25597. var fields []string
  25598. if m.addstatus != nil {
  25599. fields = append(fields, sopstage.FieldStatus)
  25600. }
  25601. if m.addcondition_type != nil {
  25602. fields = append(fields, sopstage.FieldConditionType)
  25603. }
  25604. if m.addcondition_operator != nil {
  25605. fields = append(fields, sopstage.FieldConditionOperator)
  25606. }
  25607. if m.addindex_sort != nil {
  25608. fields = append(fields, sopstage.FieldIndexSort)
  25609. }
  25610. return fields
  25611. }
  25612. // AddedField returns the numeric value that was incremented/decremented on a field
  25613. // with the given name. The second boolean return value indicates that this field
  25614. // was not set, or was not defined in the schema.
  25615. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25616. switch name {
  25617. case sopstage.FieldStatus:
  25618. return m.AddedStatus()
  25619. case sopstage.FieldConditionType:
  25620. return m.AddedConditionType()
  25621. case sopstage.FieldConditionOperator:
  25622. return m.AddedConditionOperator()
  25623. case sopstage.FieldIndexSort:
  25624. return m.AddedIndexSort()
  25625. }
  25626. return nil, false
  25627. }
  25628. // AddField adds the value to the field with the given name. It returns an error if
  25629. // the field is not defined in the schema, or if the type mismatched the field
  25630. // type.
  25631. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25632. switch name {
  25633. case sopstage.FieldStatus:
  25634. v, ok := value.(int8)
  25635. if !ok {
  25636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25637. }
  25638. m.AddStatus(v)
  25639. return nil
  25640. case sopstage.FieldConditionType:
  25641. v, ok := value.(int)
  25642. if !ok {
  25643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25644. }
  25645. m.AddConditionType(v)
  25646. return nil
  25647. case sopstage.FieldConditionOperator:
  25648. v, ok := value.(int)
  25649. if !ok {
  25650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25651. }
  25652. m.AddConditionOperator(v)
  25653. return nil
  25654. case sopstage.FieldIndexSort:
  25655. v, ok := value.(int)
  25656. if !ok {
  25657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25658. }
  25659. m.AddIndexSort(v)
  25660. return nil
  25661. }
  25662. return fmt.Errorf("unknown SopStage numeric field %s", name)
  25663. }
  25664. // ClearedFields returns all nullable fields that were cleared during this
  25665. // mutation.
  25666. func (m *SopStageMutation) ClearedFields() []string {
  25667. var fields []string
  25668. if m.FieldCleared(sopstage.FieldStatus) {
  25669. fields = append(fields, sopstage.FieldStatus)
  25670. }
  25671. if m.FieldCleared(sopstage.FieldDeletedAt) {
  25672. fields = append(fields, sopstage.FieldDeletedAt)
  25673. }
  25674. if m.FieldCleared(sopstage.FieldActionMessage) {
  25675. fields = append(fields, sopstage.FieldActionMessage)
  25676. }
  25677. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  25678. fields = append(fields, sopstage.FieldActionLabelAdd)
  25679. }
  25680. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  25681. fields = append(fields, sopstage.FieldActionLabelDel)
  25682. }
  25683. if m.FieldCleared(sopstage.FieldActionForward) {
  25684. fields = append(fields, sopstage.FieldActionForward)
  25685. }
  25686. if m.FieldCleared(sopstage.FieldIndexSort) {
  25687. fields = append(fields, sopstage.FieldIndexSort)
  25688. }
  25689. return fields
  25690. }
  25691. // FieldCleared returns a boolean indicating if a field with the given name was
  25692. // cleared in this mutation.
  25693. func (m *SopStageMutation) FieldCleared(name string) bool {
  25694. _, ok := m.clearedFields[name]
  25695. return ok
  25696. }
  25697. // ClearField clears the value of the field with the given name. It returns an
  25698. // error if the field is not defined in the schema.
  25699. func (m *SopStageMutation) ClearField(name string) error {
  25700. switch name {
  25701. case sopstage.FieldStatus:
  25702. m.ClearStatus()
  25703. return nil
  25704. case sopstage.FieldDeletedAt:
  25705. m.ClearDeletedAt()
  25706. return nil
  25707. case sopstage.FieldActionMessage:
  25708. m.ClearActionMessage()
  25709. return nil
  25710. case sopstage.FieldActionLabelAdd:
  25711. m.ClearActionLabelAdd()
  25712. return nil
  25713. case sopstage.FieldActionLabelDel:
  25714. m.ClearActionLabelDel()
  25715. return nil
  25716. case sopstage.FieldActionForward:
  25717. m.ClearActionForward()
  25718. return nil
  25719. case sopstage.FieldIndexSort:
  25720. m.ClearIndexSort()
  25721. return nil
  25722. }
  25723. return fmt.Errorf("unknown SopStage nullable field %s", name)
  25724. }
  25725. // ResetField resets all changes in the mutation for the field with the given name.
  25726. // It returns an error if the field is not defined in the schema.
  25727. func (m *SopStageMutation) ResetField(name string) error {
  25728. switch name {
  25729. case sopstage.FieldCreatedAt:
  25730. m.ResetCreatedAt()
  25731. return nil
  25732. case sopstage.FieldUpdatedAt:
  25733. m.ResetUpdatedAt()
  25734. return nil
  25735. case sopstage.FieldStatus:
  25736. m.ResetStatus()
  25737. return nil
  25738. case sopstage.FieldDeletedAt:
  25739. m.ResetDeletedAt()
  25740. return nil
  25741. case sopstage.FieldTaskID:
  25742. m.ResetTaskID()
  25743. return nil
  25744. case sopstage.FieldName:
  25745. m.ResetName()
  25746. return nil
  25747. case sopstage.FieldConditionType:
  25748. m.ResetConditionType()
  25749. return nil
  25750. case sopstage.FieldConditionOperator:
  25751. m.ResetConditionOperator()
  25752. return nil
  25753. case sopstage.FieldConditionList:
  25754. m.ResetConditionList()
  25755. return nil
  25756. case sopstage.FieldActionMessage:
  25757. m.ResetActionMessage()
  25758. return nil
  25759. case sopstage.FieldActionLabelAdd:
  25760. m.ResetActionLabelAdd()
  25761. return nil
  25762. case sopstage.FieldActionLabelDel:
  25763. m.ResetActionLabelDel()
  25764. return nil
  25765. case sopstage.FieldActionForward:
  25766. m.ResetActionForward()
  25767. return nil
  25768. case sopstage.FieldIndexSort:
  25769. m.ResetIndexSort()
  25770. return nil
  25771. }
  25772. return fmt.Errorf("unknown SopStage field %s", name)
  25773. }
  25774. // AddedEdges returns all edge names that were set/added in this mutation.
  25775. func (m *SopStageMutation) AddedEdges() []string {
  25776. edges := make([]string, 0, 3)
  25777. if m.sop_task != nil {
  25778. edges = append(edges, sopstage.EdgeSopTask)
  25779. }
  25780. if m.stage_nodes != nil {
  25781. edges = append(edges, sopstage.EdgeStageNodes)
  25782. }
  25783. if m.stage_messages != nil {
  25784. edges = append(edges, sopstage.EdgeStageMessages)
  25785. }
  25786. return edges
  25787. }
  25788. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25789. // name in this mutation.
  25790. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  25791. switch name {
  25792. case sopstage.EdgeSopTask:
  25793. if id := m.sop_task; id != nil {
  25794. return []ent.Value{*id}
  25795. }
  25796. case sopstage.EdgeStageNodes:
  25797. ids := make([]ent.Value, 0, len(m.stage_nodes))
  25798. for id := range m.stage_nodes {
  25799. ids = append(ids, id)
  25800. }
  25801. return ids
  25802. case sopstage.EdgeStageMessages:
  25803. ids := make([]ent.Value, 0, len(m.stage_messages))
  25804. for id := range m.stage_messages {
  25805. ids = append(ids, id)
  25806. }
  25807. return ids
  25808. }
  25809. return nil
  25810. }
  25811. // RemovedEdges returns all edge names that were removed in this mutation.
  25812. func (m *SopStageMutation) RemovedEdges() []string {
  25813. edges := make([]string, 0, 3)
  25814. if m.removedstage_nodes != nil {
  25815. edges = append(edges, sopstage.EdgeStageNodes)
  25816. }
  25817. if m.removedstage_messages != nil {
  25818. edges = append(edges, sopstage.EdgeStageMessages)
  25819. }
  25820. return edges
  25821. }
  25822. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25823. // the given name in this mutation.
  25824. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  25825. switch name {
  25826. case sopstage.EdgeStageNodes:
  25827. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  25828. for id := range m.removedstage_nodes {
  25829. ids = append(ids, id)
  25830. }
  25831. return ids
  25832. case sopstage.EdgeStageMessages:
  25833. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  25834. for id := range m.removedstage_messages {
  25835. ids = append(ids, id)
  25836. }
  25837. return ids
  25838. }
  25839. return nil
  25840. }
  25841. // ClearedEdges returns all edge names that were cleared in this mutation.
  25842. func (m *SopStageMutation) ClearedEdges() []string {
  25843. edges := make([]string, 0, 3)
  25844. if m.clearedsop_task {
  25845. edges = append(edges, sopstage.EdgeSopTask)
  25846. }
  25847. if m.clearedstage_nodes {
  25848. edges = append(edges, sopstage.EdgeStageNodes)
  25849. }
  25850. if m.clearedstage_messages {
  25851. edges = append(edges, sopstage.EdgeStageMessages)
  25852. }
  25853. return edges
  25854. }
  25855. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25856. // was cleared in this mutation.
  25857. func (m *SopStageMutation) EdgeCleared(name string) bool {
  25858. switch name {
  25859. case sopstage.EdgeSopTask:
  25860. return m.clearedsop_task
  25861. case sopstage.EdgeStageNodes:
  25862. return m.clearedstage_nodes
  25863. case sopstage.EdgeStageMessages:
  25864. return m.clearedstage_messages
  25865. }
  25866. return false
  25867. }
  25868. // ClearEdge clears the value of the edge with the given name. It returns an error
  25869. // if that edge is not defined in the schema.
  25870. func (m *SopStageMutation) ClearEdge(name string) error {
  25871. switch name {
  25872. case sopstage.EdgeSopTask:
  25873. m.ClearSopTask()
  25874. return nil
  25875. }
  25876. return fmt.Errorf("unknown SopStage unique edge %s", name)
  25877. }
  25878. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25879. // It returns an error if the edge is not defined in the schema.
  25880. func (m *SopStageMutation) ResetEdge(name string) error {
  25881. switch name {
  25882. case sopstage.EdgeSopTask:
  25883. m.ResetSopTask()
  25884. return nil
  25885. case sopstage.EdgeStageNodes:
  25886. m.ResetStageNodes()
  25887. return nil
  25888. case sopstage.EdgeStageMessages:
  25889. m.ResetStageMessages()
  25890. return nil
  25891. }
  25892. return fmt.Errorf("unknown SopStage edge %s", name)
  25893. }
  25894. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  25895. type SopTaskMutation struct {
  25896. config
  25897. op Op
  25898. typ string
  25899. id *uint64
  25900. created_at *time.Time
  25901. updated_at *time.Time
  25902. status *uint8
  25903. addstatus *int8
  25904. deleted_at *time.Time
  25905. name *string
  25906. bot_wxid_list *[]string
  25907. appendbot_wxid_list []string
  25908. _type *int
  25909. add_type *int
  25910. plan_start_time *time.Time
  25911. plan_end_time *time.Time
  25912. creator_id *string
  25913. organization_id *uint64
  25914. addorganization_id *int64
  25915. token *[]string
  25916. appendtoken []string
  25917. clearedFields map[string]struct{}
  25918. task_stages map[uint64]struct{}
  25919. removedtask_stages map[uint64]struct{}
  25920. clearedtask_stages bool
  25921. done bool
  25922. oldValue func(context.Context) (*SopTask, error)
  25923. predicates []predicate.SopTask
  25924. }
  25925. var _ ent.Mutation = (*SopTaskMutation)(nil)
  25926. // soptaskOption allows management of the mutation configuration using functional options.
  25927. type soptaskOption func(*SopTaskMutation)
  25928. // newSopTaskMutation creates new mutation for the SopTask entity.
  25929. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  25930. m := &SopTaskMutation{
  25931. config: c,
  25932. op: op,
  25933. typ: TypeSopTask,
  25934. clearedFields: make(map[string]struct{}),
  25935. }
  25936. for _, opt := range opts {
  25937. opt(m)
  25938. }
  25939. return m
  25940. }
  25941. // withSopTaskID sets the ID field of the mutation.
  25942. func withSopTaskID(id uint64) soptaskOption {
  25943. return func(m *SopTaskMutation) {
  25944. var (
  25945. err error
  25946. once sync.Once
  25947. value *SopTask
  25948. )
  25949. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  25950. once.Do(func() {
  25951. if m.done {
  25952. err = errors.New("querying old values post mutation is not allowed")
  25953. } else {
  25954. value, err = m.Client().SopTask.Get(ctx, id)
  25955. }
  25956. })
  25957. return value, err
  25958. }
  25959. m.id = &id
  25960. }
  25961. }
  25962. // withSopTask sets the old SopTask of the mutation.
  25963. func withSopTask(node *SopTask) soptaskOption {
  25964. return func(m *SopTaskMutation) {
  25965. m.oldValue = func(context.Context) (*SopTask, error) {
  25966. return node, nil
  25967. }
  25968. m.id = &node.ID
  25969. }
  25970. }
  25971. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25972. // executed in a transaction (ent.Tx), a transactional client is returned.
  25973. func (m SopTaskMutation) Client() *Client {
  25974. client := &Client{config: m.config}
  25975. client.init()
  25976. return client
  25977. }
  25978. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25979. // it returns an error otherwise.
  25980. func (m SopTaskMutation) Tx() (*Tx, error) {
  25981. if _, ok := m.driver.(*txDriver); !ok {
  25982. return nil, errors.New("ent: mutation is not running in a transaction")
  25983. }
  25984. tx := &Tx{config: m.config}
  25985. tx.init()
  25986. return tx, nil
  25987. }
  25988. // SetID sets the value of the id field. Note that this
  25989. // operation is only accepted on creation of SopTask entities.
  25990. func (m *SopTaskMutation) SetID(id uint64) {
  25991. m.id = &id
  25992. }
  25993. // ID returns the ID value in the mutation. Note that the ID is only available
  25994. // if it was provided to the builder or after it was returned from the database.
  25995. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  25996. if m.id == nil {
  25997. return
  25998. }
  25999. return *m.id, true
  26000. }
  26001. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26002. // That means, if the mutation is applied within a transaction with an isolation level such
  26003. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26004. // or updated by the mutation.
  26005. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  26006. switch {
  26007. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26008. id, exists := m.ID()
  26009. if exists {
  26010. return []uint64{id}, nil
  26011. }
  26012. fallthrough
  26013. case m.op.Is(OpUpdate | OpDelete):
  26014. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  26015. default:
  26016. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26017. }
  26018. }
  26019. // SetCreatedAt sets the "created_at" field.
  26020. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  26021. m.created_at = &t
  26022. }
  26023. // CreatedAt returns the value of the "created_at" field in the mutation.
  26024. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  26025. v := m.created_at
  26026. if v == nil {
  26027. return
  26028. }
  26029. return *v, true
  26030. }
  26031. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  26032. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26034. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26035. if !m.op.Is(OpUpdateOne) {
  26036. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26037. }
  26038. if m.id == nil || m.oldValue == nil {
  26039. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26040. }
  26041. oldValue, err := m.oldValue(ctx)
  26042. if err != nil {
  26043. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26044. }
  26045. return oldValue.CreatedAt, nil
  26046. }
  26047. // ResetCreatedAt resets all changes to the "created_at" field.
  26048. func (m *SopTaskMutation) ResetCreatedAt() {
  26049. m.created_at = nil
  26050. }
  26051. // SetUpdatedAt sets the "updated_at" field.
  26052. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  26053. m.updated_at = &t
  26054. }
  26055. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26056. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  26057. v := m.updated_at
  26058. if v == nil {
  26059. return
  26060. }
  26061. return *v, true
  26062. }
  26063. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  26064. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26066. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26067. if !m.op.Is(OpUpdateOne) {
  26068. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26069. }
  26070. if m.id == nil || m.oldValue == nil {
  26071. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26072. }
  26073. oldValue, err := m.oldValue(ctx)
  26074. if err != nil {
  26075. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26076. }
  26077. return oldValue.UpdatedAt, nil
  26078. }
  26079. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26080. func (m *SopTaskMutation) ResetUpdatedAt() {
  26081. m.updated_at = nil
  26082. }
  26083. // SetStatus sets the "status" field.
  26084. func (m *SopTaskMutation) SetStatus(u uint8) {
  26085. m.status = &u
  26086. m.addstatus = nil
  26087. }
  26088. // Status returns the value of the "status" field in the mutation.
  26089. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26090. v := m.status
  26091. if v == nil {
  26092. return
  26093. }
  26094. return *v, true
  26095. }
  26096. // OldStatus returns the old "status" field's value of the SopTask entity.
  26097. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26099. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26100. if !m.op.Is(OpUpdateOne) {
  26101. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26102. }
  26103. if m.id == nil || m.oldValue == nil {
  26104. return v, errors.New("OldStatus requires an ID field in the mutation")
  26105. }
  26106. oldValue, err := m.oldValue(ctx)
  26107. if err != nil {
  26108. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26109. }
  26110. return oldValue.Status, nil
  26111. }
  26112. // AddStatus adds u to the "status" field.
  26113. func (m *SopTaskMutation) AddStatus(u int8) {
  26114. if m.addstatus != nil {
  26115. *m.addstatus += u
  26116. } else {
  26117. m.addstatus = &u
  26118. }
  26119. }
  26120. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26121. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26122. v := m.addstatus
  26123. if v == nil {
  26124. return
  26125. }
  26126. return *v, true
  26127. }
  26128. // ClearStatus clears the value of the "status" field.
  26129. func (m *SopTaskMutation) ClearStatus() {
  26130. m.status = nil
  26131. m.addstatus = nil
  26132. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26133. }
  26134. // StatusCleared returns if the "status" field was cleared in this mutation.
  26135. func (m *SopTaskMutation) StatusCleared() bool {
  26136. _, ok := m.clearedFields[soptask.FieldStatus]
  26137. return ok
  26138. }
  26139. // ResetStatus resets all changes to the "status" field.
  26140. func (m *SopTaskMutation) ResetStatus() {
  26141. m.status = nil
  26142. m.addstatus = nil
  26143. delete(m.clearedFields, soptask.FieldStatus)
  26144. }
  26145. // SetDeletedAt sets the "deleted_at" field.
  26146. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26147. m.deleted_at = &t
  26148. }
  26149. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26150. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26151. v := m.deleted_at
  26152. if v == nil {
  26153. return
  26154. }
  26155. return *v, true
  26156. }
  26157. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26158. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26160. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26161. if !m.op.Is(OpUpdateOne) {
  26162. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26163. }
  26164. if m.id == nil || m.oldValue == nil {
  26165. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26166. }
  26167. oldValue, err := m.oldValue(ctx)
  26168. if err != nil {
  26169. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26170. }
  26171. return oldValue.DeletedAt, nil
  26172. }
  26173. // ClearDeletedAt clears the value of the "deleted_at" field.
  26174. func (m *SopTaskMutation) ClearDeletedAt() {
  26175. m.deleted_at = nil
  26176. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26177. }
  26178. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26179. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26180. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26181. return ok
  26182. }
  26183. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26184. func (m *SopTaskMutation) ResetDeletedAt() {
  26185. m.deleted_at = nil
  26186. delete(m.clearedFields, soptask.FieldDeletedAt)
  26187. }
  26188. // SetName sets the "name" field.
  26189. func (m *SopTaskMutation) SetName(s string) {
  26190. m.name = &s
  26191. }
  26192. // Name returns the value of the "name" field in the mutation.
  26193. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26194. v := m.name
  26195. if v == nil {
  26196. return
  26197. }
  26198. return *v, true
  26199. }
  26200. // OldName returns the old "name" field's value of the SopTask entity.
  26201. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26203. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26204. if !m.op.Is(OpUpdateOne) {
  26205. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26206. }
  26207. if m.id == nil || m.oldValue == nil {
  26208. return v, errors.New("OldName requires an ID field in the mutation")
  26209. }
  26210. oldValue, err := m.oldValue(ctx)
  26211. if err != nil {
  26212. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26213. }
  26214. return oldValue.Name, nil
  26215. }
  26216. // ResetName resets all changes to the "name" field.
  26217. func (m *SopTaskMutation) ResetName() {
  26218. m.name = nil
  26219. }
  26220. // SetBotWxidList sets the "bot_wxid_list" field.
  26221. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26222. m.bot_wxid_list = &s
  26223. m.appendbot_wxid_list = nil
  26224. }
  26225. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26226. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26227. v := m.bot_wxid_list
  26228. if v == nil {
  26229. return
  26230. }
  26231. return *v, true
  26232. }
  26233. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26234. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26236. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26237. if !m.op.Is(OpUpdateOne) {
  26238. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26239. }
  26240. if m.id == nil || m.oldValue == nil {
  26241. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26242. }
  26243. oldValue, err := m.oldValue(ctx)
  26244. if err != nil {
  26245. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26246. }
  26247. return oldValue.BotWxidList, nil
  26248. }
  26249. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26250. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26251. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26252. }
  26253. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26254. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26255. if len(m.appendbot_wxid_list) == 0 {
  26256. return nil, false
  26257. }
  26258. return m.appendbot_wxid_list, true
  26259. }
  26260. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26261. func (m *SopTaskMutation) ClearBotWxidList() {
  26262. m.bot_wxid_list = nil
  26263. m.appendbot_wxid_list = nil
  26264. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26265. }
  26266. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26267. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26268. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26269. return ok
  26270. }
  26271. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26272. func (m *SopTaskMutation) ResetBotWxidList() {
  26273. m.bot_wxid_list = nil
  26274. m.appendbot_wxid_list = nil
  26275. delete(m.clearedFields, soptask.FieldBotWxidList)
  26276. }
  26277. // SetType sets the "type" field.
  26278. func (m *SopTaskMutation) SetType(i int) {
  26279. m._type = &i
  26280. m.add_type = nil
  26281. }
  26282. // GetType returns the value of the "type" field in the mutation.
  26283. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26284. v := m._type
  26285. if v == nil {
  26286. return
  26287. }
  26288. return *v, true
  26289. }
  26290. // OldType returns the old "type" field's value of the SopTask entity.
  26291. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26293. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26294. if !m.op.Is(OpUpdateOne) {
  26295. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26296. }
  26297. if m.id == nil || m.oldValue == nil {
  26298. return v, errors.New("OldType requires an ID field in the mutation")
  26299. }
  26300. oldValue, err := m.oldValue(ctx)
  26301. if err != nil {
  26302. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26303. }
  26304. return oldValue.Type, nil
  26305. }
  26306. // AddType adds i to the "type" field.
  26307. func (m *SopTaskMutation) AddType(i int) {
  26308. if m.add_type != nil {
  26309. *m.add_type += i
  26310. } else {
  26311. m.add_type = &i
  26312. }
  26313. }
  26314. // AddedType returns the value that was added to the "type" field in this mutation.
  26315. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26316. v := m.add_type
  26317. if v == nil {
  26318. return
  26319. }
  26320. return *v, true
  26321. }
  26322. // ResetType resets all changes to the "type" field.
  26323. func (m *SopTaskMutation) ResetType() {
  26324. m._type = nil
  26325. m.add_type = nil
  26326. }
  26327. // SetPlanStartTime sets the "plan_start_time" field.
  26328. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26329. m.plan_start_time = &t
  26330. }
  26331. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26332. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26333. v := m.plan_start_time
  26334. if v == nil {
  26335. return
  26336. }
  26337. return *v, true
  26338. }
  26339. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26340. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26342. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26343. if !m.op.Is(OpUpdateOne) {
  26344. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26345. }
  26346. if m.id == nil || m.oldValue == nil {
  26347. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26348. }
  26349. oldValue, err := m.oldValue(ctx)
  26350. if err != nil {
  26351. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26352. }
  26353. return oldValue.PlanStartTime, nil
  26354. }
  26355. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26356. func (m *SopTaskMutation) ClearPlanStartTime() {
  26357. m.plan_start_time = nil
  26358. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26359. }
  26360. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26361. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26362. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26363. return ok
  26364. }
  26365. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26366. func (m *SopTaskMutation) ResetPlanStartTime() {
  26367. m.plan_start_time = nil
  26368. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26369. }
  26370. // SetPlanEndTime sets the "plan_end_time" field.
  26371. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26372. m.plan_end_time = &t
  26373. }
  26374. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26375. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26376. v := m.plan_end_time
  26377. if v == nil {
  26378. return
  26379. }
  26380. return *v, true
  26381. }
  26382. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26383. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26385. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26386. if !m.op.Is(OpUpdateOne) {
  26387. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26388. }
  26389. if m.id == nil || m.oldValue == nil {
  26390. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26391. }
  26392. oldValue, err := m.oldValue(ctx)
  26393. if err != nil {
  26394. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26395. }
  26396. return oldValue.PlanEndTime, nil
  26397. }
  26398. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26399. func (m *SopTaskMutation) ClearPlanEndTime() {
  26400. m.plan_end_time = nil
  26401. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26402. }
  26403. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26404. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26405. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26406. return ok
  26407. }
  26408. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26409. func (m *SopTaskMutation) ResetPlanEndTime() {
  26410. m.plan_end_time = nil
  26411. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26412. }
  26413. // SetCreatorID sets the "creator_id" field.
  26414. func (m *SopTaskMutation) SetCreatorID(s string) {
  26415. m.creator_id = &s
  26416. }
  26417. // CreatorID returns the value of the "creator_id" field in the mutation.
  26418. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26419. v := m.creator_id
  26420. if v == nil {
  26421. return
  26422. }
  26423. return *v, true
  26424. }
  26425. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26426. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26428. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26429. if !m.op.Is(OpUpdateOne) {
  26430. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26431. }
  26432. if m.id == nil || m.oldValue == nil {
  26433. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26434. }
  26435. oldValue, err := m.oldValue(ctx)
  26436. if err != nil {
  26437. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26438. }
  26439. return oldValue.CreatorID, nil
  26440. }
  26441. // ClearCreatorID clears the value of the "creator_id" field.
  26442. func (m *SopTaskMutation) ClearCreatorID() {
  26443. m.creator_id = nil
  26444. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26445. }
  26446. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26447. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26448. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26449. return ok
  26450. }
  26451. // ResetCreatorID resets all changes to the "creator_id" field.
  26452. func (m *SopTaskMutation) ResetCreatorID() {
  26453. m.creator_id = nil
  26454. delete(m.clearedFields, soptask.FieldCreatorID)
  26455. }
  26456. // SetOrganizationID sets the "organization_id" field.
  26457. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26458. m.organization_id = &u
  26459. m.addorganization_id = nil
  26460. }
  26461. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26462. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26463. v := m.organization_id
  26464. if v == nil {
  26465. return
  26466. }
  26467. return *v, true
  26468. }
  26469. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26470. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26472. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26473. if !m.op.Is(OpUpdateOne) {
  26474. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26475. }
  26476. if m.id == nil || m.oldValue == nil {
  26477. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26478. }
  26479. oldValue, err := m.oldValue(ctx)
  26480. if err != nil {
  26481. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26482. }
  26483. return oldValue.OrganizationID, nil
  26484. }
  26485. // AddOrganizationID adds u to the "organization_id" field.
  26486. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26487. if m.addorganization_id != nil {
  26488. *m.addorganization_id += u
  26489. } else {
  26490. m.addorganization_id = &u
  26491. }
  26492. }
  26493. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26494. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26495. v := m.addorganization_id
  26496. if v == nil {
  26497. return
  26498. }
  26499. return *v, true
  26500. }
  26501. // ClearOrganizationID clears the value of the "organization_id" field.
  26502. func (m *SopTaskMutation) ClearOrganizationID() {
  26503. m.organization_id = nil
  26504. m.addorganization_id = nil
  26505. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26506. }
  26507. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26508. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26509. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26510. return ok
  26511. }
  26512. // ResetOrganizationID resets all changes to the "organization_id" field.
  26513. func (m *SopTaskMutation) ResetOrganizationID() {
  26514. m.organization_id = nil
  26515. m.addorganization_id = nil
  26516. delete(m.clearedFields, soptask.FieldOrganizationID)
  26517. }
  26518. // SetToken sets the "token" field.
  26519. func (m *SopTaskMutation) SetToken(s []string) {
  26520. m.token = &s
  26521. m.appendtoken = nil
  26522. }
  26523. // Token returns the value of the "token" field in the mutation.
  26524. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26525. v := m.token
  26526. if v == nil {
  26527. return
  26528. }
  26529. return *v, true
  26530. }
  26531. // OldToken returns the old "token" field's value of the SopTask entity.
  26532. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26534. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26535. if !m.op.Is(OpUpdateOne) {
  26536. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26537. }
  26538. if m.id == nil || m.oldValue == nil {
  26539. return v, errors.New("OldToken requires an ID field in the mutation")
  26540. }
  26541. oldValue, err := m.oldValue(ctx)
  26542. if err != nil {
  26543. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26544. }
  26545. return oldValue.Token, nil
  26546. }
  26547. // AppendToken adds s to the "token" field.
  26548. func (m *SopTaskMutation) AppendToken(s []string) {
  26549. m.appendtoken = append(m.appendtoken, s...)
  26550. }
  26551. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26552. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26553. if len(m.appendtoken) == 0 {
  26554. return nil, false
  26555. }
  26556. return m.appendtoken, true
  26557. }
  26558. // ClearToken clears the value of the "token" field.
  26559. func (m *SopTaskMutation) ClearToken() {
  26560. m.token = nil
  26561. m.appendtoken = nil
  26562. m.clearedFields[soptask.FieldToken] = struct{}{}
  26563. }
  26564. // TokenCleared returns if the "token" field was cleared in this mutation.
  26565. func (m *SopTaskMutation) TokenCleared() bool {
  26566. _, ok := m.clearedFields[soptask.FieldToken]
  26567. return ok
  26568. }
  26569. // ResetToken resets all changes to the "token" field.
  26570. func (m *SopTaskMutation) ResetToken() {
  26571. m.token = nil
  26572. m.appendtoken = nil
  26573. delete(m.clearedFields, soptask.FieldToken)
  26574. }
  26575. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26576. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26577. if m.task_stages == nil {
  26578. m.task_stages = make(map[uint64]struct{})
  26579. }
  26580. for i := range ids {
  26581. m.task_stages[ids[i]] = struct{}{}
  26582. }
  26583. }
  26584. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26585. func (m *SopTaskMutation) ClearTaskStages() {
  26586. m.clearedtask_stages = true
  26587. }
  26588. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26589. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26590. return m.clearedtask_stages
  26591. }
  26592. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26593. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26594. if m.removedtask_stages == nil {
  26595. m.removedtask_stages = make(map[uint64]struct{})
  26596. }
  26597. for i := range ids {
  26598. delete(m.task_stages, ids[i])
  26599. m.removedtask_stages[ids[i]] = struct{}{}
  26600. }
  26601. }
  26602. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26603. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26604. for id := range m.removedtask_stages {
  26605. ids = append(ids, id)
  26606. }
  26607. return
  26608. }
  26609. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26610. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26611. for id := range m.task_stages {
  26612. ids = append(ids, id)
  26613. }
  26614. return
  26615. }
  26616. // ResetTaskStages resets all changes to the "task_stages" edge.
  26617. func (m *SopTaskMutation) ResetTaskStages() {
  26618. m.task_stages = nil
  26619. m.clearedtask_stages = false
  26620. m.removedtask_stages = nil
  26621. }
  26622. // Where appends a list predicates to the SopTaskMutation builder.
  26623. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26624. m.predicates = append(m.predicates, ps...)
  26625. }
  26626. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26627. // users can use type-assertion to append predicates that do not depend on any generated package.
  26628. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26629. p := make([]predicate.SopTask, len(ps))
  26630. for i := range ps {
  26631. p[i] = ps[i]
  26632. }
  26633. m.Where(p...)
  26634. }
  26635. // Op returns the operation name.
  26636. func (m *SopTaskMutation) Op() Op {
  26637. return m.op
  26638. }
  26639. // SetOp allows setting the mutation operation.
  26640. func (m *SopTaskMutation) SetOp(op Op) {
  26641. m.op = op
  26642. }
  26643. // Type returns the node type of this mutation (SopTask).
  26644. func (m *SopTaskMutation) Type() string {
  26645. return m.typ
  26646. }
  26647. // Fields returns all fields that were changed during this mutation. Note that in
  26648. // order to get all numeric fields that were incremented/decremented, call
  26649. // AddedFields().
  26650. func (m *SopTaskMutation) Fields() []string {
  26651. fields := make([]string, 0, 12)
  26652. if m.created_at != nil {
  26653. fields = append(fields, soptask.FieldCreatedAt)
  26654. }
  26655. if m.updated_at != nil {
  26656. fields = append(fields, soptask.FieldUpdatedAt)
  26657. }
  26658. if m.status != nil {
  26659. fields = append(fields, soptask.FieldStatus)
  26660. }
  26661. if m.deleted_at != nil {
  26662. fields = append(fields, soptask.FieldDeletedAt)
  26663. }
  26664. if m.name != nil {
  26665. fields = append(fields, soptask.FieldName)
  26666. }
  26667. if m.bot_wxid_list != nil {
  26668. fields = append(fields, soptask.FieldBotWxidList)
  26669. }
  26670. if m._type != nil {
  26671. fields = append(fields, soptask.FieldType)
  26672. }
  26673. if m.plan_start_time != nil {
  26674. fields = append(fields, soptask.FieldPlanStartTime)
  26675. }
  26676. if m.plan_end_time != nil {
  26677. fields = append(fields, soptask.FieldPlanEndTime)
  26678. }
  26679. if m.creator_id != nil {
  26680. fields = append(fields, soptask.FieldCreatorID)
  26681. }
  26682. if m.organization_id != nil {
  26683. fields = append(fields, soptask.FieldOrganizationID)
  26684. }
  26685. if m.token != nil {
  26686. fields = append(fields, soptask.FieldToken)
  26687. }
  26688. return fields
  26689. }
  26690. // Field returns the value of a field with the given name. The second boolean
  26691. // return value indicates that this field was not set, or was not defined in the
  26692. // schema.
  26693. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  26694. switch name {
  26695. case soptask.FieldCreatedAt:
  26696. return m.CreatedAt()
  26697. case soptask.FieldUpdatedAt:
  26698. return m.UpdatedAt()
  26699. case soptask.FieldStatus:
  26700. return m.Status()
  26701. case soptask.FieldDeletedAt:
  26702. return m.DeletedAt()
  26703. case soptask.FieldName:
  26704. return m.Name()
  26705. case soptask.FieldBotWxidList:
  26706. return m.BotWxidList()
  26707. case soptask.FieldType:
  26708. return m.GetType()
  26709. case soptask.FieldPlanStartTime:
  26710. return m.PlanStartTime()
  26711. case soptask.FieldPlanEndTime:
  26712. return m.PlanEndTime()
  26713. case soptask.FieldCreatorID:
  26714. return m.CreatorID()
  26715. case soptask.FieldOrganizationID:
  26716. return m.OrganizationID()
  26717. case soptask.FieldToken:
  26718. return m.Token()
  26719. }
  26720. return nil, false
  26721. }
  26722. // OldField returns the old value of the field from the database. An error is
  26723. // returned if the mutation operation is not UpdateOne, or the query to the
  26724. // database failed.
  26725. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26726. switch name {
  26727. case soptask.FieldCreatedAt:
  26728. return m.OldCreatedAt(ctx)
  26729. case soptask.FieldUpdatedAt:
  26730. return m.OldUpdatedAt(ctx)
  26731. case soptask.FieldStatus:
  26732. return m.OldStatus(ctx)
  26733. case soptask.FieldDeletedAt:
  26734. return m.OldDeletedAt(ctx)
  26735. case soptask.FieldName:
  26736. return m.OldName(ctx)
  26737. case soptask.FieldBotWxidList:
  26738. return m.OldBotWxidList(ctx)
  26739. case soptask.FieldType:
  26740. return m.OldType(ctx)
  26741. case soptask.FieldPlanStartTime:
  26742. return m.OldPlanStartTime(ctx)
  26743. case soptask.FieldPlanEndTime:
  26744. return m.OldPlanEndTime(ctx)
  26745. case soptask.FieldCreatorID:
  26746. return m.OldCreatorID(ctx)
  26747. case soptask.FieldOrganizationID:
  26748. return m.OldOrganizationID(ctx)
  26749. case soptask.FieldToken:
  26750. return m.OldToken(ctx)
  26751. }
  26752. return nil, fmt.Errorf("unknown SopTask field %s", name)
  26753. }
  26754. // SetField sets the value of a field with the given name. It returns an error if
  26755. // the field is not defined in the schema, or if the type mismatched the field
  26756. // type.
  26757. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  26758. switch name {
  26759. case soptask.FieldCreatedAt:
  26760. v, ok := value.(time.Time)
  26761. if !ok {
  26762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26763. }
  26764. m.SetCreatedAt(v)
  26765. return nil
  26766. case soptask.FieldUpdatedAt:
  26767. v, ok := value.(time.Time)
  26768. if !ok {
  26769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26770. }
  26771. m.SetUpdatedAt(v)
  26772. return nil
  26773. case soptask.FieldStatus:
  26774. v, ok := value.(uint8)
  26775. if !ok {
  26776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26777. }
  26778. m.SetStatus(v)
  26779. return nil
  26780. case soptask.FieldDeletedAt:
  26781. v, ok := value.(time.Time)
  26782. if !ok {
  26783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26784. }
  26785. m.SetDeletedAt(v)
  26786. return nil
  26787. case soptask.FieldName:
  26788. v, ok := value.(string)
  26789. if !ok {
  26790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26791. }
  26792. m.SetName(v)
  26793. return nil
  26794. case soptask.FieldBotWxidList:
  26795. v, ok := value.([]string)
  26796. if !ok {
  26797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26798. }
  26799. m.SetBotWxidList(v)
  26800. return nil
  26801. case soptask.FieldType:
  26802. v, ok := value.(int)
  26803. if !ok {
  26804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26805. }
  26806. m.SetType(v)
  26807. return nil
  26808. case soptask.FieldPlanStartTime:
  26809. v, ok := value.(time.Time)
  26810. if !ok {
  26811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26812. }
  26813. m.SetPlanStartTime(v)
  26814. return nil
  26815. case soptask.FieldPlanEndTime:
  26816. v, ok := value.(time.Time)
  26817. if !ok {
  26818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26819. }
  26820. m.SetPlanEndTime(v)
  26821. return nil
  26822. case soptask.FieldCreatorID:
  26823. v, ok := value.(string)
  26824. if !ok {
  26825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26826. }
  26827. m.SetCreatorID(v)
  26828. return nil
  26829. case soptask.FieldOrganizationID:
  26830. v, ok := value.(uint64)
  26831. if !ok {
  26832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26833. }
  26834. m.SetOrganizationID(v)
  26835. return nil
  26836. case soptask.FieldToken:
  26837. v, ok := value.([]string)
  26838. if !ok {
  26839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26840. }
  26841. m.SetToken(v)
  26842. return nil
  26843. }
  26844. return fmt.Errorf("unknown SopTask field %s", name)
  26845. }
  26846. // AddedFields returns all numeric fields that were incremented/decremented during
  26847. // this mutation.
  26848. func (m *SopTaskMutation) AddedFields() []string {
  26849. var fields []string
  26850. if m.addstatus != nil {
  26851. fields = append(fields, soptask.FieldStatus)
  26852. }
  26853. if m.add_type != nil {
  26854. fields = append(fields, soptask.FieldType)
  26855. }
  26856. if m.addorganization_id != nil {
  26857. fields = append(fields, soptask.FieldOrganizationID)
  26858. }
  26859. return fields
  26860. }
  26861. // AddedField returns the numeric value that was incremented/decremented on a field
  26862. // with the given name. The second boolean return value indicates that this field
  26863. // was not set, or was not defined in the schema.
  26864. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  26865. switch name {
  26866. case soptask.FieldStatus:
  26867. return m.AddedStatus()
  26868. case soptask.FieldType:
  26869. return m.AddedType()
  26870. case soptask.FieldOrganizationID:
  26871. return m.AddedOrganizationID()
  26872. }
  26873. return nil, false
  26874. }
  26875. // AddField adds the value to the field with the given name. It returns an error if
  26876. // the field is not defined in the schema, or if the type mismatched the field
  26877. // type.
  26878. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  26879. switch name {
  26880. case soptask.FieldStatus:
  26881. v, ok := value.(int8)
  26882. if !ok {
  26883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26884. }
  26885. m.AddStatus(v)
  26886. return nil
  26887. case soptask.FieldType:
  26888. v, ok := value.(int)
  26889. if !ok {
  26890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26891. }
  26892. m.AddType(v)
  26893. return nil
  26894. case soptask.FieldOrganizationID:
  26895. v, ok := value.(int64)
  26896. if !ok {
  26897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26898. }
  26899. m.AddOrganizationID(v)
  26900. return nil
  26901. }
  26902. return fmt.Errorf("unknown SopTask numeric field %s", name)
  26903. }
  26904. // ClearedFields returns all nullable fields that were cleared during this
  26905. // mutation.
  26906. func (m *SopTaskMutation) ClearedFields() []string {
  26907. var fields []string
  26908. if m.FieldCleared(soptask.FieldStatus) {
  26909. fields = append(fields, soptask.FieldStatus)
  26910. }
  26911. if m.FieldCleared(soptask.FieldDeletedAt) {
  26912. fields = append(fields, soptask.FieldDeletedAt)
  26913. }
  26914. if m.FieldCleared(soptask.FieldBotWxidList) {
  26915. fields = append(fields, soptask.FieldBotWxidList)
  26916. }
  26917. if m.FieldCleared(soptask.FieldPlanStartTime) {
  26918. fields = append(fields, soptask.FieldPlanStartTime)
  26919. }
  26920. if m.FieldCleared(soptask.FieldPlanEndTime) {
  26921. fields = append(fields, soptask.FieldPlanEndTime)
  26922. }
  26923. if m.FieldCleared(soptask.FieldCreatorID) {
  26924. fields = append(fields, soptask.FieldCreatorID)
  26925. }
  26926. if m.FieldCleared(soptask.FieldOrganizationID) {
  26927. fields = append(fields, soptask.FieldOrganizationID)
  26928. }
  26929. if m.FieldCleared(soptask.FieldToken) {
  26930. fields = append(fields, soptask.FieldToken)
  26931. }
  26932. return fields
  26933. }
  26934. // FieldCleared returns a boolean indicating if a field with the given name was
  26935. // cleared in this mutation.
  26936. func (m *SopTaskMutation) FieldCleared(name string) bool {
  26937. _, ok := m.clearedFields[name]
  26938. return ok
  26939. }
  26940. // ClearField clears the value of the field with the given name. It returns an
  26941. // error if the field is not defined in the schema.
  26942. func (m *SopTaskMutation) ClearField(name string) error {
  26943. switch name {
  26944. case soptask.FieldStatus:
  26945. m.ClearStatus()
  26946. return nil
  26947. case soptask.FieldDeletedAt:
  26948. m.ClearDeletedAt()
  26949. return nil
  26950. case soptask.FieldBotWxidList:
  26951. m.ClearBotWxidList()
  26952. return nil
  26953. case soptask.FieldPlanStartTime:
  26954. m.ClearPlanStartTime()
  26955. return nil
  26956. case soptask.FieldPlanEndTime:
  26957. m.ClearPlanEndTime()
  26958. return nil
  26959. case soptask.FieldCreatorID:
  26960. m.ClearCreatorID()
  26961. return nil
  26962. case soptask.FieldOrganizationID:
  26963. m.ClearOrganizationID()
  26964. return nil
  26965. case soptask.FieldToken:
  26966. m.ClearToken()
  26967. return nil
  26968. }
  26969. return fmt.Errorf("unknown SopTask nullable field %s", name)
  26970. }
  26971. // ResetField resets all changes in the mutation for the field with the given name.
  26972. // It returns an error if the field is not defined in the schema.
  26973. func (m *SopTaskMutation) ResetField(name string) error {
  26974. switch name {
  26975. case soptask.FieldCreatedAt:
  26976. m.ResetCreatedAt()
  26977. return nil
  26978. case soptask.FieldUpdatedAt:
  26979. m.ResetUpdatedAt()
  26980. return nil
  26981. case soptask.FieldStatus:
  26982. m.ResetStatus()
  26983. return nil
  26984. case soptask.FieldDeletedAt:
  26985. m.ResetDeletedAt()
  26986. return nil
  26987. case soptask.FieldName:
  26988. m.ResetName()
  26989. return nil
  26990. case soptask.FieldBotWxidList:
  26991. m.ResetBotWxidList()
  26992. return nil
  26993. case soptask.FieldType:
  26994. m.ResetType()
  26995. return nil
  26996. case soptask.FieldPlanStartTime:
  26997. m.ResetPlanStartTime()
  26998. return nil
  26999. case soptask.FieldPlanEndTime:
  27000. m.ResetPlanEndTime()
  27001. return nil
  27002. case soptask.FieldCreatorID:
  27003. m.ResetCreatorID()
  27004. return nil
  27005. case soptask.FieldOrganizationID:
  27006. m.ResetOrganizationID()
  27007. return nil
  27008. case soptask.FieldToken:
  27009. m.ResetToken()
  27010. return nil
  27011. }
  27012. return fmt.Errorf("unknown SopTask field %s", name)
  27013. }
  27014. // AddedEdges returns all edge names that were set/added in this mutation.
  27015. func (m *SopTaskMutation) AddedEdges() []string {
  27016. edges := make([]string, 0, 1)
  27017. if m.task_stages != nil {
  27018. edges = append(edges, soptask.EdgeTaskStages)
  27019. }
  27020. return edges
  27021. }
  27022. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27023. // name in this mutation.
  27024. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  27025. switch name {
  27026. case soptask.EdgeTaskStages:
  27027. ids := make([]ent.Value, 0, len(m.task_stages))
  27028. for id := range m.task_stages {
  27029. ids = append(ids, id)
  27030. }
  27031. return ids
  27032. }
  27033. return nil
  27034. }
  27035. // RemovedEdges returns all edge names that were removed in this mutation.
  27036. func (m *SopTaskMutation) RemovedEdges() []string {
  27037. edges := make([]string, 0, 1)
  27038. if m.removedtask_stages != nil {
  27039. edges = append(edges, soptask.EdgeTaskStages)
  27040. }
  27041. return edges
  27042. }
  27043. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27044. // the given name in this mutation.
  27045. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  27046. switch name {
  27047. case soptask.EdgeTaskStages:
  27048. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  27049. for id := range m.removedtask_stages {
  27050. ids = append(ids, id)
  27051. }
  27052. return ids
  27053. }
  27054. return nil
  27055. }
  27056. // ClearedEdges returns all edge names that were cleared in this mutation.
  27057. func (m *SopTaskMutation) ClearedEdges() []string {
  27058. edges := make([]string, 0, 1)
  27059. if m.clearedtask_stages {
  27060. edges = append(edges, soptask.EdgeTaskStages)
  27061. }
  27062. return edges
  27063. }
  27064. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27065. // was cleared in this mutation.
  27066. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  27067. switch name {
  27068. case soptask.EdgeTaskStages:
  27069. return m.clearedtask_stages
  27070. }
  27071. return false
  27072. }
  27073. // ClearEdge clears the value of the edge with the given name. It returns an error
  27074. // if that edge is not defined in the schema.
  27075. func (m *SopTaskMutation) ClearEdge(name string) error {
  27076. switch name {
  27077. }
  27078. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27079. }
  27080. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27081. // It returns an error if the edge is not defined in the schema.
  27082. func (m *SopTaskMutation) ResetEdge(name string) error {
  27083. switch name {
  27084. case soptask.EdgeTaskStages:
  27085. m.ResetTaskStages()
  27086. return nil
  27087. }
  27088. return fmt.Errorf("unknown SopTask edge %s", name)
  27089. }
  27090. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27091. type TokenMutation struct {
  27092. config
  27093. op Op
  27094. typ string
  27095. id *uint64
  27096. created_at *time.Time
  27097. updated_at *time.Time
  27098. deleted_at *time.Time
  27099. expire_at *time.Time
  27100. token *string
  27101. mac *string
  27102. organization_id *uint64
  27103. addorganization_id *int64
  27104. custom_agent_base *string
  27105. custom_agent_key *string
  27106. openai_base *string
  27107. openai_key *string
  27108. clearedFields map[string]struct{}
  27109. agent *uint64
  27110. clearedagent bool
  27111. done bool
  27112. oldValue func(context.Context) (*Token, error)
  27113. predicates []predicate.Token
  27114. }
  27115. var _ ent.Mutation = (*TokenMutation)(nil)
  27116. // tokenOption allows management of the mutation configuration using functional options.
  27117. type tokenOption func(*TokenMutation)
  27118. // newTokenMutation creates new mutation for the Token entity.
  27119. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27120. m := &TokenMutation{
  27121. config: c,
  27122. op: op,
  27123. typ: TypeToken,
  27124. clearedFields: make(map[string]struct{}),
  27125. }
  27126. for _, opt := range opts {
  27127. opt(m)
  27128. }
  27129. return m
  27130. }
  27131. // withTokenID sets the ID field of the mutation.
  27132. func withTokenID(id uint64) tokenOption {
  27133. return func(m *TokenMutation) {
  27134. var (
  27135. err error
  27136. once sync.Once
  27137. value *Token
  27138. )
  27139. m.oldValue = func(ctx context.Context) (*Token, error) {
  27140. once.Do(func() {
  27141. if m.done {
  27142. err = errors.New("querying old values post mutation is not allowed")
  27143. } else {
  27144. value, err = m.Client().Token.Get(ctx, id)
  27145. }
  27146. })
  27147. return value, err
  27148. }
  27149. m.id = &id
  27150. }
  27151. }
  27152. // withToken sets the old Token of the mutation.
  27153. func withToken(node *Token) tokenOption {
  27154. return func(m *TokenMutation) {
  27155. m.oldValue = func(context.Context) (*Token, error) {
  27156. return node, nil
  27157. }
  27158. m.id = &node.ID
  27159. }
  27160. }
  27161. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27162. // executed in a transaction (ent.Tx), a transactional client is returned.
  27163. func (m TokenMutation) Client() *Client {
  27164. client := &Client{config: m.config}
  27165. client.init()
  27166. return client
  27167. }
  27168. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27169. // it returns an error otherwise.
  27170. func (m TokenMutation) Tx() (*Tx, error) {
  27171. if _, ok := m.driver.(*txDriver); !ok {
  27172. return nil, errors.New("ent: mutation is not running in a transaction")
  27173. }
  27174. tx := &Tx{config: m.config}
  27175. tx.init()
  27176. return tx, nil
  27177. }
  27178. // SetID sets the value of the id field. Note that this
  27179. // operation is only accepted on creation of Token entities.
  27180. func (m *TokenMutation) SetID(id uint64) {
  27181. m.id = &id
  27182. }
  27183. // ID returns the ID value in the mutation. Note that the ID is only available
  27184. // if it was provided to the builder or after it was returned from the database.
  27185. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27186. if m.id == nil {
  27187. return
  27188. }
  27189. return *m.id, true
  27190. }
  27191. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27192. // That means, if the mutation is applied within a transaction with an isolation level such
  27193. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27194. // or updated by the mutation.
  27195. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27196. switch {
  27197. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27198. id, exists := m.ID()
  27199. if exists {
  27200. return []uint64{id}, nil
  27201. }
  27202. fallthrough
  27203. case m.op.Is(OpUpdate | OpDelete):
  27204. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27205. default:
  27206. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27207. }
  27208. }
  27209. // SetCreatedAt sets the "created_at" field.
  27210. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27211. m.created_at = &t
  27212. }
  27213. // CreatedAt returns the value of the "created_at" field in the mutation.
  27214. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27215. v := m.created_at
  27216. if v == nil {
  27217. return
  27218. }
  27219. return *v, true
  27220. }
  27221. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27222. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27224. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27225. if !m.op.Is(OpUpdateOne) {
  27226. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27227. }
  27228. if m.id == nil || m.oldValue == nil {
  27229. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27230. }
  27231. oldValue, err := m.oldValue(ctx)
  27232. if err != nil {
  27233. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27234. }
  27235. return oldValue.CreatedAt, nil
  27236. }
  27237. // ResetCreatedAt resets all changes to the "created_at" field.
  27238. func (m *TokenMutation) ResetCreatedAt() {
  27239. m.created_at = nil
  27240. }
  27241. // SetUpdatedAt sets the "updated_at" field.
  27242. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27243. m.updated_at = &t
  27244. }
  27245. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27246. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27247. v := m.updated_at
  27248. if v == nil {
  27249. return
  27250. }
  27251. return *v, true
  27252. }
  27253. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27254. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27256. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27257. if !m.op.Is(OpUpdateOne) {
  27258. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27259. }
  27260. if m.id == nil || m.oldValue == nil {
  27261. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27262. }
  27263. oldValue, err := m.oldValue(ctx)
  27264. if err != nil {
  27265. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27266. }
  27267. return oldValue.UpdatedAt, nil
  27268. }
  27269. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27270. func (m *TokenMutation) ResetUpdatedAt() {
  27271. m.updated_at = nil
  27272. }
  27273. // SetDeletedAt sets the "deleted_at" field.
  27274. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27275. m.deleted_at = &t
  27276. }
  27277. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27278. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27279. v := m.deleted_at
  27280. if v == nil {
  27281. return
  27282. }
  27283. return *v, true
  27284. }
  27285. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27286. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27288. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27289. if !m.op.Is(OpUpdateOne) {
  27290. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27291. }
  27292. if m.id == nil || m.oldValue == nil {
  27293. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27294. }
  27295. oldValue, err := m.oldValue(ctx)
  27296. if err != nil {
  27297. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27298. }
  27299. return oldValue.DeletedAt, nil
  27300. }
  27301. // ClearDeletedAt clears the value of the "deleted_at" field.
  27302. func (m *TokenMutation) ClearDeletedAt() {
  27303. m.deleted_at = nil
  27304. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27305. }
  27306. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27307. func (m *TokenMutation) DeletedAtCleared() bool {
  27308. _, ok := m.clearedFields[token.FieldDeletedAt]
  27309. return ok
  27310. }
  27311. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27312. func (m *TokenMutation) ResetDeletedAt() {
  27313. m.deleted_at = nil
  27314. delete(m.clearedFields, token.FieldDeletedAt)
  27315. }
  27316. // SetExpireAt sets the "expire_at" field.
  27317. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27318. m.expire_at = &t
  27319. }
  27320. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27321. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27322. v := m.expire_at
  27323. if v == nil {
  27324. return
  27325. }
  27326. return *v, true
  27327. }
  27328. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27329. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27331. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27332. if !m.op.Is(OpUpdateOne) {
  27333. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27334. }
  27335. if m.id == nil || m.oldValue == nil {
  27336. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27337. }
  27338. oldValue, err := m.oldValue(ctx)
  27339. if err != nil {
  27340. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27341. }
  27342. return oldValue.ExpireAt, nil
  27343. }
  27344. // ClearExpireAt clears the value of the "expire_at" field.
  27345. func (m *TokenMutation) ClearExpireAt() {
  27346. m.expire_at = nil
  27347. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27348. }
  27349. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27350. func (m *TokenMutation) ExpireAtCleared() bool {
  27351. _, ok := m.clearedFields[token.FieldExpireAt]
  27352. return ok
  27353. }
  27354. // ResetExpireAt resets all changes to the "expire_at" field.
  27355. func (m *TokenMutation) ResetExpireAt() {
  27356. m.expire_at = nil
  27357. delete(m.clearedFields, token.FieldExpireAt)
  27358. }
  27359. // SetToken sets the "token" field.
  27360. func (m *TokenMutation) SetToken(s string) {
  27361. m.token = &s
  27362. }
  27363. // Token returns the value of the "token" field in the mutation.
  27364. func (m *TokenMutation) Token() (r string, exists bool) {
  27365. v := m.token
  27366. if v == nil {
  27367. return
  27368. }
  27369. return *v, true
  27370. }
  27371. // OldToken returns the old "token" field's value of the Token entity.
  27372. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27374. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27375. if !m.op.Is(OpUpdateOne) {
  27376. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27377. }
  27378. if m.id == nil || m.oldValue == nil {
  27379. return v, errors.New("OldToken requires an ID field in the mutation")
  27380. }
  27381. oldValue, err := m.oldValue(ctx)
  27382. if err != nil {
  27383. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27384. }
  27385. return oldValue.Token, nil
  27386. }
  27387. // ClearToken clears the value of the "token" field.
  27388. func (m *TokenMutation) ClearToken() {
  27389. m.token = nil
  27390. m.clearedFields[token.FieldToken] = struct{}{}
  27391. }
  27392. // TokenCleared returns if the "token" field was cleared in this mutation.
  27393. func (m *TokenMutation) TokenCleared() bool {
  27394. _, ok := m.clearedFields[token.FieldToken]
  27395. return ok
  27396. }
  27397. // ResetToken resets all changes to the "token" field.
  27398. func (m *TokenMutation) ResetToken() {
  27399. m.token = nil
  27400. delete(m.clearedFields, token.FieldToken)
  27401. }
  27402. // SetMAC sets the "mac" field.
  27403. func (m *TokenMutation) SetMAC(s string) {
  27404. m.mac = &s
  27405. }
  27406. // MAC returns the value of the "mac" field in the mutation.
  27407. func (m *TokenMutation) MAC() (r string, exists bool) {
  27408. v := m.mac
  27409. if v == nil {
  27410. return
  27411. }
  27412. return *v, true
  27413. }
  27414. // OldMAC returns the old "mac" field's value of the Token entity.
  27415. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27417. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27418. if !m.op.Is(OpUpdateOne) {
  27419. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27420. }
  27421. if m.id == nil || m.oldValue == nil {
  27422. return v, errors.New("OldMAC requires an ID field in the mutation")
  27423. }
  27424. oldValue, err := m.oldValue(ctx)
  27425. if err != nil {
  27426. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27427. }
  27428. return oldValue.MAC, nil
  27429. }
  27430. // ClearMAC clears the value of the "mac" field.
  27431. func (m *TokenMutation) ClearMAC() {
  27432. m.mac = nil
  27433. m.clearedFields[token.FieldMAC] = struct{}{}
  27434. }
  27435. // MACCleared returns if the "mac" field was cleared in this mutation.
  27436. func (m *TokenMutation) MACCleared() bool {
  27437. _, ok := m.clearedFields[token.FieldMAC]
  27438. return ok
  27439. }
  27440. // ResetMAC resets all changes to the "mac" field.
  27441. func (m *TokenMutation) ResetMAC() {
  27442. m.mac = nil
  27443. delete(m.clearedFields, token.FieldMAC)
  27444. }
  27445. // SetOrganizationID sets the "organization_id" field.
  27446. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27447. m.organization_id = &u
  27448. m.addorganization_id = nil
  27449. }
  27450. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27451. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27452. v := m.organization_id
  27453. if v == nil {
  27454. return
  27455. }
  27456. return *v, true
  27457. }
  27458. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27459. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27461. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27462. if !m.op.Is(OpUpdateOne) {
  27463. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27464. }
  27465. if m.id == nil || m.oldValue == nil {
  27466. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27467. }
  27468. oldValue, err := m.oldValue(ctx)
  27469. if err != nil {
  27470. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27471. }
  27472. return oldValue.OrganizationID, nil
  27473. }
  27474. // AddOrganizationID adds u to the "organization_id" field.
  27475. func (m *TokenMutation) AddOrganizationID(u int64) {
  27476. if m.addorganization_id != nil {
  27477. *m.addorganization_id += u
  27478. } else {
  27479. m.addorganization_id = &u
  27480. }
  27481. }
  27482. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27483. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27484. v := m.addorganization_id
  27485. if v == nil {
  27486. return
  27487. }
  27488. return *v, true
  27489. }
  27490. // ResetOrganizationID resets all changes to the "organization_id" field.
  27491. func (m *TokenMutation) ResetOrganizationID() {
  27492. m.organization_id = nil
  27493. m.addorganization_id = nil
  27494. }
  27495. // SetAgentID sets the "agent_id" field.
  27496. func (m *TokenMutation) SetAgentID(u uint64) {
  27497. m.agent = &u
  27498. }
  27499. // AgentID returns the value of the "agent_id" field in the mutation.
  27500. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27501. v := m.agent
  27502. if v == nil {
  27503. return
  27504. }
  27505. return *v, true
  27506. }
  27507. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27508. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27510. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27511. if !m.op.Is(OpUpdateOne) {
  27512. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27513. }
  27514. if m.id == nil || m.oldValue == nil {
  27515. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27516. }
  27517. oldValue, err := m.oldValue(ctx)
  27518. if err != nil {
  27519. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27520. }
  27521. return oldValue.AgentID, nil
  27522. }
  27523. // ResetAgentID resets all changes to the "agent_id" field.
  27524. func (m *TokenMutation) ResetAgentID() {
  27525. m.agent = nil
  27526. }
  27527. // SetCustomAgentBase sets the "custom_agent_base" field.
  27528. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27529. m.custom_agent_base = &s
  27530. }
  27531. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27532. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27533. v := m.custom_agent_base
  27534. if v == nil {
  27535. return
  27536. }
  27537. return *v, true
  27538. }
  27539. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27540. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27542. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27543. if !m.op.Is(OpUpdateOne) {
  27544. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27545. }
  27546. if m.id == nil || m.oldValue == nil {
  27547. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27548. }
  27549. oldValue, err := m.oldValue(ctx)
  27550. if err != nil {
  27551. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27552. }
  27553. return oldValue.CustomAgentBase, nil
  27554. }
  27555. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27556. func (m *TokenMutation) ClearCustomAgentBase() {
  27557. m.custom_agent_base = nil
  27558. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27559. }
  27560. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27561. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27562. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27563. return ok
  27564. }
  27565. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27566. func (m *TokenMutation) ResetCustomAgentBase() {
  27567. m.custom_agent_base = nil
  27568. delete(m.clearedFields, token.FieldCustomAgentBase)
  27569. }
  27570. // SetCustomAgentKey sets the "custom_agent_key" field.
  27571. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27572. m.custom_agent_key = &s
  27573. }
  27574. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27575. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27576. v := m.custom_agent_key
  27577. if v == nil {
  27578. return
  27579. }
  27580. return *v, true
  27581. }
  27582. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27583. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27585. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27586. if !m.op.Is(OpUpdateOne) {
  27587. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27588. }
  27589. if m.id == nil || m.oldValue == nil {
  27590. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27591. }
  27592. oldValue, err := m.oldValue(ctx)
  27593. if err != nil {
  27594. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27595. }
  27596. return oldValue.CustomAgentKey, nil
  27597. }
  27598. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27599. func (m *TokenMutation) ClearCustomAgentKey() {
  27600. m.custom_agent_key = nil
  27601. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27602. }
  27603. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27604. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27605. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27606. return ok
  27607. }
  27608. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27609. func (m *TokenMutation) ResetCustomAgentKey() {
  27610. m.custom_agent_key = nil
  27611. delete(m.clearedFields, token.FieldCustomAgentKey)
  27612. }
  27613. // SetOpenaiBase sets the "openai_base" field.
  27614. func (m *TokenMutation) SetOpenaiBase(s string) {
  27615. m.openai_base = &s
  27616. }
  27617. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27618. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27619. v := m.openai_base
  27620. if v == nil {
  27621. return
  27622. }
  27623. return *v, true
  27624. }
  27625. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27626. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27628. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27629. if !m.op.Is(OpUpdateOne) {
  27630. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27631. }
  27632. if m.id == nil || m.oldValue == nil {
  27633. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  27634. }
  27635. oldValue, err := m.oldValue(ctx)
  27636. if err != nil {
  27637. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  27638. }
  27639. return oldValue.OpenaiBase, nil
  27640. }
  27641. // ClearOpenaiBase clears the value of the "openai_base" field.
  27642. func (m *TokenMutation) ClearOpenaiBase() {
  27643. m.openai_base = nil
  27644. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  27645. }
  27646. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  27647. func (m *TokenMutation) OpenaiBaseCleared() bool {
  27648. _, ok := m.clearedFields[token.FieldOpenaiBase]
  27649. return ok
  27650. }
  27651. // ResetOpenaiBase resets all changes to the "openai_base" field.
  27652. func (m *TokenMutation) ResetOpenaiBase() {
  27653. m.openai_base = nil
  27654. delete(m.clearedFields, token.FieldOpenaiBase)
  27655. }
  27656. // SetOpenaiKey sets the "openai_key" field.
  27657. func (m *TokenMutation) SetOpenaiKey(s string) {
  27658. m.openai_key = &s
  27659. }
  27660. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  27661. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  27662. v := m.openai_key
  27663. if v == nil {
  27664. return
  27665. }
  27666. return *v, true
  27667. }
  27668. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  27669. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27671. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  27672. if !m.op.Is(OpUpdateOne) {
  27673. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  27674. }
  27675. if m.id == nil || m.oldValue == nil {
  27676. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  27677. }
  27678. oldValue, err := m.oldValue(ctx)
  27679. if err != nil {
  27680. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  27681. }
  27682. return oldValue.OpenaiKey, nil
  27683. }
  27684. // ClearOpenaiKey clears the value of the "openai_key" field.
  27685. func (m *TokenMutation) ClearOpenaiKey() {
  27686. m.openai_key = nil
  27687. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  27688. }
  27689. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  27690. func (m *TokenMutation) OpenaiKeyCleared() bool {
  27691. _, ok := m.clearedFields[token.FieldOpenaiKey]
  27692. return ok
  27693. }
  27694. // ResetOpenaiKey resets all changes to the "openai_key" field.
  27695. func (m *TokenMutation) ResetOpenaiKey() {
  27696. m.openai_key = nil
  27697. delete(m.clearedFields, token.FieldOpenaiKey)
  27698. }
  27699. // ClearAgent clears the "agent" edge to the Agent entity.
  27700. func (m *TokenMutation) ClearAgent() {
  27701. m.clearedagent = true
  27702. m.clearedFields[token.FieldAgentID] = struct{}{}
  27703. }
  27704. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  27705. func (m *TokenMutation) AgentCleared() bool {
  27706. return m.clearedagent
  27707. }
  27708. // AgentIDs returns the "agent" edge IDs in the mutation.
  27709. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27710. // AgentID instead. It exists only for internal usage by the builders.
  27711. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  27712. if id := m.agent; id != nil {
  27713. ids = append(ids, *id)
  27714. }
  27715. return
  27716. }
  27717. // ResetAgent resets all changes to the "agent" edge.
  27718. func (m *TokenMutation) ResetAgent() {
  27719. m.agent = nil
  27720. m.clearedagent = false
  27721. }
  27722. // Where appends a list predicates to the TokenMutation builder.
  27723. func (m *TokenMutation) Where(ps ...predicate.Token) {
  27724. m.predicates = append(m.predicates, ps...)
  27725. }
  27726. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  27727. // users can use type-assertion to append predicates that do not depend on any generated package.
  27728. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  27729. p := make([]predicate.Token, len(ps))
  27730. for i := range ps {
  27731. p[i] = ps[i]
  27732. }
  27733. m.Where(p...)
  27734. }
  27735. // Op returns the operation name.
  27736. func (m *TokenMutation) Op() Op {
  27737. return m.op
  27738. }
  27739. // SetOp allows setting the mutation operation.
  27740. func (m *TokenMutation) SetOp(op Op) {
  27741. m.op = op
  27742. }
  27743. // Type returns the node type of this mutation (Token).
  27744. func (m *TokenMutation) Type() string {
  27745. return m.typ
  27746. }
  27747. // Fields returns all fields that were changed during this mutation. Note that in
  27748. // order to get all numeric fields that were incremented/decremented, call
  27749. // AddedFields().
  27750. func (m *TokenMutation) Fields() []string {
  27751. fields := make([]string, 0, 12)
  27752. if m.created_at != nil {
  27753. fields = append(fields, token.FieldCreatedAt)
  27754. }
  27755. if m.updated_at != nil {
  27756. fields = append(fields, token.FieldUpdatedAt)
  27757. }
  27758. if m.deleted_at != nil {
  27759. fields = append(fields, token.FieldDeletedAt)
  27760. }
  27761. if m.expire_at != nil {
  27762. fields = append(fields, token.FieldExpireAt)
  27763. }
  27764. if m.token != nil {
  27765. fields = append(fields, token.FieldToken)
  27766. }
  27767. if m.mac != nil {
  27768. fields = append(fields, token.FieldMAC)
  27769. }
  27770. if m.organization_id != nil {
  27771. fields = append(fields, token.FieldOrganizationID)
  27772. }
  27773. if m.agent != nil {
  27774. fields = append(fields, token.FieldAgentID)
  27775. }
  27776. if m.custom_agent_base != nil {
  27777. fields = append(fields, token.FieldCustomAgentBase)
  27778. }
  27779. if m.custom_agent_key != nil {
  27780. fields = append(fields, token.FieldCustomAgentKey)
  27781. }
  27782. if m.openai_base != nil {
  27783. fields = append(fields, token.FieldOpenaiBase)
  27784. }
  27785. if m.openai_key != nil {
  27786. fields = append(fields, token.FieldOpenaiKey)
  27787. }
  27788. return fields
  27789. }
  27790. // Field returns the value of a field with the given name. The second boolean
  27791. // return value indicates that this field was not set, or was not defined in the
  27792. // schema.
  27793. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  27794. switch name {
  27795. case token.FieldCreatedAt:
  27796. return m.CreatedAt()
  27797. case token.FieldUpdatedAt:
  27798. return m.UpdatedAt()
  27799. case token.FieldDeletedAt:
  27800. return m.DeletedAt()
  27801. case token.FieldExpireAt:
  27802. return m.ExpireAt()
  27803. case token.FieldToken:
  27804. return m.Token()
  27805. case token.FieldMAC:
  27806. return m.MAC()
  27807. case token.FieldOrganizationID:
  27808. return m.OrganizationID()
  27809. case token.FieldAgentID:
  27810. return m.AgentID()
  27811. case token.FieldCustomAgentBase:
  27812. return m.CustomAgentBase()
  27813. case token.FieldCustomAgentKey:
  27814. return m.CustomAgentKey()
  27815. case token.FieldOpenaiBase:
  27816. return m.OpenaiBase()
  27817. case token.FieldOpenaiKey:
  27818. return m.OpenaiKey()
  27819. }
  27820. return nil, false
  27821. }
  27822. // OldField returns the old value of the field from the database. An error is
  27823. // returned if the mutation operation is not UpdateOne, or the query to the
  27824. // database failed.
  27825. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27826. switch name {
  27827. case token.FieldCreatedAt:
  27828. return m.OldCreatedAt(ctx)
  27829. case token.FieldUpdatedAt:
  27830. return m.OldUpdatedAt(ctx)
  27831. case token.FieldDeletedAt:
  27832. return m.OldDeletedAt(ctx)
  27833. case token.FieldExpireAt:
  27834. return m.OldExpireAt(ctx)
  27835. case token.FieldToken:
  27836. return m.OldToken(ctx)
  27837. case token.FieldMAC:
  27838. return m.OldMAC(ctx)
  27839. case token.FieldOrganizationID:
  27840. return m.OldOrganizationID(ctx)
  27841. case token.FieldAgentID:
  27842. return m.OldAgentID(ctx)
  27843. case token.FieldCustomAgentBase:
  27844. return m.OldCustomAgentBase(ctx)
  27845. case token.FieldCustomAgentKey:
  27846. return m.OldCustomAgentKey(ctx)
  27847. case token.FieldOpenaiBase:
  27848. return m.OldOpenaiBase(ctx)
  27849. case token.FieldOpenaiKey:
  27850. return m.OldOpenaiKey(ctx)
  27851. }
  27852. return nil, fmt.Errorf("unknown Token field %s", name)
  27853. }
  27854. // SetField sets the value of a field with the given name. It returns an error if
  27855. // the field is not defined in the schema, or if the type mismatched the field
  27856. // type.
  27857. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  27858. switch name {
  27859. case token.FieldCreatedAt:
  27860. v, ok := value.(time.Time)
  27861. if !ok {
  27862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27863. }
  27864. m.SetCreatedAt(v)
  27865. return nil
  27866. case token.FieldUpdatedAt:
  27867. v, ok := value.(time.Time)
  27868. if !ok {
  27869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27870. }
  27871. m.SetUpdatedAt(v)
  27872. return nil
  27873. case token.FieldDeletedAt:
  27874. v, ok := value.(time.Time)
  27875. if !ok {
  27876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27877. }
  27878. m.SetDeletedAt(v)
  27879. return nil
  27880. case token.FieldExpireAt:
  27881. v, ok := value.(time.Time)
  27882. if !ok {
  27883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27884. }
  27885. m.SetExpireAt(v)
  27886. return nil
  27887. case token.FieldToken:
  27888. v, ok := value.(string)
  27889. if !ok {
  27890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27891. }
  27892. m.SetToken(v)
  27893. return nil
  27894. case token.FieldMAC:
  27895. v, ok := value.(string)
  27896. if !ok {
  27897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27898. }
  27899. m.SetMAC(v)
  27900. return nil
  27901. case token.FieldOrganizationID:
  27902. v, ok := value.(uint64)
  27903. if !ok {
  27904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27905. }
  27906. m.SetOrganizationID(v)
  27907. return nil
  27908. case token.FieldAgentID:
  27909. v, ok := value.(uint64)
  27910. if !ok {
  27911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27912. }
  27913. m.SetAgentID(v)
  27914. return nil
  27915. case token.FieldCustomAgentBase:
  27916. v, ok := value.(string)
  27917. if !ok {
  27918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27919. }
  27920. m.SetCustomAgentBase(v)
  27921. return nil
  27922. case token.FieldCustomAgentKey:
  27923. v, ok := value.(string)
  27924. if !ok {
  27925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27926. }
  27927. m.SetCustomAgentKey(v)
  27928. return nil
  27929. case token.FieldOpenaiBase:
  27930. v, ok := value.(string)
  27931. if !ok {
  27932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27933. }
  27934. m.SetOpenaiBase(v)
  27935. return nil
  27936. case token.FieldOpenaiKey:
  27937. v, ok := value.(string)
  27938. if !ok {
  27939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27940. }
  27941. m.SetOpenaiKey(v)
  27942. return nil
  27943. }
  27944. return fmt.Errorf("unknown Token field %s", name)
  27945. }
  27946. // AddedFields returns all numeric fields that were incremented/decremented during
  27947. // this mutation.
  27948. func (m *TokenMutation) AddedFields() []string {
  27949. var fields []string
  27950. if m.addorganization_id != nil {
  27951. fields = append(fields, token.FieldOrganizationID)
  27952. }
  27953. return fields
  27954. }
  27955. // AddedField returns the numeric value that was incremented/decremented on a field
  27956. // with the given name. The second boolean return value indicates that this field
  27957. // was not set, or was not defined in the schema.
  27958. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  27959. switch name {
  27960. case token.FieldOrganizationID:
  27961. return m.AddedOrganizationID()
  27962. }
  27963. return nil, false
  27964. }
  27965. // AddField adds the value to the field with the given name. It returns an error if
  27966. // the field is not defined in the schema, or if the type mismatched the field
  27967. // type.
  27968. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  27969. switch name {
  27970. case token.FieldOrganizationID:
  27971. v, ok := value.(int64)
  27972. if !ok {
  27973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27974. }
  27975. m.AddOrganizationID(v)
  27976. return nil
  27977. }
  27978. return fmt.Errorf("unknown Token numeric field %s", name)
  27979. }
  27980. // ClearedFields returns all nullable fields that were cleared during this
  27981. // mutation.
  27982. func (m *TokenMutation) ClearedFields() []string {
  27983. var fields []string
  27984. if m.FieldCleared(token.FieldDeletedAt) {
  27985. fields = append(fields, token.FieldDeletedAt)
  27986. }
  27987. if m.FieldCleared(token.FieldExpireAt) {
  27988. fields = append(fields, token.FieldExpireAt)
  27989. }
  27990. if m.FieldCleared(token.FieldToken) {
  27991. fields = append(fields, token.FieldToken)
  27992. }
  27993. if m.FieldCleared(token.FieldMAC) {
  27994. fields = append(fields, token.FieldMAC)
  27995. }
  27996. if m.FieldCleared(token.FieldCustomAgentBase) {
  27997. fields = append(fields, token.FieldCustomAgentBase)
  27998. }
  27999. if m.FieldCleared(token.FieldCustomAgentKey) {
  28000. fields = append(fields, token.FieldCustomAgentKey)
  28001. }
  28002. if m.FieldCleared(token.FieldOpenaiBase) {
  28003. fields = append(fields, token.FieldOpenaiBase)
  28004. }
  28005. if m.FieldCleared(token.FieldOpenaiKey) {
  28006. fields = append(fields, token.FieldOpenaiKey)
  28007. }
  28008. return fields
  28009. }
  28010. // FieldCleared returns a boolean indicating if a field with the given name was
  28011. // cleared in this mutation.
  28012. func (m *TokenMutation) FieldCleared(name string) bool {
  28013. _, ok := m.clearedFields[name]
  28014. return ok
  28015. }
  28016. // ClearField clears the value of the field with the given name. It returns an
  28017. // error if the field is not defined in the schema.
  28018. func (m *TokenMutation) ClearField(name string) error {
  28019. switch name {
  28020. case token.FieldDeletedAt:
  28021. m.ClearDeletedAt()
  28022. return nil
  28023. case token.FieldExpireAt:
  28024. m.ClearExpireAt()
  28025. return nil
  28026. case token.FieldToken:
  28027. m.ClearToken()
  28028. return nil
  28029. case token.FieldMAC:
  28030. m.ClearMAC()
  28031. return nil
  28032. case token.FieldCustomAgentBase:
  28033. m.ClearCustomAgentBase()
  28034. return nil
  28035. case token.FieldCustomAgentKey:
  28036. m.ClearCustomAgentKey()
  28037. return nil
  28038. case token.FieldOpenaiBase:
  28039. m.ClearOpenaiBase()
  28040. return nil
  28041. case token.FieldOpenaiKey:
  28042. m.ClearOpenaiKey()
  28043. return nil
  28044. }
  28045. return fmt.Errorf("unknown Token nullable field %s", name)
  28046. }
  28047. // ResetField resets all changes in the mutation for the field with the given name.
  28048. // It returns an error if the field is not defined in the schema.
  28049. func (m *TokenMutation) ResetField(name string) error {
  28050. switch name {
  28051. case token.FieldCreatedAt:
  28052. m.ResetCreatedAt()
  28053. return nil
  28054. case token.FieldUpdatedAt:
  28055. m.ResetUpdatedAt()
  28056. return nil
  28057. case token.FieldDeletedAt:
  28058. m.ResetDeletedAt()
  28059. return nil
  28060. case token.FieldExpireAt:
  28061. m.ResetExpireAt()
  28062. return nil
  28063. case token.FieldToken:
  28064. m.ResetToken()
  28065. return nil
  28066. case token.FieldMAC:
  28067. m.ResetMAC()
  28068. return nil
  28069. case token.FieldOrganizationID:
  28070. m.ResetOrganizationID()
  28071. return nil
  28072. case token.FieldAgentID:
  28073. m.ResetAgentID()
  28074. return nil
  28075. case token.FieldCustomAgentBase:
  28076. m.ResetCustomAgentBase()
  28077. return nil
  28078. case token.FieldCustomAgentKey:
  28079. m.ResetCustomAgentKey()
  28080. return nil
  28081. case token.FieldOpenaiBase:
  28082. m.ResetOpenaiBase()
  28083. return nil
  28084. case token.FieldOpenaiKey:
  28085. m.ResetOpenaiKey()
  28086. return nil
  28087. }
  28088. return fmt.Errorf("unknown Token field %s", name)
  28089. }
  28090. // AddedEdges returns all edge names that were set/added in this mutation.
  28091. func (m *TokenMutation) AddedEdges() []string {
  28092. edges := make([]string, 0, 1)
  28093. if m.agent != nil {
  28094. edges = append(edges, token.EdgeAgent)
  28095. }
  28096. return edges
  28097. }
  28098. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28099. // name in this mutation.
  28100. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28101. switch name {
  28102. case token.EdgeAgent:
  28103. if id := m.agent; id != nil {
  28104. return []ent.Value{*id}
  28105. }
  28106. }
  28107. return nil
  28108. }
  28109. // RemovedEdges returns all edge names that were removed in this mutation.
  28110. func (m *TokenMutation) RemovedEdges() []string {
  28111. edges := make([]string, 0, 1)
  28112. return edges
  28113. }
  28114. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28115. // the given name in this mutation.
  28116. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28117. return nil
  28118. }
  28119. // ClearedEdges returns all edge names that were cleared in this mutation.
  28120. func (m *TokenMutation) ClearedEdges() []string {
  28121. edges := make([]string, 0, 1)
  28122. if m.clearedagent {
  28123. edges = append(edges, token.EdgeAgent)
  28124. }
  28125. return edges
  28126. }
  28127. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28128. // was cleared in this mutation.
  28129. func (m *TokenMutation) EdgeCleared(name string) bool {
  28130. switch name {
  28131. case token.EdgeAgent:
  28132. return m.clearedagent
  28133. }
  28134. return false
  28135. }
  28136. // ClearEdge clears the value of the edge with the given name. It returns an error
  28137. // if that edge is not defined in the schema.
  28138. func (m *TokenMutation) ClearEdge(name string) error {
  28139. switch name {
  28140. case token.EdgeAgent:
  28141. m.ClearAgent()
  28142. return nil
  28143. }
  28144. return fmt.Errorf("unknown Token unique edge %s", name)
  28145. }
  28146. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28147. // It returns an error if the edge is not defined in the schema.
  28148. func (m *TokenMutation) ResetEdge(name string) error {
  28149. switch name {
  28150. case token.EdgeAgent:
  28151. m.ResetAgent()
  28152. return nil
  28153. }
  28154. return fmt.Errorf("unknown Token edge %s", name)
  28155. }
  28156. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28157. type TutorialMutation struct {
  28158. config
  28159. op Op
  28160. typ string
  28161. id *uint64
  28162. created_at *time.Time
  28163. updated_at *time.Time
  28164. deleted_at *time.Time
  28165. index *int
  28166. addindex *int
  28167. title *string
  28168. content *string
  28169. organization_id *uint64
  28170. addorganization_id *int64
  28171. clearedFields map[string]struct{}
  28172. employee *uint64
  28173. clearedemployee bool
  28174. done bool
  28175. oldValue func(context.Context) (*Tutorial, error)
  28176. predicates []predicate.Tutorial
  28177. }
  28178. var _ ent.Mutation = (*TutorialMutation)(nil)
  28179. // tutorialOption allows management of the mutation configuration using functional options.
  28180. type tutorialOption func(*TutorialMutation)
  28181. // newTutorialMutation creates new mutation for the Tutorial entity.
  28182. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28183. m := &TutorialMutation{
  28184. config: c,
  28185. op: op,
  28186. typ: TypeTutorial,
  28187. clearedFields: make(map[string]struct{}),
  28188. }
  28189. for _, opt := range opts {
  28190. opt(m)
  28191. }
  28192. return m
  28193. }
  28194. // withTutorialID sets the ID field of the mutation.
  28195. func withTutorialID(id uint64) tutorialOption {
  28196. return func(m *TutorialMutation) {
  28197. var (
  28198. err error
  28199. once sync.Once
  28200. value *Tutorial
  28201. )
  28202. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28203. once.Do(func() {
  28204. if m.done {
  28205. err = errors.New("querying old values post mutation is not allowed")
  28206. } else {
  28207. value, err = m.Client().Tutorial.Get(ctx, id)
  28208. }
  28209. })
  28210. return value, err
  28211. }
  28212. m.id = &id
  28213. }
  28214. }
  28215. // withTutorial sets the old Tutorial of the mutation.
  28216. func withTutorial(node *Tutorial) tutorialOption {
  28217. return func(m *TutorialMutation) {
  28218. m.oldValue = func(context.Context) (*Tutorial, error) {
  28219. return node, nil
  28220. }
  28221. m.id = &node.ID
  28222. }
  28223. }
  28224. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28225. // executed in a transaction (ent.Tx), a transactional client is returned.
  28226. func (m TutorialMutation) Client() *Client {
  28227. client := &Client{config: m.config}
  28228. client.init()
  28229. return client
  28230. }
  28231. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28232. // it returns an error otherwise.
  28233. func (m TutorialMutation) Tx() (*Tx, error) {
  28234. if _, ok := m.driver.(*txDriver); !ok {
  28235. return nil, errors.New("ent: mutation is not running in a transaction")
  28236. }
  28237. tx := &Tx{config: m.config}
  28238. tx.init()
  28239. return tx, nil
  28240. }
  28241. // SetID sets the value of the id field. Note that this
  28242. // operation is only accepted on creation of Tutorial entities.
  28243. func (m *TutorialMutation) SetID(id uint64) {
  28244. m.id = &id
  28245. }
  28246. // ID returns the ID value in the mutation. Note that the ID is only available
  28247. // if it was provided to the builder or after it was returned from the database.
  28248. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28249. if m.id == nil {
  28250. return
  28251. }
  28252. return *m.id, true
  28253. }
  28254. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28255. // That means, if the mutation is applied within a transaction with an isolation level such
  28256. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28257. // or updated by the mutation.
  28258. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28259. switch {
  28260. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28261. id, exists := m.ID()
  28262. if exists {
  28263. return []uint64{id}, nil
  28264. }
  28265. fallthrough
  28266. case m.op.Is(OpUpdate | OpDelete):
  28267. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28268. default:
  28269. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28270. }
  28271. }
  28272. // SetCreatedAt sets the "created_at" field.
  28273. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28274. m.created_at = &t
  28275. }
  28276. // CreatedAt returns the value of the "created_at" field in the mutation.
  28277. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28278. v := m.created_at
  28279. if v == nil {
  28280. return
  28281. }
  28282. return *v, true
  28283. }
  28284. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28285. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28287. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28288. if !m.op.Is(OpUpdateOne) {
  28289. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28290. }
  28291. if m.id == nil || m.oldValue == nil {
  28292. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28293. }
  28294. oldValue, err := m.oldValue(ctx)
  28295. if err != nil {
  28296. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28297. }
  28298. return oldValue.CreatedAt, nil
  28299. }
  28300. // ResetCreatedAt resets all changes to the "created_at" field.
  28301. func (m *TutorialMutation) ResetCreatedAt() {
  28302. m.created_at = nil
  28303. }
  28304. // SetUpdatedAt sets the "updated_at" field.
  28305. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28306. m.updated_at = &t
  28307. }
  28308. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28309. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28310. v := m.updated_at
  28311. if v == nil {
  28312. return
  28313. }
  28314. return *v, true
  28315. }
  28316. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28317. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28319. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28320. if !m.op.Is(OpUpdateOne) {
  28321. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28322. }
  28323. if m.id == nil || m.oldValue == nil {
  28324. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28325. }
  28326. oldValue, err := m.oldValue(ctx)
  28327. if err != nil {
  28328. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28329. }
  28330. return oldValue.UpdatedAt, nil
  28331. }
  28332. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28333. func (m *TutorialMutation) ResetUpdatedAt() {
  28334. m.updated_at = nil
  28335. }
  28336. // SetDeletedAt sets the "deleted_at" field.
  28337. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28338. m.deleted_at = &t
  28339. }
  28340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28341. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28342. v := m.deleted_at
  28343. if v == nil {
  28344. return
  28345. }
  28346. return *v, true
  28347. }
  28348. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28349. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28351. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28352. if !m.op.Is(OpUpdateOne) {
  28353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28354. }
  28355. if m.id == nil || m.oldValue == nil {
  28356. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28357. }
  28358. oldValue, err := m.oldValue(ctx)
  28359. if err != nil {
  28360. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28361. }
  28362. return oldValue.DeletedAt, nil
  28363. }
  28364. // ClearDeletedAt clears the value of the "deleted_at" field.
  28365. func (m *TutorialMutation) ClearDeletedAt() {
  28366. m.deleted_at = nil
  28367. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28368. }
  28369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28370. func (m *TutorialMutation) DeletedAtCleared() bool {
  28371. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28372. return ok
  28373. }
  28374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28375. func (m *TutorialMutation) ResetDeletedAt() {
  28376. m.deleted_at = nil
  28377. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28378. }
  28379. // SetEmployeeID sets the "employee_id" field.
  28380. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28381. m.employee = &u
  28382. }
  28383. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28384. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28385. v := m.employee
  28386. if v == nil {
  28387. return
  28388. }
  28389. return *v, true
  28390. }
  28391. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28392. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28394. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28395. if !m.op.Is(OpUpdateOne) {
  28396. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28397. }
  28398. if m.id == nil || m.oldValue == nil {
  28399. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28400. }
  28401. oldValue, err := m.oldValue(ctx)
  28402. if err != nil {
  28403. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28404. }
  28405. return oldValue.EmployeeID, nil
  28406. }
  28407. // ResetEmployeeID resets all changes to the "employee_id" field.
  28408. func (m *TutorialMutation) ResetEmployeeID() {
  28409. m.employee = nil
  28410. }
  28411. // SetIndex sets the "index" field.
  28412. func (m *TutorialMutation) SetIndex(i int) {
  28413. m.index = &i
  28414. m.addindex = nil
  28415. }
  28416. // Index returns the value of the "index" field in the mutation.
  28417. func (m *TutorialMutation) Index() (r int, exists bool) {
  28418. v := m.index
  28419. if v == nil {
  28420. return
  28421. }
  28422. return *v, true
  28423. }
  28424. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28425. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28427. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28428. if !m.op.Is(OpUpdateOne) {
  28429. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28430. }
  28431. if m.id == nil || m.oldValue == nil {
  28432. return v, errors.New("OldIndex requires an ID field in the mutation")
  28433. }
  28434. oldValue, err := m.oldValue(ctx)
  28435. if err != nil {
  28436. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28437. }
  28438. return oldValue.Index, nil
  28439. }
  28440. // AddIndex adds i to the "index" field.
  28441. func (m *TutorialMutation) AddIndex(i int) {
  28442. if m.addindex != nil {
  28443. *m.addindex += i
  28444. } else {
  28445. m.addindex = &i
  28446. }
  28447. }
  28448. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28449. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28450. v := m.addindex
  28451. if v == nil {
  28452. return
  28453. }
  28454. return *v, true
  28455. }
  28456. // ResetIndex resets all changes to the "index" field.
  28457. func (m *TutorialMutation) ResetIndex() {
  28458. m.index = nil
  28459. m.addindex = nil
  28460. }
  28461. // SetTitle sets the "title" field.
  28462. func (m *TutorialMutation) SetTitle(s string) {
  28463. m.title = &s
  28464. }
  28465. // Title returns the value of the "title" field in the mutation.
  28466. func (m *TutorialMutation) Title() (r string, exists bool) {
  28467. v := m.title
  28468. if v == nil {
  28469. return
  28470. }
  28471. return *v, true
  28472. }
  28473. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28474. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28476. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28477. if !m.op.Is(OpUpdateOne) {
  28478. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28479. }
  28480. if m.id == nil || m.oldValue == nil {
  28481. return v, errors.New("OldTitle requires an ID field in the mutation")
  28482. }
  28483. oldValue, err := m.oldValue(ctx)
  28484. if err != nil {
  28485. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28486. }
  28487. return oldValue.Title, nil
  28488. }
  28489. // ResetTitle resets all changes to the "title" field.
  28490. func (m *TutorialMutation) ResetTitle() {
  28491. m.title = nil
  28492. }
  28493. // SetContent sets the "content" field.
  28494. func (m *TutorialMutation) SetContent(s string) {
  28495. m.content = &s
  28496. }
  28497. // Content returns the value of the "content" field in the mutation.
  28498. func (m *TutorialMutation) Content() (r string, exists bool) {
  28499. v := m.content
  28500. if v == nil {
  28501. return
  28502. }
  28503. return *v, true
  28504. }
  28505. // OldContent returns the old "content" field's value of the Tutorial entity.
  28506. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28508. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28509. if !m.op.Is(OpUpdateOne) {
  28510. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28511. }
  28512. if m.id == nil || m.oldValue == nil {
  28513. return v, errors.New("OldContent requires an ID field in the mutation")
  28514. }
  28515. oldValue, err := m.oldValue(ctx)
  28516. if err != nil {
  28517. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28518. }
  28519. return oldValue.Content, nil
  28520. }
  28521. // ResetContent resets all changes to the "content" field.
  28522. func (m *TutorialMutation) ResetContent() {
  28523. m.content = nil
  28524. }
  28525. // SetOrganizationID sets the "organization_id" field.
  28526. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28527. m.organization_id = &u
  28528. m.addorganization_id = nil
  28529. }
  28530. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28531. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28532. v := m.organization_id
  28533. if v == nil {
  28534. return
  28535. }
  28536. return *v, true
  28537. }
  28538. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28539. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28541. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28542. if !m.op.Is(OpUpdateOne) {
  28543. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28544. }
  28545. if m.id == nil || m.oldValue == nil {
  28546. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28547. }
  28548. oldValue, err := m.oldValue(ctx)
  28549. if err != nil {
  28550. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28551. }
  28552. return oldValue.OrganizationID, nil
  28553. }
  28554. // AddOrganizationID adds u to the "organization_id" field.
  28555. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28556. if m.addorganization_id != nil {
  28557. *m.addorganization_id += u
  28558. } else {
  28559. m.addorganization_id = &u
  28560. }
  28561. }
  28562. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28563. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28564. v := m.addorganization_id
  28565. if v == nil {
  28566. return
  28567. }
  28568. return *v, true
  28569. }
  28570. // ResetOrganizationID resets all changes to the "organization_id" field.
  28571. func (m *TutorialMutation) ResetOrganizationID() {
  28572. m.organization_id = nil
  28573. m.addorganization_id = nil
  28574. }
  28575. // ClearEmployee clears the "employee" edge to the Employee entity.
  28576. func (m *TutorialMutation) ClearEmployee() {
  28577. m.clearedemployee = true
  28578. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28579. }
  28580. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28581. func (m *TutorialMutation) EmployeeCleared() bool {
  28582. return m.clearedemployee
  28583. }
  28584. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28585. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28586. // EmployeeID instead. It exists only for internal usage by the builders.
  28587. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28588. if id := m.employee; id != nil {
  28589. ids = append(ids, *id)
  28590. }
  28591. return
  28592. }
  28593. // ResetEmployee resets all changes to the "employee" edge.
  28594. func (m *TutorialMutation) ResetEmployee() {
  28595. m.employee = nil
  28596. m.clearedemployee = false
  28597. }
  28598. // Where appends a list predicates to the TutorialMutation builder.
  28599. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28600. m.predicates = append(m.predicates, ps...)
  28601. }
  28602. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28603. // users can use type-assertion to append predicates that do not depend on any generated package.
  28604. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28605. p := make([]predicate.Tutorial, len(ps))
  28606. for i := range ps {
  28607. p[i] = ps[i]
  28608. }
  28609. m.Where(p...)
  28610. }
  28611. // Op returns the operation name.
  28612. func (m *TutorialMutation) Op() Op {
  28613. return m.op
  28614. }
  28615. // SetOp allows setting the mutation operation.
  28616. func (m *TutorialMutation) SetOp(op Op) {
  28617. m.op = op
  28618. }
  28619. // Type returns the node type of this mutation (Tutorial).
  28620. func (m *TutorialMutation) Type() string {
  28621. return m.typ
  28622. }
  28623. // Fields returns all fields that were changed during this mutation. Note that in
  28624. // order to get all numeric fields that were incremented/decremented, call
  28625. // AddedFields().
  28626. func (m *TutorialMutation) Fields() []string {
  28627. fields := make([]string, 0, 8)
  28628. if m.created_at != nil {
  28629. fields = append(fields, tutorial.FieldCreatedAt)
  28630. }
  28631. if m.updated_at != nil {
  28632. fields = append(fields, tutorial.FieldUpdatedAt)
  28633. }
  28634. if m.deleted_at != nil {
  28635. fields = append(fields, tutorial.FieldDeletedAt)
  28636. }
  28637. if m.employee != nil {
  28638. fields = append(fields, tutorial.FieldEmployeeID)
  28639. }
  28640. if m.index != nil {
  28641. fields = append(fields, tutorial.FieldIndex)
  28642. }
  28643. if m.title != nil {
  28644. fields = append(fields, tutorial.FieldTitle)
  28645. }
  28646. if m.content != nil {
  28647. fields = append(fields, tutorial.FieldContent)
  28648. }
  28649. if m.organization_id != nil {
  28650. fields = append(fields, tutorial.FieldOrganizationID)
  28651. }
  28652. return fields
  28653. }
  28654. // Field returns the value of a field with the given name. The second boolean
  28655. // return value indicates that this field was not set, or was not defined in the
  28656. // schema.
  28657. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  28658. switch name {
  28659. case tutorial.FieldCreatedAt:
  28660. return m.CreatedAt()
  28661. case tutorial.FieldUpdatedAt:
  28662. return m.UpdatedAt()
  28663. case tutorial.FieldDeletedAt:
  28664. return m.DeletedAt()
  28665. case tutorial.FieldEmployeeID:
  28666. return m.EmployeeID()
  28667. case tutorial.FieldIndex:
  28668. return m.Index()
  28669. case tutorial.FieldTitle:
  28670. return m.Title()
  28671. case tutorial.FieldContent:
  28672. return m.Content()
  28673. case tutorial.FieldOrganizationID:
  28674. return m.OrganizationID()
  28675. }
  28676. return nil, false
  28677. }
  28678. // OldField returns the old value of the field from the database. An error is
  28679. // returned if the mutation operation is not UpdateOne, or the query to the
  28680. // database failed.
  28681. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28682. switch name {
  28683. case tutorial.FieldCreatedAt:
  28684. return m.OldCreatedAt(ctx)
  28685. case tutorial.FieldUpdatedAt:
  28686. return m.OldUpdatedAt(ctx)
  28687. case tutorial.FieldDeletedAt:
  28688. return m.OldDeletedAt(ctx)
  28689. case tutorial.FieldEmployeeID:
  28690. return m.OldEmployeeID(ctx)
  28691. case tutorial.FieldIndex:
  28692. return m.OldIndex(ctx)
  28693. case tutorial.FieldTitle:
  28694. return m.OldTitle(ctx)
  28695. case tutorial.FieldContent:
  28696. return m.OldContent(ctx)
  28697. case tutorial.FieldOrganizationID:
  28698. return m.OldOrganizationID(ctx)
  28699. }
  28700. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  28701. }
  28702. // SetField sets the value of a field with the given name. It returns an error if
  28703. // the field is not defined in the schema, or if the type mismatched the field
  28704. // type.
  28705. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  28706. switch name {
  28707. case tutorial.FieldCreatedAt:
  28708. v, ok := value.(time.Time)
  28709. if !ok {
  28710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28711. }
  28712. m.SetCreatedAt(v)
  28713. return nil
  28714. case tutorial.FieldUpdatedAt:
  28715. v, ok := value.(time.Time)
  28716. if !ok {
  28717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28718. }
  28719. m.SetUpdatedAt(v)
  28720. return nil
  28721. case tutorial.FieldDeletedAt:
  28722. v, ok := value.(time.Time)
  28723. if !ok {
  28724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28725. }
  28726. m.SetDeletedAt(v)
  28727. return nil
  28728. case tutorial.FieldEmployeeID:
  28729. v, ok := value.(uint64)
  28730. if !ok {
  28731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28732. }
  28733. m.SetEmployeeID(v)
  28734. return nil
  28735. case tutorial.FieldIndex:
  28736. v, ok := value.(int)
  28737. if !ok {
  28738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28739. }
  28740. m.SetIndex(v)
  28741. return nil
  28742. case tutorial.FieldTitle:
  28743. v, ok := value.(string)
  28744. if !ok {
  28745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28746. }
  28747. m.SetTitle(v)
  28748. return nil
  28749. case tutorial.FieldContent:
  28750. v, ok := value.(string)
  28751. if !ok {
  28752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28753. }
  28754. m.SetContent(v)
  28755. return nil
  28756. case tutorial.FieldOrganizationID:
  28757. v, ok := value.(uint64)
  28758. if !ok {
  28759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28760. }
  28761. m.SetOrganizationID(v)
  28762. return nil
  28763. }
  28764. return fmt.Errorf("unknown Tutorial field %s", name)
  28765. }
  28766. // AddedFields returns all numeric fields that were incremented/decremented during
  28767. // this mutation.
  28768. func (m *TutorialMutation) AddedFields() []string {
  28769. var fields []string
  28770. if m.addindex != nil {
  28771. fields = append(fields, tutorial.FieldIndex)
  28772. }
  28773. if m.addorganization_id != nil {
  28774. fields = append(fields, tutorial.FieldOrganizationID)
  28775. }
  28776. return fields
  28777. }
  28778. // AddedField returns the numeric value that was incremented/decremented on a field
  28779. // with the given name. The second boolean return value indicates that this field
  28780. // was not set, or was not defined in the schema.
  28781. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  28782. switch name {
  28783. case tutorial.FieldIndex:
  28784. return m.AddedIndex()
  28785. case tutorial.FieldOrganizationID:
  28786. return m.AddedOrganizationID()
  28787. }
  28788. return nil, false
  28789. }
  28790. // AddField adds the value to the field with the given name. It returns an error if
  28791. // the field is not defined in the schema, or if the type mismatched the field
  28792. // type.
  28793. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  28794. switch name {
  28795. case tutorial.FieldIndex:
  28796. v, ok := value.(int)
  28797. if !ok {
  28798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28799. }
  28800. m.AddIndex(v)
  28801. return nil
  28802. case tutorial.FieldOrganizationID:
  28803. v, ok := value.(int64)
  28804. if !ok {
  28805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28806. }
  28807. m.AddOrganizationID(v)
  28808. return nil
  28809. }
  28810. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  28811. }
  28812. // ClearedFields returns all nullable fields that were cleared during this
  28813. // mutation.
  28814. func (m *TutorialMutation) ClearedFields() []string {
  28815. var fields []string
  28816. if m.FieldCleared(tutorial.FieldDeletedAt) {
  28817. fields = append(fields, tutorial.FieldDeletedAt)
  28818. }
  28819. return fields
  28820. }
  28821. // FieldCleared returns a boolean indicating if a field with the given name was
  28822. // cleared in this mutation.
  28823. func (m *TutorialMutation) FieldCleared(name string) bool {
  28824. _, ok := m.clearedFields[name]
  28825. return ok
  28826. }
  28827. // ClearField clears the value of the field with the given name. It returns an
  28828. // error if the field is not defined in the schema.
  28829. func (m *TutorialMutation) ClearField(name string) error {
  28830. switch name {
  28831. case tutorial.FieldDeletedAt:
  28832. m.ClearDeletedAt()
  28833. return nil
  28834. }
  28835. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  28836. }
  28837. // ResetField resets all changes in the mutation for the field with the given name.
  28838. // It returns an error if the field is not defined in the schema.
  28839. func (m *TutorialMutation) ResetField(name string) error {
  28840. switch name {
  28841. case tutorial.FieldCreatedAt:
  28842. m.ResetCreatedAt()
  28843. return nil
  28844. case tutorial.FieldUpdatedAt:
  28845. m.ResetUpdatedAt()
  28846. return nil
  28847. case tutorial.FieldDeletedAt:
  28848. m.ResetDeletedAt()
  28849. return nil
  28850. case tutorial.FieldEmployeeID:
  28851. m.ResetEmployeeID()
  28852. return nil
  28853. case tutorial.FieldIndex:
  28854. m.ResetIndex()
  28855. return nil
  28856. case tutorial.FieldTitle:
  28857. m.ResetTitle()
  28858. return nil
  28859. case tutorial.FieldContent:
  28860. m.ResetContent()
  28861. return nil
  28862. case tutorial.FieldOrganizationID:
  28863. m.ResetOrganizationID()
  28864. return nil
  28865. }
  28866. return fmt.Errorf("unknown Tutorial field %s", name)
  28867. }
  28868. // AddedEdges returns all edge names that were set/added in this mutation.
  28869. func (m *TutorialMutation) AddedEdges() []string {
  28870. edges := make([]string, 0, 1)
  28871. if m.employee != nil {
  28872. edges = append(edges, tutorial.EdgeEmployee)
  28873. }
  28874. return edges
  28875. }
  28876. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28877. // name in this mutation.
  28878. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  28879. switch name {
  28880. case tutorial.EdgeEmployee:
  28881. if id := m.employee; id != nil {
  28882. return []ent.Value{*id}
  28883. }
  28884. }
  28885. return nil
  28886. }
  28887. // RemovedEdges returns all edge names that were removed in this mutation.
  28888. func (m *TutorialMutation) RemovedEdges() []string {
  28889. edges := make([]string, 0, 1)
  28890. return edges
  28891. }
  28892. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28893. // the given name in this mutation.
  28894. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  28895. return nil
  28896. }
  28897. // ClearedEdges returns all edge names that were cleared in this mutation.
  28898. func (m *TutorialMutation) ClearedEdges() []string {
  28899. edges := make([]string, 0, 1)
  28900. if m.clearedemployee {
  28901. edges = append(edges, tutorial.EdgeEmployee)
  28902. }
  28903. return edges
  28904. }
  28905. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28906. // was cleared in this mutation.
  28907. func (m *TutorialMutation) EdgeCleared(name string) bool {
  28908. switch name {
  28909. case tutorial.EdgeEmployee:
  28910. return m.clearedemployee
  28911. }
  28912. return false
  28913. }
  28914. // ClearEdge clears the value of the edge with the given name. It returns an error
  28915. // if that edge is not defined in the schema.
  28916. func (m *TutorialMutation) ClearEdge(name string) error {
  28917. switch name {
  28918. case tutorial.EdgeEmployee:
  28919. m.ClearEmployee()
  28920. return nil
  28921. }
  28922. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  28923. }
  28924. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28925. // It returns an error if the edge is not defined in the schema.
  28926. func (m *TutorialMutation) ResetEdge(name string) error {
  28927. switch name {
  28928. case tutorial.EdgeEmployee:
  28929. m.ResetEmployee()
  28930. return nil
  28931. }
  28932. return fmt.Errorf("unknown Tutorial edge %s", name)
  28933. }
  28934. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  28935. type UsageDetailMutation struct {
  28936. config
  28937. op Op
  28938. typ string
  28939. id *uint64
  28940. created_at *time.Time
  28941. updated_at *time.Time
  28942. status *uint8
  28943. addstatus *int8
  28944. _type *int
  28945. add_type *int
  28946. bot_id *string
  28947. receiver_id *string
  28948. app *int
  28949. addapp *int
  28950. session_id *uint64
  28951. addsession_id *int64
  28952. request *string
  28953. response *string
  28954. original_data *custom_types.OriginalData
  28955. total_tokens *uint64
  28956. addtotal_tokens *int64
  28957. prompt_tokens *uint64
  28958. addprompt_tokens *int64
  28959. completion_tokens *uint64
  28960. addcompletion_tokens *int64
  28961. organization_id *uint64
  28962. addorganization_id *int64
  28963. clearedFields map[string]struct{}
  28964. done bool
  28965. oldValue func(context.Context) (*UsageDetail, error)
  28966. predicates []predicate.UsageDetail
  28967. }
  28968. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  28969. // usagedetailOption allows management of the mutation configuration using functional options.
  28970. type usagedetailOption func(*UsageDetailMutation)
  28971. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  28972. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  28973. m := &UsageDetailMutation{
  28974. config: c,
  28975. op: op,
  28976. typ: TypeUsageDetail,
  28977. clearedFields: make(map[string]struct{}),
  28978. }
  28979. for _, opt := range opts {
  28980. opt(m)
  28981. }
  28982. return m
  28983. }
  28984. // withUsageDetailID sets the ID field of the mutation.
  28985. func withUsageDetailID(id uint64) usagedetailOption {
  28986. return func(m *UsageDetailMutation) {
  28987. var (
  28988. err error
  28989. once sync.Once
  28990. value *UsageDetail
  28991. )
  28992. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  28993. once.Do(func() {
  28994. if m.done {
  28995. err = errors.New("querying old values post mutation is not allowed")
  28996. } else {
  28997. value, err = m.Client().UsageDetail.Get(ctx, id)
  28998. }
  28999. })
  29000. return value, err
  29001. }
  29002. m.id = &id
  29003. }
  29004. }
  29005. // withUsageDetail sets the old UsageDetail of the mutation.
  29006. func withUsageDetail(node *UsageDetail) usagedetailOption {
  29007. return func(m *UsageDetailMutation) {
  29008. m.oldValue = func(context.Context) (*UsageDetail, error) {
  29009. return node, nil
  29010. }
  29011. m.id = &node.ID
  29012. }
  29013. }
  29014. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29015. // executed in a transaction (ent.Tx), a transactional client is returned.
  29016. func (m UsageDetailMutation) Client() *Client {
  29017. client := &Client{config: m.config}
  29018. client.init()
  29019. return client
  29020. }
  29021. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29022. // it returns an error otherwise.
  29023. func (m UsageDetailMutation) Tx() (*Tx, error) {
  29024. if _, ok := m.driver.(*txDriver); !ok {
  29025. return nil, errors.New("ent: mutation is not running in a transaction")
  29026. }
  29027. tx := &Tx{config: m.config}
  29028. tx.init()
  29029. return tx, nil
  29030. }
  29031. // SetID sets the value of the id field. Note that this
  29032. // operation is only accepted on creation of UsageDetail entities.
  29033. func (m *UsageDetailMutation) SetID(id uint64) {
  29034. m.id = &id
  29035. }
  29036. // ID returns the ID value in the mutation. Note that the ID is only available
  29037. // if it was provided to the builder or after it was returned from the database.
  29038. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  29039. if m.id == nil {
  29040. return
  29041. }
  29042. return *m.id, true
  29043. }
  29044. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29045. // That means, if the mutation is applied within a transaction with an isolation level such
  29046. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29047. // or updated by the mutation.
  29048. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  29049. switch {
  29050. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29051. id, exists := m.ID()
  29052. if exists {
  29053. return []uint64{id}, nil
  29054. }
  29055. fallthrough
  29056. case m.op.Is(OpUpdate | OpDelete):
  29057. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  29058. default:
  29059. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29060. }
  29061. }
  29062. // SetCreatedAt sets the "created_at" field.
  29063. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  29064. m.created_at = &t
  29065. }
  29066. // CreatedAt returns the value of the "created_at" field in the mutation.
  29067. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  29068. v := m.created_at
  29069. if v == nil {
  29070. return
  29071. }
  29072. return *v, true
  29073. }
  29074. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  29075. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29077. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29078. if !m.op.Is(OpUpdateOne) {
  29079. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29080. }
  29081. if m.id == nil || m.oldValue == nil {
  29082. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29083. }
  29084. oldValue, err := m.oldValue(ctx)
  29085. if err != nil {
  29086. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29087. }
  29088. return oldValue.CreatedAt, nil
  29089. }
  29090. // ResetCreatedAt resets all changes to the "created_at" field.
  29091. func (m *UsageDetailMutation) ResetCreatedAt() {
  29092. m.created_at = nil
  29093. }
  29094. // SetUpdatedAt sets the "updated_at" field.
  29095. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29096. m.updated_at = &t
  29097. }
  29098. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29099. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29100. v := m.updated_at
  29101. if v == nil {
  29102. return
  29103. }
  29104. return *v, true
  29105. }
  29106. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29107. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29109. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29110. if !m.op.Is(OpUpdateOne) {
  29111. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29112. }
  29113. if m.id == nil || m.oldValue == nil {
  29114. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29115. }
  29116. oldValue, err := m.oldValue(ctx)
  29117. if err != nil {
  29118. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29119. }
  29120. return oldValue.UpdatedAt, nil
  29121. }
  29122. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29123. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29124. m.updated_at = nil
  29125. }
  29126. // SetStatus sets the "status" field.
  29127. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29128. m.status = &u
  29129. m.addstatus = nil
  29130. }
  29131. // Status returns the value of the "status" field in the mutation.
  29132. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29133. v := m.status
  29134. if v == nil {
  29135. return
  29136. }
  29137. return *v, true
  29138. }
  29139. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29140. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29142. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29143. if !m.op.Is(OpUpdateOne) {
  29144. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29145. }
  29146. if m.id == nil || m.oldValue == nil {
  29147. return v, errors.New("OldStatus requires an ID field in the mutation")
  29148. }
  29149. oldValue, err := m.oldValue(ctx)
  29150. if err != nil {
  29151. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29152. }
  29153. return oldValue.Status, nil
  29154. }
  29155. // AddStatus adds u to the "status" field.
  29156. func (m *UsageDetailMutation) AddStatus(u int8) {
  29157. if m.addstatus != nil {
  29158. *m.addstatus += u
  29159. } else {
  29160. m.addstatus = &u
  29161. }
  29162. }
  29163. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29164. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29165. v := m.addstatus
  29166. if v == nil {
  29167. return
  29168. }
  29169. return *v, true
  29170. }
  29171. // ClearStatus clears the value of the "status" field.
  29172. func (m *UsageDetailMutation) ClearStatus() {
  29173. m.status = nil
  29174. m.addstatus = nil
  29175. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29176. }
  29177. // StatusCleared returns if the "status" field was cleared in this mutation.
  29178. func (m *UsageDetailMutation) StatusCleared() bool {
  29179. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29180. return ok
  29181. }
  29182. // ResetStatus resets all changes to the "status" field.
  29183. func (m *UsageDetailMutation) ResetStatus() {
  29184. m.status = nil
  29185. m.addstatus = nil
  29186. delete(m.clearedFields, usagedetail.FieldStatus)
  29187. }
  29188. // SetType sets the "type" field.
  29189. func (m *UsageDetailMutation) SetType(i int) {
  29190. m._type = &i
  29191. m.add_type = nil
  29192. }
  29193. // GetType returns the value of the "type" field in the mutation.
  29194. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29195. v := m._type
  29196. if v == nil {
  29197. return
  29198. }
  29199. return *v, true
  29200. }
  29201. // OldType returns the old "type" field's value of the UsageDetail entity.
  29202. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29204. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29205. if !m.op.Is(OpUpdateOne) {
  29206. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29207. }
  29208. if m.id == nil || m.oldValue == nil {
  29209. return v, errors.New("OldType requires an ID field in the mutation")
  29210. }
  29211. oldValue, err := m.oldValue(ctx)
  29212. if err != nil {
  29213. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29214. }
  29215. return oldValue.Type, nil
  29216. }
  29217. // AddType adds i to the "type" field.
  29218. func (m *UsageDetailMutation) AddType(i int) {
  29219. if m.add_type != nil {
  29220. *m.add_type += i
  29221. } else {
  29222. m.add_type = &i
  29223. }
  29224. }
  29225. // AddedType returns the value that was added to the "type" field in this mutation.
  29226. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29227. v := m.add_type
  29228. if v == nil {
  29229. return
  29230. }
  29231. return *v, true
  29232. }
  29233. // ClearType clears the value of the "type" field.
  29234. func (m *UsageDetailMutation) ClearType() {
  29235. m._type = nil
  29236. m.add_type = nil
  29237. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29238. }
  29239. // TypeCleared returns if the "type" field was cleared in this mutation.
  29240. func (m *UsageDetailMutation) TypeCleared() bool {
  29241. _, ok := m.clearedFields[usagedetail.FieldType]
  29242. return ok
  29243. }
  29244. // ResetType resets all changes to the "type" field.
  29245. func (m *UsageDetailMutation) ResetType() {
  29246. m._type = nil
  29247. m.add_type = nil
  29248. delete(m.clearedFields, usagedetail.FieldType)
  29249. }
  29250. // SetBotID sets the "bot_id" field.
  29251. func (m *UsageDetailMutation) SetBotID(s string) {
  29252. m.bot_id = &s
  29253. }
  29254. // BotID returns the value of the "bot_id" field in the mutation.
  29255. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29256. v := m.bot_id
  29257. if v == nil {
  29258. return
  29259. }
  29260. return *v, true
  29261. }
  29262. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  29263. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29265. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  29266. if !m.op.Is(OpUpdateOne) {
  29267. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29268. }
  29269. if m.id == nil || m.oldValue == nil {
  29270. return v, errors.New("OldBotID requires an ID field in the mutation")
  29271. }
  29272. oldValue, err := m.oldValue(ctx)
  29273. if err != nil {
  29274. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29275. }
  29276. return oldValue.BotID, nil
  29277. }
  29278. // ResetBotID resets all changes to the "bot_id" field.
  29279. func (m *UsageDetailMutation) ResetBotID() {
  29280. m.bot_id = nil
  29281. }
  29282. // SetReceiverID sets the "receiver_id" field.
  29283. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29284. m.receiver_id = &s
  29285. }
  29286. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29287. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29288. v := m.receiver_id
  29289. if v == nil {
  29290. return
  29291. }
  29292. return *v, true
  29293. }
  29294. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29295. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29297. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29298. if !m.op.Is(OpUpdateOne) {
  29299. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29300. }
  29301. if m.id == nil || m.oldValue == nil {
  29302. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29303. }
  29304. oldValue, err := m.oldValue(ctx)
  29305. if err != nil {
  29306. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29307. }
  29308. return oldValue.ReceiverID, nil
  29309. }
  29310. // ResetReceiverID resets all changes to the "receiver_id" field.
  29311. func (m *UsageDetailMutation) ResetReceiverID() {
  29312. m.receiver_id = nil
  29313. }
  29314. // SetApp sets the "app" field.
  29315. func (m *UsageDetailMutation) SetApp(i int) {
  29316. m.app = &i
  29317. m.addapp = nil
  29318. }
  29319. // App returns the value of the "app" field in the mutation.
  29320. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29321. v := m.app
  29322. if v == nil {
  29323. return
  29324. }
  29325. return *v, true
  29326. }
  29327. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29328. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29330. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29331. if !m.op.Is(OpUpdateOne) {
  29332. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29333. }
  29334. if m.id == nil || m.oldValue == nil {
  29335. return v, errors.New("OldApp requires an ID field in the mutation")
  29336. }
  29337. oldValue, err := m.oldValue(ctx)
  29338. if err != nil {
  29339. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29340. }
  29341. return oldValue.App, nil
  29342. }
  29343. // AddApp adds i to the "app" field.
  29344. func (m *UsageDetailMutation) AddApp(i int) {
  29345. if m.addapp != nil {
  29346. *m.addapp += i
  29347. } else {
  29348. m.addapp = &i
  29349. }
  29350. }
  29351. // AddedApp returns the value that was added to the "app" field in this mutation.
  29352. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29353. v := m.addapp
  29354. if v == nil {
  29355. return
  29356. }
  29357. return *v, true
  29358. }
  29359. // ClearApp clears the value of the "app" field.
  29360. func (m *UsageDetailMutation) ClearApp() {
  29361. m.app = nil
  29362. m.addapp = nil
  29363. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29364. }
  29365. // AppCleared returns if the "app" field was cleared in this mutation.
  29366. func (m *UsageDetailMutation) AppCleared() bool {
  29367. _, ok := m.clearedFields[usagedetail.FieldApp]
  29368. return ok
  29369. }
  29370. // ResetApp resets all changes to the "app" field.
  29371. func (m *UsageDetailMutation) ResetApp() {
  29372. m.app = nil
  29373. m.addapp = nil
  29374. delete(m.clearedFields, usagedetail.FieldApp)
  29375. }
  29376. // SetSessionID sets the "session_id" field.
  29377. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29378. m.session_id = &u
  29379. m.addsession_id = nil
  29380. }
  29381. // SessionID returns the value of the "session_id" field in the mutation.
  29382. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29383. v := m.session_id
  29384. if v == nil {
  29385. return
  29386. }
  29387. return *v, true
  29388. }
  29389. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29390. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29392. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29393. if !m.op.Is(OpUpdateOne) {
  29394. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29395. }
  29396. if m.id == nil || m.oldValue == nil {
  29397. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29398. }
  29399. oldValue, err := m.oldValue(ctx)
  29400. if err != nil {
  29401. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29402. }
  29403. return oldValue.SessionID, nil
  29404. }
  29405. // AddSessionID adds u to the "session_id" field.
  29406. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29407. if m.addsession_id != nil {
  29408. *m.addsession_id += u
  29409. } else {
  29410. m.addsession_id = &u
  29411. }
  29412. }
  29413. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29414. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29415. v := m.addsession_id
  29416. if v == nil {
  29417. return
  29418. }
  29419. return *v, true
  29420. }
  29421. // ClearSessionID clears the value of the "session_id" field.
  29422. func (m *UsageDetailMutation) ClearSessionID() {
  29423. m.session_id = nil
  29424. m.addsession_id = nil
  29425. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29426. }
  29427. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29428. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29429. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29430. return ok
  29431. }
  29432. // ResetSessionID resets all changes to the "session_id" field.
  29433. func (m *UsageDetailMutation) ResetSessionID() {
  29434. m.session_id = nil
  29435. m.addsession_id = nil
  29436. delete(m.clearedFields, usagedetail.FieldSessionID)
  29437. }
  29438. // SetRequest sets the "request" field.
  29439. func (m *UsageDetailMutation) SetRequest(s string) {
  29440. m.request = &s
  29441. }
  29442. // Request returns the value of the "request" field in the mutation.
  29443. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29444. v := m.request
  29445. if v == nil {
  29446. return
  29447. }
  29448. return *v, true
  29449. }
  29450. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  29451. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29453. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  29454. if !m.op.Is(OpUpdateOne) {
  29455. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29456. }
  29457. if m.id == nil || m.oldValue == nil {
  29458. return v, errors.New("OldRequest requires an ID field in the mutation")
  29459. }
  29460. oldValue, err := m.oldValue(ctx)
  29461. if err != nil {
  29462. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  29463. }
  29464. return oldValue.Request, nil
  29465. }
  29466. // ResetRequest resets all changes to the "request" field.
  29467. func (m *UsageDetailMutation) ResetRequest() {
  29468. m.request = nil
  29469. }
  29470. // SetResponse sets the "response" field.
  29471. func (m *UsageDetailMutation) SetResponse(s string) {
  29472. m.response = &s
  29473. }
  29474. // Response returns the value of the "response" field in the mutation.
  29475. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29476. v := m.response
  29477. if v == nil {
  29478. return
  29479. }
  29480. return *v, true
  29481. }
  29482. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29483. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29485. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29486. if !m.op.Is(OpUpdateOne) {
  29487. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29488. }
  29489. if m.id == nil || m.oldValue == nil {
  29490. return v, errors.New("OldResponse requires an ID field in the mutation")
  29491. }
  29492. oldValue, err := m.oldValue(ctx)
  29493. if err != nil {
  29494. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  29495. }
  29496. return oldValue.Response, nil
  29497. }
  29498. // ResetResponse resets all changes to the "response" field.
  29499. func (m *UsageDetailMutation) ResetResponse() {
  29500. m.response = nil
  29501. }
  29502. // SetOriginalData sets the "original_data" field.
  29503. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29504. m.original_data = &ctd
  29505. }
  29506. // OriginalData returns the value of the "original_data" field in the mutation.
  29507. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29508. v := m.original_data
  29509. if v == nil {
  29510. return
  29511. }
  29512. return *v, true
  29513. }
  29514. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29515. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29517. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29518. if !m.op.Is(OpUpdateOne) {
  29519. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29520. }
  29521. if m.id == nil || m.oldValue == nil {
  29522. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29523. }
  29524. oldValue, err := m.oldValue(ctx)
  29525. if err != nil {
  29526. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29527. }
  29528. return oldValue.OriginalData, nil
  29529. }
  29530. // ResetOriginalData resets all changes to the "original_data" field.
  29531. func (m *UsageDetailMutation) ResetOriginalData() {
  29532. m.original_data = nil
  29533. }
  29534. // SetTotalTokens sets the "total_tokens" field.
  29535. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29536. m.total_tokens = &u
  29537. m.addtotal_tokens = nil
  29538. }
  29539. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29540. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29541. v := m.total_tokens
  29542. if v == nil {
  29543. return
  29544. }
  29545. return *v, true
  29546. }
  29547. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29548. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29550. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29551. if !m.op.Is(OpUpdateOne) {
  29552. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29553. }
  29554. if m.id == nil || m.oldValue == nil {
  29555. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29556. }
  29557. oldValue, err := m.oldValue(ctx)
  29558. if err != nil {
  29559. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29560. }
  29561. return oldValue.TotalTokens, nil
  29562. }
  29563. // AddTotalTokens adds u to the "total_tokens" field.
  29564. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29565. if m.addtotal_tokens != nil {
  29566. *m.addtotal_tokens += u
  29567. } else {
  29568. m.addtotal_tokens = &u
  29569. }
  29570. }
  29571. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29572. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29573. v := m.addtotal_tokens
  29574. if v == nil {
  29575. return
  29576. }
  29577. return *v, true
  29578. }
  29579. // ClearTotalTokens clears the value of the "total_tokens" field.
  29580. func (m *UsageDetailMutation) ClearTotalTokens() {
  29581. m.total_tokens = nil
  29582. m.addtotal_tokens = nil
  29583. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29584. }
  29585. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29586. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29587. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29588. return ok
  29589. }
  29590. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29591. func (m *UsageDetailMutation) ResetTotalTokens() {
  29592. m.total_tokens = nil
  29593. m.addtotal_tokens = nil
  29594. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29595. }
  29596. // SetPromptTokens sets the "prompt_tokens" field.
  29597. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29598. m.prompt_tokens = &u
  29599. m.addprompt_tokens = nil
  29600. }
  29601. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29602. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29603. v := m.prompt_tokens
  29604. if v == nil {
  29605. return
  29606. }
  29607. return *v, true
  29608. }
  29609. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29610. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29612. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29613. if !m.op.Is(OpUpdateOne) {
  29614. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29615. }
  29616. if m.id == nil || m.oldValue == nil {
  29617. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29618. }
  29619. oldValue, err := m.oldValue(ctx)
  29620. if err != nil {
  29621. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29622. }
  29623. return oldValue.PromptTokens, nil
  29624. }
  29625. // AddPromptTokens adds u to the "prompt_tokens" field.
  29626. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29627. if m.addprompt_tokens != nil {
  29628. *m.addprompt_tokens += u
  29629. } else {
  29630. m.addprompt_tokens = &u
  29631. }
  29632. }
  29633. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  29634. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  29635. v := m.addprompt_tokens
  29636. if v == nil {
  29637. return
  29638. }
  29639. return *v, true
  29640. }
  29641. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  29642. func (m *UsageDetailMutation) ClearPromptTokens() {
  29643. m.prompt_tokens = nil
  29644. m.addprompt_tokens = nil
  29645. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  29646. }
  29647. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  29648. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  29649. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  29650. return ok
  29651. }
  29652. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  29653. func (m *UsageDetailMutation) ResetPromptTokens() {
  29654. m.prompt_tokens = nil
  29655. m.addprompt_tokens = nil
  29656. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  29657. }
  29658. // SetCompletionTokens sets the "completion_tokens" field.
  29659. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  29660. m.completion_tokens = &u
  29661. m.addcompletion_tokens = nil
  29662. }
  29663. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  29664. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  29665. v := m.completion_tokens
  29666. if v == nil {
  29667. return
  29668. }
  29669. return *v, true
  29670. }
  29671. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  29672. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29674. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  29675. if !m.op.Is(OpUpdateOne) {
  29676. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  29677. }
  29678. if m.id == nil || m.oldValue == nil {
  29679. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  29680. }
  29681. oldValue, err := m.oldValue(ctx)
  29682. if err != nil {
  29683. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  29684. }
  29685. return oldValue.CompletionTokens, nil
  29686. }
  29687. // AddCompletionTokens adds u to the "completion_tokens" field.
  29688. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  29689. if m.addcompletion_tokens != nil {
  29690. *m.addcompletion_tokens += u
  29691. } else {
  29692. m.addcompletion_tokens = &u
  29693. }
  29694. }
  29695. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  29696. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  29697. v := m.addcompletion_tokens
  29698. if v == nil {
  29699. return
  29700. }
  29701. return *v, true
  29702. }
  29703. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  29704. func (m *UsageDetailMutation) ClearCompletionTokens() {
  29705. m.completion_tokens = nil
  29706. m.addcompletion_tokens = nil
  29707. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  29708. }
  29709. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  29710. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  29711. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  29712. return ok
  29713. }
  29714. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  29715. func (m *UsageDetailMutation) ResetCompletionTokens() {
  29716. m.completion_tokens = nil
  29717. m.addcompletion_tokens = nil
  29718. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  29719. }
  29720. // SetOrganizationID sets the "organization_id" field.
  29721. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  29722. m.organization_id = &u
  29723. m.addorganization_id = nil
  29724. }
  29725. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29726. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  29727. v := m.organization_id
  29728. if v == nil {
  29729. return
  29730. }
  29731. return *v, true
  29732. }
  29733. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  29734. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29736. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29737. if !m.op.Is(OpUpdateOne) {
  29738. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29739. }
  29740. if m.id == nil || m.oldValue == nil {
  29741. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29742. }
  29743. oldValue, err := m.oldValue(ctx)
  29744. if err != nil {
  29745. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29746. }
  29747. return oldValue.OrganizationID, nil
  29748. }
  29749. // AddOrganizationID adds u to the "organization_id" field.
  29750. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  29751. if m.addorganization_id != nil {
  29752. *m.addorganization_id += u
  29753. } else {
  29754. m.addorganization_id = &u
  29755. }
  29756. }
  29757. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29758. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  29759. v := m.addorganization_id
  29760. if v == nil {
  29761. return
  29762. }
  29763. return *v, true
  29764. }
  29765. // ClearOrganizationID clears the value of the "organization_id" field.
  29766. func (m *UsageDetailMutation) ClearOrganizationID() {
  29767. m.organization_id = nil
  29768. m.addorganization_id = nil
  29769. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  29770. }
  29771. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29772. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  29773. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  29774. return ok
  29775. }
  29776. // ResetOrganizationID resets all changes to the "organization_id" field.
  29777. func (m *UsageDetailMutation) ResetOrganizationID() {
  29778. m.organization_id = nil
  29779. m.addorganization_id = nil
  29780. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  29781. }
  29782. // Where appends a list predicates to the UsageDetailMutation builder.
  29783. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  29784. m.predicates = append(m.predicates, ps...)
  29785. }
  29786. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  29787. // users can use type-assertion to append predicates that do not depend on any generated package.
  29788. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  29789. p := make([]predicate.UsageDetail, len(ps))
  29790. for i := range ps {
  29791. p[i] = ps[i]
  29792. }
  29793. m.Where(p...)
  29794. }
  29795. // Op returns the operation name.
  29796. func (m *UsageDetailMutation) Op() Op {
  29797. return m.op
  29798. }
  29799. // SetOp allows setting the mutation operation.
  29800. func (m *UsageDetailMutation) SetOp(op Op) {
  29801. m.op = op
  29802. }
  29803. // Type returns the node type of this mutation (UsageDetail).
  29804. func (m *UsageDetailMutation) Type() string {
  29805. return m.typ
  29806. }
  29807. // Fields returns all fields that were changed during this mutation. Note that in
  29808. // order to get all numeric fields that were incremented/decremented, call
  29809. // AddedFields().
  29810. func (m *UsageDetailMutation) Fields() []string {
  29811. fields := make([]string, 0, 15)
  29812. if m.created_at != nil {
  29813. fields = append(fields, usagedetail.FieldCreatedAt)
  29814. }
  29815. if m.updated_at != nil {
  29816. fields = append(fields, usagedetail.FieldUpdatedAt)
  29817. }
  29818. if m.status != nil {
  29819. fields = append(fields, usagedetail.FieldStatus)
  29820. }
  29821. if m._type != nil {
  29822. fields = append(fields, usagedetail.FieldType)
  29823. }
  29824. if m.bot_id != nil {
  29825. fields = append(fields, usagedetail.FieldBotID)
  29826. }
  29827. if m.receiver_id != nil {
  29828. fields = append(fields, usagedetail.FieldReceiverID)
  29829. }
  29830. if m.app != nil {
  29831. fields = append(fields, usagedetail.FieldApp)
  29832. }
  29833. if m.session_id != nil {
  29834. fields = append(fields, usagedetail.FieldSessionID)
  29835. }
  29836. if m.request != nil {
  29837. fields = append(fields, usagedetail.FieldRequest)
  29838. }
  29839. if m.response != nil {
  29840. fields = append(fields, usagedetail.FieldResponse)
  29841. }
  29842. if m.original_data != nil {
  29843. fields = append(fields, usagedetail.FieldOriginalData)
  29844. }
  29845. if m.total_tokens != nil {
  29846. fields = append(fields, usagedetail.FieldTotalTokens)
  29847. }
  29848. if m.prompt_tokens != nil {
  29849. fields = append(fields, usagedetail.FieldPromptTokens)
  29850. }
  29851. if m.completion_tokens != nil {
  29852. fields = append(fields, usagedetail.FieldCompletionTokens)
  29853. }
  29854. if m.organization_id != nil {
  29855. fields = append(fields, usagedetail.FieldOrganizationID)
  29856. }
  29857. return fields
  29858. }
  29859. // Field returns the value of a field with the given name. The second boolean
  29860. // return value indicates that this field was not set, or was not defined in the
  29861. // schema.
  29862. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  29863. switch name {
  29864. case usagedetail.FieldCreatedAt:
  29865. return m.CreatedAt()
  29866. case usagedetail.FieldUpdatedAt:
  29867. return m.UpdatedAt()
  29868. case usagedetail.FieldStatus:
  29869. return m.Status()
  29870. case usagedetail.FieldType:
  29871. return m.GetType()
  29872. case usagedetail.FieldBotID:
  29873. return m.BotID()
  29874. case usagedetail.FieldReceiverID:
  29875. return m.ReceiverID()
  29876. case usagedetail.FieldApp:
  29877. return m.App()
  29878. case usagedetail.FieldSessionID:
  29879. return m.SessionID()
  29880. case usagedetail.FieldRequest:
  29881. return m.Request()
  29882. case usagedetail.FieldResponse:
  29883. return m.Response()
  29884. case usagedetail.FieldOriginalData:
  29885. return m.OriginalData()
  29886. case usagedetail.FieldTotalTokens:
  29887. return m.TotalTokens()
  29888. case usagedetail.FieldPromptTokens:
  29889. return m.PromptTokens()
  29890. case usagedetail.FieldCompletionTokens:
  29891. return m.CompletionTokens()
  29892. case usagedetail.FieldOrganizationID:
  29893. return m.OrganizationID()
  29894. }
  29895. return nil, false
  29896. }
  29897. // OldField returns the old value of the field from the database. An error is
  29898. // returned if the mutation operation is not UpdateOne, or the query to the
  29899. // database failed.
  29900. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29901. switch name {
  29902. case usagedetail.FieldCreatedAt:
  29903. return m.OldCreatedAt(ctx)
  29904. case usagedetail.FieldUpdatedAt:
  29905. return m.OldUpdatedAt(ctx)
  29906. case usagedetail.FieldStatus:
  29907. return m.OldStatus(ctx)
  29908. case usagedetail.FieldType:
  29909. return m.OldType(ctx)
  29910. case usagedetail.FieldBotID:
  29911. return m.OldBotID(ctx)
  29912. case usagedetail.FieldReceiverID:
  29913. return m.OldReceiverID(ctx)
  29914. case usagedetail.FieldApp:
  29915. return m.OldApp(ctx)
  29916. case usagedetail.FieldSessionID:
  29917. return m.OldSessionID(ctx)
  29918. case usagedetail.FieldRequest:
  29919. return m.OldRequest(ctx)
  29920. case usagedetail.FieldResponse:
  29921. return m.OldResponse(ctx)
  29922. case usagedetail.FieldOriginalData:
  29923. return m.OldOriginalData(ctx)
  29924. case usagedetail.FieldTotalTokens:
  29925. return m.OldTotalTokens(ctx)
  29926. case usagedetail.FieldPromptTokens:
  29927. return m.OldPromptTokens(ctx)
  29928. case usagedetail.FieldCompletionTokens:
  29929. return m.OldCompletionTokens(ctx)
  29930. case usagedetail.FieldOrganizationID:
  29931. return m.OldOrganizationID(ctx)
  29932. }
  29933. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  29934. }
  29935. // SetField sets the value of a field with the given name. It returns an error if
  29936. // the field is not defined in the schema, or if the type mismatched the field
  29937. // type.
  29938. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  29939. switch name {
  29940. case usagedetail.FieldCreatedAt:
  29941. v, ok := value.(time.Time)
  29942. if !ok {
  29943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29944. }
  29945. m.SetCreatedAt(v)
  29946. return nil
  29947. case usagedetail.FieldUpdatedAt:
  29948. v, ok := value.(time.Time)
  29949. if !ok {
  29950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29951. }
  29952. m.SetUpdatedAt(v)
  29953. return nil
  29954. case usagedetail.FieldStatus:
  29955. v, ok := value.(uint8)
  29956. if !ok {
  29957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29958. }
  29959. m.SetStatus(v)
  29960. return nil
  29961. case usagedetail.FieldType:
  29962. v, ok := value.(int)
  29963. if !ok {
  29964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29965. }
  29966. m.SetType(v)
  29967. return nil
  29968. case usagedetail.FieldBotID:
  29969. v, ok := value.(string)
  29970. if !ok {
  29971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29972. }
  29973. m.SetBotID(v)
  29974. return nil
  29975. case usagedetail.FieldReceiverID:
  29976. v, ok := value.(string)
  29977. if !ok {
  29978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29979. }
  29980. m.SetReceiverID(v)
  29981. return nil
  29982. case usagedetail.FieldApp:
  29983. v, ok := value.(int)
  29984. if !ok {
  29985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29986. }
  29987. m.SetApp(v)
  29988. return nil
  29989. case usagedetail.FieldSessionID:
  29990. v, ok := value.(uint64)
  29991. if !ok {
  29992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29993. }
  29994. m.SetSessionID(v)
  29995. return nil
  29996. case usagedetail.FieldRequest:
  29997. v, ok := value.(string)
  29998. if !ok {
  29999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30000. }
  30001. m.SetRequest(v)
  30002. return nil
  30003. case usagedetail.FieldResponse:
  30004. v, ok := value.(string)
  30005. if !ok {
  30006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30007. }
  30008. m.SetResponse(v)
  30009. return nil
  30010. case usagedetail.FieldOriginalData:
  30011. v, ok := value.(custom_types.OriginalData)
  30012. if !ok {
  30013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30014. }
  30015. m.SetOriginalData(v)
  30016. return nil
  30017. case usagedetail.FieldTotalTokens:
  30018. v, ok := value.(uint64)
  30019. if !ok {
  30020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30021. }
  30022. m.SetTotalTokens(v)
  30023. return nil
  30024. case usagedetail.FieldPromptTokens:
  30025. v, ok := value.(uint64)
  30026. if !ok {
  30027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30028. }
  30029. m.SetPromptTokens(v)
  30030. return nil
  30031. case usagedetail.FieldCompletionTokens:
  30032. v, ok := value.(uint64)
  30033. if !ok {
  30034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30035. }
  30036. m.SetCompletionTokens(v)
  30037. return nil
  30038. case usagedetail.FieldOrganizationID:
  30039. v, ok := value.(uint64)
  30040. if !ok {
  30041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30042. }
  30043. m.SetOrganizationID(v)
  30044. return nil
  30045. }
  30046. return fmt.Errorf("unknown UsageDetail field %s", name)
  30047. }
  30048. // AddedFields returns all numeric fields that were incremented/decremented during
  30049. // this mutation.
  30050. func (m *UsageDetailMutation) AddedFields() []string {
  30051. var fields []string
  30052. if m.addstatus != nil {
  30053. fields = append(fields, usagedetail.FieldStatus)
  30054. }
  30055. if m.add_type != nil {
  30056. fields = append(fields, usagedetail.FieldType)
  30057. }
  30058. if m.addapp != nil {
  30059. fields = append(fields, usagedetail.FieldApp)
  30060. }
  30061. if m.addsession_id != nil {
  30062. fields = append(fields, usagedetail.FieldSessionID)
  30063. }
  30064. if m.addtotal_tokens != nil {
  30065. fields = append(fields, usagedetail.FieldTotalTokens)
  30066. }
  30067. if m.addprompt_tokens != nil {
  30068. fields = append(fields, usagedetail.FieldPromptTokens)
  30069. }
  30070. if m.addcompletion_tokens != nil {
  30071. fields = append(fields, usagedetail.FieldCompletionTokens)
  30072. }
  30073. if m.addorganization_id != nil {
  30074. fields = append(fields, usagedetail.FieldOrganizationID)
  30075. }
  30076. return fields
  30077. }
  30078. // AddedField returns the numeric value that was incremented/decremented on a field
  30079. // with the given name. The second boolean return value indicates that this field
  30080. // was not set, or was not defined in the schema.
  30081. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30082. switch name {
  30083. case usagedetail.FieldStatus:
  30084. return m.AddedStatus()
  30085. case usagedetail.FieldType:
  30086. return m.AddedType()
  30087. case usagedetail.FieldApp:
  30088. return m.AddedApp()
  30089. case usagedetail.FieldSessionID:
  30090. return m.AddedSessionID()
  30091. case usagedetail.FieldTotalTokens:
  30092. return m.AddedTotalTokens()
  30093. case usagedetail.FieldPromptTokens:
  30094. return m.AddedPromptTokens()
  30095. case usagedetail.FieldCompletionTokens:
  30096. return m.AddedCompletionTokens()
  30097. case usagedetail.FieldOrganizationID:
  30098. return m.AddedOrganizationID()
  30099. }
  30100. return nil, false
  30101. }
  30102. // AddField adds the value to the field with the given name. It returns an error if
  30103. // the field is not defined in the schema, or if the type mismatched the field
  30104. // type.
  30105. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30106. switch name {
  30107. case usagedetail.FieldStatus:
  30108. v, ok := value.(int8)
  30109. if !ok {
  30110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30111. }
  30112. m.AddStatus(v)
  30113. return nil
  30114. case usagedetail.FieldType:
  30115. v, ok := value.(int)
  30116. if !ok {
  30117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30118. }
  30119. m.AddType(v)
  30120. return nil
  30121. case usagedetail.FieldApp:
  30122. v, ok := value.(int)
  30123. if !ok {
  30124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30125. }
  30126. m.AddApp(v)
  30127. return nil
  30128. case usagedetail.FieldSessionID:
  30129. v, ok := value.(int64)
  30130. if !ok {
  30131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30132. }
  30133. m.AddSessionID(v)
  30134. return nil
  30135. case usagedetail.FieldTotalTokens:
  30136. v, ok := value.(int64)
  30137. if !ok {
  30138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30139. }
  30140. m.AddTotalTokens(v)
  30141. return nil
  30142. case usagedetail.FieldPromptTokens:
  30143. v, ok := value.(int64)
  30144. if !ok {
  30145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30146. }
  30147. m.AddPromptTokens(v)
  30148. return nil
  30149. case usagedetail.FieldCompletionTokens:
  30150. v, ok := value.(int64)
  30151. if !ok {
  30152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30153. }
  30154. m.AddCompletionTokens(v)
  30155. return nil
  30156. case usagedetail.FieldOrganizationID:
  30157. v, ok := value.(int64)
  30158. if !ok {
  30159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30160. }
  30161. m.AddOrganizationID(v)
  30162. return nil
  30163. }
  30164. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30165. }
  30166. // ClearedFields returns all nullable fields that were cleared during this
  30167. // mutation.
  30168. func (m *UsageDetailMutation) ClearedFields() []string {
  30169. var fields []string
  30170. if m.FieldCleared(usagedetail.FieldStatus) {
  30171. fields = append(fields, usagedetail.FieldStatus)
  30172. }
  30173. if m.FieldCleared(usagedetail.FieldType) {
  30174. fields = append(fields, usagedetail.FieldType)
  30175. }
  30176. if m.FieldCleared(usagedetail.FieldApp) {
  30177. fields = append(fields, usagedetail.FieldApp)
  30178. }
  30179. if m.FieldCleared(usagedetail.FieldSessionID) {
  30180. fields = append(fields, usagedetail.FieldSessionID)
  30181. }
  30182. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30183. fields = append(fields, usagedetail.FieldTotalTokens)
  30184. }
  30185. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30186. fields = append(fields, usagedetail.FieldPromptTokens)
  30187. }
  30188. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30189. fields = append(fields, usagedetail.FieldCompletionTokens)
  30190. }
  30191. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30192. fields = append(fields, usagedetail.FieldOrganizationID)
  30193. }
  30194. return fields
  30195. }
  30196. // FieldCleared returns a boolean indicating if a field with the given name was
  30197. // cleared in this mutation.
  30198. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30199. _, ok := m.clearedFields[name]
  30200. return ok
  30201. }
  30202. // ClearField clears the value of the field with the given name. It returns an
  30203. // error if the field is not defined in the schema.
  30204. func (m *UsageDetailMutation) ClearField(name string) error {
  30205. switch name {
  30206. case usagedetail.FieldStatus:
  30207. m.ClearStatus()
  30208. return nil
  30209. case usagedetail.FieldType:
  30210. m.ClearType()
  30211. return nil
  30212. case usagedetail.FieldApp:
  30213. m.ClearApp()
  30214. return nil
  30215. case usagedetail.FieldSessionID:
  30216. m.ClearSessionID()
  30217. return nil
  30218. case usagedetail.FieldTotalTokens:
  30219. m.ClearTotalTokens()
  30220. return nil
  30221. case usagedetail.FieldPromptTokens:
  30222. m.ClearPromptTokens()
  30223. return nil
  30224. case usagedetail.FieldCompletionTokens:
  30225. m.ClearCompletionTokens()
  30226. return nil
  30227. case usagedetail.FieldOrganizationID:
  30228. m.ClearOrganizationID()
  30229. return nil
  30230. }
  30231. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30232. }
  30233. // ResetField resets all changes in the mutation for the field with the given name.
  30234. // It returns an error if the field is not defined in the schema.
  30235. func (m *UsageDetailMutation) ResetField(name string) error {
  30236. switch name {
  30237. case usagedetail.FieldCreatedAt:
  30238. m.ResetCreatedAt()
  30239. return nil
  30240. case usagedetail.FieldUpdatedAt:
  30241. m.ResetUpdatedAt()
  30242. return nil
  30243. case usagedetail.FieldStatus:
  30244. m.ResetStatus()
  30245. return nil
  30246. case usagedetail.FieldType:
  30247. m.ResetType()
  30248. return nil
  30249. case usagedetail.FieldBotID:
  30250. m.ResetBotID()
  30251. return nil
  30252. case usagedetail.FieldReceiverID:
  30253. m.ResetReceiverID()
  30254. return nil
  30255. case usagedetail.FieldApp:
  30256. m.ResetApp()
  30257. return nil
  30258. case usagedetail.FieldSessionID:
  30259. m.ResetSessionID()
  30260. return nil
  30261. case usagedetail.FieldRequest:
  30262. m.ResetRequest()
  30263. return nil
  30264. case usagedetail.FieldResponse:
  30265. m.ResetResponse()
  30266. return nil
  30267. case usagedetail.FieldOriginalData:
  30268. m.ResetOriginalData()
  30269. return nil
  30270. case usagedetail.FieldTotalTokens:
  30271. m.ResetTotalTokens()
  30272. return nil
  30273. case usagedetail.FieldPromptTokens:
  30274. m.ResetPromptTokens()
  30275. return nil
  30276. case usagedetail.FieldCompletionTokens:
  30277. m.ResetCompletionTokens()
  30278. return nil
  30279. case usagedetail.FieldOrganizationID:
  30280. m.ResetOrganizationID()
  30281. return nil
  30282. }
  30283. return fmt.Errorf("unknown UsageDetail field %s", name)
  30284. }
  30285. // AddedEdges returns all edge names that were set/added in this mutation.
  30286. func (m *UsageDetailMutation) AddedEdges() []string {
  30287. edges := make([]string, 0, 0)
  30288. return edges
  30289. }
  30290. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30291. // name in this mutation.
  30292. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30293. return nil
  30294. }
  30295. // RemovedEdges returns all edge names that were removed in this mutation.
  30296. func (m *UsageDetailMutation) RemovedEdges() []string {
  30297. edges := make([]string, 0, 0)
  30298. return edges
  30299. }
  30300. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30301. // the given name in this mutation.
  30302. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30303. return nil
  30304. }
  30305. // ClearedEdges returns all edge names that were cleared in this mutation.
  30306. func (m *UsageDetailMutation) ClearedEdges() []string {
  30307. edges := make([]string, 0, 0)
  30308. return edges
  30309. }
  30310. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30311. // was cleared in this mutation.
  30312. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30313. return false
  30314. }
  30315. // ClearEdge clears the value of the edge with the given name. It returns an error
  30316. // if that edge is not defined in the schema.
  30317. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30318. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30319. }
  30320. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30321. // It returns an error if the edge is not defined in the schema.
  30322. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30323. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30324. }
  30325. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30326. type UsageStatisticDayMutation struct {
  30327. config
  30328. op Op
  30329. typ string
  30330. id *uint64
  30331. created_at *time.Time
  30332. updated_at *time.Time
  30333. status *uint8
  30334. addstatus *int8
  30335. deleted_at *time.Time
  30336. addtime *uint64
  30337. addaddtime *int64
  30338. _type *int
  30339. add_type *int
  30340. bot_id *string
  30341. organization_id *uint64
  30342. addorganization_id *int64
  30343. ai_response *uint64
  30344. addai_response *int64
  30345. sop_run *uint64
  30346. addsop_run *int64
  30347. total_friend *uint64
  30348. addtotal_friend *int64
  30349. total_group *uint64
  30350. addtotal_group *int64
  30351. account_balance *uint64
  30352. addaccount_balance *int64
  30353. consume_token *uint64
  30354. addconsume_token *int64
  30355. active_user *uint64
  30356. addactive_user *int64
  30357. new_user *int64
  30358. addnew_user *int64
  30359. label_dist *[]custom_types.LabelDist
  30360. appendlabel_dist []custom_types.LabelDist
  30361. clearedFields map[string]struct{}
  30362. done bool
  30363. oldValue func(context.Context) (*UsageStatisticDay, error)
  30364. predicates []predicate.UsageStatisticDay
  30365. }
  30366. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30367. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30368. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30369. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30370. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30371. m := &UsageStatisticDayMutation{
  30372. config: c,
  30373. op: op,
  30374. typ: TypeUsageStatisticDay,
  30375. clearedFields: make(map[string]struct{}),
  30376. }
  30377. for _, opt := range opts {
  30378. opt(m)
  30379. }
  30380. return m
  30381. }
  30382. // withUsageStatisticDayID sets the ID field of the mutation.
  30383. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30384. return func(m *UsageStatisticDayMutation) {
  30385. var (
  30386. err error
  30387. once sync.Once
  30388. value *UsageStatisticDay
  30389. )
  30390. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30391. once.Do(func() {
  30392. if m.done {
  30393. err = errors.New("querying old values post mutation is not allowed")
  30394. } else {
  30395. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30396. }
  30397. })
  30398. return value, err
  30399. }
  30400. m.id = &id
  30401. }
  30402. }
  30403. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30404. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30405. return func(m *UsageStatisticDayMutation) {
  30406. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30407. return node, nil
  30408. }
  30409. m.id = &node.ID
  30410. }
  30411. }
  30412. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30413. // executed in a transaction (ent.Tx), a transactional client is returned.
  30414. func (m UsageStatisticDayMutation) Client() *Client {
  30415. client := &Client{config: m.config}
  30416. client.init()
  30417. return client
  30418. }
  30419. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30420. // it returns an error otherwise.
  30421. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30422. if _, ok := m.driver.(*txDriver); !ok {
  30423. return nil, errors.New("ent: mutation is not running in a transaction")
  30424. }
  30425. tx := &Tx{config: m.config}
  30426. tx.init()
  30427. return tx, nil
  30428. }
  30429. // SetID sets the value of the id field. Note that this
  30430. // operation is only accepted on creation of UsageStatisticDay entities.
  30431. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30432. m.id = &id
  30433. }
  30434. // ID returns the ID value in the mutation. Note that the ID is only available
  30435. // if it was provided to the builder or after it was returned from the database.
  30436. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30437. if m.id == nil {
  30438. return
  30439. }
  30440. return *m.id, true
  30441. }
  30442. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30443. // That means, if the mutation is applied within a transaction with an isolation level such
  30444. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30445. // or updated by the mutation.
  30446. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30447. switch {
  30448. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30449. id, exists := m.ID()
  30450. if exists {
  30451. return []uint64{id}, nil
  30452. }
  30453. fallthrough
  30454. case m.op.Is(OpUpdate | OpDelete):
  30455. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30456. default:
  30457. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30458. }
  30459. }
  30460. // SetCreatedAt sets the "created_at" field.
  30461. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30462. m.created_at = &t
  30463. }
  30464. // CreatedAt returns the value of the "created_at" field in the mutation.
  30465. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30466. v := m.created_at
  30467. if v == nil {
  30468. return
  30469. }
  30470. return *v, true
  30471. }
  30472. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30473. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30475. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30476. if !m.op.Is(OpUpdateOne) {
  30477. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30478. }
  30479. if m.id == nil || m.oldValue == nil {
  30480. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30481. }
  30482. oldValue, err := m.oldValue(ctx)
  30483. if err != nil {
  30484. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30485. }
  30486. return oldValue.CreatedAt, nil
  30487. }
  30488. // ResetCreatedAt resets all changes to the "created_at" field.
  30489. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30490. m.created_at = nil
  30491. }
  30492. // SetUpdatedAt sets the "updated_at" field.
  30493. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30494. m.updated_at = &t
  30495. }
  30496. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30497. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30498. v := m.updated_at
  30499. if v == nil {
  30500. return
  30501. }
  30502. return *v, true
  30503. }
  30504. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30505. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30507. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30508. if !m.op.Is(OpUpdateOne) {
  30509. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30510. }
  30511. if m.id == nil || m.oldValue == nil {
  30512. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30513. }
  30514. oldValue, err := m.oldValue(ctx)
  30515. if err != nil {
  30516. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30517. }
  30518. return oldValue.UpdatedAt, nil
  30519. }
  30520. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30521. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30522. m.updated_at = nil
  30523. }
  30524. // SetStatus sets the "status" field.
  30525. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30526. m.status = &u
  30527. m.addstatus = nil
  30528. }
  30529. // Status returns the value of the "status" field in the mutation.
  30530. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30531. v := m.status
  30532. if v == nil {
  30533. return
  30534. }
  30535. return *v, true
  30536. }
  30537. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30538. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30540. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30541. if !m.op.Is(OpUpdateOne) {
  30542. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30543. }
  30544. if m.id == nil || m.oldValue == nil {
  30545. return v, errors.New("OldStatus requires an ID field in the mutation")
  30546. }
  30547. oldValue, err := m.oldValue(ctx)
  30548. if err != nil {
  30549. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30550. }
  30551. return oldValue.Status, nil
  30552. }
  30553. // AddStatus adds u to the "status" field.
  30554. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30555. if m.addstatus != nil {
  30556. *m.addstatus += u
  30557. } else {
  30558. m.addstatus = &u
  30559. }
  30560. }
  30561. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30562. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30563. v := m.addstatus
  30564. if v == nil {
  30565. return
  30566. }
  30567. return *v, true
  30568. }
  30569. // ClearStatus clears the value of the "status" field.
  30570. func (m *UsageStatisticDayMutation) ClearStatus() {
  30571. m.status = nil
  30572. m.addstatus = nil
  30573. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30574. }
  30575. // StatusCleared returns if the "status" field was cleared in this mutation.
  30576. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30577. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30578. return ok
  30579. }
  30580. // ResetStatus resets all changes to the "status" field.
  30581. func (m *UsageStatisticDayMutation) ResetStatus() {
  30582. m.status = nil
  30583. m.addstatus = nil
  30584. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30585. }
  30586. // SetDeletedAt sets the "deleted_at" field.
  30587. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30588. m.deleted_at = &t
  30589. }
  30590. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30591. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30592. v := m.deleted_at
  30593. if v == nil {
  30594. return
  30595. }
  30596. return *v, true
  30597. }
  30598. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30599. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30601. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30602. if !m.op.Is(OpUpdateOne) {
  30603. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30604. }
  30605. if m.id == nil || m.oldValue == nil {
  30606. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30607. }
  30608. oldValue, err := m.oldValue(ctx)
  30609. if err != nil {
  30610. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30611. }
  30612. return oldValue.DeletedAt, nil
  30613. }
  30614. // ClearDeletedAt clears the value of the "deleted_at" field.
  30615. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30616. m.deleted_at = nil
  30617. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30618. }
  30619. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30620. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30621. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30622. return ok
  30623. }
  30624. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30625. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30626. m.deleted_at = nil
  30627. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30628. }
  30629. // SetAddtime sets the "addtime" field.
  30630. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30631. m.addtime = &u
  30632. m.addaddtime = nil
  30633. }
  30634. // Addtime returns the value of the "addtime" field in the mutation.
  30635. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  30636. v := m.addtime
  30637. if v == nil {
  30638. return
  30639. }
  30640. return *v, true
  30641. }
  30642. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  30643. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30645. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30646. if !m.op.Is(OpUpdateOne) {
  30647. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30648. }
  30649. if m.id == nil || m.oldValue == nil {
  30650. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30651. }
  30652. oldValue, err := m.oldValue(ctx)
  30653. if err != nil {
  30654. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30655. }
  30656. return oldValue.Addtime, nil
  30657. }
  30658. // AddAddtime adds u to the "addtime" field.
  30659. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  30660. if m.addaddtime != nil {
  30661. *m.addaddtime += u
  30662. } else {
  30663. m.addaddtime = &u
  30664. }
  30665. }
  30666. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30667. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  30668. v := m.addaddtime
  30669. if v == nil {
  30670. return
  30671. }
  30672. return *v, true
  30673. }
  30674. // ResetAddtime resets all changes to the "addtime" field.
  30675. func (m *UsageStatisticDayMutation) ResetAddtime() {
  30676. m.addtime = nil
  30677. m.addaddtime = nil
  30678. }
  30679. // SetType sets the "type" field.
  30680. func (m *UsageStatisticDayMutation) SetType(i int) {
  30681. m._type = &i
  30682. m.add_type = nil
  30683. }
  30684. // GetType returns the value of the "type" field in the mutation.
  30685. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  30686. v := m._type
  30687. if v == nil {
  30688. return
  30689. }
  30690. return *v, true
  30691. }
  30692. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  30693. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30695. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  30696. if !m.op.Is(OpUpdateOne) {
  30697. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30698. }
  30699. if m.id == nil || m.oldValue == nil {
  30700. return v, errors.New("OldType requires an ID field in the mutation")
  30701. }
  30702. oldValue, err := m.oldValue(ctx)
  30703. if err != nil {
  30704. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30705. }
  30706. return oldValue.Type, nil
  30707. }
  30708. // AddType adds i to the "type" field.
  30709. func (m *UsageStatisticDayMutation) AddType(i int) {
  30710. if m.add_type != nil {
  30711. *m.add_type += i
  30712. } else {
  30713. m.add_type = &i
  30714. }
  30715. }
  30716. // AddedType returns the value that was added to the "type" field in this mutation.
  30717. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  30718. v := m.add_type
  30719. if v == nil {
  30720. return
  30721. }
  30722. return *v, true
  30723. }
  30724. // ResetType resets all changes to the "type" field.
  30725. func (m *UsageStatisticDayMutation) ResetType() {
  30726. m._type = nil
  30727. m.add_type = nil
  30728. }
  30729. // SetBotID sets the "bot_id" field.
  30730. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  30731. m.bot_id = &s
  30732. }
  30733. // BotID returns the value of the "bot_id" field in the mutation.
  30734. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  30735. v := m.bot_id
  30736. if v == nil {
  30737. return
  30738. }
  30739. return *v, true
  30740. }
  30741. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  30742. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30744. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  30745. if !m.op.Is(OpUpdateOne) {
  30746. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30747. }
  30748. if m.id == nil || m.oldValue == nil {
  30749. return v, errors.New("OldBotID requires an ID field in the mutation")
  30750. }
  30751. oldValue, err := m.oldValue(ctx)
  30752. if err != nil {
  30753. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30754. }
  30755. return oldValue.BotID, nil
  30756. }
  30757. // ClearBotID clears the value of the "bot_id" field.
  30758. func (m *UsageStatisticDayMutation) ClearBotID() {
  30759. m.bot_id = nil
  30760. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  30761. }
  30762. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30763. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  30764. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  30765. return ok
  30766. }
  30767. // ResetBotID resets all changes to the "bot_id" field.
  30768. func (m *UsageStatisticDayMutation) ResetBotID() {
  30769. m.bot_id = nil
  30770. delete(m.clearedFields, usagestatisticday.FieldBotID)
  30771. }
  30772. // SetOrganizationID sets the "organization_id" field.
  30773. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  30774. m.organization_id = &u
  30775. m.addorganization_id = nil
  30776. }
  30777. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30778. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  30779. v := m.organization_id
  30780. if v == nil {
  30781. return
  30782. }
  30783. return *v, true
  30784. }
  30785. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  30786. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30788. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30789. if !m.op.Is(OpUpdateOne) {
  30790. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30791. }
  30792. if m.id == nil || m.oldValue == nil {
  30793. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30794. }
  30795. oldValue, err := m.oldValue(ctx)
  30796. if err != nil {
  30797. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30798. }
  30799. return oldValue.OrganizationID, nil
  30800. }
  30801. // AddOrganizationID adds u to the "organization_id" field.
  30802. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  30803. if m.addorganization_id != nil {
  30804. *m.addorganization_id += u
  30805. } else {
  30806. m.addorganization_id = &u
  30807. }
  30808. }
  30809. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30810. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  30811. v := m.addorganization_id
  30812. if v == nil {
  30813. return
  30814. }
  30815. return *v, true
  30816. }
  30817. // ClearOrganizationID clears the value of the "organization_id" field.
  30818. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  30819. m.organization_id = nil
  30820. m.addorganization_id = nil
  30821. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  30822. }
  30823. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30824. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  30825. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  30826. return ok
  30827. }
  30828. // ResetOrganizationID resets all changes to the "organization_id" field.
  30829. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  30830. m.organization_id = nil
  30831. m.addorganization_id = nil
  30832. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  30833. }
  30834. // SetAiResponse sets the "ai_response" field.
  30835. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  30836. m.ai_response = &u
  30837. m.addai_response = nil
  30838. }
  30839. // AiResponse returns the value of the "ai_response" field in the mutation.
  30840. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  30841. v := m.ai_response
  30842. if v == nil {
  30843. return
  30844. }
  30845. return *v, true
  30846. }
  30847. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  30848. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30850. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30851. if !m.op.Is(OpUpdateOne) {
  30852. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30853. }
  30854. if m.id == nil || m.oldValue == nil {
  30855. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30856. }
  30857. oldValue, err := m.oldValue(ctx)
  30858. if err != nil {
  30859. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30860. }
  30861. return oldValue.AiResponse, nil
  30862. }
  30863. // AddAiResponse adds u to the "ai_response" field.
  30864. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  30865. if m.addai_response != nil {
  30866. *m.addai_response += u
  30867. } else {
  30868. m.addai_response = &u
  30869. }
  30870. }
  30871. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30872. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  30873. v := m.addai_response
  30874. if v == nil {
  30875. return
  30876. }
  30877. return *v, true
  30878. }
  30879. // ResetAiResponse resets all changes to the "ai_response" field.
  30880. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  30881. m.ai_response = nil
  30882. m.addai_response = nil
  30883. }
  30884. // SetSopRun sets the "sop_run" field.
  30885. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  30886. m.sop_run = &u
  30887. m.addsop_run = nil
  30888. }
  30889. // SopRun returns the value of the "sop_run" field in the mutation.
  30890. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  30891. v := m.sop_run
  30892. if v == nil {
  30893. return
  30894. }
  30895. return *v, true
  30896. }
  30897. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  30898. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30900. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30901. if !m.op.Is(OpUpdateOne) {
  30902. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30903. }
  30904. if m.id == nil || m.oldValue == nil {
  30905. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30906. }
  30907. oldValue, err := m.oldValue(ctx)
  30908. if err != nil {
  30909. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30910. }
  30911. return oldValue.SopRun, nil
  30912. }
  30913. // AddSopRun adds u to the "sop_run" field.
  30914. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  30915. if m.addsop_run != nil {
  30916. *m.addsop_run += u
  30917. } else {
  30918. m.addsop_run = &u
  30919. }
  30920. }
  30921. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30922. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  30923. v := m.addsop_run
  30924. if v == nil {
  30925. return
  30926. }
  30927. return *v, true
  30928. }
  30929. // ResetSopRun resets all changes to the "sop_run" field.
  30930. func (m *UsageStatisticDayMutation) ResetSopRun() {
  30931. m.sop_run = nil
  30932. m.addsop_run = nil
  30933. }
  30934. // SetTotalFriend sets the "total_friend" field.
  30935. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  30936. m.total_friend = &u
  30937. m.addtotal_friend = nil
  30938. }
  30939. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30940. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  30941. v := m.total_friend
  30942. if v == nil {
  30943. return
  30944. }
  30945. return *v, true
  30946. }
  30947. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  30948. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30950. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30951. if !m.op.Is(OpUpdateOne) {
  30952. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30953. }
  30954. if m.id == nil || m.oldValue == nil {
  30955. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30956. }
  30957. oldValue, err := m.oldValue(ctx)
  30958. if err != nil {
  30959. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30960. }
  30961. return oldValue.TotalFriend, nil
  30962. }
  30963. // AddTotalFriend adds u to the "total_friend" field.
  30964. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  30965. if m.addtotal_friend != nil {
  30966. *m.addtotal_friend += u
  30967. } else {
  30968. m.addtotal_friend = &u
  30969. }
  30970. }
  30971. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30972. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  30973. v := m.addtotal_friend
  30974. if v == nil {
  30975. return
  30976. }
  30977. return *v, true
  30978. }
  30979. // ResetTotalFriend resets all changes to the "total_friend" field.
  30980. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  30981. m.total_friend = nil
  30982. m.addtotal_friend = nil
  30983. }
  30984. // SetTotalGroup sets the "total_group" field.
  30985. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  30986. m.total_group = &u
  30987. m.addtotal_group = nil
  30988. }
  30989. // TotalGroup returns the value of the "total_group" field in the mutation.
  30990. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  30991. v := m.total_group
  30992. if v == nil {
  30993. return
  30994. }
  30995. return *v, true
  30996. }
  30997. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  30998. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31000. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31001. if !m.op.Is(OpUpdateOne) {
  31002. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31003. }
  31004. if m.id == nil || m.oldValue == nil {
  31005. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31006. }
  31007. oldValue, err := m.oldValue(ctx)
  31008. if err != nil {
  31009. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31010. }
  31011. return oldValue.TotalGroup, nil
  31012. }
  31013. // AddTotalGroup adds u to the "total_group" field.
  31014. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  31015. if m.addtotal_group != nil {
  31016. *m.addtotal_group += u
  31017. } else {
  31018. m.addtotal_group = &u
  31019. }
  31020. }
  31021. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31022. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  31023. v := m.addtotal_group
  31024. if v == nil {
  31025. return
  31026. }
  31027. return *v, true
  31028. }
  31029. // ResetTotalGroup resets all changes to the "total_group" field.
  31030. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  31031. m.total_group = nil
  31032. m.addtotal_group = nil
  31033. }
  31034. // SetAccountBalance sets the "account_balance" field.
  31035. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  31036. m.account_balance = &u
  31037. m.addaccount_balance = nil
  31038. }
  31039. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31040. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  31041. v := m.account_balance
  31042. if v == nil {
  31043. return
  31044. }
  31045. return *v, true
  31046. }
  31047. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  31048. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31050. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31051. if !m.op.Is(OpUpdateOne) {
  31052. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31053. }
  31054. if m.id == nil || m.oldValue == nil {
  31055. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31056. }
  31057. oldValue, err := m.oldValue(ctx)
  31058. if err != nil {
  31059. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31060. }
  31061. return oldValue.AccountBalance, nil
  31062. }
  31063. // AddAccountBalance adds u to the "account_balance" field.
  31064. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  31065. if m.addaccount_balance != nil {
  31066. *m.addaccount_balance += u
  31067. } else {
  31068. m.addaccount_balance = &u
  31069. }
  31070. }
  31071. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31072. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  31073. v := m.addaccount_balance
  31074. if v == nil {
  31075. return
  31076. }
  31077. return *v, true
  31078. }
  31079. // ResetAccountBalance resets all changes to the "account_balance" field.
  31080. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31081. m.account_balance = nil
  31082. m.addaccount_balance = nil
  31083. }
  31084. // SetConsumeToken sets the "consume_token" field.
  31085. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31086. m.consume_token = &u
  31087. m.addconsume_token = nil
  31088. }
  31089. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31090. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31091. v := m.consume_token
  31092. if v == nil {
  31093. return
  31094. }
  31095. return *v, true
  31096. }
  31097. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31098. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31100. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31101. if !m.op.Is(OpUpdateOne) {
  31102. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31103. }
  31104. if m.id == nil || m.oldValue == nil {
  31105. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31106. }
  31107. oldValue, err := m.oldValue(ctx)
  31108. if err != nil {
  31109. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31110. }
  31111. return oldValue.ConsumeToken, nil
  31112. }
  31113. // AddConsumeToken adds u to the "consume_token" field.
  31114. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31115. if m.addconsume_token != nil {
  31116. *m.addconsume_token += u
  31117. } else {
  31118. m.addconsume_token = &u
  31119. }
  31120. }
  31121. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31122. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31123. v := m.addconsume_token
  31124. if v == nil {
  31125. return
  31126. }
  31127. return *v, true
  31128. }
  31129. // ResetConsumeToken resets all changes to the "consume_token" field.
  31130. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31131. m.consume_token = nil
  31132. m.addconsume_token = nil
  31133. }
  31134. // SetActiveUser sets the "active_user" field.
  31135. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31136. m.active_user = &u
  31137. m.addactive_user = nil
  31138. }
  31139. // ActiveUser returns the value of the "active_user" field in the mutation.
  31140. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31141. v := m.active_user
  31142. if v == nil {
  31143. return
  31144. }
  31145. return *v, true
  31146. }
  31147. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31148. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31150. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31151. if !m.op.Is(OpUpdateOne) {
  31152. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31153. }
  31154. if m.id == nil || m.oldValue == nil {
  31155. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31156. }
  31157. oldValue, err := m.oldValue(ctx)
  31158. if err != nil {
  31159. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31160. }
  31161. return oldValue.ActiveUser, nil
  31162. }
  31163. // AddActiveUser adds u to the "active_user" field.
  31164. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31165. if m.addactive_user != nil {
  31166. *m.addactive_user += u
  31167. } else {
  31168. m.addactive_user = &u
  31169. }
  31170. }
  31171. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31172. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31173. v := m.addactive_user
  31174. if v == nil {
  31175. return
  31176. }
  31177. return *v, true
  31178. }
  31179. // ResetActiveUser resets all changes to the "active_user" field.
  31180. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31181. m.active_user = nil
  31182. m.addactive_user = nil
  31183. }
  31184. // SetNewUser sets the "new_user" field.
  31185. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31186. m.new_user = &i
  31187. m.addnew_user = nil
  31188. }
  31189. // NewUser returns the value of the "new_user" field in the mutation.
  31190. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31191. v := m.new_user
  31192. if v == nil {
  31193. return
  31194. }
  31195. return *v, true
  31196. }
  31197. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31198. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31200. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31201. if !m.op.Is(OpUpdateOne) {
  31202. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31203. }
  31204. if m.id == nil || m.oldValue == nil {
  31205. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31206. }
  31207. oldValue, err := m.oldValue(ctx)
  31208. if err != nil {
  31209. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31210. }
  31211. return oldValue.NewUser, nil
  31212. }
  31213. // AddNewUser adds i to the "new_user" field.
  31214. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31215. if m.addnew_user != nil {
  31216. *m.addnew_user += i
  31217. } else {
  31218. m.addnew_user = &i
  31219. }
  31220. }
  31221. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31222. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31223. v := m.addnew_user
  31224. if v == nil {
  31225. return
  31226. }
  31227. return *v, true
  31228. }
  31229. // ResetNewUser resets all changes to the "new_user" field.
  31230. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31231. m.new_user = nil
  31232. m.addnew_user = nil
  31233. }
  31234. // SetLabelDist sets the "label_dist" field.
  31235. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31236. m.label_dist = &ctd
  31237. m.appendlabel_dist = nil
  31238. }
  31239. // LabelDist returns the value of the "label_dist" field in the mutation.
  31240. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31241. v := m.label_dist
  31242. if v == nil {
  31243. return
  31244. }
  31245. return *v, true
  31246. }
  31247. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31248. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31250. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31251. if !m.op.Is(OpUpdateOne) {
  31252. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31253. }
  31254. if m.id == nil || m.oldValue == nil {
  31255. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31256. }
  31257. oldValue, err := m.oldValue(ctx)
  31258. if err != nil {
  31259. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31260. }
  31261. return oldValue.LabelDist, nil
  31262. }
  31263. // AppendLabelDist adds ctd to the "label_dist" field.
  31264. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31265. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31266. }
  31267. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31268. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31269. if len(m.appendlabel_dist) == 0 {
  31270. return nil, false
  31271. }
  31272. return m.appendlabel_dist, true
  31273. }
  31274. // ResetLabelDist resets all changes to the "label_dist" field.
  31275. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31276. m.label_dist = nil
  31277. m.appendlabel_dist = nil
  31278. }
  31279. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31280. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31281. m.predicates = append(m.predicates, ps...)
  31282. }
  31283. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31284. // users can use type-assertion to append predicates that do not depend on any generated package.
  31285. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31286. p := make([]predicate.UsageStatisticDay, len(ps))
  31287. for i := range ps {
  31288. p[i] = ps[i]
  31289. }
  31290. m.Where(p...)
  31291. }
  31292. // Op returns the operation name.
  31293. func (m *UsageStatisticDayMutation) Op() Op {
  31294. return m.op
  31295. }
  31296. // SetOp allows setting the mutation operation.
  31297. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31298. m.op = op
  31299. }
  31300. // Type returns the node type of this mutation (UsageStatisticDay).
  31301. func (m *UsageStatisticDayMutation) Type() string {
  31302. return m.typ
  31303. }
  31304. // Fields returns all fields that were changed during this mutation. Note that in
  31305. // order to get all numeric fields that were incremented/decremented, call
  31306. // AddedFields().
  31307. func (m *UsageStatisticDayMutation) Fields() []string {
  31308. fields := make([]string, 0, 17)
  31309. if m.created_at != nil {
  31310. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31311. }
  31312. if m.updated_at != nil {
  31313. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31314. }
  31315. if m.status != nil {
  31316. fields = append(fields, usagestatisticday.FieldStatus)
  31317. }
  31318. if m.deleted_at != nil {
  31319. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31320. }
  31321. if m.addtime != nil {
  31322. fields = append(fields, usagestatisticday.FieldAddtime)
  31323. }
  31324. if m._type != nil {
  31325. fields = append(fields, usagestatisticday.FieldType)
  31326. }
  31327. if m.bot_id != nil {
  31328. fields = append(fields, usagestatisticday.FieldBotID)
  31329. }
  31330. if m.organization_id != nil {
  31331. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31332. }
  31333. if m.ai_response != nil {
  31334. fields = append(fields, usagestatisticday.FieldAiResponse)
  31335. }
  31336. if m.sop_run != nil {
  31337. fields = append(fields, usagestatisticday.FieldSopRun)
  31338. }
  31339. if m.total_friend != nil {
  31340. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31341. }
  31342. if m.total_group != nil {
  31343. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31344. }
  31345. if m.account_balance != nil {
  31346. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31347. }
  31348. if m.consume_token != nil {
  31349. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31350. }
  31351. if m.active_user != nil {
  31352. fields = append(fields, usagestatisticday.FieldActiveUser)
  31353. }
  31354. if m.new_user != nil {
  31355. fields = append(fields, usagestatisticday.FieldNewUser)
  31356. }
  31357. if m.label_dist != nil {
  31358. fields = append(fields, usagestatisticday.FieldLabelDist)
  31359. }
  31360. return fields
  31361. }
  31362. // Field returns the value of a field with the given name. The second boolean
  31363. // return value indicates that this field was not set, or was not defined in the
  31364. // schema.
  31365. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31366. switch name {
  31367. case usagestatisticday.FieldCreatedAt:
  31368. return m.CreatedAt()
  31369. case usagestatisticday.FieldUpdatedAt:
  31370. return m.UpdatedAt()
  31371. case usagestatisticday.FieldStatus:
  31372. return m.Status()
  31373. case usagestatisticday.FieldDeletedAt:
  31374. return m.DeletedAt()
  31375. case usagestatisticday.FieldAddtime:
  31376. return m.Addtime()
  31377. case usagestatisticday.FieldType:
  31378. return m.GetType()
  31379. case usagestatisticday.FieldBotID:
  31380. return m.BotID()
  31381. case usagestatisticday.FieldOrganizationID:
  31382. return m.OrganizationID()
  31383. case usagestatisticday.FieldAiResponse:
  31384. return m.AiResponse()
  31385. case usagestatisticday.FieldSopRun:
  31386. return m.SopRun()
  31387. case usagestatisticday.FieldTotalFriend:
  31388. return m.TotalFriend()
  31389. case usagestatisticday.FieldTotalGroup:
  31390. return m.TotalGroup()
  31391. case usagestatisticday.FieldAccountBalance:
  31392. return m.AccountBalance()
  31393. case usagestatisticday.FieldConsumeToken:
  31394. return m.ConsumeToken()
  31395. case usagestatisticday.FieldActiveUser:
  31396. return m.ActiveUser()
  31397. case usagestatisticday.FieldNewUser:
  31398. return m.NewUser()
  31399. case usagestatisticday.FieldLabelDist:
  31400. return m.LabelDist()
  31401. }
  31402. return nil, false
  31403. }
  31404. // OldField returns the old value of the field from the database. An error is
  31405. // returned if the mutation operation is not UpdateOne, or the query to the
  31406. // database failed.
  31407. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31408. switch name {
  31409. case usagestatisticday.FieldCreatedAt:
  31410. return m.OldCreatedAt(ctx)
  31411. case usagestatisticday.FieldUpdatedAt:
  31412. return m.OldUpdatedAt(ctx)
  31413. case usagestatisticday.FieldStatus:
  31414. return m.OldStatus(ctx)
  31415. case usagestatisticday.FieldDeletedAt:
  31416. return m.OldDeletedAt(ctx)
  31417. case usagestatisticday.FieldAddtime:
  31418. return m.OldAddtime(ctx)
  31419. case usagestatisticday.FieldType:
  31420. return m.OldType(ctx)
  31421. case usagestatisticday.FieldBotID:
  31422. return m.OldBotID(ctx)
  31423. case usagestatisticday.FieldOrganizationID:
  31424. return m.OldOrganizationID(ctx)
  31425. case usagestatisticday.FieldAiResponse:
  31426. return m.OldAiResponse(ctx)
  31427. case usagestatisticday.FieldSopRun:
  31428. return m.OldSopRun(ctx)
  31429. case usagestatisticday.FieldTotalFriend:
  31430. return m.OldTotalFriend(ctx)
  31431. case usagestatisticday.FieldTotalGroup:
  31432. return m.OldTotalGroup(ctx)
  31433. case usagestatisticday.FieldAccountBalance:
  31434. return m.OldAccountBalance(ctx)
  31435. case usagestatisticday.FieldConsumeToken:
  31436. return m.OldConsumeToken(ctx)
  31437. case usagestatisticday.FieldActiveUser:
  31438. return m.OldActiveUser(ctx)
  31439. case usagestatisticday.FieldNewUser:
  31440. return m.OldNewUser(ctx)
  31441. case usagestatisticday.FieldLabelDist:
  31442. return m.OldLabelDist(ctx)
  31443. }
  31444. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31445. }
  31446. // SetField sets the value of a field with the given name. It returns an error if
  31447. // the field is not defined in the schema, or if the type mismatched the field
  31448. // type.
  31449. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31450. switch name {
  31451. case usagestatisticday.FieldCreatedAt:
  31452. v, ok := value.(time.Time)
  31453. if !ok {
  31454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31455. }
  31456. m.SetCreatedAt(v)
  31457. return nil
  31458. case usagestatisticday.FieldUpdatedAt:
  31459. v, ok := value.(time.Time)
  31460. if !ok {
  31461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31462. }
  31463. m.SetUpdatedAt(v)
  31464. return nil
  31465. case usagestatisticday.FieldStatus:
  31466. v, ok := value.(uint8)
  31467. if !ok {
  31468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31469. }
  31470. m.SetStatus(v)
  31471. return nil
  31472. case usagestatisticday.FieldDeletedAt:
  31473. v, ok := value.(time.Time)
  31474. if !ok {
  31475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31476. }
  31477. m.SetDeletedAt(v)
  31478. return nil
  31479. case usagestatisticday.FieldAddtime:
  31480. v, ok := value.(uint64)
  31481. if !ok {
  31482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31483. }
  31484. m.SetAddtime(v)
  31485. return nil
  31486. case usagestatisticday.FieldType:
  31487. v, ok := value.(int)
  31488. if !ok {
  31489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31490. }
  31491. m.SetType(v)
  31492. return nil
  31493. case usagestatisticday.FieldBotID:
  31494. v, ok := value.(string)
  31495. if !ok {
  31496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31497. }
  31498. m.SetBotID(v)
  31499. return nil
  31500. case usagestatisticday.FieldOrganizationID:
  31501. v, ok := value.(uint64)
  31502. if !ok {
  31503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31504. }
  31505. m.SetOrganizationID(v)
  31506. return nil
  31507. case usagestatisticday.FieldAiResponse:
  31508. v, ok := value.(uint64)
  31509. if !ok {
  31510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31511. }
  31512. m.SetAiResponse(v)
  31513. return nil
  31514. case usagestatisticday.FieldSopRun:
  31515. v, ok := value.(uint64)
  31516. if !ok {
  31517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31518. }
  31519. m.SetSopRun(v)
  31520. return nil
  31521. case usagestatisticday.FieldTotalFriend:
  31522. v, ok := value.(uint64)
  31523. if !ok {
  31524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31525. }
  31526. m.SetTotalFriend(v)
  31527. return nil
  31528. case usagestatisticday.FieldTotalGroup:
  31529. v, ok := value.(uint64)
  31530. if !ok {
  31531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31532. }
  31533. m.SetTotalGroup(v)
  31534. return nil
  31535. case usagestatisticday.FieldAccountBalance:
  31536. v, ok := value.(uint64)
  31537. if !ok {
  31538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31539. }
  31540. m.SetAccountBalance(v)
  31541. return nil
  31542. case usagestatisticday.FieldConsumeToken:
  31543. v, ok := value.(uint64)
  31544. if !ok {
  31545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31546. }
  31547. m.SetConsumeToken(v)
  31548. return nil
  31549. case usagestatisticday.FieldActiveUser:
  31550. v, ok := value.(uint64)
  31551. if !ok {
  31552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31553. }
  31554. m.SetActiveUser(v)
  31555. return nil
  31556. case usagestatisticday.FieldNewUser:
  31557. v, ok := value.(int64)
  31558. if !ok {
  31559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31560. }
  31561. m.SetNewUser(v)
  31562. return nil
  31563. case usagestatisticday.FieldLabelDist:
  31564. v, ok := value.([]custom_types.LabelDist)
  31565. if !ok {
  31566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31567. }
  31568. m.SetLabelDist(v)
  31569. return nil
  31570. }
  31571. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31572. }
  31573. // AddedFields returns all numeric fields that were incremented/decremented during
  31574. // this mutation.
  31575. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31576. var fields []string
  31577. if m.addstatus != nil {
  31578. fields = append(fields, usagestatisticday.FieldStatus)
  31579. }
  31580. if m.addaddtime != nil {
  31581. fields = append(fields, usagestatisticday.FieldAddtime)
  31582. }
  31583. if m.add_type != nil {
  31584. fields = append(fields, usagestatisticday.FieldType)
  31585. }
  31586. if m.addorganization_id != nil {
  31587. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31588. }
  31589. if m.addai_response != nil {
  31590. fields = append(fields, usagestatisticday.FieldAiResponse)
  31591. }
  31592. if m.addsop_run != nil {
  31593. fields = append(fields, usagestatisticday.FieldSopRun)
  31594. }
  31595. if m.addtotal_friend != nil {
  31596. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31597. }
  31598. if m.addtotal_group != nil {
  31599. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31600. }
  31601. if m.addaccount_balance != nil {
  31602. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31603. }
  31604. if m.addconsume_token != nil {
  31605. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31606. }
  31607. if m.addactive_user != nil {
  31608. fields = append(fields, usagestatisticday.FieldActiveUser)
  31609. }
  31610. if m.addnew_user != nil {
  31611. fields = append(fields, usagestatisticday.FieldNewUser)
  31612. }
  31613. return fields
  31614. }
  31615. // AddedField returns the numeric value that was incremented/decremented on a field
  31616. // with the given name. The second boolean return value indicates that this field
  31617. // was not set, or was not defined in the schema.
  31618. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31619. switch name {
  31620. case usagestatisticday.FieldStatus:
  31621. return m.AddedStatus()
  31622. case usagestatisticday.FieldAddtime:
  31623. return m.AddedAddtime()
  31624. case usagestatisticday.FieldType:
  31625. return m.AddedType()
  31626. case usagestatisticday.FieldOrganizationID:
  31627. return m.AddedOrganizationID()
  31628. case usagestatisticday.FieldAiResponse:
  31629. return m.AddedAiResponse()
  31630. case usagestatisticday.FieldSopRun:
  31631. return m.AddedSopRun()
  31632. case usagestatisticday.FieldTotalFriend:
  31633. return m.AddedTotalFriend()
  31634. case usagestatisticday.FieldTotalGroup:
  31635. return m.AddedTotalGroup()
  31636. case usagestatisticday.FieldAccountBalance:
  31637. return m.AddedAccountBalance()
  31638. case usagestatisticday.FieldConsumeToken:
  31639. return m.AddedConsumeToken()
  31640. case usagestatisticday.FieldActiveUser:
  31641. return m.AddedActiveUser()
  31642. case usagestatisticday.FieldNewUser:
  31643. return m.AddedNewUser()
  31644. }
  31645. return nil, false
  31646. }
  31647. // AddField adds the value to the field with the given name. It returns an error if
  31648. // the field is not defined in the schema, or if the type mismatched the field
  31649. // type.
  31650. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  31651. switch name {
  31652. case usagestatisticday.FieldStatus:
  31653. v, ok := value.(int8)
  31654. if !ok {
  31655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31656. }
  31657. m.AddStatus(v)
  31658. return nil
  31659. case usagestatisticday.FieldAddtime:
  31660. v, ok := value.(int64)
  31661. if !ok {
  31662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31663. }
  31664. m.AddAddtime(v)
  31665. return nil
  31666. case usagestatisticday.FieldType:
  31667. v, ok := value.(int)
  31668. if !ok {
  31669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31670. }
  31671. m.AddType(v)
  31672. return nil
  31673. case usagestatisticday.FieldOrganizationID:
  31674. v, ok := value.(int64)
  31675. if !ok {
  31676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31677. }
  31678. m.AddOrganizationID(v)
  31679. return nil
  31680. case usagestatisticday.FieldAiResponse:
  31681. v, ok := value.(int64)
  31682. if !ok {
  31683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31684. }
  31685. m.AddAiResponse(v)
  31686. return nil
  31687. case usagestatisticday.FieldSopRun:
  31688. v, ok := value.(int64)
  31689. if !ok {
  31690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31691. }
  31692. m.AddSopRun(v)
  31693. return nil
  31694. case usagestatisticday.FieldTotalFriend:
  31695. v, ok := value.(int64)
  31696. if !ok {
  31697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31698. }
  31699. m.AddTotalFriend(v)
  31700. return nil
  31701. case usagestatisticday.FieldTotalGroup:
  31702. v, ok := value.(int64)
  31703. if !ok {
  31704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31705. }
  31706. m.AddTotalGroup(v)
  31707. return nil
  31708. case usagestatisticday.FieldAccountBalance:
  31709. v, ok := value.(int64)
  31710. if !ok {
  31711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31712. }
  31713. m.AddAccountBalance(v)
  31714. return nil
  31715. case usagestatisticday.FieldConsumeToken:
  31716. v, ok := value.(int64)
  31717. if !ok {
  31718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31719. }
  31720. m.AddConsumeToken(v)
  31721. return nil
  31722. case usagestatisticday.FieldActiveUser:
  31723. v, ok := value.(int64)
  31724. if !ok {
  31725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31726. }
  31727. m.AddActiveUser(v)
  31728. return nil
  31729. case usagestatisticday.FieldNewUser:
  31730. v, ok := value.(int64)
  31731. if !ok {
  31732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31733. }
  31734. m.AddNewUser(v)
  31735. return nil
  31736. }
  31737. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  31738. }
  31739. // ClearedFields returns all nullable fields that were cleared during this
  31740. // mutation.
  31741. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  31742. var fields []string
  31743. if m.FieldCleared(usagestatisticday.FieldStatus) {
  31744. fields = append(fields, usagestatisticday.FieldStatus)
  31745. }
  31746. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  31747. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31748. }
  31749. if m.FieldCleared(usagestatisticday.FieldBotID) {
  31750. fields = append(fields, usagestatisticday.FieldBotID)
  31751. }
  31752. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  31753. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31754. }
  31755. return fields
  31756. }
  31757. // FieldCleared returns a boolean indicating if a field with the given name was
  31758. // cleared in this mutation.
  31759. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  31760. _, ok := m.clearedFields[name]
  31761. return ok
  31762. }
  31763. // ClearField clears the value of the field with the given name. It returns an
  31764. // error if the field is not defined in the schema.
  31765. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  31766. switch name {
  31767. case usagestatisticday.FieldStatus:
  31768. m.ClearStatus()
  31769. return nil
  31770. case usagestatisticday.FieldDeletedAt:
  31771. m.ClearDeletedAt()
  31772. return nil
  31773. case usagestatisticday.FieldBotID:
  31774. m.ClearBotID()
  31775. return nil
  31776. case usagestatisticday.FieldOrganizationID:
  31777. m.ClearOrganizationID()
  31778. return nil
  31779. }
  31780. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  31781. }
  31782. // ResetField resets all changes in the mutation for the field with the given name.
  31783. // It returns an error if the field is not defined in the schema.
  31784. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  31785. switch name {
  31786. case usagestatisticday.FieldCreatedAt:
  31787. m.ResetCreatedAt()
  31788. return nil
  31789. case usagestatisticday.FieldUpdatedAt:
  31790. m.ResetUpdatedAt()
  31791. return nil
  31792. case usagestatisticday.FieldStatus:
  31793. m.ResetStatus()
  31794. return nil
  31795. case usagestatisticday.FieldDeletedAt:
  31796. m.ResetDeletedAt()
  31797. return nil
  31798. case usagestatisticday.FieldAddtime:
  31799. m.ResetAddtime()
  31800. return nil
  31801. case usagestatisticday.FieldType:
  31802. m.ResetType()
  31803. return nil
  31804. case usagestatisticday.FieldBotID:
  31805. m.ResetBotID()
  31806. return nil
  31807. case usagestatisticday.FieldOrganizationID:
  31808. m.ResetOrganizationID()
  31809. return nil
  31810. case usagestatisticday.FieldAiResponse:
  31811. m.ResetAiResponse()
  31812. return nil
  31813. case usagestatisticday.FieldSopRun:
  31814. m.ResetSopRun()
  31815. return nil
  31816. case usagestatisticday.FieldTotalFriend:
  31817. m.ResetTotalFriend()
  31818. return nil
  31819. case usagestatisticday.FieldTotalGroup:
  31820. m.ResetTotalGroup()
  31821. return nil
  31822. case usagestatisticday.FieldAccountBalance:
  31823. m.ResetAccountBalance()
  31824. return nil
  31825. case usagestatisticday.FieldConsumeToken:
  31826. m.ResetConsumeToken()
  31827. return nil
  31828. case usagestatisticday.FieldActiveUser:
  31829. m.ResetActiveUser()
  31830. return nil
  31831. case usagestatisticday.FieldNewUser:
  31832. m.ResetNewUser()
  31833. return nil
  31834. case usagestatisticday.FieldLabelDist:
  31835. m.ResetLabelDist()
  31836. return nil
  31837. }
  31838. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31839. }
  31840. // AddedEdges returns all edge names that were set/added in this mutation.
  31841. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  31842. edges := make([]string, 0, 0)
  31843. return edges
  31844. }
  31845. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31846. // name in this mutation.
  31847. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  31848. return nil
  31849. }
  31850. // RemovedEdges returns all edge names that were removed in this mutation.
  31851. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  31852. edges := make([]string, 0, 0)
  31853. return edges
  31854. }
  31855. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31856. // the given name in this mutation.
  31857. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  31858. return nil
  31859. }
  31860. // ClearedEdges returns all edge names that were cleared in this mutation.
  31861. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  31862. edges := make([]string, 0, 0)
  31863. return edges
  31864. }
  31865. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31866. // was cleared in this mutation.
  31867. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  31868. return false
  31869. }
  31870. // ClearEdge clears the value of the edge with the given name. It returns an error
  31871. // if that edge is not defined in the schema.
  31872. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  31873. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  31874. }
  31875. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31876. // It returns an error if the edge is not defined in the schema.
  31877. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  31878. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  31879. }
  31880. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  31881. type UsageStatisticHourMutation struct {
  31882. config
  31883. op Op
  31884. typ string
  31885. id *uint64
  31886. created_at *time.Time
  31887. updated_at *time.Time
  31888. status *uint8
  31889. addstatus *int8
  31890. deleted_at *time.Time
  31891. addtime *uint64
  31892. addaddtime *int64
  31893. _type *int
  31894. add_type *int
  31895. bot_id *string
  31896. organization_id *uint64
  31897. addorganization_id *int64
  31898. ai_response *uint64
  31899. addai_response *int64
  31900. sop_run *uint64
  31901. addsop_run *int64
  31902. total_friend *uint64
  31903. addtotal_friend *int64
  31904. total_group *uint64
  31905. addtotal_group *int64
  31906. account_balance *uint64
  31907. addaccount_balance *int64
  31908. consume_token *uint64
  31909. addconsume_token *int64
  31910. active_user *uint64
  31911. addactive_user *int64
  31912. new_user *int64
  31913. addnew_user *int64
  31914. label_dist *[]custom_types.LabelDist
  31915. appendlabel_dist []custom_types.LabelDist
  31916. clearedFields map[string]struct{}
  31917. done bool
  31918. oldValue func(context.Context) (*UsageStatisticHour, error)
  31919. predicates []predicate.UsageStatisticHour
  31920. }
  31921. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  31922. // usagestatistichourOption allows management of the mutation configuration using functional options.
  31923. type usagestatistichourOption func(*UsageStatisticHourMutation)
  31924. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  31925. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  31926. m := &UsageStatisticHourMutation{
  31927. config: c,
  31928. op: op,
  31929. typ: TypeUsageStatisticHour,
  31930. clearedFields: make(map[string]struct{}),
  31931. }
  31932. for _, opt := range opts {
  31933. opt(m)
  31934. }
  31935. return m
  31936. }
  31937. // withUsageStatisticHourID sets the ID field of the mutation.
  31938. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  31939. return func(m *UsageStatisticHourMutation) {
  31940. var (
  31941. err error
  31942. once sync.Once
  31943. value *UsageStatisticHour
  31944. )
  31945. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  31946. once.Do(func() {
  31947. if m.done {
  31948. err = errors.New("querying old values post mutation is not allowed")
  31949. } else {
  31950. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  31951. }
  31952. })
  31953. return value, err
  31954. }
  31955. m.id = &id
  31956. }
  31957. }
  31958. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  31959. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  31960. return func(m *UsageStatisticHourMutation) {
  31961. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  31962. return node, nil
  31963. }
  31964. m.id = &node.ID
  31965. }
  31966. }
  31967. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31968. // executed in a transaction (ent.Tx), a transactional client is returned.
  31969. func (m UsageStatisticHourMutation) Client() *Client {
  31970. client := &Client{config: m.config}
  31971. client.init()
  31972. return client
  31973. }
  31974. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31975. // it returns an error otherwise.
  31976. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  31977. if _, ok := m.driver.(*txDriver); !ok {
  31978. return nil, errors.New("ent: mutation is not running in a transaction")
  31979. }
  31980. tx := &Tx{config: m.config}
  31981. tx.init()
  31982. return tx, nil
  31983. }
  31984. // SetID sets the value of the id field. Note that this
  31985. // operation is only accepted on creation of UsageStatisticHour entities.
  31986. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  31987. m.id = &id
  31988. }
  31989. // ID returns the ID value in the mutation. Note that the ID is only available
  31990. // if it was provided to the builder or after it was returned from the database.
  31991. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  31992. if m.id == nil {
  31993. return
  31994. }
  31995. return *m.id, true
  31996. }
  31997. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31998. // That means, if the mutation is applied within a transaction with an isolation level such
  31999. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32000. // or updated by the mutation.
  32001. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  32002. switch {
  32003. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32004. id, exists := m.ID()
  32005. if exists {
  32006. return []uint64{id}, nil
  32007. }
  32008. fallthrough
  32009. case m.op.Is(OpUpdate | OpDelete):
  32010. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  32011. default:
  32012. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32013. }
  32014. }
  32015. // SetCreatedAt sets the "created_at" field.
  32016. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  32017. m.created_at = &t
  32018. }
  32019. // CreatedAt returns the value of the "created_at" field in the mutation.
  32020. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  32021. v := m.created_at
  32022. if v == nil {
  32023. return
  32024. }
  32025. return *v, true
  32026. }
  32027. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  32028. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32030. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32031. if !m.op.Is(OpUpdateOne) {
  32032. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32033. }
  32034. if m.id == nil || m.oldValue == nil {
  32035. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32036. }
  32037. oldValue, err := m.oldValue(ctx)
  32038. if err != nil {
  32039. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32040. }
  32041. return oldValue.CreatedAt, nil
  32042. }
  32043. // ResetCreatedAt resets all changes to the "created_at" field.
  32044. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  32045. m.created_at = nil
  32046. }
  32047. // SetUpdatedAt sets the "updated_at" field.
  32048. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  32049. m.updated_at = &t
  32050. }
  32051. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32052. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  32053. v := m.updated_at
  32054. if v == nil {
  32055. return
  32056. }
  32057. return *v, true
  32058. }
  32059. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  32060. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32062. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32063. if !m.op.Is(OpUpdateOne) {
  32064. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32065. }
  32066. if m.id == nil || m.oldValue == nil {
  32067. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32068. }
  32069. oldValue, err := m.oldValue(ctx)
  32070. if err != nil {
  32071. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32072. }
  32073. return oldValue.UpdatedAt, nil
  32074. }
  32075. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32076. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  32077. m.updated_at = nil
  32078. }
  32079. // SetStatus sets the "status" field.
  32080. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32081. m.status = &u
  32082. m.addstatus = nil
  32083. }
  32084. // Status returns the value of the "status" field in the mutation.
  32085. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32086. v := m.status
  32087. if v == nil {
  32088. return
  32089. }
  32090. return *v, true
  32091. }
  32092. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32093. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32095. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32096. if !m.op.Is(OpUpdateOne) {
  32097. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32098. }
  32099. if m.id == nil || m.oldValue == nil {
  32100. return v, errors.New("OldStatus requires an ID field in the mutation")
  32101. }
  32102. oldValue, err := m.oldValue(ctx)
  32103. if err != nil {
  32104. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32105. }
  32106. return oldValue.Status, nil
  32107. }
  32108. // AddStatus adds u to the "status" field.
  32109. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32110. if m.addstatus != nil {
  32111. *m.addstatus += u
  32112. } else {
  32113. m.addstatus = &u
  32114. }
  32115. }
  32116. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32117. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32118. v := m.addstatus
  32119. if v == nil {
  32120. return
  32121. }
  32122. return *v, true
  32123. }
  32124. // ClearStatus clears the value of the "status" field.
  32125. func (m *UsageStatisticHourMutation) ClearStatus() {
  32126. m.status = nil
  32127. m.addstatus = nil
  32128. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32129. }
  32130. // StatusCleared returns if the "status" field was cleared in this mutation.
  32131. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32132. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32133. return ok
  32134. }
  32135. // ResetStatus resets all changes to the "status" field.
  32136. func (m *UsageStatisticHourMutation) ResetStatus() {
  32137. m.status = nil
  32138. m.addstatus = nil
  32139. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32140. }
  32141. // SetDeletedAt sets the "deleted_at" field.
  32142. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32143. m.deleted_at = &t
  32144. }
  32145. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32146. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32147. v := m.deleted_at
  32148. if v == nil {
  32149. return
  32150. }
  32151. return *v, true
  32152. }
  32153. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32154. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32156. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32157. if !m.op.Is(OpUpdateOne) {
  32158. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32159. }
  32160. if m.id == nil || m.oldValue == nil {
  32161. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32162. }
  32163. oldValue, err := m.oldValue(ctx)
  32164. if err != nil {
  32165. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32166. }
  32167. return oldValue.DeletedAt, nil
  32168. }
  32169. // ClearDeletedAt clears the value of the "deleted_at" field.
  32170. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32171. m.deleted_at = nil
  32172. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32173. }
  32174. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32175. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32176. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32177. return ok
  32178. }
  32179. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32180. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32181. m.deleted_at = nil
  32182. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32183. }
  32184. // SetAddtime sets the "addtime" field.
  32185. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32186. m.addtime = &u
  32187. m.addaddtime = nil
  32188. }
  32189. // Addtime returns the value of the "addtime" field in the mutation.
  32190. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32191. v := m.addtime
  32192. if v == nil {
  32193. return
  32194. }
  32195. return *v, true
  32196. }
  32197. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32198. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32200. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32201. if !m.op.Is(OpUpdateOne) {
  32202. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32203. }
  32204. if m.id == nil || m.oldValue == nil {
  32205. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32206. }
  32207. oldValue, err := m.oldValue(ctx)
  32208. if err != nil {
  32209. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32210. }
  32211. return oldValue.Addtime, nil
  32212. }
  32213. // AddAddtime adds u to the "addtime" field.
  32214. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32215. if m.addaddtime != nil {
  32216. *m.addaddtime += u
  32217. } else {
  32218. m.addaddtime = &u
  32219. }
  32220. }
  32221. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32222. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32223. v := m.addaddtime
  32224. if v == nil {
  32225. return
  32226. }
  32227. return *v, true
  32228. }
  32229. // ResetAddtime resets all changes to the "addtime" field.
  32230. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32231. m.addtime = nil
  32232. m.addaddtime = nil
  32233. }
  32234. // SetType sets the "type" field.
  32235. func (m *UsageStatisticHourMutation) SetType(i int) {
  32236. m._type = &i
  32237. m.add_type = nil
  32238. }
  32239. // GetType returns the value of the "type" field in the mutation.
  32240. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32241. v := m._type
  32242. if v == nil {
  32243. return
  32244. }
  32245. return *v, true
  32246. }
  32247. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32248. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32250. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32251. if !m.op.Is(OpUpdateOne) {
  32252. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32253. }
  32254. if m.id == nil || m.oldValue == nil {
  32255. return v, errors.New("OldType requires an ID field in the mutation")
  32256. }
  32257. oldValue, err := m.oldValue(ctx)
  32258. if err != nil {
  32259. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32260. }
  32261. return oldValue.Type, nil
  32262. }
  32263. // AddType adds i to the "type" field.
  32264. func (m *UsageStatisticHourMutation) AddType(i int) {
  32265. if m.add_type != nil {
  32266. *m.add_type += i
  32267. } else {
  32268. m.add_type = &i
  32269. }
  32270. }
  32271. // AddedType returns the value that was added to the "type" field in this mutation.
  32272. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32273. v := m.add_type
  32274. if v == nil {
  32275. return
  32276. }
  32277. return *v, true
  32278. }
  32279. // ResetType resets all changes to the "type" field.
  32280. func (m *UsageStatisticHourMutation) ResetType() {
  32281. m._type = nil
  32282. m.add_type = nil
  32283. }
  32284. // SetBotID sets the "bot_id" field.
  32285. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32286. m.bot_id = &s
  32287. }
  32288. // BotID returns the value of the "bot_id" field in the mutation.
  32289. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32290. v := m.bot_id
  32291. if v == nil {
  32292. return
  32293. }
  32294. return *v, true
  32295. }
  32296. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32297. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32299. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32300. if !m.op.Is(OpUpdateOne) {
  32301. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32302. }
  32303. if m.id == nil || m.oldValue == nil {
  32304. return v, errors.New("OldBotID requires an ID field in the mutation")
  32305. }
  32306. oldValue, err := m.oldValue(ctx)
  32307. if err != nil {
  32308. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32309. }
  32310. return oldValue.BotID, nil
  32311. }
  32312. // ClearBotID clears the value of the "bot_id" field.
  32313. func (m *UsageStatisticHourMutation) ClearBotID() {
  32314. m.bot_id = nil
  32315. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32316. }
  32317. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32318. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32319. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32320. return ok
  32321. }
  32322. // ResetBotID resets all changes to the "bot_id" field.
  32323. func (m *UsageStatisticHourMutation) ResetBotID() {
  32324. m.bot_id = nil
  32325. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32326. }
  32327. // SetOrganizationID sets the "organization_id" field.
  32328. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32329. m.organization_id = &u
  32330. m.addorganization_id = nil
  32331. }
  32332. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32333. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32334. v := m.organization_id
  32335. if v == nil {
  32336. return
  32337. }
  32338. return *v, true
  32339. }
  32340. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32341. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32343. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32344. if !m.op.Is(OpUpdateOne) {
  32345. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32346. }
  32347. if m.id == nil || m.oldValue == nil {
  32348. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32349. }
  32350. oldValue, err := m.oldValue(ctx)
  32351. if err != nil {
  32352. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32353. }
  32354. return oldValue.OrganizationID, nil
  32355. }
  32356. // AddOrganizationID adds u to the "organization_id" field.
  32357. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32358. if m.addorganization_id != nil {
  32359. *m.addorganization_id += u
  32360. } else {
  32361. m.addorganization_id = &u
  32362. }
  32363. }
  32364. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32365. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32366. v := m.addorganization_id
  32367. if v == nil {
  32368. return
  32369. }
  32370. return *v, true
  32371. }
  32372. // ClearOrganizationID clears the value of the "organization_id" field.
  32373. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32374. m.organization_id = nil
  32375. m.addorganization_id = nil
  32376. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32377. }
  32378. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32379. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32380. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32381. return ok
  32382. }
  32383. // ResetOrganizationID resets all changes to the "organization_id" field.
  32384. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32385. m.organization_id = nil
  32386. m.addorganization_id = nil
  32387. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32388. }
  32389. // SetAiResponse sets the "ai_response" field.
  32390. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32391. m.ai_response = &u
  32392. m.addai_response = nil
  32393. }
  32394. // AiResponse returns the value of the "ai_response" field in the mutation.
  32395. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32396. v := m.ai_response
  32397. if v == nil {
  32398. return
  32399. }
  32400. return *v, true
  32401. }
  32402. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32403. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32405. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32406. if !m.op.Is(OpUpdateOne) {
  32407. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32408. }
  32409. if m.id == nil || m.oldValue == nil {
  32410. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32411. }
  32412. oldValue, err := m.oldValue(ctx)
  32413. if err != nil {
  32414. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32415. }
  32416. return oldValue.AiResponse, nil
  32417. }
  32418. // AddAiResponse adds u to the "ai_response" field.
  32419. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32420. if m.addai_response != nil {
  32421. *m.addai_response += u
  32422. } else {
  32423. m.addai_response = &u
  32424. }
  32425. }
  32426. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32427. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32428. v := m.addai_response
  32429. if v == nil {
  32430. return
  32431. }
  32432. return *v, true
  32433. }
  32434. // ResetAiResponse resets all changes to the "ai_response" field.
  32435. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32436. m.ai_response = nil
  32437. m.addai_response = nil
  32438. }
  32439. // SetSopRun sets the "sop_run" field.
  32440. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32441. m.sop_run = &u
  32442. m.addsop_run = nil
  32443. }
  32444. // SopRun returns the value of the "sop_run" field in the mutation.
  32445. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32446. v := m.sop_run
  32447. if v == nil {
  32448. return
  32449. }
  32450. return *v, true
  32451. }
  32452. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  32453. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32455. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32456. if !m.op.Is(OpUpdateOne) {
  32457. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32458. }
  32459. if m.id == nil || m.oldValue == nil {
  32460. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32461. }
  32462. oldValue, err := m.oldValue(ctx)
  32463. if err != nil {
  32464. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32465. }
  32466. return oldValue.SopRun, nil
  32467. }
  32468. // AddSopRun adds u to the "sop_run" field.
  32469. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32470. if m.addsop_run != nil {
  32471. *m.addsop_run += u
  32472. } else {
  32473. m.addsop_run = &u
  32474. }
  32475. }
  32476. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32477. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32478. v := m.addsop_run
  32479. if v == nil {
  32480. return
  32481. }
  32482. return *v, true
  32483. }
  32484. // ResetSopRun resets all changes to the "sop_run" field.
  32485. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32486. m.sop_run = nil
  32487. m.addsop_run = nil
  32488. }
  32489. // SetTotalFriend sets the "total_friend" field.
  32490. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32491. m.total_friend = &u
  32492. m.addtotal_friend = nil
  32493. }
  32494. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32495. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32496. v := m.total_friend
  32497. if v == nil {
  32498. return
  32499. }
  32500. return *v, true
  32501. }
  32502. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32503. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32505. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32506. if !m.op.Is(OpUpdateOne) {
  32507. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32508. }
  32509. if m.id == nil || m.oldValue == nil {
  32510. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32511. }
  32512. oldValue, err := m.oldValue(ctx)
  32513. if err != nil {
  32514. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32515. }
  32516. return oldValue.TotalFriend, nil
  32517. }
  32518. // AddTotalFriend adds u to the "total_friend" field.
  32519. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32520. if m.addtotal_friend != nil {
  32521. *m.addtotal_friend += u
  32522. } else {
  32523. m.addtotal_friend = &u
  32524. }
  32525. }
  32526. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32527. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32528. v := m.addtotal_friend
  32529. if v == nil {
  32530. return
  32531. }
  32532. return *v, true
  32533. }
  32534. // ResetTotalFriend resets all changes to the "total_friend" field.
  32535. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32536. m.total_friend = nil
  32537. m.addtotal_friend = nil
  32538. }
  32539. // SetTotalGroup sets the "total_group" field.
  32540. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32541. m.total_group = &u
  32542. m.addtotal_group = nil
  32543. }
  32544. // TotalGroup returns the value of the "total_group" field in the mutation.
  32545. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32546. v := m.total_group
  32547. if v == nil {
  32548. return
  32549. }
  32550. return *v, true
  32551. }
  32552. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32553. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32555. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32556. if !m.op.Is(OpUpdateOne) {
  32557. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32558. }
  32559. if m.id == nil || m.oldValue == nil {
  32560. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32561. }
  32562. oldValue, err := m.oldValue(ctx)
  32563. if err != nil {
  32564. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32565. }
  32566. return oldValue.TotalGroup, nil
  32567. }
  32568. // AddTotalGroup adds u to the "total_group" field.
  32569. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32570. if m.addtotal_group != nil {
  32571. *m.addtotal_group += u
  32572. } else {
  32573. m.addtotal_group = &u
  32574. }
  32575. }
  32576. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32577. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32578. v := m.addtotal_group
  32579. if v == nil {
  32580. return
  32581. }
  32582. return *v, true
  32583. }
  32584. // ResetTotalGroup resets all changes to the "total_group" field.
  32585. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32586. m.total_group = nil
  32587. m.addtotal_group = nil
  32588. }
  32589. // SetAccountBalance sets the "account_balance" field.
  32590. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32591. m.account_balance = &u
  32592. m.addaccount_balance = nil
  32593. }
  32594. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32595. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32596. v := m.account_balance
  32597. if v == nil {
  32598. return
  32599. }
  32600. return *v, true
  32601. }
  32602. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32603. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32605. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32606. if !m.op.Is(OpUpdateOne) {
  32607. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32608. }
  32609. if m.id == nil || m.oldValue == nil {
  32610. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32611. }
  32612. oldValue, err := m.oldValue(ctx)
  32613. if err != nil {
  32614. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32615. }
  32616. return oldValue.AccountBalance, nil
  32617. }
  32618. // AddAccountBalance adds u to the "account_balance" field.
  32619. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32620. if m.addaccount_balance != nil {
  32621. *m.addaccount_balance += u
  32622. } else {
  32623. m.addaccount_balance = &u
  32624. }
  32625. }
  32626. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32627. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32628. v := m.addaccount_balance
  32629. if v == nil {
  32630. return
  32631. }
  32632. return *v, true
  32633. }
  32634. // ResetAccountBalance resets all changes to the "account_balance" field.
  32635. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  32636. m.account_balance = nil
  32637. m.addaccount_balance = nil
  32638. }
  32639. // SetConsumeToken sets the "consume_token" field.
  32640. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  32641. m.consume_token = &u
  32642. m.addconsume_token = nil
  32643. }
  32644. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32645. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  32646. v := m.consume_token
  32647. if v == nil {
  32648. return
  32649. }
  32650. return *v, true
  32651. }
  32652. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  32653. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32655. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32656. if !m.op.Is(OpUpdateOne) {
  32657. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32658. }
  32659. if m.id == nil || m.oldValue == nil {
  32660. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32661. }
  32662. oldValue, err := m.oldValue(ctx)
  32663. if err != nil {
  32664. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32665. }
  32666. return oldValue.ConsumeToken, nil
  32667. }
  32668. // AddConsumeToken adds u to the "consume_token" field.
  32669. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  32670. if m.addconsume_token != nil {
  32671. *m.addconsume_token += u
  32672. } else {
  32673. m.addconsume_token = &u
  32674. }
  32675. }
  32676. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32677. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  32678. v := m.addconsume_token
  32679. if v == nil {
  32680. return
  32681. }
  32682. return *v, true
  32683. }
  32684. // ResetConsumeToken resets all changes to the "consume_token" field.
  32685. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  32686. m.consume_token = nil
  32687. m.addconsume_token = nil
  32688. }
  32689. // SetActiveUser sets the "active_user" field.
  32690. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  32691. m.active_user = &u
  32692. m.addactive_user = nil
  32693. }
  32694. // ActiveUser returns the value of the "active_user" field in the mutation.
  32695. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  32696. v := m.active_user
  32697. if v == nil {
  32698. return
  32699. }
  32700. return *v, true
  32701. }
  32702. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  32703. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32705. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32706. if !m.op.Is(OpUpdateOne) {
  32707. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32708. }
  32709. if m.id == nil || m.oldValue == nil {
  32710. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32711. }
  32712. oldValue, err := m.oldValue(ctx)
  32713. if err != nil {
  32714. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32715. }
  32716. return oldValue.ActiveUser, nil
  32717. }
  32718. // AddActiveUser adds u to the "active_user" field.
  32719. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  32720. if m.addactive_user != nil {
  32721. *m.addactive_user += u
  32722. } else {
  32723. m.addactive_user = &u
  32724. }
  32725. }
  32726. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32727. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  32728. v := m.addactive_user
  32729. if v == nil {
  32730. return
  32731. }
  32732. return *v, true
  32733. }
  32734. // ResetActiveUser resets all changes to the "active_user" field.
  32735. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  32736. m.active_user = nil
  32737. m.addactive_user = nil
  32738. }
  32739. // SetNewUser sets the "new_user" field.
  32740. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  32741. m.new_user = &i
  32742. m.addnew_user = nil
  32743. }
  32744. // NewUser returns the value of the "new_user" field in the mutation.
  32745. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  32746. v := m.new_user
  32747. if v == nil {
  32748. return
  32749. }
  32750. return *v, true
  32751. }
  32752. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  32753. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32755. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32756. if !m.op.Is(OpUpdateOne) {
  32757. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32758. }
  32759. if m.id == nil || m.oldValue == nil {
  32760. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32761. }
  32762. oldValue, err := m.oldValue(ctx)
  32763. if err != nil {
  32764. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32765. }
  32766. return oldValue.NewUser, nil
  32767. }
  32768. // AddNewUser adds i to the "new_user" field.
  32769. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  32770. if m.addnew_user != nil {
  32771. *m.addnew_user += i
  32772. } else {
  32773. m.addnew_user = &i
  32774. }
  32775. }
  32776. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32777. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  32778. v := m.addnew_user
  32779. if v == nil {
  32780. return
  32781. }
  32782. return *v, true
  32783. }
  32784. // ResetNewUser resets all changes to the "new_user" field.
  32785. func (m *UsageStatisticHourMutation) ResetNewUser() {
  32786. m.new_user = nil
  32787. m.addnew_user = nil
  32788. }
  32789. // SetLabelDist sets the "label_dist" field.
  32790. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32791. m.label_dist = &ctd
  32792. m.appendlabel_dist = nil
  32793. }
  32794. // LabelDist returns the value of the "label_dist" field in the mutation.
  32795. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32796. v := m.label_dist
  32797. if v == nil {
  32798. return
  32799. }
  32800. return *v, true
  32801. }
  32802. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  32803. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32805. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32806. if !m.op.Is(OpUpdateOne) {
  32807. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32808. }
  32809. if m.id == nil || m.oldValue == nil {
  32810. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32811. }
  32812. oldValue, err := m.oldValue(ctx)
  32813. if err != nil {
  32814. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32815. }
  32816. return oldValue.LabelDist, nil
  32817. }
  32818. // AppendLabelDist adds ctd to the "label_dist" field.
  32819. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32820. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32821. }
  32822. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32823. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32824. if len(m.appendlabel_dist) == 0 {
  32825. return nil, false
  32826. }
  32827. return m.appendlabel_dist, true
  32828. }
  32829. // ResetLabelDist resets all changes to the "label_dist" field.
  32830. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  32831. m.label_dist = nil
  32832. m.appendlabel_dist = nil
  32833. }
  32834. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  32835. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  32836. m.predicates = append(m.predicates, ps...)
  32837. }
  32838. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  32839. // users can use type-assertion to append predicates that do not depend on any generated package.
  32840. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  32841. p := make([]predicate.UsageStatisticHour, len(ps))
  32842. for i := range ps {
  32843. p[i] = ps[i]
  32844. }
  32845. m.Where(p...)
  32846. }
  32847. // Op returns the operation name.
  32848. func (m *UsageStatisticHourMutation) Op() Op {
  32849. return m.op
  32850. }
  32851. // SetOp allows setting the mutation operation.
  32852. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  32853. m.op = op
  32854. }
  32855. // Type returns the node type of this mutation (UsageStatisticHour).
  32856. func (m *UsageStatisticHourMutation) Type() string {
  32857. return m.typ
  32858. }
  32859. // Fields returns all fields that were changed during this mutation. Note that in
  32860. // order to get all numeric fields that were incremented/decremented, call
  32861. // AddedFields().
  32862. func (m *UsageStatisticHourMutation) Fields() []string {
  32863. fields := make([]string, 0, 17)
  32864. if m.created_at != nil {
  32865. fields = append(fields, usagestatistichour.FieldCreatedAt)
  32866. }
  32867. if m.updated_at != nil {
  32868. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  32869. }
  32870. if m.status != nil {
  32871. fields = append(fields, usagestatistichour.FieldStatus)
  32872. }
  32873. if m.deleted_at != nil {
  32874. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32875. }
  32876. if m.addtime != nil {
  32877. fields = append(fields, usagestatistichour.FieldAddtime)
  32878. }
  32879. if m._type != nil {
  32880. fields = append(fields, usagestatistichour.FieldType)
  32881. }
  32882. if m.bot_id != nil {
  32883. fields = append(fields, usagestatistichour.FieldBotID)
  32884. }
  32885. if m.organization_id != nil {
  32886. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32887. }
  32888. if m.ai_response != nil {
  32889. fields = append(fields, usagestatistichour.FieldAiResponse)
  32890. }
  32891. if m.sop_run != nil {
  32892. fields = append(fields, usagestatistichour.FieldSopRun)
  32893. }
  32894. if m.total_friend != nil {
  32895. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32896. }
  32897. if m.total_group != nil {
  32898. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32899. }
  32900. if m.account_balance != nil {
  32901. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32902. }
  32903. if m.consume_token != nil {
  32904. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32905. }
  32906. if m.active_user != nil {
  32907. fields = append(fields, usagestatistichour.FieldActiveUser)
  32908. }
  32909. if m.new_user != nil {
  32910. fields = append(fields, usagestatistichour.FieldNewUser)
  32911. }
  32912. if m.label_dist != nil {
  32913. fields = append(fields, usagestatistichour.FieldLabelDist)
  32914. }
  32915. return fields
  32916. }
  32917. // Field returns the value of a field with the given name. The second boolean
  32918. // return value indicates that this field was not set, or was not defined in the
  32919. // schema.
  32920. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  32921. switch name {
  32922. case usagestatistichour.FieldCreatedAt:
  32923. return m.CreatedAt()
  32924. case usagestatistichour.FieldUpdatedAt:
  32925. return m.UpdatedAt()
  32926. case usagestatistichour.FieldStatus:
  32927. return m.Status()
  32928. case usagestatistichour.FieldDeletedAt:
  32929. return m.DeletedAt()
  32930. case usagestatistichour.FieldAddtime:
  32931. return m.Addtime()
  32932. case usagestatistichour.FieldType:
  32933. return m.GetType()
  32934. case usagestatistichour.FieldBotID:
  32935. return m.BotID()
  32936. case usagestatistichour.FieldOrganizationID:
  32937. return m.OrganizationID()
  32938. case usagestatistichour.FieldAiResponse:
  32939. return m.AiResponse()
  32940. case usagestatistichour.FieldSopRun:
  32941. return m.SopRun()
  32942. case usagestatistichour.FieldTotalFriend:
  32943. return m.TotalFriend()
  32944. case usagestatistichour.FieldTotalGroup:
  32945. return m.TotalGroup()
  32946. case usagestatistichour.FieldAccountBalance:
  32947. return m.AccountBalance()
  32948. case usagestatistichour.FieldConsumeToken:
  32949. return m.ConsumeToken()
  32950. case usagestatistichour.FieldActiveUser:
  32951. return m.ActiveUser()
  32952. case usagestatistichour.FieldNewUser:
  32953. return m.NewUser()
  32954. case usagestatistichour.FieldLabelDist:
  32955. return m.LabelDist()
  32956. }
  32957. return nil, false
  32958. }
  32959. // OldField returns the old value of the field from the database. An error is
  32960. // returned if the mutation operation is not UpdateOne, or the query to the
  32961. // database failed.
  32962. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32963. switch name {
  32964. case usagestatistichour.FieldCreatedAt:
  32965. return m.OldCreatedAt(ctx)
  32966. case usagestatistichour.FieldUpdatedAt:
  32967. return m.OldUpdatedAt(ctx)
  32968. case usagestatistichour.FieldStatus:
  32969. return m.OldStatus(ctx)
  32970. case usagestatistichour.FieldDeletedAt:
  32971. return m.OldDeletedAt(ctx)
  32972. case usagestatistichour.FieldAddtime:
  32973. return m.OldAddtime(ctx)
  32974. case usagestatistichour.FieldType:
  32975. return m.OldType(ctx)
  32976. case usagestatistichour.FieldBotID:
  32977. return m.OldBotID(ctx)
  32978. case usagestatistichour.FieldOrganizationID:
  32979. return m.OldOrganizationID(ctx)
  32980. case usagestatistichour.FieldAiResponse:
  32981. return m.OldAiResponse(ctx)
  32982. case usagestatistichour.FieldSopRun:
  32983. return m.OldSopRun(ctx)
  32984. case usagestatistichour.FieldTotalFriend:
  32985. return m.OldTotalFriend(ctx)
  32986. case usagestatistichour.FieldTotalGroup:
  32987. return m.OldTotalGroup(ctx)
  32988. case usagestatistichour.FieldAccountBalance:
  32989. return m.OldAccountBalance(ctx)
  32990. case usagestatistichour.FieldConsumeToken:
  32991. return m.OldConsumeToken(ctx)
  32992. case usagestatistichour.FieldActiveUser:
  32993. return m.OldActiveUser(ctx)
  32994. case usagestatistichour.FieldNewUser:
  32995. return m.OldNewUser(ctx)
  32996. case usagestatistichour.FieldLabelDist:
  32997. return m.OldLabelDist(ctx)
  32998. }
  32999. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33000. }
  33001. // SetField sets the value of a field with the given name. It returns an error if
  33002. // the field is not defined in the schema, or if the type mismatched the field
  33003. // type.
  33004. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  33005. switch name {
  33006. case usagestatistichour.FieldCreatedAt:
  33007. v, ok := value.(time.Time)
  33008. if !ok {
  33009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33010. }
  33011. m.SetCreatedAt(v)
  33012. return nil
  33013. case usagestatistichour.FieldUpdatedAt:
  33014. v, ok := value.(time.Time)
  33015. if !ok {
  33016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33017. }
  33018. m.SetUpdatedAt(v)
  33019. return nil
  33020. case usagestatistichour.FieldStatus:
  33021. v, ok := value.(uint8)
  33022. if !ok {
  33023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33024. }
  33025. m.SetStatus(v)
  33026. return nil
  33027. case usagestatistichour.FieldDeletedAt:
  33028. v, ok := value.(time.Time)
  33029. if !ok {
  33030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33031. }
  33032. m.SetDeletedAt(v)
  33033. return nil
  33034. case usagestatistichour.FieldAddtime:
  33035. v, ok := value.(uint64)
  33036. if !ok {
  33037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33038. }
  33039. m.SetAddtime(v)
  33040. return nil
  33041. case usagestatistichour.FieldType:
  33042. v, ok := value.(int)
  33043. if !ok {
  33044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33045. }
  33046. m.SetType(v)
  33047. return nil
  33048. case usagestatistichour.FieldBotID:
  33049. v, ok := value.(string)
  33050. if !ok {
  33051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33052. }
  33053. m.SetBotID(v)
  33054. return nil
  33055. case usagestatistichour.FieldOrganizationID:
  33056. v, ok := value.(uint64)
  33057. if !ok {
  33058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33059. }
  33060. m.SetOrganizationID(v)
  33061. return nil
  33062. case usagestatistichour.FieldAiResponse:
  33063. v, ok := value.(uint64)
  33064. if !ok {
  33065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33066. }
  33067. m.SetAiResponse(v)
  33068. return nil
  33069. case usagestatistichour.FieldSopRun:
  33070. v, ok := value.(uint64)
  33071. if !ok {
  33072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33073. }
  33074. m.SetSopRun(v)
  33075. return nil
  33076. case usagestatistichour.FieldTotalFriend:
  33077. v, ok := value.(uint64)
  33078. if !ok {
  33079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33080. }
  33081. m.SetTotalFriend(v)
  33082. return nil
  33083. case usagestatistichour.FieldTotalGroup:
  33084. v, ok := value.(uint64)
  33085. if !ok {
  33086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33087. }
  33088. m.SetTotalGroup(v)
  33089. return nil
  33090. case usagestatistichour.FieldAccountBalance:
  33091. v, ok := value.(uint64)
  33092. if !ok {
  33093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33094. }
  33095. m.SetAccountBalance(v)
  33096. return nil
  33097. case usagestatistichour.FieldConsumeToken:
  33098. v, ok := value.(uint64)
  33099. if !ok {
  33100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33101. }
  33102. m.SetConsumeToken(v)
  33103. return nil
  33104. case usagestatistichour.FieldActiveUser:
  33105. v, ok := value.(uint64)
  33106. if !ok {
  33107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33108. }
  33109. m.SetActiveUser(v)
  33110. return nil
  33111. case usagestatistichour.FieldNewUser:
  33112. v, ok := value.(int64)
  33113. if !ok {
  33114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33115. }
  33116. m.SetNewUser(v)
  33117. return nil
  33118. case usagestatistichour.FieldLabelDist:
  33119. v, ok := value.([]custom_types.LabelDist)
  33120. if !ok {
  33121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33122. }
  33123. m.SetLabelDist(v)
  33124. return nil
  33125. }
  33126. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33127. }
  33128. // AddedFields returns all numeric fields that were incremented/decremented during
  33129. // this mutation.
  33130. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33131. var fields []string
  33132. if m.addstatus != nil {
  33133. fields = append(fields, usagestatistichour.FieldStatus)
  33134. }
  33135. if m.addaddtime != nil {
  33136. fields = append(fields, usagestatistichour.FieldAddtime)
  33137. }
  33138. if m.add_type != nil {
  33139. fields = append(fields, usagestatistichour.FieldType)
  33140. }
  33141. if m.addorganization_id != nil {
  33142. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33143. }
  33144. if m.addai_response != nil {
  33145. fields = append(fields, usagestatistichour.FieldAiResponse)
  33146. }
  33147. if m.addsop_run != nil {
  33148. fields = append(fields, usagestatistichour.FieldSopRun)
  33149. }
  33150. if m.addtotal_friend != nil {
  33151. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33152. }
  33153. if m.addtotal_group != nil {
  33154. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33155. }
  33156. if m.addaccount_balance != nil {
  33157. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33158. }
  33159. if m.addconsume_token != nil {
  33160. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33161. }
  33162. if m.addactive_user != nil {
  33163. fields = append(fields, usagestatistichour.FieldActiveUser)
  33164. }
  33165. if m.addnew_user != nil {
  33166. fields = append(fields, usagestatistichour.FieldNewUser)
  33167. }
  33168. return fields
  33169. }
  33170. // AddedField returns the numeric value that was incremented/decremented on a field
  33171. // with the given name. The second boolean return value indicates that this field
  33172. // was not set, or was not defined in the schema.
  33173. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33174. switch name {
  33175. case usagestatistichour.FieldStatus:
  33176. return m.AddedStatus()
  33177. case usagestatistichour.FieldAddtime:
  33178. return m.AddedAddtime()
  33179. case usagestatistichour.FieldType:
  33180. return m.AddedType()
  33181. case usagestatistichour.FieldOrganizationID:
  33182. return m.AddedOrganizationID()
  33183. case usagestatistichour.FieldAiResponse:
  33184. return m.AddedAiResponse()
  33185. case usagestatistichour.FieldSopRun:
  33186. return m.AddedSopRun()
  33187. case usagestatistichour.FieldTotalFriend:
  33188. return m.AddedTotalFriend()
  33189. case usagestatistichour.FieldTotalGroup:
  33190. return m.AddedTotalGroup()
  33191. case usagestatistichour.FieldAccountBalance:
  33192. return m.AddedAccountBalance()
  33193. case usagestatistichour.FieldConsumeToken:
  33194. return m.AddedConsumeToken()
  33195. case usagestatistichour.FieldActiveUser:
  33196. return m.AddedActiveUser()
  33197. case usagestatistichour.FieldNewUser:
  33198. return m.AddedNewUser()
  33199. }
  33200. return nil, false
  33201. }
  33202. // AddField adds the value to the field with the given name. It returns an error if
  33203. // the field is not defined in the schema, or if the type mismatched the field
  33204. // type.
  33205. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33206. switch name {
  33207. case usagestatistichour.FieldStatus:
  33208. v, ok := value.(int8)
  33209. if !ok {
  33210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33211. }
  33212. m.AddStatus(v)
  33213. return nil
  33214. case usagestatistichour.FieldAddtime:
  33215. v, ok := value.(int64)
  33216. if !ok {
  33217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33218. }
  33219. m.AddAddtime(v)
  33220. return nil
  33221. case usagestatistichour.FieldType:
  33222. v, ok := value.(int)
  33223. if !ok {
  33224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33225. }
  33226. m.AddType(v)
  33227. return nil
  33228. case usagestatistichour.FieldOrganizationID:
  33229. v, ok := value.(int64)
  33230. if !ok {
  33231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33232. }
  33233. m.AddOrganizationID(v)
  33234. return nil
  33235. case usagestatistichour.FieldAiResponse:
  33236. v, ok := value.(int64)
  33237. if !ok {
  33238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33239. }
  33240. m.AddAiResponse(v)
  33241. return nil
  33242. case usagestatistichour.FieldSopRun:
  33243. v, ok := value.(int64)
  33244. if !ok {
  33245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33246. }
  33247. m.AddSopRun(v)
  33248. return nil
  33249. case usagestatistichour.FieldTotalFriend:
  33250. v, ok := value.(int64)
  33251. if !ok {
  33252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33253. }
  33254. m.AddTotalFriend(v)
  33255. return nil
  33256. case usagestatistichour.FieldTotalGroup:
  33257. v, ok := value.(int64)
  33258. if !ok {
  33259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33260. }
  33261. m.AddTotalGroup(v)
  33262. return nil
  33263. case usagestatistichour.FieldAccountBalance:
  33264. v, ok := value.(int64)
  33265. if !ok {
  33266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33267. }
  33268. m.AddAccountBalance(v)
  33269. return nil
  33270. case usagestatistichour.FieldConsumeToken:
  33271. v, ok := value.(int64)
  33272. if !ok {
  33273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33274. }
  33275. m.AddConsumeToken(v)
  33276. return nil
  33277. case usagestatistichour.FieldActiveUser:
  33278. v, ok := value.(int64)
  33279. if !ok {
  33280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33281. }
  33282. m.AddActiveUser(v)
  33283. return nil
  33284. case usagestatistichour.FieldNewUser:
  33285. v, ok := value.(int64)
  33286. if !ok {
  33287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33288. }
  33289. m.AddNewUser(v)
  33290. return nil
  33291. }
  33292. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33293. }
  33294. // ClearedFields returns all nullable fields that were cleared during this
  33295. // mutation.
  33296. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33297. var fields []string
  33298. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33299. fields = append(fields, usagestatistichour.FieldStatus)
  33300. }
  33301. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33302. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33303. }
  33304. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33305. fields = append(fields, usagestatistichour.FieldBotID)
  33306. }
  33307. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33308. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33309. }
  33310. return fields
  33311. }
  33312. // FieldCleared returns a boolean indicating if a field with the given name was
  33313. // cleared in this mutation.
  33314. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33315. _, ok := m.clearedFields[name]
  33316. return ok
  33317. }
  33318. // ClearField clears the value of the field with the given name. It returns an
  33319. // error if the field is not defined in the schema.
  33320. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33321. switch name {
  33322. case usagestatistichour.FieldStatus:
  33323. m.ClearStatus()
  33324. return nil
  33325. case usagestatistichour.FieldDeletedAt:
  33326. m.ClearDeletedAt()
  33327. return nil
  33328. case usagestatistichour.FieldBotID:
  33329. m.ClearBotID()
  33330. return nil
  33331. case usagestatistichour.FieldOrganizationID:
  33332. m.ClearOrganizationID()
  33333. return nil
  33334. }
  33335. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33336. }
  33337. // ResetField resets all changes in the mutation for the field with the given name.
  33338. // It returns an error if the field is not defined in the schema.
  33339. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33340. switch name {
  33341. case usagestatistichour.FieldCreatedAt:
  33342. m.ResetCreatedAt()
  33343. return nil
  33344. case usagestatistichour.FieldUpdatedAt:
  33345. m.ResetUpdatedAt()
  33346. return nil
  33347. case usagestatistichour.FieldStatus:
  33348. m.ResetStatus()
  33349. return nil
  33350. case usagestatistichour.FieldDeletedAt:
  33351. m.ResetDeletedAt()
  33352. return nil
  33353. case usagestatistichour.FieldAddtime:
  33354. m.ResetAddtime()
  33355. return nil
  33356. case usagestatistichour.FieldType:
  33357. m.ResetType()
  33358. return nil
  33359. case usagestatistichour.FieldBotID:
  33360. m.ResetBotID()
  33361. return nil
  33362. case usagestatistichour.FieldOrganizationID:
  33363. m.ResetOrganizationID()
  33364. return nil
  33365. case usagestatistichour.FieldAiResponse:
  33366. m.ResetAiResponse()
  33367. return nil
  33368. case usagestatistichour.FieldSopRun:
  33369. m.ResetSopRun()
  33370. return nil
  33371. case usagestatistichour.FieldTotalFriend:
  33372. m.ResetTotalFriend()
  33373. return nil
  33374. case usagestatistichour.FieldTotalGroup:
  33375. m.ResetTotalGroup()
  33376. return nil
  33377. case usagestatistichour.FieldAccountBalance:
  33378. m.ResetAccountBalance()
  33379. return nil
  33380. case usagestatistichour.FieldConsumeToken:
  33381. m.ResetConsumeToken()
  33382. return nil
  33383. case usagestatistichour.FieldActiveUser:
  33384. m.ResetActiveUser()
  33385. return nil
  33386. case usagestatistichour.FieldNewUser:
  33387. m.ResetNewUser()
  33388. return nil
  33389. case usagestatistichour.FieldLabelDist:
  33390. m.ResetLabelDist()
  33391. return nil
  33392. }
  33393. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33394. }
  33395. // AddedEdges returns all edge names that were set/added in this mutation.
  33396. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33397. edges := make([]string, 0, 0)
  33398. return edges
  33399. }
  33400. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33401. // name in this mutation.
  33402. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33403. return nil
  33404. }
  33405. // RemovedEdges returns all edge names that were removed in this mutation.
  33406. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33407. edges := make([]string, 0, 0)
  33408. return edges
  33409. }
  33410. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33411. // the given name in this mutation.
  33412. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33413. return nil
  33414. }
  33415. // ClearedEdges returns all edge names that were cleared in this mutation.
  33416. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33417. edges := make([]string, 0, 0)
  33418. return edges
  33419. }
  33420. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33421. // was cleared in this mutation.
  33422. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33423. return false
  33424. }
  33425. // ClearEdge clears the value of the edge with the given name. It returns an error
  33426. // if that edge is not defined in the schema.
  33427. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33428. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33429. }
  33430. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33431. // It returns an error if the edge is not defined in the schema.
  33432. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33433. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33434. }
  33435. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33436. type UsageStatisticMonthMutation struct {
  33437. config
  33438. op Op
  33439. typ string
  33440. id *uint64
  33441. created_at *time.Time
  33442. updated_at *time.Time
  33443. status *uint8
  33444. addstatus *int8
  33445. deleted_at *time.Time
  33446. addtime *uint64
  33447. addaddtime *int64
  33448. _type *int
  33449. add_type *int
  33450. bot_id *string
  33451. organization_id *uint64
  33452. addorganization_id *int64
  33453. ai_response *uint64
  33454. addai_response *int64
  33455. sop_run *uint64
  33456. addsop_run *int64
  33457. total_friend *uint64
  33458. addtotal_friend *int64
  33459. total_group *uint64
  33460. addtotal_group *int64
  33461. account_balance *uint64
  33462. addaccount_balance *int64
  33463. consume_token *uint64
  33464. addconsume_token *int64
  33465. active_user *uint64
  33466. addactive_user *int64
  33467. new_user *int64
  33468. addnew_user *int64
  33469. label_dist *[]custom_types.LabelDist
  33470. appendlabel_dist []custom_types.LabelDist
  33471. clearedFields map[string]struct{}
  33472. done bool
  33473. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33474. predicates []predicate.UsageStatisticMonth
  33475. }
  33476. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33477. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33478. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33479. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33480. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33481. m := &UsageStatisticMonthMutation{
  33482. config: c,
  33483. op: op,
  33484. typ: TypeUsageStatisticMonth,
  33485. clearedFields: make(map[string]struct{}),
  33486. }
  33487. for _, opt := range opts {
  33488. opt(m)
  33489. }
  33490. return m
  33491. }
  33492. // withUsageStatisticMonthID sets the ID field of the mutation.
  33493. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33494. return func(m *UsageStatisticMonthMutation) {
  33495. var (
  33496. err error
  33497. once sync.Once
  33498. value *UsageStatisticMonth
  33499. )
  33500. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33501. once.Do(func() {
  33502. if m.done {
  33503. err = errors.New("querying old values post mutation is not allowed")
  33504. } else {
  33505. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33506. }
  33507. })
  33508. return value, err
  33509. }
  33510. m.id = &id
  33511. }
  33512. }
  33513. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33514. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33515. return func(m *UsageStatisticMonthMutation) {
  33516. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33517. return node, nil
  33518. }
  33519. m.id = &node.ID
  33520. }
  33521. }
  33522. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33523. // executed in a transaction (ent.Tx), a transactional client is returned.
  33524. func (m UsageStatisticMonthMutation) Client() *Client {
  33525. client := &Client{config: m.config}
  33526. client.init()
  33527. return client
  33528. }
  33529. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33530. // it returns an error otherwise.
  33531. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33532. if _, ok := m.driver.(*txDriver); !ok {
  33533. return nil, errors.New("ent: mutation is not running in a transaction")
  33534. }
  33535. tx := &Tx{config: m.config}
  33536. tx.init()
  33537. return tx, nil
  33538. }
  33539. // SetID sets the value of the id field. Note that this
  33540. // operation is only accepted on creation of UsageStatisticMonth entities.
  33541. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33542. m.id = &id
  33543. }
  33544. // ID returns the ID value in the mutation. Note that the ID is only available
  33545. // if it was provided to the builder or after it was returned from the database.
  33546. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33547. if m.id == nil {
  33548. return
  33549. }
  33550. return *m.id, true
  33551. }
  33552. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33553. // That means, if the mutation is applied within a transaction with an isolation level such
  33554. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33555. // or updated by the mutation.
  33556. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33557. switch {
  33558. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33559. id, exists := m.ID()
  33560. if exists {
  33561. return []uint64{id}, nil
  33562. }
  33563. fallthrough
  33564. case m.op.Is(OpUpdate | OpDelete):
  33565. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33566. default:
  33567. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33568. }
  33569. }
  33570. // SetCreatedAt sets the "created_at" field.
  33571. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33572. m.created_at = &t
  33573. }
  33574. // CreatedAt returns the value of the "created_at" field in the mutation.
  33575. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33576. v := m.created_at
  33577. if v == nil {
  33578. return
  33579. }
  33580. return *v, true
  33581. }
  33582. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33583. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33585. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33586. if !m.op.Is(OpUpdateOne) {
  33587. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33588. }
  33589. if m.id == nil || m.oldValue == nil {
  33590. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33591. }
  33592. oldValue, err := m.oldValue(ctx)
  33593. if err != nil {
  33594. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33595. }
  33596. return oldValue.CreatedAt, nil
  33597. }
  33598. // ResetCreatedAt resets all changes to the "created_at" field.
  33599. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33600. m.created_at = nil
  33601. }
  33602. // SetUpdatedAt sets the "updated_at" field.
  33603. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33604. m.updated_at = &t
  33605. }
  33606. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33607. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33608. v := m.updated_at
  33609. if v == nil {
  33610. return
  33611. }
  33612. return *v, true
  33613. }
  33614. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33615. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33617. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33618. if !m.op.Is(OpUpdateOne) {
  33619. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33620. }
  33621. if m.id == nil || m.oldValue == nil {
  33622. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33623. }
  33624. oldValue, err := m.oldValue(ctx)
  33625. if err != nil {
  33626. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33627. }
  33628. return oldValue.UpdatedAt, nil
  33629. }
  33630. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33631. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33632. m.updated_at = nil
  33633. }
  33634. // SetStatus sets the "status" field.
  33635. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  33636. m.status = &u
  33637. m.addstatus = nil
  33638. }
  33639. // Status returns the value of the "status" field in the mutation.
  33640. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  33641. v := m.status
  33642. if v == nil {
  33643. return
  33644. }
  33645. return *v, true
  33646. }
  33647. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  33648. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33650. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33651. if !m.op.Is(OpUpdateOne) {
  33652. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33653. }
  33654. if m.id == nil || m.oldValue == nil {
  33655. return v, errors.New("OldStatus requires an ID field in the mutation")
  33656. }
  33657. oldValue, err := m.oldValue(ctx)
  33658. if err != nil {
  33659. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33660. }
  33661. return oldValue.Status, nil
  33662. }
  33663. // AddStatus adds u to the "status" field.
  33664. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  33665. if m.addstatus != nil {
  33666. *m.addstatus += u
  33667. } else {
  33668. m.addstatus = &u
  33669. }
  33670. }
  33671. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33672. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  33673. v := m.addstatus
  33674. if v == nil {
  33675. return
  33676. }
  33677. return *v, true
  33678. }
  33679. // ClearStatus clears the value of the "status" field.
  33680. func (m *UsageStatisticMonthMutation) ClearStatus() {
  33681. m.status = nil
  33682. m.addstatus = nil
  33683. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  33684. }
  33685. // StatusCleared returns if the "status" field was cleared in this mutation.
  33686. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  33687. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  33688. return ok
  33689. }
  33690. // ResetStatus resets all changes to the "status" field.
  33691. func (m *UsageStatisticMonthMutation) ResetStatus() {
  33692. m.status = nil
  33693. m.addstatus = nil
  33694. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  33695. }
  33696. // SetDeletedAt sets the "deleted_at" field.
  33697. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  33698. m.deleted_at = &t
  33699. }
  33700. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33701. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  33702. v := m.deleted_at
  33703. if v == nil {
  33704. return
  33705. }
  33706. return *v, true
  33707. }
  33708. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  33709. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33711. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33712. if !m.op.Is(OpUpdateOne) {
  33713. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33714. }
  33715. if m.id == nil || m.oldValue == nil {
  33716. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33717. }
  33718. oldValue, err := m.oldValue(ctx)
  33719. if err != nil {
  33720. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33721. }
  33722. return oldValue.DeletedAt, nil
  33723. }
  33724. // ClearDeletedAt clears the value of the "deleted_at" field.
  33725. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  33726. m.deleted_at = nil
  33727. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  33728. }
  33729. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33730. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  33731. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  33732. return ok
  33733. }
  33734. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33735. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  33736. m.deleted_at = nil
  33737. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  33738. }
  33739. // SetAddtime sets the "addtime" field.
  33740. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  33741. m.addtime = &u
  33742. m.addaddtime = nil
  33743. }
  33744. // Addtime returns the value of the "addtime" field in the mutation.
  33745. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  33746. v := m.addtime
  33747. if v == nil {
  33748. return
  33749. }
  33750. return *v, true
  33751. }
  33752. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  33753. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33755. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33756. if !m.op.Is(OpUpdateOne) {
  33757. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33758. }
  33759. if m.id == nil || m.oldValue == nil {
  33760. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33761. }
  33762. oldValue, err := m.oldValue(ctx)
  33763. if err != nil {
  33764. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33765. }
  33766. return oldValue.Addtime, nil
  33767. }
  33768. // AddAddtime adds u to the "addtime" field.
  33769. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  33770. if m.addaddtime != nil {
  33771. *m.addaddtime += u
  33772. } else {
  33773. m.addaddtime = &u
  33774. }
  33775. }
  33776. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33777. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  33778. v := m.addaddtime
  33779. if v == nil {
  33780. return
  33781. }
  33782. return *v, true
  33783. }
  33784. // ResetAddtime resets all changes to the "addtime" field.
  33785. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  33786. m.addtime = nil
  33787. m.addaddtime = nil
  33788. }
  33789. // SetType sets the "type" field.
  33790. func (m *UsageStatisticMonthMutation) SetType(i int) {
  33791. m._type = &i
  33792. m.add_type = nil
  33793. }
  33794. // GetType returns the value of the "type" field in the mutation.
  33795. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  33796. v := m._type
  33797. if v == nil {
  33798. return
  33799. }
  33800. return *v, true
  33801. }
  33802. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  33803. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33805. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  33806. if !m.op.Is(OpUpdateOne) {
  33807. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33808. }
  33809. if m.id == nil || m.oldValue == nil {
  33810. return v, errors.New("OldType requires an ID field in the mutation")
  33811. }
  33812. oldValue, err := m.oldValue(ctx)
  33813. if err != nil {
  33814. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33815. }
  33816. return oldValue.Type, nil
  33817. }
  33818. // AddType adds i to the "type" field.
  33819. func (m *UsageStatisticMonthMutation) AddType(i int) {
  33820. if m.add_type != nil {
  33821. *m.add_type += i
  33822. } else {
  33823. m.add_type = &i
  33824. }
  33825. }
  33826. // AddedType returns the value that was added to the "type" field in this mutation.
  33827. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  33828. v := m.add_type
  33829. if v == nil {
  33830. return
  33831. }
  33832. return *v, true
  33833. }
  33834. // ResetType resets all changes to the "type" field.
  33835. func (m *UsageStatisticMonthMutation) ResetType() {
  33836. m._type = nil
  33837. m.add_type = nil
  33838. }
  33839. // SetBotID sets the "bot_id" field.
  33840. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  33841. m.bot_id = &s
  33842. }
  33843. // BotID returns the value of the "bot_id" field in the mutation.
  33844. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  33845. v := m.bot_id
  33846. if v == nil {
  33847. return
  33848. }
  33849. return *v, true
  33850. }
  33851. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  33852. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33854. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  33855. if !m.op.Is(OpUpdateOne) {
  33856. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33857. }
  33858. if m.id == nil || m.oldValue == nil {
  33859. return v, errors.New("OldBotID requires an ID field in the mutation")
  33860. }
  33861. oldValue, err := m.oldValue(ctx)
  33862. if err != nil {
  33863. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33864. }
  33865. return oldValue.BotID, nil
  33866. }
  33867. // ClearBotID clears the value of the "bot_id" field.
  33868. func (m *UsageStatisticMonthMutation) ClearBotID() {
  33869. m.bot_id = nil
  33870. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  33871. }
  33872. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33873. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  33874. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  33875. return ok
  33876. }
  33877. // ResetBotID resets all changes to the "bot_id" field.
  33878. func (m *UsageStatisticMonthMutation) ResetBotID() {
  33879. m.bot_id = nil
  33880. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  33881. }
  33882. // SetOrganizationID sets the "organization_id" field.
  33883. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  33884. m.organization_id = &u
  33885. m.addorganization_id = nil
  33886. }
  33887. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33888. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  33889. v := m.organization_id
  33890. if v == nil {
  33891. return
  33892. }
  33893. return *v, true
  33894. }
  33895. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  33896. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33898. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33899. if !m.op.Is(OpUpdateOne) {
  33900. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33901. }
  33902. if m.id == nil || m.oldValue == nil {
  33903. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33904. }
  33905. oldValue, err := m.oldValue(ctx)
  33906. if err != nil {
  33907. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33908. }
  33909. return oldValue.OrganizationID, nil
  33910. }
  33911. // AddOrganizationID adds u to the "organization_id" field.
  33912. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  33913. if m.addorganization_id != nil {
  33914. *m.addorganization_id += u
  33915. } else {
  33916. m.addorganization_id = &u
  33917. }
  33918. }
  33919. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33920. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  33921. v := m.addorganization_id
  33922. if v == nil {
  33923. return
  33924. }
  33925. return *v, true
  33926. }
  33927. // ClearOrganizationID clears the value of the "organization_id" field.
  33928. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  33929. m.organization_id = nil
  33930. m.addorganization_id = nil
  33931. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  33932. }
  33933. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33934. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  33935. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  33936. return ok
  33937. }
  33938. // ResetOrganizationID resets all changes to the "organization_id" field.
  33939. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  33940. m.organization_id = nil
  33941. m.addorganization_id = nil
  33942. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  33943. }
  33944. // SetAiResponse sets the "ai_response" field.
  33945. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  33946. m.ai_response = &u
  33947. m.addai_response = nil
  33948. }
  33949. // AiResponse returns the value of the "ai_response" field in the mutation.
  33950. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  33951. v := m.ai_response
  33952. if v == nil {
  33953. return
  33954. }
  33955. return *v, true
  33956. }
  33957. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  33958. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33960. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33961. if !m.op.Is(OpUpdateOne) {
  33962. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33963. }
  33964. if m.id == nil || m.oldValue == nil {
  33965. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33966. }
  33967. oldValue, err := m.oldValue(ctx)
  33968. if err != nil {
  33969. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33970. }
  33971. return oldValue.AiResponse, nil
  33972. }
  33973. // AddAiResponse adds u to the "ai_response" field.
  33974. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  33975. if m.addai_response != nil {
  33976. *m.addai_response += u
  33977. } else {
  33978. m.addai_response = &u
  33979. }
  33980. }
  33981. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33982. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  33983. v := m.addai_response
  33984. if v == nil {
  33985. return
  33986. }
  33987. return *v, true
  33988. }
  33989. // ResetAiResponse resets all changes to the "ai_response" field.
  33990. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  33991. m.ai_response = nil
  33992. m.addai_response = nil
  33993. }
  33994. // SetSopRun sets the "sop_run" field.
  33995. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  33996. m.sop_run = &u
  33997. m.addsop_run = nil
  33998. }
  33999. // SopRun returns the value of the "sop_run" field in the mutation.
  34000. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  34001. v := m.sop_run
  34002. if v == nil {
  34003. return
  34004. }
  34005. return *v, true
  34006. }
  34007. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  34008. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34010. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34011. if !m.op.Is(OpUpdateOne) {
  34012. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34013. }
  34014. if m.id == nil || m.oldValue == nil {
  34015. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34016. }
  34017. oldValue, err := m.oldValue(ctx)
  34018. if err != nil {
  34019. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34020. }
  34021. return oldValue.SopRun, nil
  34022. }
  34023. // AddSopRun adds u to the "sop_run" field.
  34024. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  34025. if m.addsop_run != nil {
  34026. *m.addsop_run += u
  34027. } else {
  34028. m.addsop_run = &u
  34029. }
  34030. }
  34031. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34032. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  34033. v := m.addsop_run
  34034. if v == nil {
  34035. return
  34036. }
  34037. return *v, true
  34038. }
  34039. // ResetSopRun resets all changes to the "sop_run" field.
  34040. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  34041. m.sop_run = nil
  34042. m.addsop_run = nil
  34043. }
  34044. // SetTotalFriend sets the "total_friend" field.
  34045. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  34046. m.total_friend = &u
  34047. m.addtotal_friend = nil
  34048. }
  34049. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34050. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  34051. v := m.total_friend
  34052. if v == nil {
  34053. return
  34054. }
  34055. return *v, true
  34056. }
  34057. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  34058. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34060. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34061. if !m.op.Is(OpUpdateOne) {
  34062. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34063. }
  34064. if m.id == nil || m.oldValue == nil {
  34065. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34066. }
  34067. oldValue, err := m.oldValue(ctx)
  34068. if err != nil {
  34069. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34070. }
  34071. return oldValue.TotalFriend, nil
  34072. }
  34073. // AddTotalFriend adds u to the "total_friend" field.
  34074. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  34075. if m.addtotal_friend != nil {
  34076. *m.addtotal_friend += u
  34077. } else {
  34078. m.addtotal_friend = &u
  34079. }
  34080. }
  34081. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34082. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34083. v := m.addtotal_friend
  34084. if v == nil {
  34085. return
  34086. }
  34087. return *v, true
  34088. }
  34089. // ResetTotalFriend resets all changes to the "total_friend" field.
  34090. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34091. m.total_friend = nil
  34092. m.addtotal_friend = nil
  34093. }
  34094. // SetTotalGroup sets the "total_group" field.
  34095. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34096. m.total_group = &u
  34097. m.addtotal_group = nil
  34098. }
  34099. // TotalGroup returns the value of the "total_group" field in the mutation.
  34100. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34101. v := m.total_group
  34102. if v == nil {
  34103. return
  34104. }
  34105. return *v, true
  34106. }
  34107. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34108. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34110. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34111. if !m.op.Is(OpUpdateOne) {
  34112. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34113. }
  34114. if m.id == nil || m.oldValue == nil {
  34115. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34116. }
  34117. oldValue, err := m.oldValue(ctx)
  34118. if err != nil {
  34119. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34120. }
  34121. return oldValue.TotalGroup, nil
  34122. }
  34123. // AddTotalGroup adds u to the "total_group" field.
  34124. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34125. if m.addtotal_group != nil {
  34126. *m.addtotal_group += u
  34127. } else {
  34128. m.addtotal_group = &u
  34129. }
  34130. }
  34131. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34132. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34133. v := m.addtotal_group
  34134. if v == nil {
  34135. return
  34136. }
  34137. return *v, true
  34138. }
  34139. // ResetTotalGroup resets all changes to the "total_group" field.
  34140. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34141. m.total_group = nil
  34142. m.addtotal_group = nil
  34143. }
  34144. // SetAccountBalance sets the "account_balance" field.
  34145. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34146. m.account_balance = &u
  34147. m.addaccount_balance = nil
  34148. }
  34149. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34150. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34151. v := m.account_balance
  34152. if v == nil {
  34153. return
  34154. }
  34155. return *v, true
  34156. }
  34157. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34158. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34160. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34161. if !m.op.Is(OpUpdateOne) {
  34162. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34163. }
  34164. if m.id == nil || m.oldValue == nil {
  34165. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34166. }
  34167. oldValue, err := m.oldValue(ctx)
  34168. if err != nil {
  34169. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34170. }
  34171. return oldValue.AccountBalance, nil
  34172. }
  34173. // AddAccountBalance adds u to the "account_balance" field.
  34174. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34175. if m.addaccount_balance != nil {
  34176. *m.addaccount_balance += u
  34177. } else {
  34178. m.addaccount_balance = &u
  34179. }
  34180. }
  34181. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34182. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34183. v := m.addaccount_balance
  34184. if v == nil {
  34185. return
  34186. }
  34187. return *v, true
  34188. }
  34189. // ResetAccountBalance resets all changes to the "account_balance" field.
  34190. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34191. m.account_balance = nil
  34192. m.addaccount_balance = nil
  34193. }
  34194. // SetConsumeToken sets the "consume_token" field.
  34195. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34196. m.consume_token = &u
  34197. m.addconsume_token = nil
  34198. }
  34199. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34200. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34201. v := m.consume_token
  34202. if v == nil {
  34203. return
  34204. }
  34205. return *v, true
  34206. }
  34207. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34208. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34210. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34211. if !m.op.Is(OpUpdateOne) {
  34212. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34213. }
  34214. if m.id == nil || m.oldValue == nil {
  34215. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34216. }
  34217. oldValue, err := m.oldValue(ctx)
  34218. if err != nil {
  34219. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34220. }
  34221. return oldValue.ConsumeToken, nil
  34222. }
  34223. // AddConsumeToken adds u to the "consume_token" field.
  34224. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34225. if m.addconsume_token != nil {
  34226. *m.addconsume_token += u
  34227. } else {
  34228. m.addconsume_token = &u
  34229. }
  34230. }
  34231. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34232. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34233. v := m.addconsume_token
  34234. if v == nil {
  34235. return
  34236. }
  34237. return *v, true
  34238. }
  34239. // ResetConsumeToken resets all changes to the "consume_token" field.
  34240. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34241. m.consume_token = nil
  34242. m.addconsume_token = nil
  34243. }
  34244. // SetActiveUser sets the "active_user" field.
  34245. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34246. m.active_user = &u
  34247. m.addactive_user = nil
  34248. }
  34249. // ActiveUser returns the value of the "active_user" field in the mutation.
  34250. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34251. v := m.active_user
  34252. if v == nil {
  34253. return
  34254. }
  34255. return *v, true
  34256. }
  34257. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34258. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34260. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34261. if !m.op.Is(OpUpdateOne) {
  34262. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34263. }
  34264. if m.id == nil || m.oldValue == nil {
  34265. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34266. }
  34267. oldValue, err := m.oldValue(ctx)
  34268. if err != nil {
  34269. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34270. }
  34271. return oldValue.ActiveUser, nil
  34272. }
  34273. // AddActiveUser adds u to the "active_user" field.
  34274. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34275. if m.addactive_user != nil {
  34276. *m.addactive_user += u
  34277. } else {
  34278. m.addactive_user = &u
  34279. }
  34280. }
  34281. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34282. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34283. v := m.addactive_user
  34284. if v == nil {
  34285. return
  34286. }
  34287. return *v, true
  34288. }
  34289. // ResetActiveUser resets all changes to the "active_user" field.
  34290. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34291. m.active_user = nil
  34292. m.addactive_user = nil
  34293. }
  34294. // SetNewUser sets the "new_user" field.
  34295. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34296. m.new_user = &i
  34297. m.addnew_user = nil
  34298. }
  34299. // NewUser returns the value of the "new_user" field in the mutation.
  34300. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34301. v := m.new_user
  34302. if v == nil {
  34303. return
  34304. }
  34305. return *v, true
  34306. }
  34307. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34308. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34310. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34311. if !m.op.Is(OpUpdateOne) {
  34312. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34313. }
  34314. if m.id == nil || m.oldValue == nil {
  34315. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34316. }
  34317. oldValue, err := m.oldValue(ctx)
  34318. if err != nil {
  34319. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34320. }
  34321. return oldValue.NewUser, nil
  34322. }
  34323. // AddNewUser adds i to the "new_user" field.
  34324. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34325. if m.addnew_user != nil {
  34326. *m.addnew_user += i
  34327. } else {
  34328. m.addnew_user = &i
  34329. }
  34330. }
  34331. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34332. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34333. v := m.addnew_user
  34334. if v == nil {
  34335. return
  34336. }
  34337. return *v, true
  34338. }
  34339. // ResetNewUser resets all changes to the "new_user" field.
  34340. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34341. m.new_user = nil
  34342. m.addnew_user = nil
  34343. }
  34344. // SetLabelDist sets the "label_dist" field.
  34345. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34346. m.label_dist = &ctd
  34347. m.appendlabel_dist = nil
  34348. }
  34349. // LabelDist returns the value of the "label_dist" field in the mutation.
  34350. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34351. v := m.label_dist
  34352. if v == nil {
  34353. return
  34354. }
  34355. return *v, true
  34356. }
  34357. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34358. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34360. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34361. if !m.op.Is(OpUpdateOne) {
  34362. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34363. }
  34364. if m.id == nil || m.oldValue == nil {
  34365. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34366. }
  34367. oldValue, err := m.oldValue(ctx)
  34368. if err != nil {
  34369. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34370. }
  34371. return oldValue.LabelDist, nil
  34372. }
  34373. // AppendLabelDist adds ctd to the "label_dist" field.
  34374. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34375. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34376. }
  34377. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34378. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34379. if len(m.appendlabel_dist) == 0 {
  34380. return nil, false
  34381. }
  34382. return m.appendlabel_dist, true
  34383. }
  34384. // ResetLabelDist resets all changes to the "label_dist" field.
  34385. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34386. m.label_dist = nil
  34387. m.appendlabel_dist = nil
  34388. }
  34389. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34390. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34391. m.predicates = append(m.predicates, ps...)
  34392. }
  34393. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34394. // users can use type-assertion to append predicates that do not depend on any generated package.
  34395. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34396. p := make([]predicate.UsageStatisticMonth, len(ps))
  34397. for i := range ps {
  34398. p[i] = ps[i]
  34399. }
  34400. m.Where(p...)
  34401. }
  34402. // Op returns the operation name.
  34403. func (m *UsageStatisticMonthMutation) Op() Op {
  34404. return m.op
  34405. }
  34406. // SetOp allows setting the mutation operation.
  34407. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34408. m.op = op
  34409. }
  34410. // Type returns the node type of this mutation (UsageStatisticMonth).
  34411. func (m *UsageStatisticMonthMutation) Type() string {
  34412. return m.typ
  34413. }
  34414. // Fields returns all fields that were changed during this mutation. Note that in
  34415. // order to get all numeric fields that were incremented/decremented, call
  34416. // AddedFields().
  34417. func (m *UsageStatisticMonthMutation) Fields() []string {
  34418. fields := make([]string, 0, 17)
  34419. if m.created_at != nil {
  34420. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34421. }
  34422. if m.updated_at != nil {
  34423. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34424. }
  34425. if m.status != nil {
  34426. fields = append(fields, usagestatisticmonth.FieldStatus)
  34427. }
  34428. if m.deleted_at != nil {
  34429. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34430. }
  34431. if m.addtime != nil {
  34432. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34433. }
  34434. if m._type != nil {
  34435. fields = append(fields, usagestatisticmonth.FieldType)
  34436. }
  34437. if m.bot_id != nil {
  34438. fields = append(fields, usagestatisticmonth.FieldBotID)
  34439. }
  34440. if m.organization_id != nil {
  34441. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34442. }
  34443. if m.ai_response != nil {
  34444. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34445. }
  34446. if m.sop_run != nil {
  34447. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34448. }
  34449. if m.total_friend != nil {
  34450. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34451. }
  34452. if m.total_group != nil {
  34453. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34454. }
  34455. if m.account_balance != nil {
  34456. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34457. }
  34458. if m.consume_token != nil {
  34459. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34460. }
  34461. if m.active_user != nil {
  34462. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34463. }
  34464. if m.new_user != nil {
  34465. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34466. }
  34467. if m.label_dist != nil {
  34468. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34469. }
  34470. return fields
  34471. }
  34472. // Field returns the value of a field with the given name. The second boolean
  34473. // return value indicates that this field was not set, or was not defined in the
  34474. // schema.
  34475. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34476. switch name {
  34477. case usagestatisticmonth.FieldCreatedAt:
  34478. return m.CreatedAt()
  34479. case usagestatisticmonth.FieldUpdatedAt:
  34480. return m.UpdatedAt()
  34481. case usagestatisticmonth.FieldStatus:
  34482. return m.Status()
  34483. case usagestatisticmonth.FieldDeletedAt:
  34484. return m.DeletedAt()
  34485. case usagestatisticmonth.FieldAddtime:
  34486. return m.Addtime()
  34487. case usagestatisticmonth.FieldType:
  34488. return m.GetType()
  34489. case usagestatisticmonth.FieldBotID:
  34490. return m.BotID()
  34491. case usagestatisticmonth.FieldOrganizationID:
  34492. return m.OrganizationID()
  34493. case usagestatisticmonth.FieldAiResponse:
  34494. return m.AiResponse()
  34495. case usagestatisticmonth.FieldSopRun:
  34496. return m.SopRun()
  34497. case usagestatisticmonth.FieldTotalFriend:
  34498. return m.TotalFriend()
  34499. case usagestatisticmonth.FieldTotalGroup:
  34500. return m.TotalGroup()
  34501. case usagestatisticmonth.FieldAccountBalance:
  34502. return m.AccountBalance()
  34503. case usagestatisticmonth.FieldConsumeToken:
  34504. return m.ConsumeToken()
  34505. case usagestatisticmonth.FieldActiveUser:
  34506. return m.ActiveUser()
  34507. case usagestatisticmonth.FieldNewUser:
  34508. return m.NewUser()
  34509. case usagestatisticmonth.FieldLabelDist:
  34510. return m.LabelDist()
  34511. }
  34512. return nil, false
  34513. }
  34514. // OldField returns the old value of the field from the database. An error is
  34515. // returned if the mutation operation is not UpdateOne, or the query to the
  34516. // database failed.
  34517. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34518. switch name {
  34519. case usagestatisticmonth.FieldCreatedAt:
  34520. return m.OldCreatedAt(ctx)
  34521. case usagestatisticmonth.FieldUpdatedAt:
  34522. return m.OldUpdatedAt(ctx)
  34523. case usagestatisticmonth.FieldStatus:
  34524. return m.OldStatus(ctx)
  34525. case usagestatisticmonth.FieldDeletedAt:
  34526. return m.OldDeletedAt(ctx)
  34527. case usagestatisticmonth.FieldAddtime:
  34528. return m.OldAddtime(ctx)
  34529. case usagestatisticmonth.FieldType:
  34530. return m.OldType(ctx)
  34531. case usagestatisticmonth.FieldBotID:
  34532. return m.OldBotID(ctx)
  34533. case usagestatisticmonth.FieldOrganizationID:
  34534. return m.OldOrganizationID(ctx)
  34535. case usagestatisticmonth.FieldAiResponse:
  34536. return m.OldAiResponse(ctx)
  34537. case usagestatisticmonth.FieldSopRun:
  34538. return m.OldSopRun(ctx)
  34539. case usagestatisticmonth.FieldTotalFriend:
  34540. return m.OldTotalFriend(ctx)
  34541. case usagestatisticmonth.FieldTotalGroup:
  34542. return m.OldTotalGroup(ctx)
  34543. case usagestatisticmonth.FieldAccountBalance:
  34544. return m.OldAccountBalance(ctx)
  34545. case usagestatisticmonth.FieldConsumeToken:
  34546. return m.OldConsumeToken(ctx)
  34547. case usagestatisticmonth.FieldActiveUser:
  34548. return m.OldActiveUser(ctx)
  34549. case usagestatisticmonth.FieldNewUser:
  34550. return m.OldNewUser(ctx)
  34551. case usagestatisticmonth.FieldLabelDist:
  34552. return m.OldLabelDist(ctx)
  34553. }
  34554. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34555. }
  34556. // SetField sets the value of a field with the given name. It returns an error if
  34557. // the field is not defined in the schema, or if the type mismatched the field
  34558. // type.
  34559. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34560. switch name {
  34561. case usagestatisticmonth.FieldCreatedAt:
  34562. v, ok := value.(time.Time)
  34563. if !ok {
  34564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34565. }
  34566. m.SetCreatedAt(v)
  34567. return nil
  34568. case usagestatisticmonth.FieldUpdatedAt:
  34569. v, ok := value.(time.Time)
  34570. if !ok {
  34571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34572. }
  34573. m.SetUpdatedAt(v)
  34574. return nil
  34575. case usagestatisticmonth.FieldStatus:
  34576. v, ok := value.(uint8)
  34577. if !ok {
  34578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34579. }
  34580. m.SetStatus(v)
  34581. return nil
  34582. case usagestatisticmonth.FieldDeletedAt:
  34583. v, ok := value.(time.Time)
  34584. if !ok {
  34585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34586. }
  34587. m.SetDeletedAt(v)
  34588. return nil
  34589. case usagestatisticmonth.FieldAddtime:
  34590. v, ok := value.(uint64)
  34591. if !ok {
  34592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34593. }
  34594. m.SetAddtime(v)
  34595. return nil
  34596. case usagestatisticmonth.FieldType:
  34597. v, ok := value.(int)
  34598. if !ok {
  34599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34600. }
  34601. m.SetType(v)
  34602. return nil
  34603. case usagestatisticmonth.FieldBotID:
  34604. v, ok := value.(string)
  34605. if !ok {
  34606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34607. }
  34608. m.SetBotID(v)
  34609. return nil
  34610. case usagestatisticmonth.FieldOrganizationID:
  34611. v, ok := value.(uint64)
  34612. if !ok {
  34613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34614. }
  34615. m.SetOrganizationID(v)
  34616. return nil
  34617. case usagestatisticmonth.FieldAiResponse:
  34618. v, ok := value.(uint64)
  34619. if !ok {
  34620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34621. }
  34622. m.SetAiResponse(v)
  34623. return nil
  34624. case usagestatisticmonth.FieldSopRun:
  34625. v, ok := value.(uint64)
  34626. if !ok {
  34627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34628. }
  34629. m.SetSopRun(v)
  34630. return nil
  34631. case usagestatisticmonth.FieldTotalFriend:
  34632. v, ok := value.(uint64)
  34633. if !ok {
  34634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34635. }
  34636. m.SetTotalFriend(v)
  34637. return nil
  34638. case usagestatisticmonth.FieldTotalGroup:
  34639. v, ok := value.(uint64)
  34640. if !ok {
  34641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34642. }
  34643. m.SetTotalGroup(v)
  34644. return nil
  34645. case usagestatisticmonth.FieldAccountBalance:
  34646. v, ok := value.(uint64)
  34647. if !ok {
  34648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34649. }
  34650. m.SetAccountBalance(v)
  34651. return nil
  34652. case usagestatisticmonth.FieldConsumeToken:
  34653. v, ok := value.(uint64)
  34654. if !ok {
  34655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34656. }
  34657. m.SetConsumeToken(v)
  34658. return nil
  34659. case usagestatisticmonth.FieldActiveUser:
  34660. v, ok := value.(uint64)
  34661. if !ok {
  34662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34663. }
  34664. m.SetActiveUser(v)
  34665. return nil
  34666. case usagestatisticmonth.FieldNewUser:
  34667. v, ok := value.(int64)
  34668. if !ok {
  34669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34670. }
  34671. m.SetNewUser(v)
  34672. return nil
  34673. case usagestatisticmonth.FieldLabelDist:
  34674. v, ok := value.([]custom_types.LabelDist)
  34675. if !ok {
  34676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34677. }
  34678. m.SetLabelDist(v)
  34679. return nil
  34680. }
  34681. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34682. }
  34683. // AddedFields returns all numeric fields that were incremented/decremented during
  34684. // this mutation.
  34685. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  34686. var fields []string
  34687. if m.addstatus != nil {
  34688. fields = append(fields, usagestatisticmonth.FieldStatus)
  34689. }
  34690. if m.addaddtime != nil {
  34691. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34692. }
  34693. if m.add_type != nil {
  34694. fields = append(fields, usagestatisticmonth.FieldType)
  34695. }
  34696. if m.addorganization_id != nil {
  34697. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34698. }
  34699. if m.addai_response != nil {
  34700. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34701. }
  34702. if m.addsop_run != nil {
  34703. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34704. }
  34705. if m.addtotal_friend != nil {
  34706. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34707. }
  34708. if m.addtotal_group != nil {
  34709. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34710. }
  34711. if m.addaccount_balance != nil {
  34712. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34713. }
  34714. if m.addconsume_token != nil {
  34715. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34716. }
  34717. if m.addactive_user != nil {
  34718. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34719. }
  34720. if m.addnew_user != nil {
  34721. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34722. }
  34723. return fields
  34724. }
  34725. // AddedField returns the numeric value that was incremented/decremented on a field
  34726. // with the given name. The second boolean return value indicates that this field
  34727. // was not set, or was not defined in the schema.
  34728. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  34729. switch name {
  34730. case usagestatisticmonth.FieldStatus:
  34731. return m.AddedStatus()
  34732. case usagestatisticmonth.FieldAddtime:
  34733. return m.AddedAddtime()
  34734. case usagestatisticmonth.FieldType:
  34735. return m.AddedType()
  34736. case usagestatisticmonth.FieldOrganizationID:
  34737. return m.AddedOrganizationID()
  34738. case usagestatisticmonth.FieldAiResponse:
  34739. return m.AddedAiResponse()
  34740. case usagestatisticmonth.FieldSopRun:
  34741. return m.AddedSopRun()
  34742. case usagestatisticmonth.FieldTotalFriend:
  34743. return m.AddedTotalFriend()
  34744. case usagestatisticmonth.FieldTotalGroup:
  34745. return m.AddedTotalGroup()
  34746. case usagestatisticmonth.FieldAccountBalance:
  34747. return m.AddedAccountBalance()
  34748. case usagestatisticmonth.FieldConsumeToken:
  34749. return m.AddedConsumeToken()
  34750. case usagestatisticmonth.FieldActiveUser:
  34751. return m.AddedActiveUser()
  34752. case usagestatisticmonth.FieldNewUser:
  34753. return m.AddedNewUser()
  34754. }
  34755. return nil, false
  34756. }
  34757. // AddField adds the value to the field with the given name. It returns an error if
  34758. // the field is not defined in the schema, or if the type mismatched the field
  34759. // type.
  34760. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  34761. switch name {
  34762. case usagestatisticmonth.FieldStatus:
  34763. v, ok := value.(int8)
  34764. if !ok {
  34765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34766. }
  34767. m.AddStatus(v)
  34768. return nil
  34769. case usagestatisticmonth.FieldAddtime:
  34770. v, ok := value.(int64)
  34771. if !ok {
  34772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34773. }
  34774. m.AddAddtime(v)
  34775. return nil
  34776. case usagestatisticmonth.FieldType:
  34777. v, ok := value.(int)
  34778. if !ok {
  34779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34780. }
  34781. m.AddType(v)
  34782. return nil
  34783. case usagestatisticmonth.FieldOrganizationID:
  34784. v, ok := value.(int64)
  34785. if !ok {
  34786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34787. }
  34788. m.AddOrganizationID(v)
  34789. return nil
  34790. case usagestatisticmonth.FieldAiResponse:
  34791. v, ok := value.(int64)
  34792. if !ok {
  34793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34794. }
  34795. m.AddAiResponse(v)
  34796. return nil
  34797. case usagestatisticmonth.FieldSopRun:
  34798. v, ok := value.(int64)
  34799. if !ok {
  34800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34801. }
  34802. m.AddSopRun(v)
  34803. return nil
  34804. case usagestatisticmonth.FieldTotalFriend:
  34805. v, ok := value.(int64)
  34806. if !ok {
  34807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34808. }
  34809. m.AddTotalFriend(v)
  34810. return nil
  34811. case usagestatisticmonth.FieldTotalGroup:
  34812. v, ok := value.(int64)
  34813. if !ok {
  34814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34815. }
  34816. m.AddTotalGroup(v)
  34817. return nil
  34818. case usagestatisticmonth.FieldAccountBalance:
  34819. v, ok := value.(int64)
  34820. if !ok {
  34821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34822. }
  34823. m.AddAccountBalance(v)
  34824. return nil
  34825. case usagestatisticmonth.FieldConsumeToken:
  34826. v, ok := value.(int64)
  34827. if !ok {
  34828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34829. }
  34830. m.AddConsumeToken(v)
  34831. return nil
  34832. case usagestatisticmonth.FieldActiveUser:
  34833. v, ok := value.(int64)
  34834. if !ok {
  34835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34836. }
  34837. m.AddActiveUser(v)
  34838. return nil
  34839. case usagestatisticmonth.FieldNewUser:
  34840. v, ok := value.(int64)
  34841. if !ok {
  34842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34843. }
  34844. m.AddNewUser(v)
  34845. return nil
  34846. }
  34847. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  34848. }
  34849. // ClearedFields returns all nullable fields that were cleared during this
  34850. // mutation.
  34851. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  34852. var fields []string
  34853. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  34854. fields = append(fields, usagestatisticmonth.FieldStatus)
  34855. }
  34856. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  34857. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34858. }
  34859. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  34860. fields = append(fields, usagestatisticmonth.FieldBotID)
  34861. }
  34862. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  34863. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34864. }
  34865. return fields
  34866. }
  34867. // FieldCleared returns a boolean indicating if a field with the given name was
  34868. // cleared in this mutation.
  34869. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  34870. _, ok := m.clearedFields[name]
  34871. return ok
  34872. }
  34873. // ClearField clears the value of the field with the given name. It returns an
  34874. // error if the field is not defined in the schema.
  34875. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  34876. switch name {
  34877. case usagestatisticmonth.FieldStatus:
  34878. m.ClearStatus()
  34879. return nil
  34880. case usagestatisticmonth.FieldDeletedAt:
  34881. m.ClearDeletedAt()
  34882. return nil
  34883. case usagestatisticmonth.FieldBotID:
  34884. m.ClearBotID()
  34885. return nil
  34886. case usagestatisticmonth.FieldOrganizationID:
  34887. m.ClearOrganizationID()
  34888. return nil
  34889. }
  34890. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  34891. }
  34892. // ResetField resets all changes in the mutation for the field with the given name.
  34893. // It returns an error if the field is not defined in the schema.
  34894. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  34895. switch name {
  34896. case usagestatisticmonth.FieldCreatedAt:
  34897. m.ResetCreatedAt()
  34898. return nil
  34899. case usagestatisticmonth.FieldUpdatedAt:
  34900. m.ResetUpdatedAt()
  34901. return nil
  34902. case usagestatisticmonth.FieldStatus:
  34903. m.ResetStatus()
  34904. return nil
  34905. case usagestatisticmonth.FieldDeletedAt:
  34906. m.ResetDeletedAt()
  34907. return nil
  34908. case usagestatisticmonth.FieldAddtime:
  34909. m.ResetAddtime()
  34910. return nil
  34911. case usagestatisticmonth.FieldType:
  34912. m.ResetType()
  34913. return nil
  34914. case usagestatisticmonth.FieldBotID:
  34915. m.ResetBotID()
  34916. return nil
  34917. case usagestatisticmonth.FieldOrganizationID:
  34918. m.ResetOrganizationID()
  34919. return nil
  34920. case usagestatisticmonth.FieldAiResponse:
  34921. m.ResetAiResponse()
  34922. return nil
  34923. case usagestatisticmonth.FieldSopRun:
  34924. m.ResetSopRun()
  34925. return nil
  34926. case usagestatisticmonth.FieldTotalFriend:
  34927. m.ResetTotalFriend()
  34928. return nil
  34929. case usagestatisticmonth.FieldTotalGroup:
  34930. m.ResetTotalGroup()
  34931. return nil
  34932. case usagestatisticmonth.FieldAccountBalance:
  34933. m.ResetAccountBalance()
  34934. return nil
  34935. case usagestatisticmonth.FieldConsumeToken:
  34936. m.ResetConsumeToken()
  34937. return nil
  34938. case usagestatisticmonth.FieldActiveUser:
  34939. m.ResetActiveUser()
  34940. return nil
  34941. case usagestatisticmonth.FieldNewUser:
  34942. m.ResetNewUser()
  34943. return nil
  34944. case usagestatisticmonth.FieldLabelDist:
  34945. m.ResetLabelDist()
  34946. return nil
  34947. }
  34948. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34949. }
  34950. // AddedEdges returns all edge names that were set/added in this mutation.
  34951. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  34952. edges := make([]string, 0, 0)
  34953. return edges
  34954. }
  34955. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34956. // name in this mutation.
  34957. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  34958. return nil
  34959. }
  34960. // RemovedEdges returns all edge names that were removed in this mutation.
  34961. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  34962. edges := make([]string, 0, 0)
  34963. return edges
  34964. }
  34965. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34966. // the given name in this mutation.
  34967. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  34968. return nil
  34969. }
  34970. // ClearedEdges returns all edge names that were cleared in this mutation.
  34971. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  34972. edges := make([]string, 0, 0)
  34973. return edges
  34974. }
  34975. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34976. // was cleared in this mutation.
  34977. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  34978. return false
  34979. }
  34980. // ClearEdge clears the value of the edge with the given name. It returns an error
  34981. // if that edge is not defined in the schema.
  34982. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  34983. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  34984. }
  34985. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34986. // It returns an error if the edge is not defined in the schema.
  34987. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  34988. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  34989. }
  34990. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  34991. type UsageTotalMutation struct {
  34992. config
  34993. op Op
  34994. typ string
  34995. id *uint64
  34996. created_at *time.Time
  34997. updated_at *time.Time
  34998. status *uint8
  34999. addstatus *int8
  35000. _type *int
  35001. add_type *int
  35002. bot_id *string
  35003. total_tokens *uint64
  35004. addtotal_tokens *int64
  35005. start_index *uint64
  35006. addstart_index *int64
  35007. end_index *uint64
  35008. addend_index *int64
  35009. organization_id *uint64
  35010. addorganization_id *int64
  35011. clearedFields map[string]struct{}
  35012. done bool
  35013. oldValue func(context.Context) (*UsageTotal, error)
  35014. predicates []predicate.UsageTotal
  35015. }
  35016. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  35017. // usagetotalOption allows management of the mutation configuration using functional options.
  35018. type usagetotalOption func(*UsageTotalMutation)
  35019. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  35020. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  35021. m := &UsageTotalMutation{
  35022. config: c,
  35023. op: op,
  35024. typ: TypeUsageTotal,
  35025. clearedFields: make(map[string]struct{}),
  35026. }
  35027. for _, opt := range opts {
  35028. opt(m)
  35029. }
  35030. return m
  35031. }
  35032. // withUsageTotalID sets the ID field of the mutation.
  35033. func withUsageTotalID(id uint64) usagetotalOption {
  35034. return func(m *UsageTotalMutation) {
  35035. var (
  35036. err error
  35037. once sync.Once
  35038. value *UsageTotal
  35039. )
  35040. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  35041. once.Do(func() {
  35042. if m.done {
  35043. err = errors.New("querying old values post mutation is not allowed")
  35044. } else {
  35045. value, err = m.Client().UsageTotal.Get(ctx, id)
  35046. }
  35047. })
  35048. return value, err
  35049. }
  35050. m.id = &id
  35051. }
  35052. }
  35053. // withUsageTotal sets the old UsageTotal of the mutation.
  35054. func withUsageTotal(node *UsageTotal) usagetotalOption {
  35055. return func(m *UsageTotalMutation) {
  35056. m.oldValue = func(context.Context) (*UsageTotal, error) {
  35057. return node, nil
  35058. }
  35059. m.id = &node.ID
  35060. }
  35061. }
  35062. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35063. // executed in a transaction (ent.Tx), a transactional client is returned.
  35064. func (m UsageTotalMutation) Client() *Client {
  35065. client := &Client{config: m.config}
  35066. client.init()
  35067. return client
  35068. }
  35069. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35070. // it returns an error otherwise.
  35071. func (m UsageTotalMutation) Tx() (*Tx, error) {
  35072. if _, ok := m.driver.(*txDriver); !ok {
  35073. return nil, errors.New("ent: mutation is not running in a transaction")
  35074. }
  35075. tx := &Tx{config: m.config}
  35076. tx.init()
  35077. return tx, nil
  35078. }
  35079. // SetID sets the value of the id field. Note that this
  35080. // operation is only accepted on creation of UsageTotal entities.
  35081. func (m *UsageTotalMutation) SetID(id uint64) {
  35082. m.id = &id
  35083. }
  35084. // ID returns the ID value in the mutation. Note that the ID is only available
  35085. // if it was provided to the builder or after it was returned from the database.
  35086. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35087. if m.id == nil {
  35088. return
  35089. }
  35090. return *m.id, true
  35091. }
  35092. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35093. // That means, if the mutation is applied within a transaction with an isolation level such
  35094. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35095. // or updated by the mutation.
  35096. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35097. switch {
  35098. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35099. id, exists := m.ID()
  35100. if exists {
  35101. return []uint64{id}, nil
  35102. }
  35103. fallthrough
  35104. case m.op.Is(OpUpdate | OpDelete):
  35105. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35106. default:
  35107. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35108. }
  35109. }
  35110. // SetCreatedAt sets the "created_at" field.
  35111. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35112. m.created_at = &t
  35113. }
  35114. // CreatedAt returns the value of the "created_at" field in the mutation.
  35115. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35116. v := m.created_at
  35117. if v == nil {
  35118. return
  35119. }
  35120. return *v, true
  35121. }
  35122. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35123. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35125. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35126. if !m.op.Is(OpUpdateOne) {
  35127. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35128. }
  35129. if m.id == nil || m.oldValue == nil {
  35130. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35131. }
  35132. oldValue, err := m.oldValue(ctx)
  35133. if err != nil {
  35134. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35135. }
  35136. return oldValue.CreatedAt, nil
  35137. }
  35138. // ResetCreatedAt resets all changes to the "created_at" field.
  35139. func (m *UsageTotalMutation) ResetCreatedAt() {
  35140. m.created_at = nil
  35141. }
  35142. // SetUpdatedAt sets the "updated_at" field.
  35143. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35144. m.updated_at = &t
  35145. }
  35146. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35147. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35148. v := m.updated_at
  35149. if v == nil {
  35150. return
  35151. }
  35152. return *v, true
  35153. }
  35154. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35155. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35157. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35158. if !m.op.Is(OpUpdateOne) {
  35159. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35160. }
  35161. if m.id == nil || m.oldValue == nil {
  35162. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35163. }
  35164. oldValue, err := m.oldValue(ctx)
  35165. if err != nil {
  35166. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35167. }
  35168. return oldValue.UpdatedAt, nil
  35169. }
  35170. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35171. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35172. m.updated_at = nil
  35173. }
  35174. // SetStatus sets the "status" field.
  35175. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35176. m.status = &u
  35177. m.addstatus = nil
  35178. }
  35179. // Status returns the value of the "status" field in the mutation.
  35180. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35181. v := m.status
  35182. if v == nil {
  35183. return
  35184. }
  35185. return *v, true
  35186. }
  35187. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35188. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35190. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35191. if !m.op.Is(OpUpdateOne) {
  35192. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35193. }
  35194. if m.id == nil || m.oldValue == nil {
  35195. return v, errors.New("OldStatus requires an ID field in the mutation")
  35196. }
  35197. oldValue, err := m.oldValue(ctx)
  35198. if err != nil {
  35199. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35200. }
  35201. return oldValue.Status, nil
  35202. }
  35203. // AddStatus adds u to the "status" field.
  35204. func (m *UsageTotalMutation) AddStatus(u int8) {
  35205. if m.addstatus != nil {
  35206. *m.addstatus += u
  35207. } else {
  35208. m.addstatus = &u
  35209. }
  35210. }
  35211. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35212. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35213. v := m.addstatus
  35214. if v == nil {
  35215. return
  35216. }
  35217. return *v, true
  35218. }
  35219. // ClearStatus clears the value of the "status" field.
  35220. func (m *UsageTotalMutation) ClearStatus() {
  35221. m.status = nil
  35222. m.addstatus = nil
  35223. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35224. }
  35225. // StatusCleared returns if the "status" field was cleared in this mutation.
  35226. func (m *UsageTotalMutation) StatusCleared() bool {
  35227. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35228. return ok
  35229. }
  35230. // ResetStatus resets all changes to the "status" field.
  35231. func (m *UsageTotalMutation) ResetStatus() {
  35232. m.status = nil
  35233. m.addstatus = nil
  35234. delete(m.clearedFields, usagetotal.FieldStatus)
  35235. }
  35236. // SetType sets the "type" field.
  35237. func (m *UsageTotalMutation) SetType(i int) {
  35238. m._type = &i
  35239. m.add_type = nil
  35240. }
  35241. // GetType returns the value of the "type" field in the mutation.
  35242. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35243. v := m._type
  35244. if v == nil {
  35245. return
  35246. }
  35247. return *v, true
  35248. }
  35249. // OldType returns the old "type" field's value of the UsageTotal entity.
  35250. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35252. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35253. if !m.op.Is(OpUpdateOne) {
  35254. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35255. }
  35256. if m.id == nil || m.oldValue == nil {
  35257. return v, errors.New("OldType requires an ID field in the mutation")
  35258. }
  35259. oldValue, err := m.oldValue(ctx)
  35260. if err != nil {
  35261. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35262. }
  35263. return oldValue.Type, nil
  35264. }
  35265. // AddType adds i to the "type" field.
  35266. func (m *UsageTotalMutation) AddType(i int) {
  35267. if m.add_type != nil {
  35268. *m.add_type += i
  35269. } else {
  35270. m.add_type = &i
  35271. }
  35272. }
  35273. // AddedType returns the value that was added to the "type" field in this mutation.
  35274. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35275. v := m.add_type
  35276. if v == nil {
  35277. return
  35278. }
  35279. return *v, true
  35280. }
  35281. // ClearType clears the value of the "type" field.
  35282. func (m *UsageTotalMutation) ClearType() {
  35283. m._type = nil
  35284. m.add_type = nil
  35285. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35286. }
  35287. // TypeCleared returns if the "type" field was cleared in this mutation.
  35288. func (m *UsageTotalMutation) TypeCleared() bool {
  35289. _, ok := m.clearedFields[usagetotal.FieldType]
  35290. return ok
  35291. }
  35292. // ResetType resets all changes to the "type" field.
  35293. func (m *UsageTotalMutation) ResetType() {
  35294. m._type = nil
  35295. m.add_type = nil
  35296. delete(m.clearedFields, usagetotal.FieldType)
  35297. }
  35298. // SetBotID sets the "bot_id" field.
  35299. func (m *UsageTotalMutation) SetBotID(s string) {
  35300. m.bot_id = &s
  35301. }
  35302. // BotID returns the value of the "bot_id" field in the mutation.
  35303. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35304. v := m.bot_id
  35305. if v == nil {
  35306. return
  35307. }
  35308. return *v, true
  35309. }
  35310. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  35311. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35313. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  35314. if !m.op.Is(OpUpdateOne) {
  35315. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35316. }
  35317. if m.id == nil || m.oldValue == nil {
  35318. return v, errors.New("OldBotID requires an ID field in the mutation")
  35319. }
  35320. oldValue, err := m.oldValue(ctx)
  35321. if err != nil {
  35322. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35323. }
  35324. return oldValue.BotID, nil
  35325. }
  35326. // ResetBotID resets all changes to the "bot_id" field.
  35327. func (m *UsageTotalMutation) ResetBotID() {
  35328. m.bot_id = nil
  35329. }
  35330. // SetTotalTokens sets the "total_tokens" field.
  35331. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35332. m.total_tokens = &u
  35333. m.addtotal_tokens = nil
  35334. }
  35335. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35336. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35337. v := m.total_tokens
  35338. if v == nil {
  35339. return
  35340. }
  35341. return *v, true
  35342. }
  35343. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  35344. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35346. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35347. if !m.op.Is(OpUpdateOne) {
  35348. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35349. }
  35350. if m.id == nil || m.oldValue == nil {
  35351. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35352. }
  35353. oldValue, err := m.oldValue(ctx)
  35354. if err != nil {
  35355. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35356. }
  35357. return oldValue.TotalTokens, nil
  35358. }
  35359. // AddTotalTokens adds u to the "total_tokens" field.
  35360. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35361. if m.addtotal_tokens != nil {
  35362. *m.addtotal_tokens += u
  35363. } else {
  35364. m.addtotal_tokens = &u
  35365. }
  35366. }
  35367. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35368. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35369. v := m.addtotal_tokens
  35370. if v == nil {
  35371. return
  35372. }
  35373. return *v, true
  35374. }
  35375. // ClearTotalTokens clears the value of the "total_tokens" field.
  35376. func (m *UsageTotalMutation) ClearTotalTokens() {
  35377. m.total_tokens = nil
  35378. m.addtotal_tokens = nil
  35379. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35380. }
  35381. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35382. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35383. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35384. return ok
  35385. }
  35386. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35387. func (m *UsageTotalMutation) ResetTotalTokens() {
  35388. m.total_tokens = nil
  35389. m.addtotal_tokens = nil
  35390. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35391. }
  35392. // SetStartIndex sets the "start_index" field.
  35393. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35394. m.start_index = &u
  35395. m.addstart_index = nil
  35396. }
  35397. // StartIndex returns the value of the "start_index" field in the mutation.
  35398. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35399. v := m.start_index
  35400. if v == nil {
  35401. return
  35402. }
  35403. return *v, true
  35404. }
  35405. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  35406. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35408. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35409. if !m.op.Is(OpUpdateOne) {
  35410. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35411. }
  35412. if m.id == nil || m.oldValue == nil {
  35413. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  35414. }
  35415. oldValue, err := m.oldValue(ctx)
  35416. if err != nil {
  35417. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  35418. }
  35419. return oldValue.StartIndex, nil
  35420. }
  35421. // AddStartIndex adds u to the "start_index" field.
  35422. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35423. if m.addstart_index != nil {
  35424. *m.addstart_index += u
  35425. } else {
  35426. m.addstart_index = &u
  35427. }
  35428. }
  35429. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35430. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35431. v := m.addstart_index
  35432. if v == nil {
  35433. return
  35434. }
  35435. return *v, true
  35436. }
  35437. // ClearStartIndex clears the value of the "start_index" field.
  35438. func (m *UsageTotalMutation) ClearStartIndex() {
  35439. m.start_index = nil
  35440. m.addstart_index = nil
  35441. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35442. }
  35443. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35444. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35445. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35446. return ok
  35447. }
  35448. // ResetStartIndex resets all changes to the "start_index" field.
  35449. func (m *UsageTotalMutation) ResetStartIndex() {
  35450. m.start_index = nil
  35451. m.addstart_index = nil
  35452. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35453. }
  35454. // SetEndIndex sets the "end_index" field.
  35455. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35456. m.end_index = &u
  35457. m.addend_index = nil
  35458. }
  35459. // EndIndex returns the value of the "end_index" field in the mutation.
  35460. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35461. v := m.end_index
  35462. if v == nil {
  35463. return
  35464. }
  35465. return *v, true
  35466. }
  35467. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35468. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35470. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35471. if !m.op.Is(OpUpdateOne) {
  35472. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35473. }
  35474. if m.id == nil || m.oldValue == nil {
  35475. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  35476. }
  35477. oldValue, err := m.oldValue(ctx)
  35478. if err != nil {
  35479. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  35480. }
  35481. return oldValue.EndIndex, nil
  35482. }
  35483. // AddEndIndex adds u to the "end_index" field.
  35484. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35485. if m.addend_index != nil {
  35486. *m.addend_index += u
  35487. } else {
  35488. m.addend_index = &u
  35489. }
  35490. }
  35491. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35492. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35493. v := m.addend_index
  35494. if v == nil {
  35495. return
  35496. }
  35497. return *v, true
  35498. }
  35499. // ClearEndIndex clears the value of the "end_index" field.
  35500. func (m *UsageTotalMutation) ClearEndIndex() {
  35501. m.end_index = nil
  35502. m.addend_index = nil
  35503. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35504. }
  35505. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35506. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35507. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35508. return ok
  35509. }
  35510. // ResetEndIndex resets all changes to the "end_index" field.
  35511. func (m *UsageTotalMutation) ResetEndIndex() {
  35512. m.end_index = nil
  35513. m.addend_index = nil
  35514. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35515. }
  35516. // SetOrganizationID sets the "organization_id" field.
  35517. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35518. m.organization_id = &u
  35519. m.addorganization_id = nil
  35520. }
  35521. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35522. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35523. v := m.organization_id
  35524. if v == nil {
  35525. return
  35526. }
  35527. return *v, true
  35528. }
  35529. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35530. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35532. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35533. if !m.op.Is(OpUpdateOne) {
  35534. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35535. }
  35536. if m.id == nil || m.oldValue == nil {
  35537. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35538. }
  35539. oldValue, err := m.oldValue(ctx)
  35540. if err != nil {
  35541. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35542. }
  35543. return oldValue.OrganizationID, nil
  35544. }
  35545. // AddOrganizationID adds u to the "organization_id" field.
  35546. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35547. if m.addorganization_id != nil {
  35548. *m.addorganization_id += u
  35549. } else {
  35550. m.addorganization_id = &u
  35551. }
  35552. }
  35553. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35554. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35555. v := m.addorganization_id
  35556. if v == nil {
  35557. return
  35558. }
  35559. return *v, true
  35560. }
  35561. // ClearOrganizationID clears the value of the "organization_id" field.
  35562. func (m *UsageTotalMutation) ClearOrganizationID() {
  35563. m.organization_id = nil
  35564. m.addorganization_id = nil
  35565. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35566. }
  35567. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35568. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35569. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35570. return ok
  35571. }
  35572. // ResetOrganizationID resets all changes to the "organization_id" field.
  35573. func (m *UsageTotalMutation) ResetOrganizationID() {
  35574. m.organization_id = nil
  35575. m.addorganization_id = nil
  35576. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35577. }
  35578. // Where appends a list predicates to the UsageTotalMutation builder.
  35579. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35580. m.predicates = append(m.predicates, ps...)
  35581. }
  35582. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35583. // users can use type-assertion to append predicates that do not depend on any generated package.
  35584. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35585. p := make([]predicate.UsageTotal, len(ps))
  35586. for i := range ps {
  35587. p[i] = ps[i]
  35588. }
  35589. m.Where(p...)
  35590. }
  35591. // Op returns the operation name.
  35592. func (m *UsageTotalMutation) Op() Op {
  35593. return m.op
  35594. }
  35595. // SetOp allows setting the mutation operation.
  35596. func (m *UsageTotalMutation) SetOp(op Op) {
  35597. m.op = op
  35598. }
  35599. // Type returns the node type of this mutation (UsageTotal).
  35600. func (m *UsageTotalMutation) Type() string {
  35601. return m.typ
  35602. }
  35603. // Fields returns all fields that were changed during this mutation. Note that in
  35604. // order to get all numeric fields that were incremented/decremented, call
  35605. // AddedFields().
  35606. func (m *UsageTotalMutation) Fields() []string {
  35607. fields := make([]string, 0, 9)
  35608. if m.created_at != nil {
  35609. fields = append(fields, usagetotal.FieldCreatedAt)
  35610. }
  35611. if m.updated_at != nil {
  35612. fields = append(fields, usagetotal.FieldUpdatedAt)
  35613. }
  35614. if m.status != nil {
  35615. fields = append(fields, usagetotal.FieldStatus)
  35616. }
  35617. if m._type != nil {
  35618. fields = append(fields, usagetotal.FieldType)
  35619. }
  35620. if m.bot_id != nil {
  35621. fields = append(fields, usagetotal.FieldBotID)
  35622. }
  35623. if m.total_tokens != nil {
  35624. fields = append(fields, usagetotal.FieldTotalTokens)
  35625. }
  35626. if m.start_index != nil {
  35627. fields = append(fields, usagetotal.FieldStartIndex)
  35628. }
  35629. if m.end_index != nil {
  35630. fields = append(fields, usagetotal.FieldEndIndex)
  35631. }
  35632. if m.organization_id != nil {
  35633. fields = append(fields, usagetotal.FieldOrganizationID)
  35634. }
  35635. return fields
  35636. }
  35637. // Field returns the value of a field with the given name. The second boolean
  35638. // return value indicates that this field was not set, or was not defined in the
  35639. // schema.
  35640. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  35641. switch name {
  35642. case usagetotal.FieldCreatedAt:
  35643. return m.CreatedAt()
  35644. case usagetotal.FieldUpdatedAt:
  35645. return m.UpdatedAt()
  35646. case usagetotal.FieldStatus:
  35647. return m.Status()
  35648. case usagetotal.FieldType:
  35649. return m.GetType()
  35650. case usagetotal.FieldBotID:
  35651. return m.BotID()
  35652. case usagetotal.FieldTotalTokens:
  35653. return m.TotalTokens()
  35654. case usagetotal.FieldStartIndex:
  35655. return m.StartIndex()
  35656. case usagetotal.FieldEndIndex:
  35657. return m.EndIndex()
  35658. case usagetotal.FieldOrganizationID:
  35659. return m.OrganizationID()
  35660. }
  35661. return nil, false
  35662. }
  35663. // OldField returns the old value of the field from the database. An error is
  35664. // returned if the mutation operation is not UpdateOne, or the query to the
  35665. // database failed.
  35666. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35667. switch name {
  35668. case usagetotal.FieldCreatedAt:
  35669. return m.OldCreatedAt(ctx)
  35670. case usagetotal.FieldUpdatedAt:
  35671. return m.OldUpdatedAt(ctx)
  35672. case usagetotal.FieldStatus:
  35673. return m.OldStatus(ctx)
  35674. case usagetotal.FieldType:
  35675. return m.OldType(ctx)
  35676. case usagetotal.FieldBotID:
  35677. return m.OldBotID(ctx)
  35678. case usagetotal.FieldTotalTokens:
  35679. return m.OldTotalTokens(ctx)
  35680. case usagetotal.FieldStartIndex:
  35681. return m.OldStartIndex(ctx)
  35682. case usagetotal.FieldEndIndex:
  35683. return m.OldEndIndex(ctx)
  35684. case usagetotal.FieldOrganizationID:
  35685. return m.OldOrganizationID(ctx)
  35686. }
  35687. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  35688. }
  35689. // SetField sets the value of a field with the given name. It returns an error if
  35690. // the field is not defined in the schema, or if the type mismatched the field
  35691. // type.
  35692. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  35693. switch name {
  35694. case usagetotal.FieldCreatedAt:
  35695. v, ok := value.(time.Time)
  35696. if !ok {
  35697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35698. }
  35699. m.SetCreatedAt(v)
  35700. return nil
  35701. case usagetotal.FieldUpdatedAt:
  35702. v, ok := value.(time.Time)
  35703. if !ok {
  35704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35705. }
  35706. m.SetUpdatedAt(v)
  35707. return nil
  35708. case usagetotal.FieldStatus:
  35709. v, ok := value.(uint8)
  35710. if !ok {
  35711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35712. }
  35713. m.SetStatus(v)
  35714. return nil
  35715. case usagetotal.FieldType:
  35716. v, ok := value.(int)
  35717. if !ok {
  35718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35719. }
  35720. m.SetType(v)
  35721. return nil
  35722. case usagetotal.FieldBotID:
  35723. v, ok := value.(string)
  35724. if !ok {
  35725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35726. }
  35727. m.SetBotID(v)
  35728. return nil
  35729. case usagetotal.FieldTotalTokens:
  35730. v, ok := value.(uint64)
  35731. if !ok {
  35732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35733. }
  35734. m.SetTotalTokens(v)
  35735. return nil
  35736. case usagetotal.FieldStartIndex:
  35737. v, ok := value.(uint64)
  35738. if !ok {
  35739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35740. }
  35741. m.SetStartIndex(v)
  35742. return nil
  35743. case usagetotal.FieldEndIndex:
  35744. v, ok := value.(uint64)
  35745. if !ok {
  35746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35747. }
  35748. m.SetEndIndex(v)
  35749. return nil
  35750. case usagetotal.FieldOrganizationID:
  35751. v, ok := value.(uint64)
  35752. if !ok {
  35753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35754. }
  35755. m.SetOrganizationID(v)
  35756. return nil
  35757. }
  35758. return fmt.Errorf("unknown UsageTotal field %s", name)
  35759. }
  35760. // AddedFields returns all numeric fields that were incremented/decremented during
  35761. // this mutation.
  35762. func (m *UsageTotalMutation) AddedFields() []string {
  35763. var fields []string
  35764. if m.addstatus != nil {
  35765. fields = append(fields, usagetotal.FieldStatus)
  35766. }
  35767. if m.add_type != nil {
  35768. fields = append(fields, usagetotal.FieldType)
  35769. }
  35770. if m.addtotal_tokens != nil {
  35771. fields = append(fields, usagetotal.FieldTotalTokens)
  35772. }
  35773. if m.addstart_index != nil {
  35774. fields = append(fields, usagetotal.FieldStartIndex)
  35775. }
  35776. if m.addend_index != nil {
  35777. fields = append(fields, usagetotal.FieldEndIndex)
  35778. }
  35779. if m.addorganization_id != nil {
  35780. fields = append(fields, usagetotal.FieldOrganizationID)
  35781. }
  35782. return fields
  35783. }
  35784. // AddedField returns the numeric value that was incremented/decremented on a field
  35785. // with the given name. The second boolean return value indicates that this field
  35786. // was not set, or was not defined in the schema.
  35787. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  35788. switch name {
  35789. case usagetotal.FieldStatus:
  35790. return m.AddedStatus()
  35791. case usagetotal.FieldType:
  35792. return m.AddedType()
  35793. case usagetotal.FieldTotalTokens:
  35794. return m.AddedTotalTokens()
  35795. case usagetotal.FieldStartIndex:
  35796. return m.AddedStartIndex()
  35797. case usagetotal.FieldEndIndex:
  35798. return m.AddedEndIndex()
  35799. case usagetotal.FieldOrganizationID:
  35800. return m.AddedOrganizationID()
  35801. }
  35802. return nil, false
  35803. }
  35804. // AddField adds the value to the field with the given name. It returns an error if
  35805. // the field is not defined in the schema, or if the type mismatched the field
  35806. // type.
  35807. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  35808. switch name {
  35809. case usagetotal.FieldStatus:
  35810. v, ok := value.(int8)
  35811. if !ok {
  35812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35813. }
  35814. m.AddStatus(v)
  35815. return nil
  35816. case usagetotal.FieldType:
  35817. v, ok := value.(int)
  35818. if !ok {
  35819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35820. }
  35821. m.AddType(v)
  35822. return nil
  35823. case usagetotal.FieldTotalTokens:
  35824. v, ok := value.(int64)
  35825. if !ok {
  35826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35827. }
  35828. m.AddTotalTokens(v)
  35829. return nil
  35830. case usagetotal.FieldStartIndex:
  35831. v, ok := value.(int64)
  35832. if !ok {
  35833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35834. }
  35835. m.AddStartIndex(v)
  35836. return nil
  35837. case usagetotal.FieldEndIndex:
  35838. v, ok := value.(int64)
  35839. if !ok {
  35840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35841. }
  35842. m.AddEndIndex(v)
  35843. return nil
  35844. case usagetotal.FieldOrganizationID:
  35845. v, ok := value.(int64)
  35846. if !ok {
  35847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35848. }
  35849. m.AddOrganizationID(v)
  35850. return nil
  35851. }
  35852. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  35853. }
  35854. // ClearedFields returns all nullable fields that were cleared during this
  35855. // mutation.
  35856. func (m *UsageTotalMutation) ClearedFields() []string {
  35857. var fields []string
  35858. if m.FieldCleared(usagetotal.FieldStatus) {
  35859. fields = append(fields, usagetotal.FieldStatus)
  35860. }
  35861. if m.FieldCleared(usagetotal.FieldType) {
  35862. fields = append(fields, usagetotal.FieldType)
  35863. }
  35864. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  35865. fields = append(fields, usagetotal.FieldTotalTokens)
  35866. }
  35867. if m.FieldCleared(usagetotal.FieldStartIndex) {
  35868. fields = append(fields, usagetotal.FieldStartIndex)
  35869. }
  35870. if m.FieldCleared(usagetotal.FieldEndIndex) {
  35871. fields = append(fields, usagetotal.FieldEndIndex)
  35872. }
  35873. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  35874. fields = append(fields, usagetotal.FieldOrganizationID)
  35875. }
  35876. return fields
  35877. }
  35878. // FieldCleared returns a boolean indicating if a field with the given name was
  35879. // cleared in this mutation.
  35880. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  35881. _, ok := m.clearedFields[name]
  35882. return ok
  35883. }
  35884. // ClearField clears the value of the field with the given name. It returns an
  35885. // error if the field is not defined in the schema.
  35886. func (m *UsageTotalMutation) ClearField(name string) error {
  35887. switch name {
  35888. case usagetotal.FieldStatus:
  35889. m.ClearStatus()
  35890. return nil
  35891. case usagetotal.FieldType:
  35892. m.ClearType()
  35893. return nil
  35894. case usagetotal.FieldTotalTokens:
  35895. m.ClearTotalTokens()
  35896. return nil
  35897. case usagetotal.FieldStartIndex:
  35898. m.ClearStartIndex()
  35899. return nil
  35900. case usagetotal.FieldEndIndex:
  35901. m.ClearEndIndex()
  35902. return nil
  35903. case usagetotal.FieldOrganizationID:
  35904. m.ClearOrganizationID()
  35905. return nil
  35906. }
  35907. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  35908. }
  35909. // ResetField resets all changes in the mutation for the field with the given name.
  35910. // It returns an error if the field is not defined in the schema.
  35911. func (m *UsageTotalMutation) ResetField(name string) error {
  35912. switch name {
  35913. case usagetotal.FieldCreatedAt:
  35914. m.ResetCreatedAt()
  35915. return nil
  35916. case usagetotal.FieldUpdatedAt:
  35917. m.ResetUpdatedAt()
  35918. return nil
  35919. case usagetotal.FieldStatus:
  35920. m.ResetStatus()
  35921. return nil
  35922. case usagetotal.FieldType:
  35923. m.ResetType()
  35924. return nil
  35925. case usagetotal.FieldBotID:
  35926. m.ResetBotID()
  35927. return nil
  35928. case usagetotal.FieldTotalTokens:
  35929. m.ResetTotalTokens()
  35930. return nil
  35931. case usagetotal.FieldStartIndex:
  35932. m.ResetStartIndex()
  35933. return nil
  35934. case usagetotal.FieldEndIndex:
  35935. m.ResetEndIndex()
  35936. return nil
  35937. case usagetotal.FieldOrganizationID:
  35938. m.ResetOrganizationID()
  35939. return nil
  35940. }
  35941. return fmt.Errorf("unknown UsageTotal field %s", name)
  35942. }
  35943. // AddedEdges returns all edge names that were set/added in this mutation.
  35944. func (m *UsageTotalMutation) AddedEdges() []string {
  35945. edges := make([]string, 0, 0)
  35946. return edges
  35947. }
  35948. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35949. // name in this mutation.
  35950. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  35951. return nil
  35952. }
  35953. // RemovedEdges returns all edge names that were removed in this mutation.
  35954. func (m *UsageTotalMutation) RemovedEdges() []string {
  35955. edges := make([]string, 0, 0)
  35956. return edges
  35957. }
  35958. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35959. // the given name in this mutation.
  35960. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  35961. return nil
  35962. }
  35963. // ClearedEdges returns all edge names that were cleared in this mutation.
  35964. func (m *UsageTotalMutation) ClearedEdges() []string {
  35965. edges := make([]string, 0, 0)
  35966. return edges
  35967. }
  35968. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35969. // was cleared in this mutation.
  35970. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  35971. return false
  35972. }
  35973. // ClearEdge clears the value of the edge with the given name. It returns an error
  35974. // if that edge is not defined in the schema.
  35975. func (m *UsageTotalMutation) ClearEdge(name string) error {
  35976. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  35977. }
  35978. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35979. // It returns an error if the edge is not defined in the schema.
  35980. func (m *UsageTotalMutation) ResetEdge(name string) error {
  35981. return fmt.Errorf("unknown UsageTotal edge %s", name)
  35982. }
  35983. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  35984. type WhatsappMutation struct {
  35985. config
  35986. op Op
  35987. typ string
  35988. id *uint64
  35989. created_at *time.Time
  35990. updated_at *time.Time
  35991. status *uint8
  35992. addstatus *int8
  35993. deleted_at *time.Time
  35994. wa_id *string
  35995. wa_name *string
  35996. callback *string
  35997. account *string
  35998. cc *string
  35999. phone *string
  36000. cc_phone *string
  36001. phone_name *string
  36002. phone_status *int8
  36003. addphone_status *int8
  36004. organization_id *uint64
  36005. addorganization_id *int64
  36006. api_base *string
  36007. api_key *string
  36008. allow_list *[]string
  36009. appendallow_list []string
  36010. group_allow_list *[]string
  36011. appendgroup_allow_list []string
  36012. block_list *[]string
  36013. appendblock_list []string
  36014. group_block_list *[]string
  36015. appendgroup_block_list []string
  36016. clearedFields map[string]struct{}
  36017. agent *uint64
  36018. clearedagent bool
  36019. done bool
  36020. oldValue func(context.Context) (*Whatsapp, error)
  36021. predicates []predicate.Whatsapp
  36022. }
  36023. var _ ent.Mutation = (*WhatsappMutation)(nil)
  36024. // whatsappOption allows management of the mutation configuration using functional options.
  36025. type whatsappOption func(*WhatsappMutation)
  36026. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  36027. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  36028. m := &WhatsappMutation{
  36029. config: c,
  36030. op: op,
  36031. typ: TypeWhatsapp,
  36032. clearedFields: make(map[string]struct{}),
  36033. }
  36034. for _, opt := range opts {
  36035. opt(m)
  36036. }
  36037. return m
  36038. }
  36039. // withWhatsappID sets the ID field of the mutation.
  36040. func withWhatsappID(id uint64) whatsappOption {
  36041. return func(m *WhatsappMutation) {
  36042. var (
  36043. err error
  36044. once sync.Once
  36045. value *Whatsapp
  36046. )
  36047. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  36048. once.Do(func() {
  36049. if m.done {
  36050. err = errors.New("querying old values post mutation is not allowed")
  36051. } else {
  36052. value, err = m.Client().Whatsapp.Get(ctx, id)
  36053. }
  36054. })
  36055. return value, err
  36056. }
  36057. m.id = &id
  36058. }
  36059. }
  36060. // withWhatsapp sets the old Whatsapp of the mutation.
  36061. func withWhatsapp(node *Whatsapp) whatsappOption {
  36062. return func(m *WhatsappMutation) {
  36063. m.oldValue = func(context.Context) (*Whatsapp, error) {
  36064. return node, nil
  36065. }
  36066. m.id = &node.ID
  36067. }
  36068. }
  36069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36070. // executed in a transaction (ent.Tx), a transactional client is returned.
  36071. func (m WhatsappMutation) Client() *Client {
  36072. client := &Client{config: m.config}
  36073. client.init()
  36074. return client
  36075. }
  36076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36077. // it returns an error otherwise.
  36078. func (m WhatsappMutation) Tx() (*Tx, error) {
  36079. if _, ok := m.driver.(*txDriver); !ok {
  36080. return nil, errors.New("ent: mutation is not running in a transaction")
  36081. }
  36082. tx := &Tx{config: m.config}
  36083. tx.init()
  36084. return tx, nil
  36085. }
  36086. // SetID sets the value of the id field. Note that this
  36087. // operation is only accepted on creation of Whatsapp entities.
  36088. func (m *WhatsappMutation) SetID(id uint64) {
  36089. m.id = &id
  36090. }
  36091. // ID returns the ID value in the mutation. Note that the ID is only available
  36092. // if it was provided to the builder or after it was returned from the database.
  36093. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36094. if m.id == nil {
  36095. return
  36096. }
  36097. return *m.id, true
  36098. }
  36099. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36100. // That means, if the mutation is applied within a transaction with an isolation level such
  36101. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36102. // or updated by the mutation.
  36103. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36104. switch {
  36105. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36106. id, exists := m.ID()
  36107. if exists {
  36108. return []uint64{id}, nil
  36109. }
  36110. fallthrough
  36111. case m.op.Is(OpUpdate | OpDelete):
  36112. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36113. default:
  36114. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36115. }
  36116. }
  36117. // SetCreatedAt sets the "created_at" field.
  36118. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36119. m.created_at = &t
  36120. }
  36121. // CreatedAt returns the value of the "created_at" field in the mutation.
  36122. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36123. v := m.created_at
  36124. if v == nil {
  36125. return
  36126. }
  36127. return *v, true
  36128. }
  36129. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36130. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36132. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36133. if !m.op.Is(OpUpdateOne) {
  36134. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36135. }
  36136. if m.id == nil || m.oldValue == nil {
  36137. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36138. }
  36139. oldValue, err := m.oldValue(ctx)
  36140. if err != nil {
  36141. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36142. }
  36143. return oldValue.CreatedAt, nil
  36144. }
  36145. // ResetCreatedAt resets all changes to the "created_at" field.
  36146. func (m *WhatsappMutation) ResetCreatedAt() {
  36147. m.created_at = nil
  36148. }
  36149. // SetUpdatedAt sets the "updated_at" field.
  36150. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36151. m.updated_at = &t
  36152. }
  36153. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36154. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36155. v := m.updated_at
  36156. if v == nil {
  36157. return
  36158. }
  36159. return *v, true
  36160. }
  36161. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36162. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36164. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36165. if !m.op.Is(OpUpdateOne) {
  36166. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36167. }
  36168. if m.id == nil || m.oldValue == nil {
  36169. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36170. }
  36171. oldValue, err := m.oldValue(ctx)
  36172. if err != nil {
  36173. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36174. }
  36175. return oldValue.UpdatedAt, nil
  36176. }
  36177. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36178. func (m *WhatsappMutation) ResetUpdatedAt() {
  36179. m.updated_at = nil
  36180. }
  36181. // SetStatus sets the "status" field.
  36182. func (m *WhatsappMutation) SetStatus(u uint8) {
  36183. m.status = &u
  36184. m.addstatus = nil
  36185. }
  36186. // Status returns the value of the "status" field in the mutation.
  36187. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36188. v := m.status
  36189. if v == nil {
  36190. return
  36191. }
  36192. return *v, true
  36193. }
  36194. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36195. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36197. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36198. if !m.op.Is(OpUpdateOne) {
  36199. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36200. }
  36201. if m.id == nil || m.oldValue == nil {
  36202. return v, errors.New("OldStatus requires an ID field in the mutation")
  36203. }
  36204. oldValue, err := m.oldValue(ctx)
  36205. if err != nil {
  36206. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36207. }
  36208. return oldValue.Status, nil
  36209. }
  36210. // AddStatus adds u to the "status" field.
  36211. func (m *WhatsappMutation) AddStatus(u int8) {
  36212. if m.addstatus != nil {
  36213. *m.addstatus += u
  36214. } else {
  36215. m.addstatus = &u
  36216. }
  36217. }
  36218. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36219. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36220. v := m.addstatus
  36221. if v == nil {
  36222. return
  36223. }
  36224. return *v, true
  36225. }
  36226. // ClearStatus clears the value of the "status" field.
  36227. func (m *WhatsappMutation) ClearStatus() {
  36228. m.status = nil
  36229. m.addstatus = nil
  36230. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36231. }
  36232. // StatusCleared returns if the "status" field was cleared in this mutation.
  36233. func (m *WhatsappMutation) StatusCleared() bool {
  36234. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36235. return ok
  36236. }
  36237. // ResetStatus resets all changes to the "status" field.
  36238. func (m *WhatsappMutation) ResetStatus() {
  36239. m.status = nil
  36240. m.addstatus = nil
  36241. delete(m.clearedFields, whatsapp.FieldStatus)
  36242. }
  36243. // SetDeletedAt sets the "deleted_at" field.
  36244. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36245. m.deleted_at = &t
  36246. }
  36247. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36248. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36249. v := m.deleted_at
  36250. if v == nil {
  36251. return
  36252. }
  36253. return *v, true
  36254. }
  36255. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36256. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36258. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36259. if !m.op.Is(OpUpdateOne) {
  36260. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36261. }
  36262. if m.id == nil || m.oldValue == nil {
  36263. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36264. }
  36265. oldValue, err := m.oldValue(ctx)
  36266. if err != nil {
  36267. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36268. }
  36269. return oldValue.DeletedAt, nil
  36270. }
  36271. // ClearDeletedAt clears the value of the "deleted_at" field.
  36272. func (m *WhatsappMutation) ClearDeletedAt() {
  36273. m.deleted_at = nil
  36274. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36275. }
  36276. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36277. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36278. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36279. return ok
  36280. }
  36281. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36282. func (m *WhatsappMutation) ResetDeletedAt() {
  36283. m.deleted_at = nil
  36284. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36285. }
  36286. // SetWaID sets the "wa_id" field.
  36287. func (m *WhatsappMutation) SetWaID(s string) {
  36288. m.wa_id = &s
  36289. }
  36290. // WaID returns the value of the "wa_id" field in the mutation.
  36291. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36292. v := m.wa_id
  36293. if v == nil {
  36294. return
  36295. }
  36296. return *v, true
  36297. }
  36298. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36299. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36301. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36302. if !m.op.Is(OpUpdateOne) {
  36303. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36304. }
  36305. if m.id == nil || m.oldValue == nil {
  36306. return v, errors.New("OldWaID requires an ID field in the mutation")
  36307. }
  36308. oldValue, err := m.oldValue(ctx)
  36309. if err != nil {
  36310. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36311. }
  36312. return oldValue.WaID, nil
  36313. }
  36314. // ClearWaID clears the value of the "wa_id" field.
  36315. func (m *WhatsappMutation) ClearWaID() {
  36316. m.wa_id = nil
  36317. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36318. }
  36319. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36320. func (m *WhatsappMutation) WaIDCleared() bool {
  36321. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36322. return ok
  36323. }
  36324. // ResetWaID resets all changes to the "wa_id" field.
  36325. func (m *WhatsappMutation) ResetWaID() {
  36326. m.wa_id = nil
  36327. delete(m.clearedFields, whatsapp.FieldWaID)
  36328. }
  36329. // SetWaName sets the "wa_name" field.
  36330. func (m *WhatsappMutation) SetWaName(s string) {
  36331. m.wa_name = &s
  36332. }
  36333. // WaName returns the value of the "wa_name" field in the mutation.
  36334. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36335. v := m.wa_name
  36336. if v == nil {
  36337. return
  36338. }
  36339. return *v, true
  36340. }
  36341. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36342. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36344. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36345. if !m.op.Is(OpUpdateOne) {
  36346. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36347. }
  36348. if m.id == nil || m.oldValue == nil {
  36349. return v, errors.New("OldWaName requires an ID field in the mutation")
  36350. }
  36351. oldValue, err := m.oldValue(ctx)
  36352. if err != nil {
  36353. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36354. }
  36355. return oldValue.WaName, nil
  36356. }
  36357. // ClearWaName clears the value of the "wa_name" field.
  36358. func (m *WhatsappMutation) ClearWaName() {
  36359. m.wa_name = nil
  36360. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36361. }
  36362. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36363. func (m *WhatsappMutation) WaNameCleared() bool {
  36364. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36365. return ok
  36366. }
  36367. // ResetWaName resets all changes to the "wa_name" field.
  36368. func (m *WhatsappMutation) ResetWaName() {
  36369. m.wa_name = nil
  36370. delete(m.clearedFields, whatsapp.FieldWaName)
  36371. }
  36372. // SetCallback sets the "callback" field.
  36373. func (m *WhatsappMutation) SetCallback(s string) {
  36374. m.callback = &s
  36375. }
  36376. // Callback returns the value of the "callback" field in the mutation.
  36377. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36378. v := m.callback
  36379. if v == nil {
  36380. return
  36381. }
  36382. return *v, true
  36383. }
  36384. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36385. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36387. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36388. if !m.op.Is(OpUpdateOne) {
  36389. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36390. }
  36391. if m.id == nil || m.oldValue == nil {
  36392. return v, errors.New("OldCallback requires an ID field in the mutation")
  36393. }
  36394. oldValue, err := m.oldValue(ctx)
  36395. if err != nil {
  36396. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36397. }
  36398. return oldValue.Callback, nil
  36399. }
  36400. // ClearCallback clears the value of the "callback" field.
  36401. func (m *WhatsappMutation) ClearCallback() {
  36402. m.callback = nil
  36403. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36404. }
  36405. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36406. func (m *WhatsappMutation) CallbackCleared() bool {
  36407. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36408. return ok
  36409. }
  36410. // ResetCallback resets all changes to the "callback" field.
  36411. func (m *WhatsappMutation) ResetCallback() {
  36412. m.callback = nil
  36413. delete(m.clearedFields, whatsapp.FieldCallback)
  36414. }
  36415. // SetAgentID sets the "agent_id" field.
  36416. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36417. m.agent = &u
  36418. }
  36419. // AgentID returns the value of the "agent_id" field in the mutation.
  36420. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36421. v := m.agent
  36422. if v == nil {
  36423. return
  36424. }
  36425. return *v, true
  36426. }
  36427. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36428. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36430. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36431. if !m.op.Is(OpUpdateOne) {
  36432. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36433. }
  36434. if m.id == nil || m.oldValue == nil {
  36435. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36436. }
  36437. oldValue, err := m.oldValue(ctx)
  36438. if err != nil {
  36439. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36440. }
  36441. return oldValue.AgentID, nil
  36442. }
  36443. // ResetAgentID resets all changes to the "agent_id" field.
  36444. func (m *WhatsappMutation) ResetAgentID() {
  36445. m.agent = nil
  36446. }
  36447. // SetAccount sets the "account" field.
  36448. func (m *WhatsappMutation) SetAccount(s string) {
  36449. m.account = &s
  36450. }
  36451. // Account returns the value of the "account" field in the mutation.
  36452. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36453. v := m.account
  36454. if v == nil {
  36455. return
  36456. }
  36457. return *v, true
  36458. }
  36459. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36460. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36462. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36463. if !m.op.Is(OpUpdateOne) {
  36464. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36465. }
  36466. if m.id == nil || m.oldValue == nil {
  36467. return v, errors.New("OldAccount requires an ID field in the mutation")
  36468. }
  36469. oldValue, err := m.oldValue(ctx)
  36470. if err != nil {
  36471. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36472. }
  36473. return oldValue.Account, nil
  36474. }
  36475. // ClearAccount clears the value of the "account" field.
  36476. func (m *WhatsappMutation) ClearAccount() {
  36477. m.account = nil
  36478. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36479. }
  36480. // AccountCleared returns if the "account" field was cleared in this mutation.
  36481. func (m *WhatsappMutation) AccountCleared() bool {
  36482. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36483. return ok
  36484. }
  36485. // ResetAccount resets all changes to the "account" field.
  36486. func (m *WhatsappMutation) ResetAccount() {
  36487. m.account = nil
  36488. delete(m.clearedFields, whatsapp.FieldAccount)
  36489. }
  36490. // SetCc sets the "cc" field.
  36491. func (m *WhatsappMutation) SetCc(s string) {
  36492. m.cc = &s
  36493. }
  36494. // Cc returns the value of the "cc" field in the mutation.
  36495. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36496. v := m.cc
  36497. if v == nil {
  36498. return
  36499. }
  36500. return *v, true
  36501. }
  36502. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36503. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36505. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36506. if !m.op.Is(OpUpdateOne) {
  36507. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36508. }
  36509. if m.id == nil || m.oldValue == nil {
  36510. return v, errors.New("OldCc requires an ID field in the mutation")
  36511. }
  36512. oldValue, err := m.oldValue(ctx)
  36513. if err != nil {
  36514. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36515. }
  36516. return oldValue.Cc, nil
  36517. }
  36518. // ResetCc resets all changes to the "cc" field.
  36519. func (m *WhatsappMutation) ResetCc() {
  36520. m.cc = nil
  36521. }
  36522. // SetPhone sets the "phone" field.
  36523. func (m *WhatsappMutation) SetPhone(s string) {
  36524. m.phone = &s
  36525. }
  36526. // Phone returns the value of the "phone" field in the mutation.
  36527. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36528. v := m.phone
  36529. if v == nil {
  36530. return
  36531. }
  36532. return *v, true
  36533. }
  36534. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36535. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36537. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36538. if !m.op.Is(OpUpdateOne) {
  36539. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36540. }
  36541. if m.id == nil || m.oldValue == nil {
  36542. return v, errors.New("OldPhone requires an ID field in the mutation")
  36543. }
  36544. oldValue, err := m.oldValue(ctx)
  36545. if err != nil {
  36546. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36547. }
  36548. return oldValue.Phone, nil
  36549. }
  36550. // ResetPhone resets all changes to the "phone" field.
  36551. func (m *WhatsappMutation) ResetPhone() {
  36552. m.phone = nil
  36553. }
  36554. // SetCcPhone sets the "cc_phone" field.
  36555. func (m *WhatsappMutation) SetCcPhone(s string) {
  36556. m.cc_phone = &s
  36557. }
  36558. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36559. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36560. v := m.cc_phone
  36561. if v == nil {
  36562. return
  36563. }
  36564. return *v, true
  36565. }
  36566. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36567. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36569. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36570. if !m.op.Is(OpUpdateOne) {
  36571. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36572. }
  36573. if m.id == nil || m.oldValue == nil {
  36574. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36575. }
  36576. oldValue, err := m.oldValue(ctx)
  36577. if err != nil {
  36578. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36579. }
  36580. return oldValue.CcPhone, nil
  36581. }
  36582. // ResetCcPhone resets all changes to the "cc_phone" field.
  36583. func (m *WhatsappMutation) ResetCcPhone() {
  36584. m.cc_phone = nil
  36585. }
  36586. // SetPhoneName sets the "phone_name" field.
  36587. func (m *WhatsappMutation) SetPhoneName(s string) {
  36588. m.phone_name = &s
  36589. }
  36590. // PhoneName returns the value of the "phone_name" field in the mutation.
  36591. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36592. v := m.phone_name
  36593. if v == nil {
  36594. return
  36595. }
  36596. return *v, true
  36597. }
  36598. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36599. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36601. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36602. if !m.op.Is(OpUpdateOne) {
  36603. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36604. }
  36605. if m.id == nil || m.oldValue == nil {
  36606. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36607. }
  36608. oldValue, err := m.oldValue(ctx)
  36609. if err != nil {
  36610. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36611. }
  36612. return oldValue.PhoneName, nil
  36613. }
  36614. // ResetPhoneName resets all changes to the "phone_name" field.
  36615. func (m *WhatsappMutation) ResetPhoneName() {
  36616. m.phone_name = nil
  36617. }
  36618. // SetPhoneStatus sets the "phone_status" field.
  36619. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36620. m.phone_status = &i
  36621. m.addphone_status = nil
  36622. }
  36623. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36624. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36625. v := m.phone_status
  36626. if v == nil {
  36627. return
  36628. }
  36629. return *v, true
  36630. }
  36631. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36632. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36634. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  36635. if !m.op.Is(OpUpdateOne) {
  36636. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  36637. }
  36638. if m.id == nil || m.oldValue == nil {
  36639. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  36640. }
  36641. oldValue, err := m.oldValue(ctx)
  36642. if err != nil {
  36643. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  36644. }
  36645. return oldValue.PhoneStatus, nil
  36646. }
  36647. // AddPhoneStatus adds i to the "phone_status" field.
  36648. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  36649. if m.addphone_status != nil {
  36650. *m.addphone_status += i
  36651. } else {
  36652. m.addphone_status = &i
  36653. }
  36654. }
  36655. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  36656. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  36657. v := m.addphone_status
  36658. if v == nil {
  36659. return
  36660. }
  36661. return *v, true
  36662. }
  36663. // ResetPhoneStatus resets all changes to the "phone_status" field.
  36664. func (m *WhatsappMutation) ResetPhoneStatus() {
  36665. m.phone_status = nil
  36666. m.addphone_status = nil
  36667. }
  36668. // SetOrganizationID sets the "organization_id" field.
  36669. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  36670. m.organization_id = &u
  36671. m.addorganization_id = nil
  36672. }
  36673. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36674. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  36675. v := m.organization_id
  36676. if v == nil {
  36677. return
  36678. }
  36679. return *v, true
  36680. }
  36681. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  36682. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36684. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36685. if !m.op.Is(OpUpdateOne) {
  36686. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36687. }
  36688. if m.id == nil || m.oldValue == nil {
  36689. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36690. }
  36691. oldValue, err := m.oldValue(ctx)
  36692. if err != nil {
  36693. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36694. }
  36695. return oldValue.OrganizationID, nil
  36696. }
  36697. // AddOrganizationID adds u to the "organization_id" field.
  36698. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  36699. if m.addorganization_id != nil {
  36700. *m.addorganization_id += u
  36701. } else {
  36702. m.addorganization_id = &u
  36703. }
  36704. }
  36705. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36706. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  36707. v := m.addorganization_id
  36708. if v == nil {
  36709. return
  36710. }
  36711. return *v, true
  36712. }
  36713. // ClearOrganizationID clears the value of the "organization_id" field.
  36714. func (m *WhatsappMutation) ClearOrganizationID() {
  36715. m.organization_id = nil
  36716. m.addorganization_id = nil
  36717. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  36718. }
  36719. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36720. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  36721. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  36722. return ok
  36723. }
  36724. // ResetOrganizationID resets all changes to the "organization_id" field.
  36725. func (m *WhatsappMutation) ResetOrganizationID() {
  36726. m.organization_id = nil
  36727. m.addorganization_id = nil
  36728. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  36729. }
  36730. // SetAPIBase sets the "api_base" field.
  36731. func (m *WhatsappMutation) SetAPIBase(s string) {
  36732. m.api_base = &s
  36733. }
  36734. // APIBase returns the value of the "api_base" field in the mutation.
  36735. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  36736. v := m.api_base
  36737. if v == nil {
  36738. return
  36739. }
  36740. return *v, true
  36741. }
  36742. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  36743. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36745. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36746. if !m.op.Is(OpUpdateOne) {
  36747. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36748. }
  36749. if m.id == nil || m.oldValue == nil {
  36750. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  36751. }
  36752. oldValue, err := m.oldValue(ctx)
  36753. if err != nil {
  36754. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  36755. }
  36756. return oldValue.APIBase, nil
  36757. }
  36758. // ClearAPIBase clears the value of the "api_base" field.
  36759. func (m *WhatsappMutation) ClearAPIBase() {
  36760. m.api_base = nil
  36761. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  36762. }
  36763. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  36764. func (m *WhatsappMutation) APIBaseCleared() bool {
  36765. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  36766. return ok
  36767. }
  36768. // ResetAPIBase resets all changes to the "api_base" field.
  36769. func (m *WhatsappMutation) ResetAPIBase() {
  36770. m.api_base = nil
  36771. delete(m.clearedFields, whatsapp.FieldAPIBase)
  36772. }
  36773. // SetAPIKey sets the "api_key" field.
  36774. func (m *WhatsappMutation) SetAPIKey(s string) {
  36775. m.api_key = &s
  36776. }
  36777. // APIKey returns the value of the "api_key" field in the mutation.
  36778. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  36779. v := m.api_key
  36780. if v == nil {
  36781. return
  36782. }
  36783. return *v, true
  36784. }
  36785. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  36786. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36788. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  36789. if !m.op.Is(OpUpdateOne) {
  36790. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  36791. }
  36792. if m.id == nil || m.oldValue == nil {
  36793. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  36794. }
  36795. oldValue, err := m.oldValue(ctx)
  36796. if err != nil {
  36797. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  36798. }
  36799. return oldValue.APIKey, nil
  36800. }
  36801. // ClearAPIKey clears the value of the "api_key" field.
  36802. func (m *WhatsappMutation) ClearAPIKey() {
  36803. m.api_key = nil
  36804. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  36805. }
  36806. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  36807. func (m *WhatsappMutation) APIKeyCleared() bool {
  36808. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  36809. return ok
  36810. }
  36811. // ResetAPIKey resets all changes to the "api_key" field.
  36812. func (m *WhatsappMutation) ResetAPIKey() {
  36813. m.api_key = nil
  36814. delete(m.clearedFields, whatsapp.FieldAPIKey)
  36815. }
  36816. // SetAllowList sets the "allow_list" field.
  36817. func (m *WhatsappMutation) SetAllowList(s []string) {
  36818. m.allow_list = &s
  36819. m.appendallow_list = nil
  36820. }
  36821. // AllowList returns the value of the "allow_list" field in the mutation.
  36822. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  36823. v := m.allow_list
  36824. if v == nil {
  36825. return
  36826. }
  36827. return *v, true
  36828. }
  36829. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  36830. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36832. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  36833. if !m.op.Is(OpUpdateOne) {
  36834. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  36835. }
  36836. if m.id == nil || m.oldValue == nil {
  36837. return v, errors.New("OldAllowList requires an ID field in the mutation")
  36838. }
  36839. oldValue, err := m.oldValue(ctx)
  36840. if err != nil {
  36841. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  36842. }
  36843. return oldValue.AllowList, nil
  36844. }
  36845. // AppendAllowList adds s to the "allow_list" field.
  36846. func (m *WhatsappMutation) AppendAllowList(s []string) {
  36847. m.appendallow_list = append(m.appendallow_list, s...)
  36848. }
  36849. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  36850. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  36851. if len(m.appendallow_list) == 0 {
  36852. return nil, false
  36853. }
  36854. return m.appendallow_list, true
  36855. }
  36856. // ClearAllowList clears the value of the "allow_list" field.
  36857. func (m *WhatsappMutation) ClearAllowList() {
  36858. m.allow_list = nil
  36859. m.appendallow_list = nil
  36860. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  36861. }
  36862. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  36863. func (m *WhatsappMutation) AllowListCleared() bool {
  36864. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  36865. return ok
  36866. }
  36867. // ResetAllowList resets all changes to the "allow_list" field.
  36868. func (m *WhatsappMutation) ResetAllowList() {
  36869. m.allow_list = nil
  36870. m.appendallow_list = nil
  36871. delete(m.clearedFields, whatsapp.FieldAllowList)
  36872. }
  36873. // SetGroupAllowList sets the "group_allow_list" field.
  36874. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  36875. m.group_allow_list = &s
  36876. m.appendgroup_allow_list = nil
  36877. }
  36878. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  36879. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  36880. v := m.group_allow_list
  36881. if v == nil {
  36882. return
  36883. }
  36884. return *v, true
  36885. }
  36886. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  36887. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36889. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  36890. if !m.op.Is(OpUpdateOne) {
  36891. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  36892. }
  36893. if m.id == nil || m.oldValue == nil {
  36894. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  36895. }
  36896. oldValue, err := m.oldValue(ctx)
  36897. if err != nil {
  36898. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  36899. }
  36900. return oldValue.GroupAllowList, nil
  36901. }
  36902. // AppendGroupAllowList adds s to the "group_allow_list" field.
  36903. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  36904. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  36905. }
  36906. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  36907. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  36908. if len(m.appendgroup_allow_list) == 0 {
  36909. return nil, false
  36910. }
  36911. return m.appendgroup_allow_list, true
  36912. }
  36913. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  36914. func (m *WhatsappMutation) ClearGroupAllowList() {
  36915. m.group_allow_list = nil
  36916. m.appendgroup_allow_list = nil
  36917. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  36918. }
  36919. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  36920. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  36921. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  36922. return ok
  36923. }
  36924. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  36925. func (m *WhatsappMutation) ResetGroupAllowList() {
  36926. m.group_allow_list = nil
  36927. m.appendgroup_allow_list = nil
  36928. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  36929. }
  36930. // SetBlockList sets the "block_list" field.
  36931. func (m *WhatsappMutation) SetBlockList(s []string) {
  36932. m.block_list = &s
  36933. m.appendblock_list = nil
  36934. }
  36935. // BlockList returns the value of the "block_list" field in the mutation.
  36936. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  36937. v := m.block_list
  36938. if v == nil {
  36939. return
  36940. }
  36941. return *v, true
  36942. }
  36943. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  36944. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36946. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  36947. if !m.op.Is(OpUpdateOne) {
  36948. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  36949. }
  36950. if m.id == nil || m.oldValue == nil {
  36951. return v, errors.New("OldBlockList requires an ID field in the mutation")
  36952. }
  36953. oldValue, err := m.oldValue(ctx)
  36954. if err != nil {
  36955. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  36956. }
  36957. return oldValue.BlockList, nil
  36958. }
  36959. // AppendBlockList adds s to the "block_list" field.
  36960. func (m *WhatsappMutation) AppendBlockList(s []string) {
  36961. m.appendblock_list = append(m.appendblock_list, s...)
  36962. }
  36963. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  36964. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  36965. if len(m.appendblock_list) == 0 {
  36966. return nil, false
  36967. }
  36968. return m.appendblock_list, true
  36969. }
  36970. // ClearBlockList clears the value of the "block_list" field.
  36971. func (m *WhatsappMutation) ClearBlockList() {
  36972. m.block_list = nil
  36973. m.appendblock_list = nil
  36974. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  36975. }
  36976. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  36977. func (m *WhatsappMutation) BlockListCleared() bool {
  36978. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  36979. return ok
  36980. }
  36981. // ResetBlockList resets all changes to the "block_list" field.
  36982. func (m *WhatsappMutation) ResetBlockList() {
  36983. m.block_list = nil
  36984. m.appendblock_list = nil
  36985. delete(m.clearedFields, whatsapp.FieldBlockList)
  36986. }
  36987. // SetGroupBlockList sets the "group_block_list" field.
  36988. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  36989. m.group_block_list = &s
  36990. m.appendgroup_block_list = nil
  36991. }
  36992. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  36993. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  36994. v := m.group_block_list
  36995. if v == nil {
  36996. return
  36997. }
  36998. return *v, true
  36999. }
  37000. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  37001. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37003. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  37004. if !m.op.Is(OpUpdateOne) {
  37005. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  37006. }
  37007. if m.id == nil || m.oldValue == nil {
  37008. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  37009. }
  37010. oldValue, err := m.oldValue(ctx)
  37011. if err != nil {
  37012. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  37013. }
  37014. return oldValue.GroupBlockList, nil
  37015. }
  37016. // AppendGroupBlockList adds s to the "group_block_list" field.
  37017. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  37018. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  37019. }
  37020. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  37021. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  37022. if len(m.appendgroup_block_list) == 0 {
  37023. return nil, false
  37024. }
  37025. return m.appendgroup_block_list, true
  37026. }
  37027. // ClearGroupBlockList clears the value of the "group_block_list" field.
  37028. func (m *WhatsappMutation) ClearGroupBlockList() {
  37029. m.group_block_list = nil
  37030. m.appendgroup_block_list = nil
  37031. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  37032. }
  37033. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  37034. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  37035. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  37036. return ok
  37037. }
  37038. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  37039. func (m *WhatsappMutation) ResetGroupBlockList() {
  37040. m.group_block_list = nil
  37041. m.appendgroup_block_list = nil
  37042. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  37043. }
  37044. // ClearAgent clears the "agent" edge to the Agent entity.
  37045. func (m *WhatsappMutation) ClearAgent() {
  37046. m.clearedagent = true
  37047. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  37048. }
  37049. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  37050. func (m *WhatsappMutation) AgentCleared() bool {
  37051. return m.clearedagent
  37052. }
  37053. // AgentIDs returns the "agent" edge IDs in the mutation.
  37054. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37055. // AgentID instead. It exists only for internal usage by the builders.
  37056. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  37057. if id := m.agent; id != nil {
  37058. ids = append(ids, *id)
  37059. }
  37060. return
  37061. }
  37062. // ResetAgent resets all changes to the "agent" edge.
  37063. func (m *WhatsappMutation) ResetAgent() {
  37064. m.agent = nil
  37065. m.clearedagent = false
  37066. }
  37067. // Where appends a list predicates to the WhatsappMutation builder.
  37068. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  37069. m.predicates = append(m.predicates, ps...)
  37070. }
  37071. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  37072. // users can use type-assertion to append predicates that do not depend on any generated package.
  37073. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  37074. p := make([]predicate.Whatsapp, len(ps))
  37075. for i := range ps {
  37076. p[i] = ps[i]
  37077. }
  37078. m.Where(p...)
  37079. }
  37080. // Op returns the operation name.
  37081. func (m *WhatsappMutation) Op() Op {
  37082. return m.op
  37083. }
  37084. // SetOp allows setting the mutation operation.
  37085. func (m *WhatsappMutation) SetOp(op Op) {
  37086. m.op = op
  37087. }
  37088. // Type returns the node type of this mutation (Whatsapp).
  37089. func (m *WhatsappMutation) Type() string {
  37090. return m.typ
  37091. }
  37092. // Fields returns all fields that were changed during this mutation. Note that in
  37093. // order to get all numeric fields that were incremented/decremented, call
  37094. // AddedFields().
  37095. func (m *WhatsappMutation) Fields() []string {
  37096. fields := make([]string, 0, 21)
  37097. if m.created_at != nil {
  37098. fields = append(fields, whatsapp.FieldCreatedAt)
  37099. }
  37100. if m.updated_at != nil {
  37101. fields = append(fields, whatsapp.FieldUpdatedAt)
  37102. }
  37103. if m.status != nil {
  37104. fields = append(fields, whatsapp.FieldStatus)
  37105. }
  37106. if m.deleted_at != nil {
  37107. fields = append(fields, whatsapp.FieldDeletedAt)
  37108. }
  37109. if m.wa_id != nil {
  37110. fields = append(fields, whatsapp.FieldWaID)
  37111. }
  37112. if m.wa_name != nil {
  37113. fields = append(fields, whatsapp.FieldWaName)
  37114. }
  37115. if m.callback != nil {
  37116. fields = append(fields, whatsapp.FieldCallback)
  37117. }
  37118. if m.agent != nil {
  37119. fields = append(fields, whatsapp.FieldAgentID)
  37120. }
  37121. if m.account != nil {
  37122. fields = append(fields, whatsapp.FieldAccount)
  37123. }
  37124. if m.cc != nil {
  37125. fields = append(fields, whatsapp.FieldCc)
  37126. }
  37127. if m.phone != nil {
  37128. fields = append(fields, whatsapp.FieldPhone)
  37129. }
  37130. if m.cc_phone != nil {
  37131. fields = append(fields, whatsapp.FieldCcPhone)
  37132. }
  37133. if m.phone_name != nil {
  37134. fields = append(fields, whatsapp.FieldPhoneName)
  37135. }
  37136. if m.phone_status != nil {
  37137. fields = append(fields, whatsapp.FieldPhoneStatus)
  37138. }
  37139. if m.organization_id != nil {
  37140. fields = append(fields, whatsapp.FieldOrganizationID)
  37141. }
  37142. if m.api_base != nil {
  37143. fields = append(fields, whatsapp.FieldAPIBase)
  37144. }
  37145. if m.api_key != nil {
  37146. fields = append(fields, whatsapp.FieldAPIKey)
  37147. }
  37148. if m.allow_list != nil {
  37149. fields = append(fields, whatsapp.FieldAllowList)
  37150. }
  37151. if m.group_allow_list != nil {
  37152. fields = append(fields, whatsapp.FieldGroupAllowList)
  37153. }
  37154. if m.block_list != nil {
  37155. fields = append(fields, whatsapp.FieldBlockList)
  37156. }
  37157. if m.group_block_list != nil {
  37158. fields = append(fields, whatsapp.FieldGroupBlockList)
  37159. }
  37160. return fields
  37161. }
  37162. // Field returns the value of a field with the given name. The second boolean
  37163. // return value indicates that this field was not set, or was not defined in the
  37164. // schema.
  37165. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37166. switch name {
  37167. case whatsapp.FieldCreatedAt:
  37168. return m.CreatedAt()
  37169. case whatsapp.FieldUpdatedAt:
  37170. return m.UpdatedAt()
  37171. case whatsapp.FieldStatus:
  37172. return m.Status()
  37173. case whatsapp.FieldDeletedAt:
  37174. return m.DeletedAt()
  37175. case whatsapp.FieldWaID:
  37176. return m.WaID()
  37177. case whatsapp.FieldWaName:
  37178. return m.WaName()
  37179. case whatsapp.FieldCallback:
  37180. return m.Callback()
  37181. case whatsapp.FieldAgentID:
  37182. return m.AgentID()
  37183. case whatsapp.FieldAccount:
  37184. return m.Account()
  37185. case whatsapp.FieldCc:
  37186. return m.Cc()
  37187. case whatsapp.FieldPhone:
  37188. return m.Phone()
  37189. case whatsapp.FieldCcPhone:
  37190. return m.CcPhone()
  37191. case whatsapp.FieldPhoneName:
  37192. return m.PhoneName()
  37193. case whatsapp.FieldPhoneStatus:
  37194. return m.PhoneStatus()
  37195. case whatsapp.FieldOrganizationID:
  37196. return m.OrganizationID()
  37197. case whatsapp.FieldAPIBase:
  37198. return m.APIBase()
  37199. case whatsapp.FieldAPIKey:
  37200. return m.APIKey()
  37201. case whatsapp.FieldAllowList:
  37202. return m.AllowList()
  37203. case whatsapp.FieldGroupAllowList:
  37204. return m.GroupAllowList()
  37205. case whatsapp.FieldBlockList:
  37206. return m.BlockList()
  37207. case whatsapp.FieldGroupBlockList:
  37208. return m.GroupBlockList()
  37209. }
  37210. return nil, false
  37211. }
  37212. // OldField returns the old value of the field from the database. An error is
  37213. // returned if the mutation operation is not UpdateOne, or the query to the
  37214. // database failed.
  37215. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37216. switch name {
  37217. case whatsapp.FieldCreatedAt:
  37218. return m.OldCreatedAt(ctx)
  37219. case whatsapp.FieldUpdatedAt:
  37220. return m.OldUpdatedAt(ctx)
  37221. case whatsapp.FieldStatus:
  37222. return m.OldStatus(ctx)
  37223. case whatsapp.FieldDeletedAt:
  37224. return m.OldDeletedAt(ctx)
  37225. case whatsapp.FieldWaID:
  37226. return m.OldWaID(ctx)
  37227. case whatsapp.FieldWaName:
  37228. return m.OldWaName(ctx)
  37229. case whatsapp.FieldCallback:
  37230. return m.OldCallback(ctx)
  37231. case whatsapp.FieldAgentID:
  37232. return m.OldAgentID(ctx)
  37233. case whatsapp.FieldAccount:
  37234. return m.OldAccount(ctx)
  37235. case whatsapp.FieldCc:
  37236. return m.OldCc(ctx)
  37237. case whatsapp.FieldPhone:
  37238. return m.OldPhone(ctx)
  37239. case whatsapp.FieldCcPhone:
  37240. return m.OldCcPhone(ctx)
  37241. case whatsapp.FieldPhoneName:
  37242. return m.OldPhoneName(ctx)
  37243. case whatsapp.FieldPhoneStatus:
  37244. return m.OldPhoneStatus(ctx)
  37245. case whatsapp.FieldOrganizationID:
  37246. return m.OldOrganizationID(ctx)
  37247. case whatsapp.FieldAPIBase:
  37248. return m.OldAPIBase(ctx)
  37249. case whatsapp.FieldAPIKey:
  37250. return m.OldAPIKey(ctx)
  37251. case whatsapp.FieldAllowList:
  37252. return m.OldAllowList(ctx)
  37253. case whatsapp.FieldGroupAllowList:
  37254. return m.OldGroupAllowList(ctx)
  37255. case whatsapp.FieldBlockList:
  37256. return m.OldBlockList(ctx)
  37257. case whatsapp.FieldGroupBlockList:
  37258. return m.OldGroupBlockList(ctx)
  37259. }
  37260. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37261. }
  37262. // SetField sets the value of a field with the given name. It returns an error if
  37263. // the field is not defined in the schema, or if the type mismatched the field
  37264. // type.
  37265. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37266. switch name {
  37267. case whatsapp.FieldCreatedAt:
  37268. v, ok := value.(time.Time)
  37269. if !ok {
  37270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37271. }
  37272. m.SetCreatedAt(v)
  37273. return nil
  37274. case whatsapp.FieldUpdatedAt:
  37275. v, ok := value.(time.Time)
  37276. if !ok {
  37277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37278. }
  37279. m.SetUpdatedAt(v)
  37280. return nil
  37281. case whatsapp.FieldStatus:
  37282. v, ok := value.(uint8)
  37283. if !ok {
  37284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37285. }
  37286. m.SetStatus(v)
  37287. return nil
  37288. case whatsapp.FieldDeletedAt:
  37289. v, ok := value.(time.Time)
  37290. if !ok {
  37291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37292. }
  37293. m.SetDeletedAt(v)
  37294. return nil
  37295. case whatsapp.FieldWaID:
  37296. v, ok := value.(string)
  37297. if !ok {
  37298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37299. }
  37300. m.SetWaID(v)
  37301. return nil
  37302. case whatsapp.FieldWaName:
  37303. v, ok := value.(string)
  37304. if !ok {
  37305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37306. }
  37307. m.SetWaName(v)
  37308. return nil
  37309. case whatsapp.FieldCallback:
  37310. v, ok := value.(string)
  37311. if !ok {
  37312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37313. }
  37314. m.SetCallback(v)
  37315. return nil
  37316. case whatsapp.FieldAgentID:
  37317. v, ok := value.(uint64)
  37318. if !ok {
  37319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37320. }
  37321. m.SetAgentID(v)
  37322. return nil
  37323. case whatsapp.FieldAccount:
  37324. v, ok := value.(string)
  37325. if !ok {
  37326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37327. }
  37328. m.SetAccount(v)
  37329. return nil
  37330. case whatsapp.FieldCc:
  37331. v, ok := value.(string)
  37332. if !ok {
  37333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37334. }
  37335. m.SetCc(v)
  37336. return nil
  37337. case whatsapp.FieldPhone:
  37338. v, ok := value.(string)
  37339. if !ok {
  37340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37341. }
  37342. m.SetPhone(v)
  37343. return nil
  37344. case whatsapp.FieldCcPhone:
  37345. v, ok := value.(string)
  37346. if !ok {
  37347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37348. }
  37349. m.SetCcPhone(v)
  37350. return nil
  37351. case whatsapp.FieldPhoneName:
  37352. v, ok := value.(string)
  37353. if !ok {
  37354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37355. }
  37356. m.SetPhoneName(v)
  37357. return nil
  37358. case whatsapp.FieldPhoneStatus:
  37359. v, ok := value.(int8)
  37360. if !ok {
  37361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37362. }
  37363. m.SetPhoneStatus(v)
  37364. return nil
  37365. case whatsapp.FieldOrganizationID:
  37366. v, ok := value.(uint64)
  37367. if !ok {
  37368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37369. }
  37370. m.SetOrganizationID(v)
  37371. return nil
  37372. case whatsapp.FieldAPIBase:
  37373. v, ok := value.(string)
  37374. if !ok {
  37375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37376. }
  37377. m.SetAPIBase(v)
  37378. return nil
  37379. case whatsapp.FieldAPIKey:
  37380. v, ok := value.(string)
  37381. if !ok {
  37382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37383. }
  37384. m.SetAPIKey(v)
  37385. return nil
  37386. case whatsapp.FieldAllowList:
  37387. v, ok := value.([]string)
  37388. if !ok {
  37389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37390. }
  37391. m.SetAllowList(v)
  37392. return nil
  37393. case whatsapp.FieldGroupAllowList:
  37394. v, ok := value.([]string)
  37395. if !ok {
  37396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37397. }
  37398. m.SetGroupAllowList(v)
  37399. return nil
  37400. case whatsapp.FieldBlockList:
  37401. v, ok := value.([]string)
  37402. if !ok {
  37403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37404. }
  37405. m.SetBlockList(v)
  37406. return nil
  37407. case whatsapp.FieldGroupBlockList:
  37408. v, ok := value.([]string)
  37409. if !ok {
  37410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37411. }
  37412. m.SetGroupBlockList(v)
  37413. return nil
  37414. }
  37415. return fmt.Errorf("unknown Whatsapp field %s", name)
  37416. }
  37417. // AddedFields returns all numeric fields that were incremented/decremented during
  37418. // this mutation.
  37419. func (m *WhatsappMutation) AddedFields() []string {
  37420. var fields []string
  37421. if m.addstatus != nil {
  37422. fields = append(fields, whatsapp.FieldStatus)
  37423. }
  37424. if m.addphone_status != nil {
  37425. fields = append(fields, whatsapp.FieldPhoneStatus)
  37426. }
  37427. if m.addorganization_id != nil {
  37428. fields = append(fields, whatsapp.FieldOrganizationID)
  37429. }
  37430. return fields
  37431. }
  37432. // AddedField returns the numeric value that was incremented/decremented on a field
  37433. // with the given name. The second boolean return value indicates that this field
  37434. // was not set, or was not defined in the schema.
  37435. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37436. switch name {
  37437. case whatsapp.FieldStatus:
  37438. return m.AddedStatus()
  37439. case whatsapp.FieldPhoneStatus:
  37440. return m.AddedPhoneStatus()
  37441. case whatsapp.FieldOrganizationID:
  37442. return m.AddedOrganizationID()
  37443. }
  37444. return nil, false
  37445. }
  37446. // AddField adds the value to the field with the given name. It returns an error if
  37447. // the field is not defined in the schema, or if the type mismatched the field
  37448. // type.
  37449. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37450. switch name {
  37451. case whatsapp.FieldStatus:
  37452. v, ok := value.(int8)
  37453. if !ok {
  37454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37455. }
  37456. m.AddStatus(v)
  37457. return nil
  37458. case whatsapp.FieldPhoneStatus:
  37459. v, ok := value.(int8)
  37460. if !ok {
  37461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37462. }
  37463. m.AddPhoneStatus(v)
  37464. return nil
  37465. case whatsapp.FieldOrganizationID:
  37466. v, ok := value.(int64)
  37467. if !ok {
  37468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37469. }
  37470. m.AddOrganizationID(v)
  37471. return nil
  37472. }
  37473. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37474. }
  37475. // ClearedFields returns all nullable fields that were cleared during this
  37476. // mutation.
  37477. func (m *WhatsappMutation) ClearedFields() []string {
  37478. var fields []string
  37479. if m.FieldCleared(whatsapp.FieldStatus) {
  37480. fields = append(fields, whatsapp.FieldStatus)
  37481. }
  37482. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37483. fields = append(fields, whatsapp.FieldDeletedAt)
  37484. }
  37485. if m.FieldCleared(whatsapp.FieldWaID) {
  37486. fields = append(fields, whatsapp.FieldWaID)
  37487. }
  37488. if m.FieldCleared(whatsapp.FieldWaName) {
  37489. fields = append(fields, whatsapp.FieldWaName)
  37490. }
  37491. if m.FieldCleared(whatsapp.FieldCallback) {
  37492. fields = append(fields, whatsapp.FieldCallback)
  37493. }
  37494. if m.FieldCleared(whatsapp.FieldAccount) {
  37495. fields = append(fields, whatsapp.FieldAccount)
  37496. }
  37497. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37498. fields = append(fields, whatsapp.FieldOrganizationID)
  37499. }
  37500. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37501. fields = append(fields, whatsapp.FieldAPIBase)
  37502. }
  37503. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37504. fields = append(fields, whatsapp.FieldAPIKey)
  37505. }
  37506. if m.FieldCleared(whatsapp.FieldAllowList) {
  37507. fields = append(fields, whatsapp.FieldAllowList)
  37508. }
  37509. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37510. fields = append(fields, whatsapp.FieldGroupAllowList)
  37511. }
  37512. if m.FieldCleared(whatsapp.FieldBlockList) {
  37513. fields = append(fields, whatsapp.FieldBlockList)
  37514. }
  37515. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37516. fields = append(fields, whatsapp.FieldGroupBlockList)
  37517. }
  37518. return fields
  37519. }
  37520. // FieldCleared returns a boolean indicating if a field with the given name was
  37521. // cleared in this mutation.
  37522. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37523. _, ok := m.clearedFields[name]
  37524. return ok
  37525. }
  37526. // ClearField clears the value of the field with the given name. It returns an
  37527. // error if the field is not defined in the schema.
  37528. func (m *WhatsappMutation) ClearField(name string) error {
  37529. switch name {
  37530. case whatsapp.FieldStatus:
  37531. m.ClearStatus()
  37532. return nil
  37533. case whatsapp.FieldDeletedAt:
  37534. m.ClearDeletedAt()
  37535. return nil
  37536. case whatsapp.FieldWaID:
  37537. m.ClearWaID()
  37538. return nil
  37539. case whatsapp.FieldWaName:
  37540. m.ClearWaName()
  37541. return nil
  37542. case whatsapp.FieldCallback:
  37543. m.ClearCallback()
  37544. return nil
  37545. case whatsapp.FieldAccount:
  37546. m.ClearAccount()
  37547. return nil
  37548. case whatsapp.FieldOrganizationID:
  37549. m.ClearOrganizationID()
  37550. return nil
  37551. case whatsapp.FieldAPIBase:
  37552. m.ClearAPIBase()
  37553. return nil
  37554. case whatsapp.FieldAPIKey:
  37555. m.ClearAPIKey()
  37556. return nil
  37557. case whatsapp.FieldAllowList:
  37558. m.ClearAllowList()
  37559. return nil
  37560. case whatsapp.FieldGroupAllowList:
  37561. m.ClearGroupAllowList()
  37562. return nil
  37563. case whatsapp.FieldBlockList:
  37564. m.ClearBlockList()
  37565. return nil
  37566. case whatsapp.FieldGroupBlockList:
  37567. m.ClearGroupBlockList()
  37568. return nil
  37569. }
  37570. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37571. }
  37572. // ResetField resets all changes in the mutation for the field with the given name.
  37573. // It returns an error if the field is not defined in the schema.
  37574. func (m *WhatsappMutation) ResetField(name string) error {
  37575. switch name {
  37576. case whatsapp.FieldCreatedAt:
  37577. m.ResetCreatedAt()
  37578. return nil
  37579. case whatsapp.FieldUpdatedAt:
  37580. m.ResetUpdatedAt()
  37581. return nil
  37582. case whatsapp.FieldStatus:
  37583. m.ResetStatus()
  37584. return nil
  37585. case whatsapp.FieldDeletedAt:
  37586. m.ResetDeletedAt()
  37587. return nil
  37588. case whatsapp.FieldWaID:
  37589. m.ResetWaID()
  37590. return nil
  37591. case whatsapp.FieldWaName:
  37592. m.ResetWaName()
  37593. return nil
  37594. case whatsapp.FieldCallback:
  37595. m.ResetCallback()
  37596. return nil
  37597. case whatsapp.FieldAgentID:
  37598. m.ResetAgentID()
  37599. return nil
  37600. case whatsapp.FieldAccount:
  37601. m.ResetAccount()
  37602. return nil
  37603. case whatsapp.FieldCc:
  37604. m.ResetCc()
  37605. return nil
  37606. case whatsapp.FieldPhone:
  37607. m.ResetPhone()
  37608. return nil
  37609. case whatsapp.FieldCcPhone:
  37610. m.ResetCcPhone()
  37611. return nil
  37612. case whatsapp.FieldPhoneName:
  37613. m.ResetPhoneName()
  37614. return nil
  37615. case whatsapp.FieldPhoneStatus:
  37616. m.ResetPhoneStatus()
  37617. return nil
  37618. case whatsapp.FieldOrganizationID:
  37619. m.ResetOrganizationID()
  37620. return nil
  37621. case whatsapp.FieldAPIBase:
  37622. m.ResetAPIBase()
  37623. return nil
  37624. case whatsapp.FieldAPIKey:
  37625. m.ResetAPIKey()
  37626. return nil
  37627. case whatsapp.FieldAllowList:
  37628. m.ResetAllowList()
  37629. return nil
  37630. case whatsapp.FieldGroupAllowList:
  37631. m.ResetGroupAllowList()
  37632. return nil
  37633. case whatsapp.FieldBlockList:
  37634. m.ResetBlockList()
  37635. return nil
  37636. case whatsapp.FieldGroupBlockList:
  37637. m.ResetGroupBlockList()
  37638. return nil
  37639. }
  37640. return fmt.Errorf("unknown Whatsapp field %s", name)
  37641. }
  37642. // AddedEdges returns all edge names that were set/added in this mutation.
  37643. func (m *WhatsappMutation) AddedEdges() []string {
  37644. edges := make([]string, 0, 1)
  37645. if m.agent != nil {
  37646. edges = append(edges, whatsapp.EdgeAgent)
  37647. }
  37648. return edges
  37649. }
  37650. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37651. // name in this mutation.
  37652. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  37653. switch name {
  37654. case whatsapp.EdgeAgent:
  37655. if id := m.agent; id != nil {
  37656. return []ent.Value{*id}
  37657. }
  37658. }
  37659. return nil
  37660. }
  37661. // RemovedEdges returns all edge names that were removed in this mutation.
  37662. func (m *WhatsappMutation) RemovedEdges() []string {
  37663. edges := make([]string, 0, 1)
  37664. return edges
  37665. }
  37666. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37667. // the given name in this mutation.
  37668. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  37669. return nil
  37670. }
  37671. // ClearedEdges returns all edge names that were cleared in this mutation.
  37672. func (m *WhatsappMutation) ClearedEdges() []string {
  37673. edges := make([]string, 0, 1)
  37674. if m.clearedagent {
  37675. edges = append(edges, whatsapp.EdgeAgent)
  37676. }
  37677. return edges
  37678. }
  37679. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37680. // was cleared in this mutation.
  37681. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  37682. switch name {
  37683. case whatsapp.EdgeAgent:
  37684. return m.clearedagent
  37685. }
  37686. return false
  37687. }
  37688. // ClearEdge clears the value of the edge with the given name. It returns an error
  37689. // if that edge is not defined in the schema.
  37690. func (m *WhatsappMutation) ClearEdge(name string) error {
  37691. switch name {
  37692. case whatsapp.EdgeAgent:
  37693. m.ClearAgent()
  37694. return nil
  37695. }
  37696. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  37697. }
  37698. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37699. // It returns an error if the edge is not defined in the schema.
  37700. func (m *WhatsappMutation) ResetEdge(name string) error {
  37701. switch name {
  37702. case whatsapp.EdgeAgent:
  37703. m.ResetAgent()
  37704. return nil
  37705. }
  37706. return fmt.Errorf("unknown Whatsapp edge %s", name)
  37707. }
  37708. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  37709. type WhatsappChannelMutation struct {
  37710. config
  37711. op Op
  37712. typ string
  37713. id *uint64
  37714. created_at *time.Time
  37715. updated_at *time.Time
  37716. status *uint8
  37717. addstatus *int8
  37718. deleted_at *time.Time
  37719. ak *string
  37720. sk *string
  37721. wa_id *string
  37722. wa_name *string
  37723. waba_id *uint64
  37724. addwaba_id *int64
  37725. business_id *uint64
  37726. addbusiness_id *int64
  37727. organization_id *uint64
  37728. addorganization_id *int64
  37729. verify_account *string
  37730. clearedFields map[string]struct{}
  37731. done bool
  37732. oldValue func(context.Context) (*WhatsappChannel, error)
  37733. predicates []predicate.WhatsappChannel
  37734. }
  37735. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  37736. // whatsappchannelOption allows management of the mutation configuration using functional options.
  37737. type whatsappchannelOption func(*WhatsappChannelMutation)
  37738. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  37739. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  37740. m := &WhatsappChannelMutation{
  37741. config: c,
  37742. op: op,
  37743. typ: TypeWhatsappChannel,
  37744. clearedFields: make(map[string]struct{}),
  37745. }
  37746. for _, opt := range opts {
  37747. opt(m)
  37748. }
  37749. return m
  37750. }
  37751. // withWhatsappChannelID sets the ID field of the mutation.
  37752. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  37753. return func(m *WhatsappChannelMutation) {
  37754. var (
  37755. err error
  37756. once sync.Once
  37757. value *WhatsappChannel
  37758. )
  37759. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  37760. once.Do(func() {
  37761. if m.done {
  37762. err = errors.New("querying old values post mutation is not allowed")
  37763. } else {
  37764. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  37765. }
  37766. })
  37767. return value, err
  37768. }
  37769. m.id = &id
  37770. }
  37771. }
  37772. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  37773. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  37774. return func(m *WhatsappChannelMutation) {
  37775. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  37776. return node, nil
  37777. }
  37778. m.id = &node.ID
  37779. }
  37780. }
  37781. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37782. // executed in a transaction (ent.Tx), a transactional client is returned.
  37783. func (m WhatsappChannelMutation) Client() *Client {
  37784. client := &Client{config: m.config}
  37785. client.init()
  37786. return client
  37787. }
  37788. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37789. // it returns an error otherwise.
  37790. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  37791. if _, ok := m.driver.(*txDriver); !ok {
  37792. return nil, errors.New("ent: mutation is not running in a transaction")
  37793. }
  37794. tx := &Tx{config: m.config}
  37795. tx.init()
  37796. return tx, nil
  37797. }
  37798. // SetID sets the value of the id field. Note that this
  37799. // operation is only accepted on creation of WhatsappChannel entities.
  37800. func (m *WhatsappChannelMutation) SetID(id uint64) {
  37801. m.id = &id
  37802. }
  37803. // ID returns the ID value in the mutation. Note that the ID is only available
  37804. // if it was provided to the builder or after it was returned from the database.
  37805. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  37806. if m.id == nil {
  37807. return
  37808. }
  37809. return *m.id, true
  37810. }
  37811. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37812. // That means, if the mutation is applied within a transaction with an isolation level such
  37813. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37814. // or updated by the mutation.
  37815. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  37816. switch {
  37817. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37818. id, exists := m.ID()
  37819. if exists {
  37820. return []uint64{id}, nil
  37821. }
  37822. fallthrough
  37823. case m.op.Is(OpUpdate | OpDelete):
  37824. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  37825. default:
  37826. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37827. }
  37828. }
  37829. // SetCreatedAt sets the "created_at" field.
  37830. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  37831. m.created_at = &t
  37832. }
  37833. // CreatedAt returns the value of the "created_at" field in the mutation.
  37834. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  37835. v := m.created_at
  37836. if v == nil {
  37837. return
  37838. }
  37839. return *v, true
  37840. }
  37841. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  37842. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37844. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37845. if !m.op.Is(OpUpdateOne) {
  37846. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37847. }
  37848. if m.id == nil || m.oldValue == nil {
  37849. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37850. }
  37851. oldValue, err := m.oldValue(ctx)
  37852. if err != nil {
  37853. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37854. }
  37855. return oldValue.CreatedAt, nil
  37856. }
  37857. // ResetCreatedAt resets all changes to the "created_at" field.
  37858. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  37859. m.created_at = nil
  37860. }
  37861. // SetUpdatedAt sets the "updated_at" field.
  37862. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  37863. m.updated_at = &t
  37864. }
  37865. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37866. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  37867. v := m.updated_at
  37868. if v == nil {
  37869. return
  37870. }
  37871. return *v, true
  37872. }
  37873. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  37874. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37876. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37877. if !m.op.Is(OpUpdateOne) {
  37878. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37879. }
  37880. if m.id == nil || m.oldValue == nil {
  37881. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37882. }
  37883. oldValue, err := m.oldValue(ctx)
  37884. if err != nil {
  37885. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37886. }
  37887. return oldValue.UpdatedAt, nil
  37888. }
  37889. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37890. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  37891. m.updated_at = nil
  37892. }
  37893. // SetStatus sets the "status" field.
  37894. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  37895. m.status = &u
  37896. m.addstatus = nil
  37897. }
  37898. // Status returns the value of the "status" field in the mutation.
  37899. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  37900. v := m.status
  37901. if v == nil {
  37902. return
  37903. }
  37904. return *v, true
  37905. }
  37906. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  37907. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37909. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37910. if !m.op.Is(OpUpdateOne) {
  37911. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37912. }
  37913. if m.id == nil || m.oldValue == nil {
  37914. return v, errors.New("OldStatus requires an ID field in the mutation")
  37915. }
  37916. oldValue, err := m.oldValue(ctx)
  37917. if err != nil {
  37918. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37919. }
  37920. return oldValue.Status, nil
  37921. }
  37922. // AddStatus adds u to the "status" field.
  37923. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  37924. if m.addstatus != nil {
  37925. *m.addstatus += u
  37926. } else {
  37927. m.addstatus = &u
  37928. }
  37929. }
  37930. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37931. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  37932. v := m.addstatus
  37933. if v == nil {
  37934. return
  37935. }
  37936. return *v, true
  37937. }
  37938. // ClearStatus clears the value of the "status" field.
  37939. func (m *WhatsappChannelMutation) ClearStatus() {
  37940. m.status = nil
  37941. m.addstatus = nil
  37942. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  37943. }
  37944. // StatusCleared returns if the "status" field was cleared in this mutation.
  37945. func (m *WhatsappChannelMutation) StatusCleared() bool {
  37946. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  37947. return ok
  37948. }
  37949. // ResetStatus resets all changes to the "status" field.
  37950. func (m *WhatsappChannelMutation) ResetStatus() {
  37951. m.status = nil
  37952. m.addstatus = nil
  37953. delete(m.clearedFields, whatsappchannel.FieldStatus)
  37954. }
  37955. // SetDeletedAt sets the "deleted_at" field.
  37956. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  37957. m.deleted_at = &t
  37958. }
  37959. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37960. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  37961. v := m.deleted_at
  37962. if v == nil {
  37963. return
  37964. }
  37965. return *v, true
  37966. }
  37967. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  37968. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37970. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37971. if !m.op.Is(OpUpdateOne) {
  37972. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37973. }
  37974. if m.id == nil || m.oldValue == nil {
  37975. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37976. }
  37977. oldValue, err := m.oldValue(ctx)
  37978. if err != nil {
  37979. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37980. }
  37981. return oldValue.DeletedAt, nil
  37982. }
  37983. // ClearDeletedAt clears the value of the "deleted_at" field.
  37984. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  37985. m.deleted_at = nil
  37986. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  37987. }
  37988. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37989. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  37990. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  37991. return ok
  37992. }
  37993. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37994. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  37995. m.deleted_at = nil
  37996. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  37997. }
  37998. // SetAk sets the "ak" field.
  37999. func (m *WhatsappChannelMutation) SetAk(s string) {
  38000. m.ak = &s
  38001. }
  38002. // Ak returns the value of the "ak" field in the mutation.
  38003. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  38004. v := m.ak
  38005. if v == nil {
  38006. return
  38007. }
  38008. return *v, true
  38009. }
  38010. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  38011. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38013. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  38014. if !m.op.Is(OpUpdateOne) {
  38015. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  38016. }
  38017. if m.id == nil || m.oldValue == nil {
  38018. return v, errors.New("OldAk requires an ID field in the mutation")
  38019. }
  38020. oldValue, err := m.oldValue(ctx)
  38021. if err != nil {
  38022. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  38023. }
  38024. return oldValue.Ak, nil
  38025. }
  38026. // ClearAk clears the value of the "ak" field.
  38027. func (m *WhatsappChannelMutation) ClearAk() {
  38028. m.ak = nil
  38029. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  38030. }
  38031. // AkCleared returns if the "ak" field was cleared in this mutation.
  38032. func (m *WhatsappChannelMutation) AkCleared() bool {
  38033. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  38034. return ok
  38035. }
  38036. // ResetAk resets all changes to the "ak" field.
  38037. func (m *WhatsappChannelMutation) ResetAk() {
  38038. m.ak = nil
  38039. delete(m.clearedFields, whatsappchannel.FieldAk)
  38040. }
  38041. // SetSk sets the "sk" field.
  38042. func (m *WhatsappChannelMutation) SetSk(s string) {
  38043. m.sk = &s
  38044. }
  38045. // Sk returns the value of the "sk" field in the mutation.
  38046. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  38047. v := m.sk
  38048. if v == nil {
  38049. return
  38050. }
  38051. return *v, true
  38052. }
  38053. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  38054. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38056. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  38057. if !m.op.Is(OpUpdateOne) {
  38058. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  38059. }
  38060. if m.id == nil || m.oldValue == nil {
  38061. return v, errors.New("OldSk requires an ID field in the mutation")
  38062. }
  38063. oldValue, err := m.oldValue(ctx)
  38064. if err != nil {
  38065. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  38066. }
  38067. return oldValue.Sk, nil
  38068. }
  38069. // ResetSk resets all changes to the "sk" field.
  38070. func (m *WhatsappChannelMutation) ResetSk() {
  38071. m.sk = nil
  38072. }
  38073. // SetWaID sets the "wa_id" field.
  38074. func (m *WhatsappChannelMutation) SetWaID(s string) {
  38075. m.wa_id = &s
  38076. }
  38077. // WaID returns the value of the "wa_id" field in the mutation.
  38078. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38079. v := m.wa_id
  38080. if v == nil {
  38081. return
  38082. }
  38083. return *v, true
  38084. }
  38085. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38086. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38088. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38089. if !m.op.Is(OpUpdateOne) {
  38090. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38091. }
  38092. if m.id == nil || m.oldValue == nil {
  38093. return v, errors.New("OldWaID requires an ID field in the mutation")
  38094. }
  38095. oldValue, err := m.oldValue(ctx)
  38096. if err != nil {
  38097. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38098. }
  38099. return oldValue.WaID, nil
  38100. }
  38101. // ClearWaID clears the value of the "wa_id" field.
  38102. func (m *WhatsappChannelMutation) ClearWaID() {
  38103. m.wa_id = nil
  38104. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38105. }
  38106. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38107. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38108. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38109. return ok
  38110. }
  38111. // ResetWaID resets all changes to the "wa_id" field.
  38112. func (m *WhatsappChannelMutation) ResetWaID() {
  38113. m.wa_id = nil
  38114. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38115. }
  38116. // SetWaName sets the "wa_name" field.
  38117. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38118. m.wa_name = &s
  38119. }
  38120. // WaName returns the value of the "wa_name" field in the mutation.
  38121. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38122. v := m.wa_name
  38123. if v == nil {
  38124. return
  38125. }
  38126. return *v, true
  38127. }
  38128. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38129. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38131. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38132. if !m.op.Is(OpUpdateOne) {
  38133. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38134. }
  38135. if m.id == nil || m.oldValue == nil {
  38136. return v, errors.New("OldWaName requires an ID field in the mutation")
  38137. }
  38138. oldValue, err := m.oldValue(ctx)
  38139. if err != nil {
  38140. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38141. }
  38142. return oldValue.WaName, nil
  38143. }
  38144. // ClearWaName clears the value of the "wa_name" field.
  38145. func (m *WhatsappChannelMutation) ClearWaName() {
  38146. m.wa_name = nil
  38147. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38148. }
  38149. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38150. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38151. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38152. return ok
  38153. }
  38154. // ResetWaName resets all changes to the "wa_name" field.
  38155. func (m *WhatsappChannelMutation) ResetWaName() {
  38156. m.wa_name = nil
  38157. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38158. }
  38159. // SetWabaID sets the "waba_id" field.
  38160. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38161. m.waba_id = &u
  38162. m.addwaba_id = nil
  38163. }
  38164. // WabaID returns the value of the "waba_id" field in the mutation.
  38165. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38166. v := m.waba_id
  38167. if v == nil {
  38168. return
  38169. }
  38170. return *v, true
  38171. }
  38172. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38173. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38175. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38176. if !m.op.Is(OpUpdateOne) {
  38177. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38178. }
  38179. if m.id == nil || m.oldValue == nil {
  38180. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38181. }
  38182. oldValue, err := m.oldValue(ctx)
  38183. if err != nil {
  38184. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38185. }
  38186. return oldValue.WabaID, nil
  38187. }
  38188. // AddWabaID adds u to the "waba_id" field.
  38189. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38190. if m.addwaba_id != nil {
  38191. *m.addwaba_id += u
  38192. } else {
  38193. m.addwaba_id = &u
  38194. }
  38195. }
  38196. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38197. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38198. v := m.addwaba_id
  38199. if v == nil {
  38200. return
  38201. }
  38202. return *v, true
  38203. }
  38204. // ResetWabaID resets all changes to the "waba_id" field.
  38205. func (m *WhatsappChannelMutation) ResetWabaID() {
  38206. m.waba_id = nil
  38207. m.addwaba_id = nil
  38208. }
  38209. // SetBusinessID sets the "business_id" field.
  38210. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38211. m.business_id = &u
  38212. m.addbusiness_id = nil
  38213. }
  38214. // BusinessID returns the value of the "business_id" field in the mutation.
  38215. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38216. v := m.business_id
  38217. if v == nil {
  38218. return
  38219. }
  38220. return *v, true
  38221. }
  38222. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38223. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38225. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38226. if !m.op.Is(OpUpdateOne) {
  38227. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38228. }
  38229. if m.id == nil || m.oldValue == nil {
  38230. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38231. }
  38232. oldValue, err := m.oldValue(ctx)
  38233. if err != nil {
  38234. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38235. }
  38236. return oldValue.BusinessID, nil
  38237. }
  38238. // AddBusinessID adds u to the "business_id" field.
  38239. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38240. if m.addbusiness_id != nil {
  38241. *m.addbusiness_id += u
  38242. } else {
  38243. m.addbusiness_id = &u
  38244. }
  38245. }
  38246. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38247. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38248. v := m.addbusiness_id
  38249. if v == nil {
  38250. return
  38251. }
  38252. return *v, true
  38253. }
  38254. // ResetBusinessID resets all changes to the "business_id" field.
  38255. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38256. m.business_id = nil
  38257. m.addbusiness_id = nil
  38258. }
  38259. // SetOrganizationID sets the "organization_id" field.
  38260. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38261. m.organization_id = &u
  38262. m.addorganization_id = nil
  38263. }
  38264. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38265. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38266. v := m.organization_id
  38267. if v == nil {
  38268. return
  38269. }
  38270. return *v, true
  38271. }
  38272. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38273. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38275. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38276. if !m.op.Is(OpUpdateOne) {
  38277. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38278. }
  38279. if m.id == nil || m.oldValue == nil {
  38280. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38281. }
  38282. oldValue, err := m.oldValue(ctx)
  38283. if err != nil {
  38284. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38285. }
  38286. return oldValue.OrganizationID, nil
  38287. }
  38288. // AddOrganizationID adds u to the "organization_id" field.
  38289. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38290. if m.addorganization_id != nil {
  38291. *m.addorganization_id += u
  38292. } else {
  38293. m.addorganization_id = &u
  38294. }
  38295. }
  38296. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38297. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38298. v := m.addorganization_id
  38299. if v == nil {
  38300. return
  38301. }
  38302. return *v, true
  38303. }
  38304. // ClearOrganizationID clears the value of the "organization_id" field.
  38305. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38306. m.organization_id = nil
  38307. m.addorganization_id = nil
  38308. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38309. }
  38310. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38311. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38312. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38313. return ok
  38314. }
  38315. // ResetOrganizationID resets all changes to the "organization_id" field.
  38316. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38317. m.organization_id = nil
  38318. m.addorganization_id = nil
  38319. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38320. }
  38321. // SetVerifyAccount sets the "verify_account" field.
  38322. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38323. m.verify_account = &s
  38324. }
  38325. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38326. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38327. v := m.verify_account
  38328. if v == nil {
  38329. return
  38330. }
  38331. return *v, true
  38332. }
  38333. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38334. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38336. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38337. if !m.op.Is(OpUpdateOne) {
  38338. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38339. }
  38340. if m.id == nil || m.oldValue == nil {
  38341. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38342. }
  38343. oldValue, err := m.oldValue(ctx)
  38344. if err != nil {
  38345. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38346. }
  38347. return oldValue.VerifyAccount, nil
  38348. }
  38349. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38350. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38351. m.verify_account = nil
  38352. }
  38353. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38354. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38355. m.predicates = append(m.predicates, ps...)
  38356. }
  38357. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38358. // users can use type-assertion to append predicates that do not depend on any generated package.
  38359. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38360. p := make([]predicate.WhatsappChannel, len(ps))
  38361. for i := range ps {
  38362. p[i] = ps[i]
  38363. }
  38364. m.Where(p...)
  38365. }
  38366. // Op returns the operation name.
  38367. func (m *WhatsappChannelMutation) Op() Op {
  38368. return m.op
  38369. }
  38370. // SetOp allows setting the mutation operation.
  38371. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38372. m.op = op
  38373. }
  38374. // Type returns the node type of this mutation (WhatsappChannel).
  38375. func (m *WhatsappChannelMutation) Type() string {
  38376. return m.typ
  38377. }
  38378. // Fields returns all fields that were changed during this mutation. Note that in
  38379. // order to get all numeric fields that were incremented/decremented, call
  38380. // AddedFields().
  38381. func (m *WhatsappChannelMutation) Fields() []string {
  38382. fields := make([]string, 0, 12)
  38383. if m.created_at != nil {
  38384. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38385. }
  38386. if m.updated_at != nil {
  38387. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38388. }
  38389. if m.status != nil {
  38390. fields = append(fields, whatsappchannel.FieldStatus)
  38391. }
  38392. if m.deleted_at != nil {
  38393. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38394. }
  38395. if m.ak != nil {
  38396. fields = append(fields, whatsappchannel.FieldAk)
  38397. }
  38398. if m.sk != nil {
  38399. fields = append(fields, whatsappchannel.FieldSk)
  38400. }
  38401. if m.wa_id != nil {
  38402. fields = append(fields, whatsappchannel.FieldWaID)
  38403. }
  38404. if m.wa_name != nil {
  38405. fields = append(fields, whatsappchannel.FieldWaName)
  38406. }
  38407. if m.waba_id != nil {
  38408. fields = append(fields, whatsappchannel.FieldWabaID)
  38409. }
  38410. if m.business_id != nil {
  38411. fields = append(fields, whatsappchannel.FieldBusinessID)
  38412. }
  38413. if m.organization_id != nil {
  38414. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38415. }
  38416. if m.verify_account != nil {
  38417. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38418. }
  38419. return fields
  38420. }
  38421. // Field returns the value of a field with the given name. The second boolean
  38422. // return value indicates that this field was not set, or was not defined in the
  38423. // schema.
  38424. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38425. switch name {
  38426. case whatsappchannel.FieldCreatedAt:
  38427. return m.CreatedAt()
  38428. case whatsappchannel.FieldUpdatedAt:
  38429. return m.UpdatedAt()
  38430. case whatsappchannel.FieldStatus:
  38431. return m.Status()
  38432. case whatsappchannel.FieldDeletedAt:
  38433. return m.DeletedAt()
  38434. case whatsappchannel.FieldAk:
  38435. return m.Ak()
  38436. case whatsappchannel.FieldSk:
  38437. return m.Sk()
  38438. case whatsappchannel.FieldWaID:
  38439. return m.WaID()
  38440. case whatsappchannel.FieldWaName:
  38441. return m.WaName()
  38442. case whatsappchannel.FieldWabaID:
  38443. return m.WabaID()
  38444. case whatsappchannel.FieldBusinessID:
  38445. return m.BusinessID()
  38446. case whatsappchannel.FieldOrganizationID:
  38447. return m.OrganizationID()
  38448. case whatsappchannel.FieldVerifyAccount:
  38449. return m.VerifyAccount()
  38450. }
  38451. return nil, false
  38452. }
  38453. // OldField returns the old value of the field from the database. An error is
  38454. // returned if the mutation operation is not UpdateOne, or the query to the
  38455. // database failed.
  38456. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38457. switch name {
  38458. case whatsappchannel.FieldCreatedAt:
  38459. return m.OldCreatedAt(ctx)
  38460. case whatsappchannel.FieldUpdatedAt:
  38461. return m.OldUpdatedAt(ctx)
  38462. case whatsappchannel.FieldStatus:
  38463. return m.OldStatus(ctx)
  38464. case whatsappchannel.FieldDeletedAt:
  38465. return m.OldDeletedAt(ctx)
  38466. case whatsappchannel.FieldAk:
  38467. return m.OldAk(ctx)
  38468. case whatsappchannel.FieldSk:
  38469. return m.OldSk(ctx)
  38470. case whatsappchannel.FieldWaID:
  38471. return m.OldWaID(ctx)
  38472. case whatsappchannel.FieldWaName:
  38473. return m.OldWaName(ctx)
  38474. case whatsappchannel.FieldWabaID:
  38475. return m.OldWabaID(ctx)
  38476. case whatsappchannel.FieldBusinessID:
  38477. return m.OldBusinessID(ctx)
  38478. case whatsappchannel.FieldOrganizationID:
  38479. return m.OldOrganizationID(ctx)
  38480. case whatsappchannel.FieldVerifyAccount:
  38481. return m.OldVerifyAccount(ctx)
  38482. }
  38483. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38484. }
  38485. // SetField sets the value of a field with the given name. It returns an error if
  38486. // the field is not defined in the schema, or if the type mismatched the field
  38487. // type.
  38488. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38489. switch name {
  38490. case whatsappchannel.FieldCreatedAt:
  38491. v, ok := value.(time.Time)
  38492. if !ok {
  38493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38494. }
  38495. m.SetCreatedAt(v)
  38496. return nil
  38497. case whatsappchannel.FieldUpdatedAt:
  38498. v, ok := value.(time.Time)
  38499. if !ok {
  38500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38501. }
  38502. m.SetUpdatedAt(v)
  38503. return nil
  38504. case whatsappchannel.FieldStatus:
  38505. v, ok := value.(uint8)
  38506. if !ok {
  38507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38508. }
  38509. m.SetStatus(v)
  38510. return nil
  38511. case whatsappchannel.FieldDeletedAt:
  38512. v, ok := value.(time.Time)
  38513. if !ok {
  38514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38515. }
  38516. m.SetDeletedAt(v)
  38517. return nil
  38518. case whatsappchannel.FieldAk:
  38519. v, ok := value.(string)
  38520. if !ok {
  38521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38522. }
  38523. m.SetAk(v)
  38524. return nil
  38525. case whatsappchannel.FieldSk:
  38526. v, ok := value.(string)
  38527. if !ok {
  38528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38529. }
  38530. m.SetSk(v)
  38531. return nil
  38532. case whatsappchannel.FieldWaID:
  38533. v, ok := value.(string)
  38534. if !ok {
  38535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38536. }
  38537. m.SetWaID(v)
  38538. return nil
  38539. case whatsappchannel.FieldWaName:
  38540. v, ok := value.(string)
  38541. if !ok {
  38542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38543. }
  38544. m.SetWaName(v)
  38545. return nil
  38546. case whatsappchannel.FieldWabaID:
  38547. v, ok := value.(uint64)
  38548. if !ok {
  38549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38550. }
  38551. m.SetWabaID(v)
  38552. return nil
  38553. case whatsappchannel.FieldBusinessID:
  38554. v, ok := value.(uint64)
  38555. if !ok {
  38556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38557. }
  38558. m.SetBusinessID(v)
  38559. return nil
  38560. case whatsappchannel.FieldOrganizationID:
  38561. v, ok := value.(uint64)
  38562. if !ok {
  38563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38564. }
  38565. m.SetOrganizationID(v)
  38566. return nil
  38567. case whatsappchannel.FieldVerifyAccount:
  38568. v, ok := value.(string)
  38569. if !ok {
  38570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38571. }
  38572. m.SetVerifyAccount(v)
  38573. return nil
  38574. }
  38575. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38576. }
  38577. // AddedFields returns all numeric fields that were incremented/decremented during
  38578. // this mutation.
  38579. func (m *WhatsappChannelMutation) AddedFields() []string {
  38580. var fields []string
  38581. if m.addstatus != nil {
  38582. fields = append(fields, whatsappchannel.FieldStatus)
  38583. }
  38584. if m.addwaba_id != nil {
  38585. fields = append(fields, whatsappchannel.FieldWabaID)
  38586. }
  38587. if m.addbusiness_id != nil {
  38588. fields = append(fields, whatsappchannel.FieldBusinessID)
  38589. }
  38590. if m.addorganization_id != nil {
  38591. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38592. }
  38593. return fields
  38594. }
  38595. // AddedField returns the numeric value that was incremented/decremented on a field
  38596. // with the given name. The second boolean return value indicates that this field
  38597. // was not set, or was not defined in the schema.
  38598. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38599. switch name {
  38600. case whatsappchannel.FieldStatus:
  38601. return m.AddedStatus()
  38602. case whatsappchannel.FieldWabaID:
  38603. return m.AddedWabaID()
  38604. case whatsappchannel.FieldBusinessID:
  38605. return m.AddedBusinessID()
  38606. case whatsappchannel.FieldOrganizationID:
  38607. return m.AddedOrganizationID()
  38608. }
  38609. return nil, false
  38610. }
  38611. // AddField adds the value to the field with the given name. It returns an error if
  38612. // the field is not defined in the schema, or if the type mismatched the field
  38613. // type.
  38614. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38615. switch name {
  38616. case whatsappchannel.FieldStatus:
  38617. v, ok := value.(int8)
  38618. if !ok {
  38619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38620. }
  38621. m.AddStatus(v)
  38622. return nil
  38623. case whatsappchannel.FieldWabaID:
  38624. v, ok := value.(int64)
  38625. if !ok {
  38626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38627. }
  38628. m.AddWabaID(v)
  38629. return nil
  38630. case whatsappchannel.FieldBusinessID:
  38631. v, ok := value.(int64)
  38632. if !ok {
  38633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38634. }
  38635. m.AddBusinessID(v)
  38636. return nil
  38637. case whatsappchannel.FieldOrganizationID:
  38638. v, ok := value.(int64)
  38639. if !ok {
  38640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38641. }
  38642. m.AddOrganizationID(v)
  38643. return nil
  38644. }
  38645. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  38646. }
  38647. // ClearedFields returns all nullable fields that were cleared during this
  38648. // mutation.
  38649. func (m *WhatsappChannelMutation) ClearedFields() []string {
  38650. var fields []string
  38651. if m.FieldCleared(whatsappchannel.FieldStatus) {
  38652. fields = append(fields, whatsappchannel.FieldStatus)
  38653. }
  38654. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  38655. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38656. }
  38657. if m.FieldCleared(whatsappchannel.FieldAk) {
  38658. fields = append(fields, whatsappchannel.FieldAk)
  38659. }
  38660. if m.FieldCleared(whatsappchannel.FieldWaID) {
  38661. fields = append(fields, whatsappchannel.FieldWaID)
  38662. }
  38663. if m.FieldCleared(whatsappchannel.FieldWaName) {
  38664. fields = append(fields, whatsappchannel.FieldWaName)
  38665. }
  38666. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  38667. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38668. }
  38669. return fields
  38670. }
  38671. // FieldCleared returns a boolean indicating if a field with the given name was
  38672. // cleared in this mutation.
  38673. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  38674. _, ok := m.clearedFields[name]
  38675. return ok
  38676. }
  38677. // ClearField clears the value of the field with the given name. It returns an
  38678. // error if the field is not defined in the schema.
  38679. func (m *WhatsappChannelMutation) ClearField(name string) error {
  38680. switch name {
  38681. case whatsappchannel.FieldStatus:
  38682. m.ClearStatus()
  38683. return nil
  38684. case whatsappchannel.FieldDeletedAt:
  38685. m.ClearDeletedAt()
  38686. return nil
  38687. case whatsappchannel.FieldAk:
  38688. m.ClearAk()
  38689. return nil
  38690. case whatsappchannel.FieldWaID:
  38691. m.ClearWaID()
  38692. return nil
  38693. case whatsappchannel.FieldWaName:
  38694. m.ClearWaName()
  38695. return nil
  38696. case whatsappchannel.FieldOrganizationID:
  38697. m.ClearOrganizationID()
  38698. return nil
  38699. }
  38700. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  38701. }
  38702. // ResetField resets all changes in the mutation for the field with the given name.
  38703. // It returns an error if the field is not defined in the schema.
  38704. func (m *WhatsappChannelMutation) ResetField(name string) error {
  38705. switch name {
  38706. case whatsappchannel.FieldCreatedAt:
  38707. m.ResetCreatedAt()
  38708. return nil
  38709. case whatsappchannel.FieldUpdatedAt:
  38710. m.ResetUpdatedAt()
  38711. return nil
  38712. case whatsappchannel.FieldStatus:
  38713. m.ResetStatus()
  38714. return nil
  38715. case whatsappchannel.FieldDeletedAt:
  38716. m.ResetDeletedAt()
  38717. return nil
  38718. case whatsappchannel.FieldAk:
  38719. m.ResetAk()
  38720. return nil
  38721. case whatsappchannel.FieldSk:
  38722. m.ResetSk()
  38723. return nil
  38724. case whatsappchannel.FieldWaID:
  38725. m.ResetWaID()
  38726. return nil
  38727. case whatsappchannel.FieldWaName:
  38728. m.ResetWaName()
  38729. return nil
  38730. case whatsappchannel.FieldWabaID:
  38731. m.ResetWabaID()
  38732. return nil
  38733. case whatsappchannel.FieldBusinessID:
  38734. m.ResetBusinessID()
  38735. return nil
  38736. case whatsappchannel.FieldOrganizationID:
  38737. m.ResetOrganizationID()
  38738. return nil
  38739. case whatsappchannel.FieldVerifyAccount:
  38740. m.ResetVerifyAccount()
  38741. return nil
  38742. }
  38743. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38744. }
  38745. // AddedEdges returns all edge names that were set/added in this mutation.
  38746. func (m *WhatsappChannelMutation) AddedEdges() []string {
  38747. edges := make([]string, 0, 0)
  38748. return edges
  38749. }
  38750. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38751. // name in this mutation.
  38752. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  38753. return nil
  38754. }
  38755. // RemovedEdges returns all edge names that were removed in this mutation.
  38756. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  38757. edges := make([]string, 0, 0)
  38758. return edges
  38759. }
  38760. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38761. // the given name in this mutation.
  38762. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  38763. return nil
  38764. }
  38765. // ClearedEdges returns all edge names that were cleared in this mutation.
  38766. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  38767. edges := make([]string, 0, 0)
  38768. return edges
  38769. }
  38770. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38771. // was cleared in this mutation.
  38772. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  38773. return false
  38774. }
  38775. // ClearEdge clears the value of the edge with the given name. It returns an error
  38776. // if that edge is not defined in the schema.
  38777. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  38778. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  38779. }
  38780. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38781. // It returns an error if the edge is not defined in the schema.
  38782. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  38783. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  38784. }
  38785. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  38786. type WorkExperienceMutation struct {
  38787. config
  38788. op Op
  38789. typ string
  38790. id *uint64
  38791. created_at *time.Time
  38792. updated_at *time.Time
  38793. deleted_at *time.Time
  38794. start_date *time.Time
  38795. end_date *time.Time
  38796. company *string
  38797. experience *string
  38798. organization_id *uint64
  38799. addorganization_id *int64
  38800. clearedFields map[string]struct{}
  38801. employee *uint64
  38802. clearedemployee bool
  38803. done bool
  38804. oldValue func(context.Context) (*WorkExperience, error)
  38805. predicates []predicate.WorkExperience
  38806. }
  38807. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  38808. // workexperienceOption allows management of the mutation configuration using functional options.
  38809. type workexperienceOption func(*WorkExperienceMutation)
  38810. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  38811. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  38812. m := &WorkExperienceMutation{
  38813. config: c,
  38814. op: op,
  38815. typ: TypeWorkExperience,
  38816. clearedFields: make(map[string]struct{}),
  38817. }
  38818. for _, opt := range opts {
  38819. opt(m)
  38820. }
  38821. return m
  38822. }
  38823. // withWorkExperienceID sets the ID field of the mutation.
  38824. func withWorkExperienceID(id uint64) workexperienceOption {
  38825. return func(m *WorkExperienceMutation) {
  38826. var (
  38827. err error
  38828. once sync.Once
  38829. value *WorkExperience
  38830. )
  38831. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  38832. once.Do(func() {
  38833. if m.done {
  38834. err = errors.New("querying old values post mutation is not allowed")
  38835. } else {
  38836. value, err = m.Client().WorkExperience.Get(ctx, id)
  38837. }
  38838. })
  38839. return value, err
  38840. }
  38841. m.id = &id
  38842. }
  38843. }
  38844. // withWorkExperience sets the old WorkExperience of the mutation.
  38845. func withWorkExperience(node *WorkExperience) workexperienceOption {
  38846. return func(m *WorkExperienceMutation) {
  38847. m.oldValue = func(context.Context) (*WorkExperience, error) {
  38848. return node, nil
  38849. }
  38850. m.id = &node.ID
  38851. }
  38852. }
  38853. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38854. // executed in a transaction (ent.Tx), a transactional client is returned.
  38855. func (m WorkExperienceMutation) Client() *Client {
  38856. client := &Client{config: m.config}
  38857. client.init()
  38858. return client
  38859. }
  38860. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38861. // it returns an error otherwise.
  38862. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  38863. if _, ok := m.driver.(*txDriver); !ok {
  38864. return nil, errors.New("ent: mutation is not running in a transaction")
  38865. }
  38866. tx := &Tx{config: m.config}
  38867. tx.init()
  38868. return tx, nil
  38869. }
  38870. // SetID sets the value of the id field. Note that this
  38871. // operation is only accepted on creation of WorkExperience entities.
  38872. func (m *WorkExperienceMutation) SetID(id uint64) {
  38873. m.id = &id
  38874. }
  38875. // ID returns the ID value in the mutation. Note that the ID is only available
  38876. // if it was provided to the builder or after it was returned from the database.
  38877. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  38878. if m.id == nil {
  38879. return
  38880. }
  38881. return *m.id, true
  38882. }
  38883. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38884. // That means, if the mutation is applied within a transaction with an isolation level such
  38885. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38886. // or updated by the mutation.
  38887. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  38888. switch {
  38889. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38890. id, exists := m.ID()
  38891. if exists {
  38892. return []uint64{id}, nil
  38893. }
  38894. fallthrough
  38895. case m.op.Is(OpUpdate | OpDelete):
  38896. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  38897. default:
  38898. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38899. }
  38900. }
  38901. // SetCreatedAt sets the "created_at" field.
  38902. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  38903. m.created_at = &t
  38904. }
  38905. // CreatedAt returns the value of the "created_at" field in the mutation.
  38906. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  38907. v := m.created_at
  38908. if v == nil {
  38909. return
  38910. }
  38911. return *v, true
  38912. }
  38913. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  38914. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38916. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38917. if !m.op.Is(OpUpdateOne) {
  38918. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38919. }
  38920. if m.id == nil || m.oldValue == nil {
  38921. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38922. }
  38923. oldValue, err := m.oldValue(ctx)
  38924. if err != nil {
  38925. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38926. }
  38927. return oldValue.CreatedAt, nil
  38928. }
  38929. // ResetCreatedAt resets all changes to the "created_at" field.
  38930. func (m *WorkExperienceMutation) ResetCreatedAt() {
  38931. m.created_at = nil
  38932. }
  38933. // SetUpdatedAt sets the "updated_at" field.
  38934. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  38935. m.updated_at = &t
  38936. }
  38937. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38938. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  38939. v := m.updated_at
  38940. if v == nil {
  38941. return
  38942. }
  38943. return *v, true
  38944. }
  38945. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  38946. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38948. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38949. if !m.op.Is(OpUpdateOne) {
  38950. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38951. }
  38952. if m.id == nil || m.oldValue == nil {
  38953. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38954. }
  38955. oldValue, err := m.oldValue(ctx)
  38956. if err != nil {
  38957. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38958. }
  38959. return oldValue.UpdatedAt, nil
  38960. }
  38961. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38962. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  38963. m.updated_at = nil
  38964. }
  38965. // SetDeletedAt sets the "deleted_at" field.
  38966. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  38967. m.deleted_at = &t
  38968. }
  38969. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38970. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  38971. v := m.deleted_at
  38972. if v == nil {
  38973. return
  38974. }
  38975. return *v, true
  38976. }
  38977. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  38978. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38980. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38981. if !m.op.Is(OpUpdateOne) {
  38982. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38983. }
  38984. if m.id == nil || m.oldValue == nil {
  38985. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38986. }
  38987. oldValue, err := m.oldValue(ctx)
  38988. if err != nil {
  38989. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38990. }
  38991. return oldValue.DeletedAt, nil
  38992. }
  38993. // ClearDeletedAt clears the value of the "deleted_at" field.
  38994. func (m *WorkExperienceMutation) ClearDeletedAt() {
  38995. m.deleted_at = nil
  38996. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  38997. }
  38998. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38999. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  39000. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  39001. return ok
  39002. }
  39003. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39004. func (m *WorkExperienceMutation) ResetDeletedAt() {
  39005. m.deleted_at = nil
  39006. delete(m.clearedFields, workexperience.FieldDeletedAt)
  39007. }
  39008. // SetEmployeeID sets the "employee_id" field.
  39009. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  39010. m.employee = &u
  39011. }
  39012. // EmployeeID returns the value of the "employee_id" field in the mutation.
  39013. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  39014. v := m.employee
  39015. if v == nil {
  39016. return
  39017. }
  39018. return *v, true
  39019. }
  39020. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  39021. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39023. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  39024. if !m.op.Is(OpUpdateOne) {
  39025. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  39026. }
  39027. if m.id == nil || m.oldValue == nil {
  39028. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  39029. }
  39030. oldValue, err := m.oldValue(ctx)
  39031. if err != nil {
  39032. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  39033. }
  39034. return oldValue.EmployeeID, nil
  39035. }
  39036. // ResetEmployeeID resets all changes to the "employee_id" field.
  39037. func (m *WorkExperienceMutation) ResetEmployeeID() {
  39038. m.employee = nil
  39039. }
  39040. // SetStartDate sets the "start_date" field.
  39041. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  39042. m.start_date = &t
  39043. }
  39044. // StartDate returns the value of the "start_date" field in the mutation.
  39045. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  39046. v := m.start_date
  39047. if v == nil {
  39048. return
  39049. }
  39050. return *v, true
  39051. }
  39052. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  39053. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39055. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  39056. if !m.op.Is(OpUpdateOne) {
  39057. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  39058. }
  39059. if m.id == nil || m.oldValue == nil {
  39060. return v, errors.New("OldStartDate requires an ID field in the mutation")
  39061. }
  39062. oldValue, err := m.oldValue(ctx)
  39063. if err != nil {
  39064. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  39065. }
  39066. return oldValue.StartDate, nil
  39067. }
  39068. // ResetStartDate resets all changes to the "start_date" field.
  39069. func (m *WorkExperienceMutation) ResetStartDate() {
  39070. m.start_date = nil
  39071. }
  39072. // SetEndDate sets the "end_date" field.
  39073. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  39074. m.end_date = &t
  39075. }
  39076. // EndDate returns the value of the "end_date" field in the mutation.
  39077. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39078. v := m.end_date
  39079. if v == nil {
  39080. return
  39081. }
  39082. return *v, true
  39083. }
  39084. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39085. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39087. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39088. if !m.op.Is(OpUpdateOne) {
  39089. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39090. }
  39091. if m.id == nil || m.oldValue == nil {
  39092. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39093. }
  39094. oldValue, err := m.oldValue(ctx)
  39095. if err != nil {
  39096. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39097. }
  39098. return oldValue.EndDate, nil
  39099. }
  39100. // ResetEndDate resets all changes to the "end_date" field.
  39101. func (m *WorkExperienceMutation) ResetEndDate() {
  39102. m.end_date = nil
  39103. }
  39104. // SetCompany sets the "company" field.
  39105. func (m *WorkExperienceMutation) SetCompany(s string) {
  39106. m.company = &s
  39107. }
  39108. // Company returns the value of the "company" field in the mutation.
  39109. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39110. v := m.company
  39111. if v == nil {
  39112. return
  39113. }
  39114. return *v, true
  39115. }
  39116. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39117. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39119. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39120. if !m.op.Is(OpUpdateOne) {
  39121. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39122. }
  39123. if m.id == nil || m.oldValue == nil {
  39124. return v, errors.New("OldCompany requires an ID field in the mutation")
  39125. }
  39126. oldValue, err := m.oldValue(ctx)
  39127. if err != nil {
  39128. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39129. }
  39130. return oldValue.Company, nil
  39131. }
  39132. // ResetCompany resets all changes to the "company" field.
  39133. func (m *WorkExperienceMutation) ResetCompany() {
  39134. m.company = nil
  39135. }
  39136. // SetExperience sets the "experience" field.
  39137. func (m *WorkExperienceMutation) SetExperience(s string) {
  39138. m.experience = &s
  39139. }
  39140. // Experience returns the value of the "experience" field in the mutation.
  39141. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39142. v := m.experience
  39143. if v == nil {
  39144. return
  39145. }
  39146. return *v, true
  39147. }
  39148. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39149. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39151. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39152. if !m.op.Is(OpUpdateOne) {
  39153. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39154. }
  39155. if m.id == nil || m.oldValue == nil {
  39156. return v, errors.New("OldExperience requires an ID field in the mutation")
  39157. }
  39158. oldValue, err := m.oldValue(ctx)
  39159. if err != nil {
  39160. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39161. }
  39162. return oldValue.Experience, nil
  39163. }
  39164. // ResetExperience resets all changes to the "experience" field.
  39165. func (m *WorkExperienceMutation) ResetExperience() {
  39166. m.experience = nil
  39167. }
  39168. // SetOrganizationID sets the "organization_id" field.
  39169. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39170. m.organization_id = &u
  39171. m.addorganization_id = nil
  39172. }
  39173. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39174. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39175. v := m.organization_id
  39176. if v == nil {
  39177. return
  39178. }
  39179. return *v, true
  39180. }
  39181. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39182. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39184. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39185. if !m.op.Is(OpUpdateOne) {
  39186. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39187. }
  39188. if m.id == nil || m.oldValue == nil {
  39189. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39190. }
  39191. oldValue, err := m.oldValue(ctx)
  39192. if err != nil {
  39193. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39194. }
  39195. return oldValue.OrganizationID, nil
  39196. }
  39197. // AddOrganizationID adds u to the "organization_id" field.
  39198. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39199. if m.addorganization_id != nil {
  39200. *m.addorganization_id += u
  39201. } else {
  39202. m.addorganization_id = &u
  39203. }
  39204. }
  39205. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39206. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39207. v := m.addorganization_id
  39208. if v == nil {
  39209. return
  39210. }
  39211. return *v, true
  39212. }
  39213. // ResetOrganizationID resets all changes to the "organization_id" field.
  39214. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39215. m.organization_id = nil
  39216. m.addorganization_id = nil
  39217. }
  39218. // ClearEmployee clears the "employee" edge to the Employee entity.
  39219. func (m *WorkExperienceMutation) ClearEmployee() {
  39220. m.clearedemployee = true
  39221. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39222. }
  39223. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39224. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39225. return m.clearedemployee
  39226. }
  39227. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39228. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39229. // EmployeeID instead. It exists only for internal usage by the builders.
  39230. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39231. if id := m.employee; id != nil {
  39232. ids = append(ids, *id)
  39233. }
  39234. return
  39235. }
  39236. // ResetEmployee resets all changes to the "employee" edge.
  39237. func (m *WorkExperienceMutation) ResetEmployee() {
  39238. m.employee = nil
  39239. m.clearedemployee = false
  39240. }
  39241. // Where appends a list predicates to the WorkExperienceMutation builder.
  39242. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39243. m.predicates = append(m.predicates, ps...)
  39244. }
  39245. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39246. // users can use type-assertion to append predicates that do not depend on any generated package.
  39247. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39248. p := make([]predicate.WorkExperience, len(ps))
  39249. for i := range ps {
  39250. p[i] = ps[i]
  39251. }
  39252. m.Where(p...)
  39253. }
  39254. // Op returns the operation name.
  39255. func (m *WorkExperienceMutation) Op() Op {
  39256. return m.op
  39257. }
  39258. // SetOp allows setting the mutation operation.
  39259. func (m *WorkExperienceMutation) SetOp(op Op) {
  39260. m.op = op
  39261. }
  39262. // Type returns the node type of this mutation (WorkExperience).
  39263. func (m *WorkExperienceMutation) Type() string {
  39264. return m.typ
  39265. }
  39266. // Fields returns all fields that were changed during this mutation. Note that in
  39267. // order to get all numeric fields that were incremented/decremented, call
  39268. // AddedFields().
  39269. func (m *WorkExperienceMutation) Fields() []string {
  39270. fields := make([]string, 0, 9)
  39271. if m.created_at != nil {
  39272. fields = append(fields, workexperience.FieldCreatedAt)
  39273. }
  39274. if m.updated_at != nil {
  39275. fields = append(fields, workexperience.FieldUpdatedAt)
  39276. }
  39277. if m.deleted_at != nil {
  39278. fields = append(fields, workexperience.FieldDeletedAt)
  39279. }
  39280. if m.employee != nil {
  39281. fields = append(fields, workexperience.FieldEmployeeID)
  39282. }
  39283. if m.start_date != nil {
  39284. fields = append(fields, workexperience.FieldStartDate)
  39285. }
  39286. if m.end_date != nil {
  39287. fields = append(fields, workexperience.FieldEndDate)
  39288. }
  39289. if m.company != nil {
  39290. fields = append(fields, workexperience.FieldCompany)
  39291. }
  39292. if m.experience != nil {
  39293. fields = append(fields, workexperience.FieldExperience)
  39294. }
  39295. if m.organization_id != nil {
  39296. fields = append(fields, workexperience.FieldOrganizationID)
  39297. }
  39298. return fields
  39299. }
  39300. // Field returns the value of a field with the given name. The second boolean
  39301. // return value indicates that this field was not set, or was not defined in the
  39302. // schema.
  39303. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39304. switch name {
  39305. case workexperience.FieldCreatedAt:
  39306. return m.CreatedAt()
  39307. case workexperience.FieldUpdatedAt:
  39308. return m.UpdatedAt()
  39309. case workexperience.FieldDeletedAt:
  39310. return m.DeletedAt()
  39311. case workexperience.FieldEmployeeID:
  39312. return m.EmployeeID()
  39313. case workexperience.FieldStartDate:
  39314. return m.StartDate()
  39315. case workexperience.FieldEndDate:
  39316. return m.EndDate()
  39317. case workexperience.FieldCompany:
  39318. return m.Company()
  39319. case workexperience.FieldExperience:
  39320. return m.Experience()
  39321. case workexperience.FieldOrganizationID:
  39322. return m.OrganizationID()
  39323. }
  39324. return nil, false
  39325. }
  39326. // OldField returns the old value of the field from the database. An error is
  39327. // returned if the mutation operation is not UpdateOne, or the query to the
  39328. // database failed.
  39329. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39330. switch name {
  39331. case workexperience.FieldCreatedAt:
  39332. return m.OldCreatedAt(ctx)
  39333. case workexperience.FieldUpdatedAt:
  39334. return m.OldUpdatedAt(ctx)
  39335. case workexperience.FieldDeletedAt:
  39336. return m.OldDeletedAt(ctx)
  39337. case workexperience.FieldEmployeeID:
  39338. return m.OldEmployeeID(ctx)
  39339. case workexperience.FieldStartDate:
  39340. return m.OldStartDate(ctx)
  39341. case workexperience.FieldEndDate:
  39342. return m.OldEndDate(ctx)
  39343. case workexperience.FieldCompany:
  39344. return m.OldCompany(ctx)
  39345. case workexperience.FieldExperience:
  39346. return m.OldExperience(ctx)
  39347. case workexperience.FieldOrganizationID:
  39348. return m.OldOrganizationID(ctx)
  39349. }
  39350. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39351. }
  39352. // SetField sets the value of a field with the given name. It returns an error if
  39353. // the field is not defined in the schema, or if the type mismatched the field
  39354. // type.
  39355. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39356. switch name {
  39357. case workexperience.FieldCreatedAt:
  39358. v, ok := value.(time.Time)
  39359. if !ok {
  39360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39361. }
  39362. m.SetCreatedAt(v)
  39363. return nil
  39364. case workexperience.FieldUpdatedAt:
  39365. v, ok := value.(time.Time)
  39366. if !ok {
  39367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39368. }
  39369. m.SetUpdatedAt(v)
  39370. return nil
  39371. case workexperience.FieldDeletedAt:
  39372. v, ok := value.(time.Time)
  39373. if !ok {
  39374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39375. }
  39376. m.SetDeletedAt(v)
  39377. return nil
  39378. case workexperience.FieldEmployeeID:
  39379. v, ok := value.(uint64)
  39380. if !ok {
  39381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39382. }
  39383. m.SetEmployeeID(v)
  39384. return nil
  39385. case workexperience.FieldStartDate:
  39386. v, ok := value.(time.Time)
  39387. if !ok {
  39388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39389. }
  39390. m.SetStartDate(v)
  39391. return nil
  39392. case workexperience.FieldEndDate:
  39393. v, ok := value.(time.Time)
  39394. if !ok {
  39395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39396. }
  39397. m.SetEndDate(v)
  39398. return nil
  39399. case workexperience.FieldCompany:
  39400. v, ok := value.(string)
  39401. if !ok {
  39402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39403. }
  39404. m.SetCompany(v)
  39405. return nil
  39406. case workexperience.FieldExperience:
  39407. v, ok := value.(string)
  39408. if !ok {
  39409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39410. }
  39411. m.SetExperience(v)
  39412. return nil
  39413. case workexperience.FieldOrganizationID:
  39414. v, ok := value.(uint64)
  39415. if !ok {
  39416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39417. }
  39418. m.SetOrganizationID(v)
  39419. return nil
  39420. }
  39421. return fmt.Errorf("unknown WorkExperience field %s", name)
  39422. }
  39423. // AddedFields returns all numeric fields that were incremented/decremented during
  39424. // this mutation.
  39425. func (m *WorkExperienceMutation) AddedFields() []string {
  39426. var fields []string
  39427. if m.addorganization_id != nil {
  39428. fields = append(fields, workexperience.FieldOrganizationID)
  39429. }
  39430. return fields
  39431. }
  39432. // AddedField returns the numeric value that was incremented/decremented on a field
  39433. // with the given name. The second boolean return value indicates that this field
  39434. // was not set, or was not defined in the schema.
  39435. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39436. switch name {
  39437. case workexperience.FieldOrganizationID:
  39438. return m.AddedOrganizationID()
  39439. }
  39440. return nil, false
  39441. }
  39442. // AddField adds the value to the field with the given name. It returns an error if
  39443. // the field is not defined in the schema, or if the type mismatched the field
  39444. // type.
  39445. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39446. switch name {
  39447. case workexperience.FieldOrganizationID:
  39448. v, ok := value.(int64)
  39449. if !ok {
  39450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39451. }
  39452. m.AddOrganizationID(v)
  39453. return nil
  39454. }
  39455. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39456. }
  39457. // ClearedFields returns all nullable fields that were cleared during this
  39458. // mutation.
  39459. func (m *WorkExperienceMutation) ClearedFields() []string {
  39460. var fields []string
  39461. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39462. fields = append(fields, workexperience.FieldDeletedAt)
  39463. }
  39464. return fields
  39465. }
  39466. // FieldCleared returns a boolean indicating if a field with the given name was
  39467. // cleared in this mutation.
  39468. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39469. _, ok := m.clearedFields[name]
  39470. return ok
  39471. }
  39472. // ClearField clears the value of the field with the given name. It returns an
  39473. // error if the field is not defined in the schema.
  39474. func (m *WorkExperienceMutation) ClearField(name string) error {
  39475. switch name {
  39476. case workexperience.FieldDeletedAt:
  39477. m.ClearDeletedAt()
  39478. return nil
  39479. }
  39480. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39481. }
  39482. // ResetField resets all changes in the mutation for the field with the given name.
  39483. // It returns an error if the field is not defined in the schema.
  39484. func (m *WorkExperienceMutation) ResetField(name string) error {
  39485. switch name {
  39486. case workexperience.FieldCreatedAt:
  39487. m.ResetCreatedAt()
  39488. return nil
  39489. case workexperience.FieldUpdatedAt:
  39490. m.ResetUpdatedAt()
  39491. return nil
  39492. case workexperience.FieldDeletedAt:
  39493. m.ResetDeletedAt()
  39494. return nil
  39495. case workexperience.FieldEmployeeID:
  39496. m.ResetEmployeeID()
  39497. return nil
  39498. case workexperience.FieldStartDate:
  39499. m.ResetStartDate()
  39500. return nil
  39501. case workexperience.FieldEndDate:
  39502. m.ResetEndDate()
  39503. return nil
  39504. case workexperience.FieldCompany:
  39505. m.ResetCompany()
  39506. return nil
  39507. case workexperience.FieldExperience:
  39508. m.ResetExperience()
  39509. return nil
  39510. case workexperience.FieldOrganizationID:
  39511. m.ResetOrganizationID()
  39512. return nil
  39513. }
  39514. return fmt.Errorf("unknown WorkExperience field %s", name)
  39515. }
  39516. // AddedEdges returns all edge names that were set/added in this mutation.
  39517. func (m *WorkExperienceMutation) AddedEdges() []string {
  39518. edges := make([]string, 0, 1)
  39519. if m.employee != nil {
  39520. edges = append(edges, workexperience.EdgeEmployee)
  39521. }
  39522. return edges
  39523. }
  39524. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39525. // name in this mutation.
  39526. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39527. switch name {
  39528. case workexperience.EdgeEmployee:
  39529. if id := m.employee; id != nil {
  39530. return []ent.Value{*id}
  39531. }
  39532. }
  39533. return nil
  39534. }
  39535. // RemovedEdges returns all edge names that were removed in this mutation.
  39536. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39537. edges := make([]string, 0, 1)
  39538. return edges
  39539. }
  39540. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39541. // the given name in this mutation.
  39542. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39543. return nil
  39544. }
  39545. // ClearedEdges returns all edge names that were cleared in this mutation.
  39546. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39547. edges := make([]string, 0, 1)
  39548. if m.clearedemployee {
  39549. edges = append(edges, workexperience.EdgeEmployee)
  39550. }
  39551. return edges
  39552. }
  39553. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39554. // was cleared in this mutation.
  39555. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39556. switch name {
  39557. case workexperience.EdgeEmployee:
  39558. return m.clearedemployee
  39559. }
  39560. return false
  39561. }
  39562. // ClearEdge clears the value of the edge with the given name. It returns an error
  39563. // if that edge is not defined in the schema.
  39564. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39565. switch name {
  39566. case workexperience.EdgeEmployee:
  39567. m.ClearEmployee()
  39568. return nil
  39569. }
  39570. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39571. }
  39572. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39573. // It returns an error if the edge is not defined in the schema.
  39574. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39575. switch name {
  39576. case workexperience.EdgeEmployee:
  39577. m.ResetEmployee()
  39578. return nil
  39579. }
  39580. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39581. }
  39582. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39583. type WpChatroomMutation struct {
  39584. config
  39585. op Op
  39586. typ string
  39587. id *uint64
  39588. created_at *time.Time
  39589. updated_at *time.Time
  39590. status *uint8
  39591. addstatus *int8
  39592. wx_wxid *string
  39593. chatroom_id *string
  39594. nickname *string
  39595. owner *string
  39596. avatar *string
  39597. member_list *[]string
  39598. appendmember_list []string
  39599. clearedFields map[string]struct{}
  39600. done bool
  39601. oldValue func(context.Context) (*WpChatroom, error)
  39602. predicates []predicate.WpChatroom
  39603. }
  39604. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39605. // wpchatroomOption allows management of the mutation configuration using functional options.
  39606. type wpchatroomOption func(*WpChatroomMutation)
  39607. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39608. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39609. m := &WpChatroomMutation{
  39610. config: c,
  39611. op: op,
  39612. typ: TypeWpChatroom,
  39613. clearedFields: make(map[string]struct{}),
  39614. }
  39615. for _, opt := range opts {
  39616. opt(m)
  39617. }
  39618. return m
  39619. }
  39620. // withWpChatroomID sets the ID field of the mutation.
  39621. func withWpChatroomID(id uint64) wpchatroomOption {
  39622. return func(m *WpChatroomMutation) {
  39623. var (
  39624. err error
  39625. once sync.Once
  39626. value *WpChatroom
  39627. )
  39628. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39629. once.Do(func() {
  39630. if m.done {
  39631. err = errors.New("querying old values post mutation is not allowed")
  39632. } else {
  39633. value, err = m.Client().WpChatroom.Get(ctx, id)
  39634. }
  39635. })
  39636. return value, err
  39637. }
  39638. m.id = &id
  39639. }
  39640. }
  39641. // withWpChatroom sets the old WpChatroom of the mutation.
  39642. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  39643. return func(m *WpChatroomMutation) {
  39644. m.oldValue = func(context.Context) (*WpChatroom, error) {
  39645. return node, nil
  39646. }
  39647. m.id = &node.ID
  39648. }
  39649. }
  39650. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39651. // executed in a transaction (ent.Tx), a transactional client is returned.
  39652. func (m WpChatroomMutation) Client() *Client {
  39653. client := &Client{config: m.config}
  39654. client.init()
  39655. return client
  39656. }
  39657. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39658. // it returns an error otherwise.
  39659. func (m WpChatroomMutation) Tx() (*Tx, error) {
  39660. if _, ok := m.driver.(*txDriver); !ok {
  39661. return nil, errors.New("ent: mutation is not running in a transaction")
  39662. }
  39663. tx := &Tx{config: m.config}
  39664. tx.init()
  39665. return tx, nil
  39666. }
  39667. // SetID sets the value of the id field. Note that this
  39668. // operation is only accepted on creation of WpChatroom entities.
  39669. func (m *WpChatroomMutation) SetID(id uint64) {
  39670. m.id = &id
  39671. }
  39672. // ID returns the ID value in the mutation. Note that the ID is only available
  39673. // if it was provided to the builder or after it was returned from the database.
  39674. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  39675. if m.id == nil {
  39676. return
  39677. }
  39678. return *m.id, true
  39679. }
  39680. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39681. // That means, if the mutation is applied within a transaction with an isolation level such
  39682. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39683. // or updated by the mutation.
  39684. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  39685. switch {
  39686. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39687. id, exists := m.ID()
  39688. if exists {
  39689. return []uint64{id}, nil
  39690. }
  39691. fallthrough
  39692. case m.op.Is(OpUpdate | OpDelete):
  39693. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  39694. default:
  39695. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39696. }
  39697. }
  39698. // SetCreatedAt sets the "created_at" field.
  39699. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  39700. m.created_at = &t
  39701. }
  39702. // CreatedAt returns the value of the "created_at" field in the mutation.
  39703. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  39704. v := m.created_at
  39705. if v == nil {
  39706. return
  39707. }
  39708. return *v, true
  39709. }
  39710. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  39711. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39713. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39714. if !m.op.Is(OpUpdateOne) {
  39715. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39716. }
  39717. if m.id == nil || m.oldValue == nil {
  39718. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39719. }
  39720. oldValue, err := m.oldValue(ctx)
  39721. if err != nil {
  39722. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39723. }
  39724. return oldValue.CreatedAt, nil
  39725. }
  39726. // ResetCreatedAt resets all changes to the "created_at" field.
  39727. func (m *WpChatroomMutation) ResetCreatedAt() {
  39728. m.created_at = nil
  39729. }
  39730. // SetUpdatedAt sets the "updated_at" field.
  39731. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  39732. m.updated_at = &t
  39733. }
  39734. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39735. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  39736. v := m.updated_at
  39737. if v == nil {
  39738. return
  39739. }
  39740. return *v, true
  39741. }
  39742. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  39743. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39745. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39746. if !m.op.Is(OpUpdateOne) {
  39747. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39748. }
  39749. if m.id == nil || m.oldValue == nil {
  39750. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39751. }
  39752. oldValue, err := m.oldValue(ctx)
  39753. if err != nil {
  39754. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39755. }
  39756. return oldValue.UpdatedAt, nil
  39757. }
  39758. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39759. func (m *WpChatroomMutation) ResetUpdatedAt() {
  39760. m.updated_at = nil
  39761. }
  39762. // SetStatus sets the "status" field.
  39763. func (m *WpChatroomMutation) SetStatus(u uint8) {
  39764. m.status = &u
  39765. m.addstatus = nil
  39766. }
  39767. // Status returns the value of the "status" field in the mutation.
  39768. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  39769. v := m.status
  39770. if v == nil {
  39771. return
  39772. }
  39773. return *v, true
  39774. }
  39775. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  39776. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39778. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39779. if !m.op.Is(OpUpdateOne) {
  39780. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39781. }
  39782. if m.id == nil || m.oldValue == nil {
  39783. return v, errors.New("OldStatus requires an ID field in the mutation")
  39784. }
  39785. oldValue, err := m.oldValue(ctx)
  39786. if err != nil {
  39787. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39788. }
  39789. return oldValue.Status, nil
  39790. }
  39791. // AddStatus adds u to the "status" field.
  39792. func (m *WpChatroomMutation) AddStatus(u int8) {
  39793. if m.addstatus != nil {
  39794. *m.addstatus += u
  39795. } else {
  39796. m.addstatus = &u
  39797. }
  39798. }
  39799. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39800. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  39801. v := m.addstatus
  39802. if v == nil {
  39803. return
  39804. }
  39805. return *v, true
  39806. }
  39807. // ClearStatus clears the value of the "status" field.
  39808. func (m *WpChatroomMutation) ClearStatus() {
  39809. m.status = nil
  39810. m.addstatus = nil
  39811. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  39812. }
  39813. // StatusCleared returns if the "status" field was cleared in this mutation.
  39814. func (m *WpChatroomMutation) StatusCleared() bool {
  39815. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  39816. return ok
  39817. }
  39818. // ResetStatus resets all changes to the "status" field.
  39819. func (m *WpChatroomMutation) ResetStatus() {
  39820. m.status = nil
  39821. m.addstatus = nil
  39822. delete(m.clearedFields, wpchatroom.FieldStatus)
  39823. }
  39824. // SetWxWxid sets the "wx_wxid" field.
  39825. func (m *WpChatroomMutation) SetWxWxid(s string) {
  39826. m.wx_wxid = &s
  39827. }
  39828. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39829. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  39830. v := m.wx_wxid
  39831. if v == nil {
  39832. return
  39833. }
  39834. return *v, true
  39835. }
  39836. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  39837. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39839. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39840. if !m.op.Is(OpUpdateOne) {
  39841. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39842. }
  39843. if m.id == nil || m.oldValue == nil {
  39844. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39845. }
  39846. oldValue, err := m.oldValue(ctx)
  39847. if err != nil {
  39848. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39849. }
  39850. return oldValue.WxWxid, nil
  39851. }
  39852. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39853. func (m *WpChatroomMutation) ResetWxWxid() {
  39854. m.wx_wxid = nil
  39855. }
  39856. // SetChatroomID sets the "chatroom_id" field.
  39857. func (m *WpChatroomMutation) SetChatroomID(s string) {
  39858. m.chatroom_id = &s
  39859. }
  39860. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  39861. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  39862. v := m.chatroom_id
  39863. if v == nil {
  39864. return
  39865. }
  39866. return *v, true
  39867. }
  39868. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  39869. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39871. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  39872. if !m.op.Is(OpUpdateOne) {
  39873. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  39874. }
  39875. if m.id == nil || m.oldValue == nil {
  39876. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  39877. }
  39878. oldValue, err := m.oldValue(ctx)
  39879. if err != nil {
  39880. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  39881. }
  39882. return oldValue.ChatroomID, nil
  39883. }
  39884. // ResetChatroomID resets all changes to the "chatroom_id" field.
  39885. func (m *WpChatroomMutation) ResetChatroomID() {
  39886. m.chatroom_id = nil
  39887. }
  39888. // SetNickname sets the "nickname" field.
  39889. func (m *WpChatroomMutation) SetNickname(s string) {
  39890. m.nickname = &s
  39891. }
  39892. // Nickname returns the value of the "nickname" field in the mutation.
  39893. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  39894. v := m.nickname
  39895. if v == nil {
  39896. return
  39897. }
  39898. return *v, true
  39899. }
  39900. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  39901. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39903. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  39904. if !m.op.Is(OpUpdateOne) {
  39905. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39906. }
  39907. if m.id == nil || m.oldValue == nil {
  39908. return v, errors.New("OldNickname requires an ID field in the mutation")
  39909. }
  39910. oldValue, err := m.oldValue(ctx)
  39911. if err != nil {
  39912. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39913. }
  39914. return oldValue.Nickname, nil
  39915. }
  39916. // ResetNickname resets all changes to the "nickname" field.
  39917. func (m *WpChatroomMutation) ResetNickname() {
  39918. m.nickname = nil
  39919. }
  39920. // SetOwner sets the "owner" field.
  39921. func (m *WpChatroomMutation) SetOwner(s string) {
  39922. m.owner = &s
  39923. }
  39924. // Owner returns the value of the "owner" field in the mutation.
  39925. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  39926. v := m.owner
  39927. if v == nil {
  39928. return
  39929. }
  39930. return *v, true
  39931. }
  39932. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  39933. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39935. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  39936. if !m.op.Is(OpUpdateOne) {
  39937. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  39938. }
  39939. if m.id == nil || m.oldValue == nil {
  39940. return v, errors.New("OldOwner requires an ID field in the mutation")
  39941. }
  39942. oldValue, err := m.oldValue(ctx)
  39943. if err != nil {
  39944. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  39945. }
  39946. return oldValue.Owner, nil
  39947. }
  39948. // ResetOwner resets all changes to the "owner" field.
  39949. func (m *WpChatroomMutation) ResetOwner() {
  39950. m.owner = nil
  39951. }
  39952. // SetAvatar sets the "avatar" field.
  39953. func (m *WpChatroomMutation) SetAvatar(s string) {
  39954. m.avatar = &s
  39955. }
  39956. // Avatar returns the value of the "avatar" field in the mutation.
  39957. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  39958. v := m.avatar
  39959. if v == nil {
  39960. return
  39961. }
  39962. return *v, true
  39963. }
  39964. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  39965. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39967. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39968. if !m.op.Is(OpUpdateOne) {
  39969. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39970. }
  39971. if m.id == nil || m.oldValue == nil {
  39972. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39973. }
  39974. oldValue, err := m.oldValue(ctx)
  39975. if err != nil {
  39976. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39977. }
  39978. return oldValue.Avatar, nil
  39979. }
  39980. // ResetAvatar resets all changes to the "avatar" field.
  39981. func (m *WpChatroomMutation) ResetAvatar() {
  39982. m.avatar = nil
  39983. }
  39984. // SetMemberList sets the "member_list" field.
  39985. func (m *WpChatroomMutation) SetMemberList(s []string) {
  39986. m.member_list = &s
  39987. m.appendmember_list = nil
  39988. }
  39989. // MemberList returns the value of the "member_list" field in the mutation.
  39990. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  39991. v := m.member_list
  39992. if v == nil {
  39993. return
  39994. }
  39995. return *v, true
  39996. }
  39997. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  39998. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40000. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  40001. if !m.op.Is(OpUpdateOne) {
  40002. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  40003. }
  40004. if m.id == nil || m.oldValue == nil {
  40005. return v, errors.New("OldMemberList requires an ID field in the mutation")
  40006. }
  40007. oldValue, err := m.oldValue(ctx)
  40008. if err != nil {
  40009. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  40010. }
  40011. return oldValue.MemberList, nil
  40012. }
  40013. // AppendMemberList adds s to the "member_list" field.
  40014. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  40015. m.appendmember_list = append(m.appendmember_list, s...)
  40016. }
  40017. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  40018. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  40019. if len(m.appendmember_list) == 0 {
  40020. return nil, false
  40021. }
  40022. return m.appendmember_list, true
  40023. }
  40024. // ResetMemberList resets all changes to the "member_list" field.
  40025. func (m *WpChatroomMutation) ResetMemberList() {
  40026. m.member_list = nil
  40027. m.appendmember_list = nil
  40028. }
  40029. // Where appends a list predicates to the WpChatroomMutation builder.
  40030. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  40031. m.predicates = append(m.predicates, ps...)
  40032. }
  40033. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  40034. // users can use type-assertion to append predicates that do not depend on any generated package.
  40035. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  40036. p := make([]predicate.WpChatroom, len(ps))
  40037. for i := range ps {
  40038. p[i] = ps[i]
  40039. }
  40040. m.Where(p...)
  40041. }
  40042. // Op returns the operation name.
  40043. func (m *WpChatroomMutation) Op() Op {
  40044. return m.op
  40045. }
  40046. // SetOp allows setting the mutation operation.
  40047. func (m *WpChatroomMutation) SetOp(op Op) {
  40048. m.op = op
  40049. }
  40050. // Type returns the node type of this mutation (WpChatroom).
  40051. func (m *WpChatroomMutation) Type() string {
  40052. return m.typ
  40053. }
  40054. // Fields returns all fields that were changed during this mutation. Note that in
  40055. // order to get all numeric fields that were incremented/decremented, call
  40056. // AddedFields().
  40057. func (m *WpChatroomMutation) Fields() []string {
  40058. fields := make([]string, 0, 9)
  40059. if m.created_at != nil {
  40060. fields = append(fields, wpchatroom.FieldCreatedAt)
  40061. }
  40062. if m.updated_at != nil {
  40063. fields = append(fields, wpchatroom.FieldUpdatedAt)
  40064. }
  40065. if m.status != nil {
  40066. fields = append(fields, wpchatroom.FieldStatus)
  40067. }
  40068. if m.wx_wxid != nil {
  40069. fields = append(fields, wpchatroom.FieldWxWxid)
  40070. }
  40071. if m.chatroom_id != nil {
  40072. fields = append(fields, wpchatroom.FieldChatroomID)
  40073. }
  40074. if m.nickname != nil {
  40075. fields = append(fields, wpchatroom.FieldNickname)
  40076. }
  40077. if m.owner != nil {
  40078. fields = append(fields, wpchatroom.FieldOwner)
  40079. }
  40080. if m.avatar != nil {
  40081. fields = append(fields, wpchatroom.FieldAvatar)
  40082. }
  40083. if m.member_list != nil {
  40084. fields = append(fields, wpchatroom.FieldMemberList)
  40085. }
  40086. return fields
  40087. }
  40088. // Field returns the value of a field with the given name. The second boolean
  40089. // return value indicates that this field was not set, or was not defined in the
  40090. // schema.
  40091. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40092. switch name {
  40093. case wpchatroom.FieldCreatedAt:
  40094. return m.CreatedAt()
  40095. case wpchatroom.FieldUpdatedAt:
  40096. return m.UpdatedAt()
  40097. case wpchatroom.FieldStatus:
  40098. return m.Status()
  40099. case wpchatroom.FieldWxWxid:
  40100. return m.WxWxid()
  40101. case wpchatroom.FieldChatroomID:
  40102. return m.ChatroomID()
  40103. case wpchatroom.FieldNickname:
  40104. return m.Nickname()
  40105. case wpchatroom.FieldOwner:
  40106. return m.Owner()
  40107. case wpchatroom.FieldAvatar:
  40108. return m.Avatar()
  40109. case wpchatroom.FieldMemberList:
  40110. return m.MemberList()
  40111. }
  40112. return nil, false
  40113. }
  40114. // OldField returns the old value of the field from the database. An error is
  40115. // returned if the mutation operation is not UpdateOne, or the query to the
  40116. // database failed.
  40117. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40118. switch name {
  40119. case wpchatroom.FieldCreatedAt:
  40120. return m.OldCreatedAt(ctx)
  40121. case wpchatroom.FieldUpdatedAt:
  40122. return m.OldUpdatedAt(ctx)
  40123. case wpchatroom.FieldStatus:
  40124. return m.OldStatus(ctx)
  40125. case wpchatroom.FieldWxWxid:
  40126. return m.OldWxWxid(ctx)
  40127. case wpchatroom.FieldChatroomID:
  40128. return m.OldChatroomID(ctx)
  40129. case wpchatroom.FieldNickname:
  40130. return m.OldNickname(ctx)
  40131. case wpchatroom.FieldOwner:
  40132. return m.OldOwner(ctx)
  40133. case wpchatroom.FieldAvatar:
  40134. return m.OldAvatar(ctx)
  40135. case wpchatroom.FieldMemberList:
  40136. return m.OldMemberList(ctx)
  40137. }
  40138. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40139. }
  40140. // SetField sets the value of a field with the given name. It returns an error if
  40141. // the field is not defined in the schema, or if the type mismatched the field
  40142. // type.
  40143. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40144. switch name {
  40145. case wpchatroom.FieldCreatedAt:
  40146. v, ok := value.(time.Time)
  40147. if !ok {
  40148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40149. }
  40150. m.SetCreatedAt(v)
  40151. return nil
  40152. case wpchatroom.FieldUpdatedAt:
  40153. v, ok := value.(time.Time)
  40154. if !ok {
  40155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40156. }
  40157. m.SetUpdatedAt(v)
  40158. return nil
  40159. case wpchatroom.FieldStatus:
  40160. v, ok := value.(uint8)
  40161. if !ok {
  40162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40163. }
  40164. m.SetStatus(v)
  40165. return nil
  40166. case wpchatroom.FieldWxWxid:
  40167. v, ok := value.(string)
  40168. if !ok {
  40169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40170. }
  40171. m.SetWxWxid(v)
  40172. return nil
  40173. case wpchatroom.FieldChatroomID:
  40174. v, ok := value.(string)
  40175. if !ok {
  40176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40177. }
  40178. m.SetChatroomID(v)
  40179. return nil
  40180. case wpchatroom.FieldNickname:
  40181. v, ok := value.(string)
  40182. if !ok {
  40183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40184. }
  40185. m.SetNickname(v)
  40186. return nil
  40187. case wpchatroom.FieldOwner:
  40188. v, ok := value.(string)
  40189. if !ok {
  40190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40191. }
  40192. m.SetOwner(v)
  40193. return nil
  40194. case wpchatroom.FieldAvatar:
  40195. v, ok := value.(string)
  40196. if !ok {
  40197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40198. }
  40199. m.SetAvatar(v)
  40200. return nil
  40201. case wpchatroom.FieldMemberList:
  40202. v, ok := value.([]string)
  40203. if !ok {
  40204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40205. }
  40206. m.SetMemberList(v)
  40207. return nil
  40208. }
  40209. return fmt.Errorf("unknown WpChatroom field %s", name)
  40210. }
  40211. // AddedFields returns all numeric fields that were incremented/decremented during
  40212. // this mutation.
  40213. func (m *WpChatroomMutation) AddedFields() []string {
  40214. var fields []string
  40215. if m.addstatus != nil {
  40216. fields = append(fields, wpchatroom.FieldStatus)
  40217. }
  40218. return fields
  40219. }
  40220. // AddedField returns the numeric value that was incremented/decremented on a field
  40221. // with the given name. The second boolean return value indicates that this field
  40222. // was not set, or was not defined in the schema.
  40223. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40224. switch name {
  40225. case wpchatroom.FieldStatus:
  40226. return m.AddedStatus()
  40227. }
  40228. return nil, false
  40229. }
  40230. // AddField adds the value to the field with the given name. It returns an error if
  40231. // the field is not defined in the schema, or if the type mismatched the field
  40232. // type.
  40233. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40234. switch name {
  40235. case wpchatroom.FieldStatus:
  40236. v, ok := value.(int8)
  40237. if !ok {
  40238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40239. }
  40240. m.AddStatus(v)
  40241. return nil
  40242. }
  40243. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40244. }
  40245. // ClearedFields returns all nullable fields that were cleared during this
  40246. // mutation.
  40247. func (m *WpChatroomMutation) ClearedFields() []string {
  40248. var fields []string
  40249. if m.FieldCleared(wpchatroom.FieldStatus) {
  40250. fields = append(fields, wpchatroom.FieldStatus)
  40251. }
  40252. return fields
  40253. }
  40254. // FieldCleared returns a boolean indicating if a field with the given name was
  40255. // cleared in this mutation.
  40256. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40257. _, ok := m.clearedFields[name]
  40258. return ok
  40259. }
  40260. // ClearField clears the value of the field with the given name. It returns an
  40261. // error if the field is not defined in the schema.
  40262. func (m *WpChatroomMutation) ClearField(name string) error {
  40263. switch name {
  40264. case wpchatroom.FieldStatus:
  40265. m.ClearStatus()
  40266. return nil
  40267. }
  40268. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40269. }
  40270. // ResetField resets all changes in the mutation for the field with the given name.
  40271. // It returns an error if the field is not defined in the schema.
  40272. func (m *WpChatroomMutation) ResetField(name string) error {
  40273. switch name {
  40274. case wpchatroom.FieldCreatedAt:
  40275. m.ResetCreatedAt()
  40276. return nil
  40277. case wpchatroom.FieldUpdatedAt:
  40278. m.ResetUpdatedAt()
  40279. return nil
  40280. case wpchatroom.FieldStatus:
  40281. m.ResetStatus()
  40282. return nil
  40283. case wpchatroom.FieldWxWxid:
  40284. m.ResetWxWxid()
  40285. return nil
  40286. case wpchatroom.FieldChatroomID:
  40287. m.ResetChatroomID()
  40288. return nil
  40289. case wpchatroom.FieldNickname:
  40290. m.ResetNickname()
  40291. return nil
  40292. case wpchatroom.FieldOwner:
  40293. m.ResetOwner()
  40294. return nil
  40295. case wpchatroom.FieldAvatar:
  40296. m.ResetAvatar()
  40297. return nil
  40298. case wpchatroom.FieldMemberList:
  40299. m.ResetMemberList()
  40300. return nil
  40301. }
  40302. return fmt.Errorf("unknown WpChatroom field %s", name)
  40303. }
  40304. // AddedEdges returns all edge names that were set/added in this mutation.
  40305. func (m *WpChatroomMutation) AddedEdges() []string {
  40306. edges := make([]string, 0, 0)
  40307. return edges
  40308. }
  40309. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40310. // name in this mutation.
  40311. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40312. return nil
  40313. }
  40314. // RemovedEdges returns all edge names that were removed in this mutation.
  40315. func (m *WpChatroomMutation) RemovedEdges() []string {
  40316. edges := make([]string, 0, 0)
  40317. return edges
  40318. }
  40319. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40320. // the given name in this mutation.
  40321. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40322. return nil
  40323. }
  40324. // ClearedEdges returns all edge names that were cleared in this mutation.
  40325. func (m *WpChatroomMutation) ClearedEdges() []string {
  40326. edges := make([]string, 0, 0)
  40327. return edges
  40328. }
  40329. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40330. // was cleared in this mutation.
  40331. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40332. return false
  40333. }
  40334. // ClearEdge clears the value of the edge with the given name. It returns an error
  40335. // if that edge is not defined in the schema.
  40336. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40337. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40338. }
  40339. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40340. // It returns an error if the edge is not defined in the schema.
  40341. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40342. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40343. }
  40344. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40345. type WpChatroomMemberMutation struct {
  40346. config
  40347. op Op
  40348. typ string
  40349. id *uint64
  40350. created_at *time.Time
  40351. updated_at *time.Time
  40352. status *uint8
  40353. addstatus *int8
  40354. wx_wxid *string
  40355. wxid *string
  40356. nickname *string
  40357. avatar *string
  40358. clearedFields map[string]struct{}
  40359. done bool
  40360. oldValue func(context.Context) (*WpChatroomMember, error)
  40361. predicates []predicate.WpChatroomMember
  40362. }
  40363. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40364. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40365. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40366. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40367. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40368. m := &WpChatroomMemberMutation{
  40369. config: c,
  40370. op: op,
  40371. typ: TypeWpChatroomMember,
  40372. clearedFields: make(map[string]struct{}),
  40373. }
  40374. for _, opt := range opts {
  40375. opt(m)
  40376. }
  40377. return m
  40378. }
  40379. // withWpChatroomMemberID sets the ID field of the mutation.
  40380. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40381. return func(m *WpChatroomMemberMutation) {
  40382. var (
  40383. err error
  40384. once sync.Once
  40385. value *WpChatroomMember
  40386. )
  40387. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40388. once.Do(func() {
  40389. if m.done {
  40390. err = errors.New("querying old values post mutation is not allowed")
  40391. } else {
  40392. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40393. }
  40394. })
  40395. return value, err
  40396. }
  40397. m.id = &id
  40398. }
  40399. }
  40400. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40401. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40402. return func(m *WpChatroomMemberMutation) {
  40403. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40404. return node, nil
  40405. }
  40406. m.id = &node.ID
  40407. }
  40408. }
  40409. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40410. // executed in a transaction (ent.Tx), a transactional client is returned.
  40411. func (m WpChatroomMemberMutation) Client() *Client {
  40412. client := &Client{config: m.config}
  40413. client.init()
  40414. return client
  40415. }
  40416. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40417. // it returns an error otherwise.
  40418. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40419. if _, ok := m.driver.(*txDriver); !ok {
  40420. return nil, errors.New("ent: mutation is not running in a transaction")
  40421. }
  40422. tx := &Tx{config: m.config}
  40423. tx.init()
  40424. return tx, nil
  40425. }
  40426. // SetID sets the value of the id field. Note that this
  40427. // operation is only accepted on creation of WpChatroomMember entities.
  40428. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40429. m.id = &id
  40430. }
  40431. // ID returns the ID value in the mutation. Note that the ID is only available
  40432. // if it was provided to the builder or after it was returned from the database.
  40433. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40434. if m.id == nil {
  40435. return
  40436. }
  40437. return *m.id, true
  40438. }
  40439. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40440. // That means, if the mutation is applied within a transaction with an isolation level such
  40441. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40442. // or updated by the mutation.
  40443. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40444. switch {
  40445. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40446. id, exists := m.ID()
  40447. if exists {
  40448. return []uint64{id}, nil
  40449. }
  40450. fallthrough
  40451. case m.op.Is(OpUpdate | OpDelete):
  40452. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40453. default:
  40454. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40455. }
  40456. }
  40457. // SetCreatedAt sets the "created_at" field.
  40458. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40459. m.created_at = &t
  40460. }
  40461. // CreatedAt returns the value of the "created_at" field in the mutation.
  40462. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40463. v := m.created_at
  40464. if v == nil {
  40465. return
  40466. }
  40467. return *v, true
  40468. }
  40469. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40470. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40472. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40473. if !m.op.Is(OpUpdateOne) {
  40474. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40475. }
  40476. if m.id == nil || m.oldValue == nil {
  40477. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40478. }
  40479. oldValue, err := m.oldValue(ctx)
  40480. if err != nil {
  40481. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40482. }
  40483. return oldValue.CreatedAt, nil
  40484. }
  40485. // ResetCreatedAt resets all changes to the "created_at" field.
  40486. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40487. m.created_at = nil
  40488. }
  40489. // SetUpdatedAt sets the "updated_at" field.
  40490. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40491. m.updated_at = &t
  40492. }
  40493. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40494. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40495. v := m.updated_at
  40496. if v == nil {
  40497. return
  40498. }
  40499. return *v, true
  40500. }
  40501. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40502. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40504. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40505. if !m.op.Is(OpUpdateOne) {
  40506. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40507. }
  40508. if m.id == nil || m.oldValue == nil {
  40509. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40510. }
  40511. oldValue, err := m.oldValue(ctx)
  40512. if err != nil {
  40513. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40514. }
  40515. return oldValue.UpdatedAt, nil
  40516. }
  40517. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40518. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40519. m.updated_at = nil
  40520. }
  40521. // SetStatus sets the "status" field.
  40522. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40523. m.status = &u
  40524. m.addstatus = nil
  40525. }
  40526. // Status returns the value of the "status" field in the mutation.
  40527. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40528. v := m.status
  40529. if v == nil {
  40530. return
  40531. }
  40532. return *v, true
  40533. }
  40534. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40535. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40537. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40538. if !m.op.Is(OpUpdateOne) {
  40539. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40540. }
  40541. if m.id == nil || m.oldValue == nil {
  40542. return v, errors.New("OldStatus requires an ID field in the mutation")
  40543. }
  40544. oldValue, err := m.oldValue(ctx)
  40545. if err != nil {
  40546. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40547. }
  40548. return oldValue.Status, nil
  40549. }
  40550. // AddStatus adds u to the "status" field.
  40551. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40552. if m.addstatus != nil {
  40553. *m.addstatus += u
  40554. } else {
  40555. m.addstatus = &u
  40556. }
  40557. }
  40558. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40559. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40560. v := m.addstatus
  40561. if v == nil {
  40562. return
  40563. }
  40564. return *v, true
  40565. }
  40566. // ClearStatus clears the value of the "status" field.
  40567. func (m *WpChatroomMemberMutation) ClearStatus() {
  40568. m.status = nil
  40569. m.addstatus = nil
  40570. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40571. }
  40572. // StatusCleared returns if the "status" field was cleared in this mutation.
  40573. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40574. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40575. return ok
  40576. }
  40577. // ResetStatus resets all changes to the "status" field.
  40578. func (m *WpChatroomMemberMutation) ResetStatus() {
  40579. m.status = nil
  40580. m.addstatus = nil
  40581. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40582. }
  40583. // SetWxWxid sets the "wx_wxid" field.
  40584. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40585. m.wx_wxid = &s
  40586. }
  40587. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40588. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40589. v := m.wx_wxid
  40590. if v == nil {
  40591. return
  40592. }
  40593. return *v, true
  40594. }
  40595. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40596. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40598. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40599. if !m.op.Is(OpUpdateOne) {
  40600. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40601. }
  40602. if m.id == nil || m.oldValue == nil {
  40603. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40604. }
  40605. oldValue, err := m.oldValue(ctx)
  40606. if err != nil {
  40607. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40608. }
  40609. return oldValue.WxWxid, nil
  40610. }
  40611. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40612. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40613. m.wx_wxid = nil
  40614. }
  40615. // SetWxid sets the "wxid" field.
  40616. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40617. m.wxid = &s
  40618. }
  40619. // Wxid returns the value of the "wxid" field in the mutation.
  40620. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40621. v := m.wxid
  40622. if v == nil {
  40623. return
  40624. }
  40625. return *v, true
  40626. }
  40627. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40628. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40630. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40631. if !m.op.Is(OpUpdateOne) {
  40632. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40633. }
  40634. if m.id == nil || m.oldValue == nil {
  40635. return v, errors.New("OldWxid requires an ID field in the mutation")
  40636. }
  40637. oldValue, err := m.oldValue(ctx)
  40638. if err != nil {
  40639. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40640. }
  40641. return oldValue.Wxid, nil
  40642. }
  40643. // ResetWxid resets all changes to the "wxid" field.
  40644. func (m *WpChatroomMemberMutation) ResetWxid() {
  40645. m.wxid = nil
  40646. }
  40647. // SetNickname sets the "nickname" field.
  40648. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  40649. m.nickname = &s
  40650. }
  40651. // Nickname returns the value of the "nickname" field in the mutation.
  40652. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  40653. v := m.nickname
  40654. if v == nil {
  40655. return
  40656. }
  40657. return *v, true
  40658. }
  40659. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  40660. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40662. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  40663. if !m.op.Is(OpUpdateOne) {
  40664. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40665. }
  40666. if m.id == nil || m.oldValue == nil {
  40667. return v, errors.New("OldNickname requires an ID field in the mutation")
  40668. }
  40669. oldValue, err := m.oldValue(ctx)
  40670. if err != nil {
  40671. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40672. }
  40673. return oldValue.Nickname, nil
  40674. }
  40675. // ResetNickname resets all changes to the "nickname" field.
  40676. func (m *WpChatroomMemberMutation) ResetNickname() {
  40677. m.nickname = nil
  40678. }
  40679. // SetAvatar sets the "avatar" field.
  40680. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  40681. m.avatar = &s
  40682. }
  40683. // Avatar returns the value of the "avatar" field in the mutation.
  40684. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  40685. v := m.avatar
  40686. if v == nil {
  40687. return
  40688. }
  40689. return *v, true
  40690. }
  40691. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  40692. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40694. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40695. if !m.op.Is(OpUpdateOne) {
  40696. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40697. }
  40698. if m.id == nil || m.oldValue == nil {
  40699. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40700. }
  40701. oldValue, err := m.oldValue(ctx)
  40702. if err != nil {
  40703. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40704. }
  40705. return oldValue.Avatar, nil
  40706. }
  40707. // ResetAvatar resets all changes to the "avatar" field.
  40708. func (m *WpChatroomMemberMutation) ResetAvatar() {
  40709. m.avatar = nil
  40710. }
  40711. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  40712. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  40713. m.predicates = append(m.predicates, ps...)
  40714. }
  40715. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  40716. // users can use type-assertion to append predicates that do not depend on any generated package.
  40717. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  40718. p := make([]predicate.WpChatroomMember, len(ps))
  40719. for i := range ps {
  40720. p[i] = ps[i]
  40721. }
  40722. m.Where(p...)
  40723. }
  40724. // Op returns the operation name.
  40725. func (m *WpChatroomMemberMutation) Op() Op {
  40726. return m.op
  40727. }
  40728. // SetOp allows setting the mutation operation.
  40729. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  40730. m.op = op
  40731. }
  40732. // Type returns the node type of this mutation (WpChatroomMember).
  40733. func (m *WpChatroomMemberMutation) Type() string {
  40734. return m.typ
  40735. }
  40736. // Fields returns all fields that were changed during this mutation. Note that in
  40737. // order to get all numeric fields that were incremented/decremented, call
  40738. // AddedFields().
  40739. func (m *WpChatroomMemberMutation) Fields() []string {
  40740. fields := make([]string, 0, 7)
  40741. if m.created_at != nil {
  40742. fields = append(fields, wpchatroommember.FieldCreatedAt)
  40743. }
  40744. if m.updated_at != nil {
  40745. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  40746. }
  40747. if m.status != nil {
  40748. fields = append(fields, wpchatroommember.FieldStatus)
  40749. }
  40750. if m.wx_wxid != nil {
  40751. fields = append(fields, wpchatroommember.FieldWxWxid)
  40752. }
  40753. if m.wxid != nil {
  40754. fields = append(fields, wpchatroommember.FieldWxid)
  40755. }
  40756. if m.nickname != nil {
  40757. fields = append(fields, wpchatroommember.FieldNickname)
  40758. }
  40759. if m.avatar != nil {
  40760. fields = append(fields, wpchatroommember.FieldAvatar)
  40761. }
  40762. return fields
  40763. }
  40764. // Field returns the value of a field with the given name. The second boolean
  40765. // return value indicates that this field was not set, or was not defined in the
  40766. // schema.
  40767. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  40768. switch name {
  40769. case wpchatroommember.FieldCreatedAt:
  40770. return m.CreatedAt()
  40771. case wpchatroommember.FieldUpdatedAt:
  40772. return m.UpdatedAt()
  40773. case wpchatroommember.FieldStatus:
  40774. return m.Status()
  40775. case wpchatroommember.FieldWxWxid:
  40776. return m.WxWxid()
  40777. case wpchatroommember.FieldWxid:
  40778. return m.Wxid()
  40779. case wpchatroommember.FieldNickname:
  40780. return m.Nickname()
  40781. case wpchatroommember.FieldAvatar:
  40782. return m.Avatar()
  40783. }
  40784. return nil, false
  40785. }
  40786. // OldField returns the old value of the field from the database. An error is
  40787. // returned if the mutation operation is not UpdateOne, or the query to the
  40788. // database failed.
  40789. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40790. switch name {
  40791. case wpchatroommember.FieldCreatedAt:
  40792. return m.OldCreatedAt(ctx)
  40793. case wpchatroommember.FieldUpdatedAt:
  40794. return m.OldUpdatedAt(ctx)
  40795. case wpchatroommember.FieldStatus:
  40796. return m.OldStatus(ctx)
  40797. case wpchatroommember.FieldWxWxid:
  40798. return m.OldWxWxid(ctx)
  40799. case wpchatroommember.FieldWxid:
  40800. return m.OldWxid(ctx)
  40801. case wpchatroommember.FieldNickname:
  40802. return m.OldNickname(ctx)
  40803. case wpchatroommember.FieldAvatar:
  40804. return m.OldAvatar(ctx)
  40805. }
  40806. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  40807. }
  40808. // SetField sets the value of a field with the given name. It returns an error if
  40809. // the field is not defined in the schema, or if the type mismatched the field
  40810. // type.
  40811. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  40812. switch name {
  40813. case wpchatroommember.FieldCreatedAt:
  40814. v, ok := value.(time.Time)
  40815. if !ok {
  40816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40817. }
  40818. m.SetCreatedAt(v)
  40819. return nil
  40820. case wpchatroommember.FieldUpdatedAt:
  40821. v, ok := value.(time.Time)
  40822. if !ok {
  40823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40824. }
  40825. m.SetUpdatedAt(v)
  40826. return nil
  40827. case wpchatroommember.FieldStatus:
  40828. v, ok := value.(uint8)
  40829. if !ok {
  40830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40831. }
  40832. m.SetStatus(v)
  40833. return nil
  40834. case wpchatroommember.FieldWxWxid:
  40835. v, ok := value.(string)
  40836. if !ok {
  40837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40838. }
  40839. m.SetWxWxid(v)
  40840. return nil
  40841. case wpchatroommember.FieldWxid:
  40842. v, ok := value.(string)
  40843. if !ok {
  40844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40845. }
  40846. m.SetWxid(v)
  40847. return nil
  40848. case wpchatroommember.FieldNickname:
  40849. v, ok := value.(string)
  40850. if !ok {
  40851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40852. }
  40853. m.SetNickname(v)
  40854. return nil
  40855. case wpchatroommember.FieldAvatar:
  40856. v, ok := value.(string)
  40857. if !ok {
  40858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40859. }
  40860. m.SetAvatar(v)
  40861. return nil
  40862. }
  40863. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40864. }
  40865. // AddedFields returns all numeric fields that were incremented/decremented during
  40866. // this mutation.
  40867. func (m *WpChatroomMemberMutation) AddedFields() []string {
  40868. var fields []string
  40869. if m.addstatus != nil {
  40870. fields = append(fields, wpchatroommember.FieldStatus)
  40871. }
  40872. return fields
  40873. }
  40874. // AddedField returns the numeric value that was incremented/decremented on a field
  40875. // with the given name. The second boolean return value indicates that this field
  40876. // was not set, or was not defined in the schema.
  40877. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  40878. switch name {
  40879. case wpchatroommember.FieldStatus:
  40880. return m.AddedStatus()
  40881. }
  40882. return nil, false
  40883. }
  40884. // AddField adds the value to the field with the given name. It returns an error if
  40885. // the field is not defined in the schema, or if the type mismatched the field
  40886. // type.
  40887. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  40888. switch name {
  40889. case wpchatroommember.FieldStatus:
  40890. v, ok := value.(int8)
  40891. if !ok {
  40892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40893. }
  40894. m.AddStatus(v)
  40895. return nil
  40896. }
  40897. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  40898. }
  40899. // ClearedFields returns all nullable fields that were cleared during this
  40900. // mutation.
  40901. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  40902. var fields []string
  40903. if m.FieldCleared(wpchatroommember.FieldStatus) {
  40904. fields = append(fields, wpchatroommember.FieldStatus)
  40905. }
  40906. return fields
  40907. }
  40908. // FieldCleared returns a boolean indicating if a field with the given name was
  40909. // cleared in this mutation.
  40910. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  40911. _, ok := m.clearedFields[name]
  40912. return ok
  40913. }
  40914. // ClearField clears the value of the field with the given name. It returns an
  40915. // error if the field is not defined in the schema.
  40916. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  40917. switch name {
  40918. case wpchatroommember.FieldStatus:
  40919. m.ClearStatus()
  40920. return nil
  40921. }
  40922. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  40923. }
  40924. // ResetField resets all changes in the mutation for the field with the given name.
  40925. // It returns an error if the field is not defined in the schema.
  40926. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  40927. switch name {
  40928. case wpchatroommember.FieldCreatedAt:
  40929. m.ResetCreatedAt()
  40930. return nil
  40931. case wpchatroommember.FieldUpdatedAt:
  40932. m.ResetUpdatedAt()
  40933. return nil
  40934. case wpchatroommember.FieldStatus:
  40935. m.ResetStatus()
  40936. return nil
  40937. case wpchatroommember.FieldWxWxid:
  40938. m.ResetWxWxid()
  40939. return nil
  40940. case wpchatroommember.FieldWxid:
  40941. m.ResetWxid()
  40942. return nil
  40943. case wpchatroommember.FieldNickname:
  40944. m.ResetNickname()
  40945. return nil
  40946. case wpchatroommember.FieldAvatar:
  40947. m.ResetAvatar()
  40948. return nil
  40949. }
  40950. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40951. }
  40952. // AddedEdges returns all edge names that were set/added in this mutation.
  40953. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  40954. edges := make([]string, 0, 0)
  40955. return edges
  40956. }
  40957. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40958. // name in this mutation.
  40959. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  40960. return nil
  40961. }
  40962. // RemovedEdges returns all edge names that were removed in this mutation.
  40963. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  40964. edges := make([]string, 0, 0)
  40965. return edges
  40966. }
  40967. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40968. // the given name in this mutation.
  40969. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  40970. return nil
  40971. }
  40972. // ClearedEdges returns all edge names that were cleared in this mutation.
  40973. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  40974. edges := make([]string, 0, 0)
  40975. return edges
  40976. }
  40977. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40978. // was cleared in this mutation.
  40979. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  40980. return false
  40981. }
  40982. // ClearEdge clears the value of the edge with the given name. It returns an error
  40983. // if that edge is not defined in the schema.
  40984. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  40985. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  40986. }
  40987. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40988. // It returns an error if the edge is not defined in the schema.
  40989. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  40990. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  40991. }
  40992. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  40993. type WxMutation struct {
  40994. config
  40995. op Op
  40996. typ string
  40997. id *uint64
  40998. created_at *time.Time
  40999. updated_at *time.Time
  41000. status *uint8
  41001. addstatus *int8
  41002. deleted_at *time.Time
  41003. port *string
  41004. process_id *string
  41005. callback *string
  41006. wxid *string
  41007. account *string
  41008. nickname *string
  41009. tel *string
  41010. head_big *string
  41011. organization_id *uint64
  41012. addorganization_id *int64
  41013. api_base *string
  41014. api_key *string
  41015. allow_list *[]string
  41016. appendallow_list []string
  41017. group_allow_list *[]string
  41018. appendgroup_allow_list []string
  41019. block_list *[]string
  41020. appendblock_list []string
  41021. group_block_list *[]string
  41022. appendgroup_block_list []string
  41023. ctype *uint64
  41024. addctype *int64
  41025. clearedFields map[string]struct{}
  41026. server *uint64
  41027. clearedserver bool
  41028. agent *uint64
  41029. clearedagent bool
  41030. done bool
  41031. oldValue func(context.Context) (*Wx, error)
  41032. predicates []predicate.Wx
  41033. }
  41034. var _ ent.Mutation = (*WxMutation)(nil)
  41035. // wxOption allows management of the mutation configuration using functional options.
  41036. type wxOption func(*WxMutation)
  41037. // newWxMutation creates new mutation for the Wx entity.
  41038. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  41039. m := &WxMutation{
  41040. config: c,
  41041. op: op,
  41042. typ: TypeWx,
  41043. clearedFields: make(map[string]struct{}),
  41044. }
  41045. for _, opt := range opts {
  41046. opt(m)
  41047. }
  41048. return m
  41049. }
  41050. // withWxID sets the ID field of the mutation.
  41051. func withWxID(id uint64) wxOption {
  41052. return func(m *WxMutation) {
  41053. var (
  41054. err error
  41055. once sync.Once
  41056. value *Wx
  41057. )
  41058. m.oldValue = func(ctx context.Context) (*Wx, error) {
  41059. once.Do(func() {
  41060. if m.done {
  41061. err = errors.New("querying old values post mutation is not allowed")
  41062. } else {
  41063. value, err = m.Client().Wx.Get(ctx, id)
  41064. }
  41065. })
  41066. return value, err
  41067. }
  41068. m.id = &id
  41069. }
  41070. }
  41071. // withWx sets the old Wx of the mutation.
  41072. func withWx(node *Wx) wxOption {
  41073. return func(m *WxMutation) {
  41074. m.oldValue = func(context.Context) (*Wx, error) {
  41075. return node, nil
  41076. }
  41077. m.id = &node.ID
  41078. }
  41079. }
  41080. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41081. // executed in a transaction (ent.Tx), a transactional client is returned.
  41082. func (m WxMutation) Client() *Client {
  41083. client := &Client{config: m.config}
  41084. client.init()
  41085. return client
  41086. }
  41087. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41088. // it returns an error otherwise.
  41089. func (m WxMutation) Tx() (*Tx, error) {
  41090. if _, ok := m.driver.(*txDriver); !ok {
  41091. return nil, errors.New("ent: mutation is not running in a transaction")
  41092. }
  41093. tx := &Tx{config: m.config}
  41094. tx.init()
  41095. return tx, nil
  41096. }
  41097. // SetID sets the value of the id field. Note that this
  41098. // operation is only accepted on creation of Wx entities.
  41099. func (m *WxMutation) SetID(id uint64) {
  41100. m.id = &id
  41101. }
  41102. // ID returns the ID value in the mutation. Note that the ID is only available
  41103. // if it was provided to the builder or after it was returned from the database.
  41104. func (m *WxMutation) ID() (id uint64, exists bool) {
  41105. if m.id == nil {
  41106. return
  41107. }
  41108. return *m.id, true
  41109. }
  41110. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41111. // That means, if the mutation is applied within a transaction with an isolation level such
  41112. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41113. // or updated by the mutation.
  41114. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41115. switch {
  41116. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41117. id, exists := m.ID()
  41118. if exists {
  41119. return []uint64{id}, nil
  41120. }
  41121. fallthrough
  41122. case m.op.Is(OpUpdate | OpDelete):
  41123. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41124. default:
  41125. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41126. }
  41127. }
  41128. // SetCreatedAt sets the "created_at" field.
  41129. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41130. m.created_at = &t
  41131. }
  41132. // CreatedAt returns the value of the "created_at" field in the mutation.
  41133. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41134. v := m.created_at
  41135. if v == nil {
  41136. return
  41137. }
  41138. return *v, true
  41139. }
  41140. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41141. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41143. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41144. if !m.op.Is(OpUpdateOne) {
  41145. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41146. }
  41147. if m.id == nil || m.oldValue == nil {
  41148. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41149. }
  41150. oldValue, err := m.oldValue(ctx)
  41151. if err != nil {
  41152. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41153. }
  41154. return oldValue.CreatedAt, nil
  41155. }
  41156. // ResetCreatedAt resets all changes to the "created_at" field.
  41157. func (m *WxMutation) ResetCreatedAt() {
  41158. m.created_at = nil
  41159. }
  41160. // SetUpdatedAt sets the "updated_at" field.
  41161. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41162. m.updated_at = &t
  41163. }
  41164. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41165. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41166. v := m.updated_at
  41167. if v == nil {
  41168. return
  41169. }
  41170. return *v, true
  41171. }
  41172. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41173. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41175. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41176. if !m.op.Is(OpUpdateOne) {
  41177. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41178. }
  41179. if m.id == nil || m.oldValue == nil {
  41180. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41181. }
  41182. oldValue, err := m.oldValue(ctx)
  41183. if err != nil {
  41184. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41185. }
  41186. return oldValue.UpdatedAt, nil
  41187. }
  41188. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41189. func (m *WxMutation) ResetUpdatedAt() {
  41190. m.updated_at = nil
  41191. }
  41192. // SetStatus sets the "status" field.
  41193. func (m *WxMutation) SetStatus(u uint8) {
  41194. m.status = &u
  41195. m.addstatus = nil
  41196. }
  41197. // Status returns the value of the "status" field in the mutation.
  41198. func (m *WxMutation) Status() (r uint8, exists bool) {
  41199. v := m.status
  41200. if v == nil {
  41201. return
  41202. }
  41203. return *v, true
  41204. }
  41205. // OldStatus returns the old "status" field's value of the Wx entity.
  41206. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41208. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41209. if !m.op.Is(OpUpdateOne) {
  41210. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41211. }
  41212. if m.id == nil || m.oldValue == nil {
  41213. return v, errors.New("OldStatus requires an ID field in the mutation")
  41214. }
  41215. oldValue, err := m.oldValue(ctx)
  41216. if err != nil {
  41217. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41218. }
  41219. return oldValue.Status, nil
  41220. }
  41221. // AddStatus adds u to the "status" field.
  41222. func (m *WxMutation) AddStatus(u int8) {
  41223. if m.addstatus != nil {
  41224. *m.addstatus += u
  41225. } else {
  41226. m.addstatus = &u
  41227. }
  41228. }
  41229. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41230. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41231. v := m.addstatus
  41232. if v == nil {
  41233. return
  41234. }
  41235. return *v, true
  41236. }
  41237. // ClearStatus clears the value of the "status" field.
  41238. func (m *WxMutation) ClearStatus() {
  41239. m.status = nil
  41240. m.addstatus = nil
  41241. m.clearedFields[wx.FieldStatus] = struct{}{}
  41242. }
  41243. // StatusCleared returns if the "status" field was cleared in this mutation.
  41244. func (m *WxMutation) StatusCleared() bool {
  41245. _, ok := m.clearedFields[wx.FieldStatus]
  41246. return ok
  41247. }
  41248. // ResetStatus resets all changes to the "status" field.
  41249. func (m *WxMutation) ResetStatus() {
  41250. m.status = nil
  41251. m.addstatus = nil
  41252. delete(m.clearedFields, wx.FieldStatus)
  41253. }
  41254. // SetDeletedAt sets the "deleted_at" field.
  41255. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41256. m.deleted_at = &t
  41257. }
  41258. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41259. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41260. v := m.deleted_at
  41261. if v == nil {
  41262. return
  41263. }
  41264. return *v, true
  41265. }
  41266. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41267. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41269. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41270. if !m.op.Is(OpUpdateOne) {
  41271. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41272. }
  41273. if m.id == nil || m.oldValue == nil {
  41274. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41275. }
  41276. oldValue, err := m.oldValue(ctx)
  41277. if err != nil {
  41278. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41279. }
  41280. return oldValue.DeletedAt, nil
  41281. }
  41282. // ClearDeletedAt clears the value of the "deleted_at" field.
  41283. func (m *WxMutation) ClearDeletedAt() {
  41284. m.deleted_at = nil
  41285. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41286. }
  41287. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41288. func (m *WxMutation) DeletedAtCleared() bool {
  41289. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41290. return ok
  41291. }
  41292. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41293. func (m *WxMutation) ResetDeletedAt() {
  41294. m.deleted_at = nil
  41295. delete(m.clearedFields, wx.FieldDeletedAt)
  41296. }
  41297. // SetServerID sets the "server_id" field.
  41298. func (m *WxMutation) SetServerID(u uint64) {
  41299. m.server = &u
  41300. }
  41301. // ServerID returns the value of the "server_id" field in the mutation.
  41302. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41303. v := m.server
  41304. if v == nil {
  41305. return
  41306. }
  41307. return *v, true
  41308. }
  41309. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41310. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41312. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41313. if !m.op.Is(OpUpdateOne) {
  41314. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41315. }
  41316. if m.id == nil || m.oldValue == nil {
  41317. return v, errors.New("OldServerID requires an ID field in the mutation")
  41318. }
  41319. oldValue, err := m.oldValue(ctx)
  41320. if err != nil {
  41321. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41322. }
  41323. return oldValue.ServerID, nil
  41324. }
  41325. // ClearServerID clears the value of the "server_id" field.
  41326. func (m *WxMutation) ClearServerID() {
  41327. m.server = nil
  41328. m.clearedFields[wx.FieldServerID] = struct{}{}
  41329. }
  41330. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41331. func (m *WxMutation) ServerIDCleared() bool {
  41332. _, ok := m.clearedFields[wx.FieldServerID]
  41333. return ok
  41334. }
  41335. // ResetServerID resets all changes to the "server_id" field.
  41336. func (m *WxMutation) ResetServerID() {
  41337. m.server = nil
  41338. delete(m.clearedFields, wx.FieldServerID)
  41339. }
  41340. // SetPort sets the "port" field.
  41341. func (m *WxMutation) SetPort(s string) {
  41342. m.port = &s
  41343. }
  41344. // Port returns the value of the "port" field in the mutation.
  41345. func (m *WxMutation) Port() (r string, exists bool) {
  41346. v := m.port
  41347. if v == nil {
  41348. return
  41349. }
  41350. return *v, true
  41351. }
  41352. // OldPort returns the old "port" field's value of the Wx entity.
  41353. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41355. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41356. if !m.op.Is(OpUpdateOne) {
  41357. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41358. }
  41359. if m.id == nil || m.oldValue == nil {
  41360. return v, errors.New("OldPort requires an ID field in the mutation")
  41361. }
  41362. oldValue, err := m.oldValue(ctx)
  41363. if err != nil {
  41364. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41365. }
  41366. return oldValue.Port, nil
  41367. }
  41368. // ResetPort resets all changes to the "port" field.
  41369. func (m *WxMutation) ResetPort() {
  41370. m.port = nil
  41371. }
  41372. // SetProcessID sets the "process_id" field.
  41373. func (m *WxMutation) SetProcessID(s string) {
  41374. m.process_id = &s
  41375. }
  41376. // ProcessID returns the value of the "process_id" field in the mutation.
  41377. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41378. v := m.process_id
  41379. if v == nil {
  41380. return
  41381. }
  41382. return *v, true
  41383. }
  41384. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41385. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41387. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41388. if !m.op.Is(OpUpdateOne) {
  41389. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41390. }
  41391. if m.id == nil || m.oldValue == nil {
  41392. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41393. }
  41394. oldValue, err := m.oldValue(ctx)
  41395. if err != nil {
  41396. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41397. }
  41398. return oldValue.ProcessID, nil
  41399. }
  41400. // ResetProcessID resets all changes to the "process_id" field.
  41401. func (m *WxMutation) ResetProcessID() {
  41402. m.process_id = nil
  41403. }
  41404. // SetCallback sets the "callback" field.
  41405. func (m *WxMutation) SetCallback(s string) {
  41406. m.callback = &s
  41407. }
  41408. // Callback returns the value of the "callback" field in the mutation.
  41409. func (m *WxMutation) Callback() (r string, exists bool) {
  41410. v := m.callback
  41411. if v == nil {
  41412. return
  41413. }
  41414. return *v, true
  41415. }
  41416. // OldCallback returns the old "callback" field's value of the Wx entity.
  41417. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41419. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41420. if !m.op.Is(OpUpdateOne) {
  41421. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41422. }
  41423. if m.id == nil || m.oldValue == nil {
  41424. return v, errors.New("OldCallback requires an ID field in the mutation")
  41425. }
  41426. oldValue, err := m.oldValue(ctx)
  41427. if err != nil {
  41428. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41429. }
  41430. return oldValue.Callback, nil
  41431. }
  41432. // ResetCallback resets all changes to the "callback" field.
  41433. func (m *WxMutation) ResetCallback() {
  41434. m.callback = nil
  41435. }
  41436. // SetWxid sets the "wxid" field.
  41437. func (m *WxMutation) SetWxid(s string) {
  41438. m.wxid = &s
  41439. }
  41440. // Wxid returns the value of the "wxid" field in the mutation.
  41441. func (m *WxMutation) Wxid() (r string, exists bool) {
  41442. v := m.wxid
  41443. if v == nil {
  41444. return
  41445. }
  41446. return *v, true
  41447. }
  41448. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41449. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41451. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41452. if !m.op.Is(OpUpdateOne) {
  41453. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41454. }
  41455. if m.id == nil || m.oldValue == nil {
  41456. return v, errors.New("OldWxid requires an ID field in the mutation")
  41457. }
  41458. oldValue, err := m.oldValue(ctx)
  41459. if err != nil {
  41460. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41461. }
  41462. return oldValue.Wxid, nil
  41463. }
  41464. // ResetWxid resets all changes to the "wxid" field.
  41465. func (m *WxMutation) ResetWxid() {
  41466. m.wxid = nil
  41467. }
  41468. // SetAccount sets the "account" field.
  41469. func (m *WxMutation) SetAccount(s string) {
  41470. m.account = &s
  41471. }
  41472. // Account returns the value of the "account" field in the mutation.
  41473. func (m *WxMutation) Account() (r string, exists bool) {
  41474. v := m.account
  41475. if v == nil {
  41476. return
  41477. }
  41478. return *v, true
  41479. }
  41480. // OldAccount returns the old "account" field's value of the Wx entity.
  41481. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41483. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41484. if !m.op.Is(OpUpdateOne) {
  41485. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41486. }
  41487. if m.id == nil || m.oldValue == nil {
  41488. return v, errors.New("OldAccount requires an ID field in the mutation")
  41489. }
  41490. oldValue, err := m.oldValue(ctx)
  41491. if err != nil {
  41492. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41493. }
  41494. return oldValue.Account, nil
  41495. }
  41496. // ResetAccount resets all changes to the "account" field.
  41497. func (m *WxMutation) ResetAccount() {
  41498. m.account = nil
  41499. }
  41500. // SetNickname sets the "nickname" field.
  41501. func (m *WxMutation) SetNickname(s string) {
  41502. m.nickname = &s
  41503. }
  41504. // Nickname returns the value of the "nickname" field in the mutation.
  41505. func (m *WxMutation) Nickname() (r string, exists bool) {
  41506. v := m.nickname
  41507. if v == nil {
  41508. return
  41509. }
  41510. return *v, true
  41511. }
  41512. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41513. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41515. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41516. if !m.op.Is(OpUpdateOne) {
  41517. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41518. }
  41519. if m.id == nil || m.oldValue == nil {
  41520. return v, errors.New("OldNickname requires an ID field in the mutation")
  41521. }
  41522. oldValue, err := m.oldValue(ctx)
  41523. if err != nil {
  41524. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41525. }
  41526. return oldValue.Nickname, nil
  41527. }
  41528. // ResetNickname resets all changes to the "nickname" field.
  41529. func (m *WxMutation) ResetNickname() {
  41530. m.nickname = nil
  41531. }
  41532. // SetTel sets the "tel" field.
  41533. func (m *WxMutation) SetTel(s string) {
  41534. m.tel = &s
  41535. }
  41536. // Tel returns the value of the "tel" field in the mutation.
  41537. func (m *WxMutation) Tel() (r string, exists bool) {
  41538. v := m.tel
  41539. if v == nil {
  41540. return
  41541. }
  41542. return *v, true
  41543. }
  41544. // OldTel returns the old "tel" field's value of the Wx entity.
  41545. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41547. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41548. if !m.op.Is(OpUpdateOne) {
  41549. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41550. }
  41551. if m.id == nil || m.oldValue == nil {
  41552. return v, errors.New("OldTel requires an ID field in the mutation")
  41553. }
  41554. oldValue, err := m.oldValue(ctx)
  41555. if err != nil {
  41556. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41557. }
  41558. return oldValue.Tel, nil
  41559. }
  41560. // ResetTel resets all changes to the "tel" field.
  41561. func (m *WxMutation) ResetTel() {
  41562. m.tel = nil
  41563. }
  41564. // SetHeadBig sets the "head_big" field.
  41565. func (m *WxMutation) SetHeadBig(s string) {
  41566. m.head_big = &s
  41567. }
  41568. // HeadBig returns the value of the "head_big" field in the mutation.
  41569. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41570. v := m.head_big
  41571. if v == nil {
  41572. return
  41573. }
  41574. return *v, true
  41575. }
  41576. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41577. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41579. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41580. if !m.op.Is(OpUpdateOne) {
  41581. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41582. }
  41583. if m.id == nil || m.oldValue == nil {
  41584. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41585. }
  41586. oldValue, err := m.oldValue(ctx)
  41587. if err != nil {
  41588. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41589. }
  41590. return oldValue.HeadBig, nil
  41591. }
  41592. // ResetHeadBig resets all changes to the "head_big" field.
  41593. func (m *WxMutation) ResetHeadBig() {
  41594. m.head_big = nil
  41595. }
  41596. // SetOrganizationID sets the "organization_id" field.
  41597. func (m *WxMutation) SetOrganizationID(u uint64) {
  41598. m.organization_id = &u
  41599. m.addorganization_id = nil
  41600. }
  41601. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41602. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41603. v := m.organization_id
  41604. if v == nil {
  41605. return
  41606. }
  41607. return *v, true
  41608. }
  41609. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41610. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41612. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41613. if !m.op.Is(OpUpdateOne) {
  41614. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41615. }
  41616. if m.id == nil || m.oldValue == nil {
  41617. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41618. }
  41619. oldValue, err := m.oldValue(ctx)
  41620. if err != nil {
  41621. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41622. }
  41623. return oldValue.OrganizationID, nil
  41624. }
  41625. // AddOrganizationID adds u to the "organization_id" field.
  41626. func (m *WxMutation) AddOrganizationID(u int64) {
  41627. if m.addorganization_id != nil {
  41628. *m.addorganization_id += u
  41629. } else {
  41630. m.addorganization_id = &u
  41631. }
  41632. }
  41633. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41634. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  41635. v := m.addorganization_id
  41636. if v == nil {
  41637. return
  41638. }
  41639. return *v, true
  41640. }
  41641. // ClearOrganizationID clears the value of the "organization_id" field.
  41642. func (m *WxMutation) ClearOrganizationID() {
  41643. m.organization_id = nil
  41644. m.addorganization_id = nil
  41645. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  41646. }
  41647. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41648. func (m *WxMutation) OrganizationIDCleared() bool {
  41649. _, ok := m.clearedFields[wx.FieldOrganizationID]
  41650. return ok
  41651. }
  41652. // ResetOrganizationID resets all changes to the "organization_id" field.
  41653. func (m *WxMutation) ResetOrganizationID() {
  41654. m.organization_id = nil
  41655. m.addorganization_id = nil
  41656. delete(m.clearedFields, wx.FieldOrganizationID)
  41657. }
  41658. // SetAgentID sets the "agent_id" field.
  41659. func (m *WxMutation) SetAgentID(u uint64) {
  41660. m.agent = &u
  41661. }
  41662. // AgentID returns the value of the "agent_id" field in the mutation.
  41663. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  41664. v := m.agent
  41665. if v == nil {
  41666. return
  41667. }
  41668. return *v, true
  41669. }
  41670. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  41671. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41673. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41674. if !m.op.Is(OpUpdateOne) {
  41675. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41676. }
  41677. if m.id == nil || m.oldValue == nil {
  41678. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41679. }
  41680. oldValue, err := m.oldValue(ctx)
  41681. if err != nil {
  41682. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41683. }
  41684. return oldValue.AgentID, nil
  41685. }
  41686. // ResetAgentID resets all changes to the "agent_id" field.
  41687. func (m *WxMutation) ResetAgentID() {
  41688. m.agent = nil
  41689. }
  41690. // SetAPIBase sets the "api_base" field.
  41691. func (m *WxMutation) SetAPIBase(s string) {
  41692. m.api_base = &s
  41693. }
  41694. // APIBase returns the value of the "api_base" field in the mutation.
  41695. func (m *WxMutation) APIBase() (r string, exists bool) {
  41696. v := m.api_base
  41697. if v == nil {
  41698. return
  41699. }
  41700. return *v, true
  41701. }
  41702. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  41703. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41705. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41706. if !m.op.Is(OpUpdateOne) {
  41707. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41708. }
  41709. if m.id == nil || m.oldValue == nil {
  41710. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41711. }
  41712. oldValue, err := m.oldValue(ctx)
  41713. if err != nil {
  41714. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41715. }
  41716. return oldValue.APIBase, nil
  41717. }
  41718. // ClearAPIBase clears the value of the "api_base" field.
  41719. func (m *WxMutation) ClearAPIBase() {
  41720. m.api_base = nil
  41721. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  41722. }
  41723. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41724. func (m *WxMutation) APIBaseCleared() bool {
  41725. _, ok := m.clearedFields[wx.FieldAPIBase]
  41726. return ok
  41727. }
  41728. // ResetAPIBase resets all changes to the "api_base" field.
  41729. func (m *WxMutation) ResetAPIBase() {
  41730. m.api_base = nil
  41731. delete(m.clearedFields, wx.FieldAPIBase)
  41732. }
  41733. // SetAPIKey sets the "api_key" field.
  41734. func (m *WxMutation) SetAPIKey(s string) {
  41735. m.api_key = &s
  41736. }
  41737. // APIKey returns the value of the "api_key" field in the mutation.
  41738. func (m *WxMutation) APIKey() (r string, exists bool) {
  41739. v := m.api_key
  41740. if v == nil {
  41741. return
  41742. }
  41743. return *v, true
  41744. }
  41745. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  41746. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41748. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41749. if !m.op.Is(OpUpdateOne) {
  41750. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41751. }
  41752. if m.id == nil || m.oldValue == nil {
  41753. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41754. }
  41755. oldValue, err := m.oldValue(ctx)
  41756. if err != nil {
  41757. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41758. }
  41759. return oldValue.APIKey, nil
  41760. }
  41761. // ClearAPIKey clears the value of the "api_key" field.
  41762. func (m *WxMutation) ClearAPIKey() {
  41763. m.api_key = nil
  41764. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  41765. }
  41766. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41767. func (m *WxMutation) APIKeyCleared() bool {
  41768. _, ok := m.clearedFields[wx.FieldAPIKey]
  41769. return ok
  41770. }
  41771. // ResetAPIKey resets all changes to the "api_key" field.
  41772. func (m *WxMutation) ResetAPIKey() {
  41773. m.api_key = nil
  41774. delete(m.clearedFields, wx.FieldAPIKey)
  41775. }
  41776. // SetAllowList sets the "allow_list" field.
  41777. func (m *WxMutation) SetAllowList(s []string) {
  41778. m.allow_list = &s
  41779. m.appendallow_list = nil
  41780. }
  41781. // AllowList returns the value of the "allow_list" field in the mutation.
  41782. func (m *WxMutation) AllowList() (r []string, exists bool) {
  41783. v := m.allow_list
  41784. if v == nil {
  41785. return
  41786. }
  41787. return *v, true
  41788. }
  41789. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  41790. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41792. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41793. if !m.op.Is(OpUpdateOne) {
  41794. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41795. }
  41796. if m.id == nil || m.oldValue == nil {
  41797. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41798. }
  41799. oldValue, err := m.oldValue(ctx)
  41800. if err != nil {
  41801. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41802. }
  41803. return oldValue.AllowList, nil
  41804. }
  41805. // AppendAllowList adds s to the "allow_list" field.
  41806. func (m *WxMutation) AppendAllowList(s []string) {
  41807. m.appendallow_list = append(m.appendallow_list, s...)
  41808. }
  41809. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41810. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  41811. if len(m.appendallow_list) == 0 {
  41812. return nil, false
  41813. }
  41814. return m.appendallow_list, true
  41815. }
  41816. // ResetAllowList resets all changes to the "allow_list" field.
  41817. func (m *WxMutation) ResetAllowList() {
  41818. m.allow_list = nil
  41819. m.appendallow_list = nil
  41820. }
  41821. // SetGroupAllowList sets the "group_allow_list" field.
  41822. func (m *WxMutation) SetGroupAllowList(s []string) {
  41823. m.group_allow_list = &s
  41824. m.appendgroup_allow_list = nil
  41825. }
  41826. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41827. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  41828. v := m.group_allow_list
  41829. if v == nil {
  41830. return
  41831. }
  41832. return *v, true
  41833. }
  41834. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  41835. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41837. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41838. if !m.op.Is(OpUpdateOne) {
  41839. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41840. }
  41841. if m.id == nil || m.oldValue == nil {
  41842. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41843. }
  41844. oldValue, err := m.oldValue(ctx)
  41845. if err != nil {
  41846. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41847. }
  41848. return oldValue.GroupAllowList, nil
  41849. }
  41850. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41851. func (m *WxMutation) AppendGroupAllowList(s []string) {
  41852. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41853. }
  41854. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41855. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  41856. if len(m.appendgroup_allow_list) == 0 {
  41857. return nil, false
  41858. }
  41859. return m.appendgroup_allow_list, true
  41860. }
  41861. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41862. func (m *WxMutation) ResetGroupAllowList() {
  41863. m.group_allow_list = nil
  41864. m.appendgroup_allow_list = nil
  41865. }
  41866. // SetBlockList sets the "block_list" field.
  41867. func (m *WxMutation) SetBlockList(s []string) {
  41868. m.block_list = &s
  41869. m.appendblock_list = nil
  41870. }
  41871. // BlockList returns the value of the "block_list" field in the mutation.
  41872. func (m *WxMutation) BlockList() (r []string, exists bool) {
  41873. v := m.block_list
  41874. if v == nil {
  41875. return
  41876. }
  41877. return *v, true
  41878. }
  41879. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  41880. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41882. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41883. if !m.op.Is(OpUpdateOne) {
  41884. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41885. }
  41886. if m.id == nil || m.oldValue == nil {
  41887. return v, errors.New("OldBlockList requires an ID field in the mutation")
  41888. }
  41889. oldValue, err := m.oldValue(ctx)
  41890. if err != nil {
  41891. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  41892. }
  41893. return oldValue.BlockList, nil
  41894. }
  41895. // AppendBlockList adds s to the "block_list" field.
  41896. func (m *WxMutation) AppendBlockList(s []string) {
  41897. m.appendblock_list = append(m.appendblock_list, s...)
  41898. }
  41899. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41900. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  41901. if len(m.appendblock_list) == 0 {
  41902. return nil, false
  41903. }
  41904. return m.appendblock_list, true
  41905. }
  41906. // ResetBlockList resets all changes to the "block_list" field.
  41907. func (m *WxMutation) ResetBlockList() {
  41908. m.block_list = nil
  41909. m.appendblock_list = nil
  41910. }
  41911. // SetGroupBlockList sets the "group_block_list" field.
  41912. func (m *WxMutation) SetGroupBlockList(s []string) {
  41913. m.group_block_list = &s
  41914. m.appendgroup_block_list = nil
  41915. }
  41916. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41917. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  41918. v := m.group_block_list
  41919. if v == nil {
  41920. return
  41921. }
  41922. return *v, true
  41923. }
  41924. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  41925. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41927. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  41928. if !m.op.Is(OpUpdateOne) {
  41929. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  41930. }
  41931. if m.id == nil || m.oldValue == nil {
  41932. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  41933. }
  41934. oldValue, err := m.oldValue(ctx)
  41935. if err != nil {
  41936. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  41937. }
  41938. return oldValue.GroupBlockList, nil
  41939. }
  41940. // AppendGroupBlockList adds s to the "group_block_list" field.
  41941. func (m *WxMutation) AppendGroupBlockList(s []string) {
  41942. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  41943. }
  41944. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  41945. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  41946. if len(m.appendgroup_block_list) == 0 {
  41947. return nil, false
  41948. }
  41949. return m.appendgroup_block_list, true
  41950. }
  41951. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  41952. func (m *WxMutation) ResetGroupBlockList() {
  41953. m.group_block_list = nil
  41954. m.appendgroup_block_list = nil
  41955. }
  41956. // SetCtype sets the "ctype" field.
  41957. func (m *WxMutation) SetCtype(u uint64) {
  41958. m.ctype = &u
  41959. m.addctype = nil
  41960. }
  41961. // Ctype returns the value of the "ctype" field in the mutation.
  41962. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  41963. v := m.ctype
  41964. if v == nil {
  41965. return
  41966. }
  41967. return *v, true
  41968. }
  41969. // OldCtype returns the old "ctype" field's value of the Wx entity.
  41970. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41972. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  41973. if !m.op.Is(OpUpdateOne) {
  41974. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  41975. }
  41976. if m.id == nil || m.oldValue == nil {
  41977. return v, errors.New("OldCtype requires an ID field in the mutation")
  41978. }
  41979. oldValue, err := m.oldValue(ctx)
  41980. if err != nil {
  41981. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  41982. }
  41983. return oldValue.Ctype, nil
  41984. }
  41985. // AddCtype adds u to the "ctype" field.
  41986. func (m *WxMutation) AddCtype(u int64) {
  41987. if m.addctype != nil {
  41988. *m.addctype += u
  41989. } else {
  41990. m.addctype = &u
  41991. }
  41992. }
  41993. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  41994. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  41995. v := m.addctype
  41996. if v == nil {
  41997. return
  41998. }
  41999. return *v, true
  42000. }
  42001. // ClearCtype clears the value of the "ctype" field.
  42002. func (m *WxMutation) ClearCtype() {
  42003. m.ctype = nil
  42004. m.addctype = nil
  42005. m.clearedFields[wx.FieldCtype] = struct{}{}
  42006. }
  42007. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  42008. func (m *WxMutation) CtypeCleared() bool {
  42009. _, ok := m.clearedFields[wx.FieldCtype]
  42010. return ok
  42011. }
  42012. // ResetCtype resets all changes to the "ctype" field.
  42013. func (m *WxMutation) ResetCtype() {
  42014. m.ctype = nil
  42015. m.addctype = nil
  42016. delete(m.clearedFields, wx.FieldCtype)
  42017. }
  42018. // ClearServer clears the "server" edge to the Server entity.
  42019. func (m *WxMutation) ClearServer() {
  42020. m.clearedserver = true
  42021. m.clearedFields[wx.FieldServerID] = struct{}{}
  42022. }
  42023. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  42024. func (m *WxMutation) ServerCleared() bool {
  42025. return m.ServerIDCleared() || m.clearedserver
  42026. }
  42027. // ServerIDs returns the "server" edge IDs in the mutation.
  42028. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42029. // ServerID instead. It exists only for internal usage by the builders.
  42030. func (m *WxMutation) ServerIDs() (ids []uint64) {
  42031. if id := m.server; id != nil {
  42032. ids = append(ids, *id)
  42033. }
  42034. return
  42035. }
  42036. // ResetServer resets all changes to the "server" edge.
  42037. func (m *WxMutation) ResetServer() {
  42038. m.server = nil
  42039. m.clearedserver = false
  42040. }
  42041. // ClearAgent clears the "agent" edge to the Agent entity.
  42042. func (m *WxMutation) ClearAgent() {
  42043. m.clearedagent = true
  42044. m.clearedFields[wx.FieldAgentID] = struct{}{}
  42045. }
  42046. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42047. func (m *WxMutation) AgentCleared() bool {
  42048. return m.clearedagent
  42049. }
  42050. // AgentIDs returns the "agent" edge IDs in the mutation.
  42051. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42052. // AgentID instead. It exists only for internal usage by the builders.
  42053. func (m *WxMutation) AgentIDs() (ids []uint64) {
  42054. if id := m.agent; id != nil {
  42055. ids = append(ids, *id)
  42056. }
  42057. return
  42058. }
  42059. // ResetAgent resets all changes to the "agent" edge.
  42060. func (m *WxMutation) ResetAgent() {
  42061. m.agent = nil
  42062. m.clearedagent = false
  42063. }
  42064. // Where appends a list predicates to the WxMutation builder.
  42065. func (m *WxMutation) Where(ps ...predicate.Wx) {
  42066. m.predicates = append(m.predicates, ps...)
  42067. }
  42068. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  42069. // users can use type-assertion to append predicates that do not depend on any generated package.
  42070. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  42071. p := make([]predicate.Wx, len(ps))
  42072. for i := range ps {
  42073. p[i] = ps[i]
  42074. }
  42075. m.Where(p...)
  42076. }
  42077. // Op returns the operation name.
  42078. func (m *WxMutation) Op() Op {
  42079. return m.op
  42080. }
  42081. // SetOp allows setting the mutation operation.
  42082. func (m *WxMutation) SetOp(op Op) {
  42083. m.op = op
  42084. }
  42085. // Type returns the node type of this mutation (Wx).
  42086. func (m *WxMutation) Type() string {
  42087. return m.typ
  42088. }
  42089. // Fields returns all fields that were changed during this mutation. Note that in
  42090. // order to get all numeric fields that were incremented/decremented, call
  42091. // AddedFields().
  42092. func (m *WxMutation) Fields() []string {
  42093. fields := make([]string, 0, 22)
  42094. if m.created_at != nil {
  42095. fields = append(fields, wx.FieldCreatedAt)
  42096. }
  42097. if m.updated_at != nil {
  42098. fields = append(fields, wx.FieldUpdatedAt)
  42099. }
  42100. if m.status != nil {
  42101. fields = append(fields, wx.FieldStatus)
  42102. }
  42103. if m.deleted_at != nil {
  42104. fields = append(fields, wx.FieldDeletedAt)
  42105. }
  42106. if m.server != nil {
  42107. fields = append(fields, wx.FieldServerID)
  42108. }
  42109. if m.port != nil {
  42110. fields = append(fields, wx.FieldPort)
  42111. }
  42112. if m.process_id != nil {
  42113. fields = append(fields, wx.FieldProcessID)
  42114. }
  42115. if m.callback != nil {
  42116. fields = append(fields, wx.FieldCallback)
  42117. }
  42118. if m.wxid != nil {
  42119. fields = append(fields, wx.FieldWxid)
  42120. }
  42121. if m.account != nil {
  42122. fields = append(fields, wx.FieldAccount)
  42123. }
  42124. if m.nickname != nil {
  42125. fields = append(fields, wx.FieldNickname)
  42126. }
  42127. if m.tel != nil {
  42128. fields = append(fields, wx.FieldTel)
  42129. }
  42130. if m.head_big != nil {
  42131. fields = append(fields, wx.FieldHeadBig)
  42132. }
  42133. if m.organization_id != nil {
  42134. fields = append(fields, wx.FieldOrganizationID)
  42135. }
  42136. if m.agent != nil {
  42137. fields = append(fields, wx.FieldAgentID)
  42138. }
  42139. if m.api_base != nil {
  42140. fields = append(fields, wx.FieldAPIBase)
  42141. }
  42142. if m.api_key != nil {
  42143. fields = append(fields, wx.FieldAPIKey)
  42144. }
  42145. if m.allow_list != nil {
  42146. fields = append(fields, wx.FieldAllowList)
  42147. }
  42148. if m.group_allow_list != nil {
  42149. fields = append(fields, wx.FieldGroupAllowList)
  42150. }
  42151. if m.block_list != nil {
  42152. fields = append(fields, wx.FieldBlockList)
  42153. }
  42154. if m.group_block_list != nil {
  42155. fields = append(fields, wx.FieldGroupBlockList)
  42156. }
  42157. if m.ctype != nil {
  42158. fields = append(fields, wx.FieldCtype)
  42159. }
  42160. return fields
  42161. }
  42162. // Field returns the value of a field with the given name. The second boolean
  42163. // return value indicates that this field was not set, or was not defined in the
  42164. // schema.
  42165. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42166. switch name {
  42167. case wx.FieldCreatedAt:
  42168. return m.CreatedAt()
  42169. case wx.FieldUpdatedAt:
  42170. return m.UpdatedAt()
  42171. case wx.FieldStatus:
  42172. return m.Status()
  42173. case wx.FieldDeletedAt:
  42174. return m.DeletedAt()
  42175. case wx.FieldServerID:
  42176. return m.ServerID()
  42177. case wx.FieldPort:
  42178. return m.Port()
  42179. case wx.FieldProcessID:
  42180. return m.ProcessID()
  42181. case wx.FieldCallback:
  42182. return m.Callback()
  42183. case wx.FieldWxid:
  42184. return m.Wxid()
  42185. case wx.FieldAccount:
  42186. return m.Account()
  42187. case wx.FieldNickname:
  42188. return m.Nickname()
  42189. case wx.FieldTel:
  42190. return m.Tel()
  42191. case wx.FieldHeadBig:
  42192. return m.HeadBig()
  42193. case wx.FieldOrganizationID:
  42194. return m.OrganizationID()
  42195. case wx.FieldAgentID:
  42196. return m.AgentID()
  42197. case wx.FieldAPIBase:
  42198. return m.APIBase()
  42199. case wx.FieldAPIKey:
  42200. return m.APIKey()
  42201. case wx.FieldAllowList:
  42202. return m.AllowList()
  42203. case wx.FieldGroupAllowList:
  42204. return m.GroupAllowList()
  42205. case wx.FieldBlockList:
  42206. return m.BlockList()
  42207. case wx.FieldGroupBlockList:
  42208. return m.GroupBlockList()
  42209. case wx.FieldCtype:
  42210. return m.Ctype()
  42211. }
  42212. return nil, false
  42213. }
  42214. // OldField returns the old value of the field from the database. An error is
  42215. // returned if the mutation operation is not UpdateOne, or the query to the
  42216. // database failed.
  42217. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42218. switch name {
  42219. case wx.FieldCreatedAt:
  42220. return m.OldCreatedAt(ctx)
  42221. case wx.FieldUpdatedAt:
  42222. return m.OldUpdatedAt(ctx)
  42223. case wx.FieldStatus:
  42224. return m.OldStatus(ctx)
  42225. case wx.FieldDeletedAt:
  42226. return m.OldDeletedAt(ctx)
  42227. case wx.FieldServerID:
  42228. return m.OldServerID(ctx)
  42229. case wx.FieldPort:
  42230. return m.OldPort(ctx)
  42231. case wx.FieldProcessID:
  42232. return m.OldProcessID(ctx)
  42233. case wx.FieldCallback:
  42234. return m.OldCallback(ctx)
  42235. case wx.FieldWxid:
  42236. return m.OldWxid(ctx)
  42237. case wx.FieldAccount:
  42238. return m.OldAccount(ctx)
  42239. case wx.FieldNickname:
  42240. return m.OldNickname(ctx)
  42241. case wx.FieldTel:
  42242. return m.OldTel(ctx)
  42243. case wx.FieldHeadBig:
  42244. return m.OldHeadBig(ctx)
  42245. case wx.FieldOrganizationID:
  42246. return m.OldOrganizationID(ctx)
  42247. case wx.FieldAgentID:
  42248. return m.OldAgentID(ctx)
  42249. case wx.FieldAPIBase:
  42250. return m.OldAPIBase(ctx)
  42251. case wx.FieldAPIKey:
  42252. return m.OldAPIKey(ctx)
  42253. case wx.FieldAllowList:
  42254. return m.OldAllowList(ctx)
  42255. case wx.FieldGroupAllowList:
  42256. return m.OldGroupAllowList(ctx)
  42257. case wx.FieldBlockList:
  42258. return m.OldBlockList(ctx)
  42259. case wx.FieldGroupBlockList:
  42260. return m.OldGroupBlockList(ctx)
  42261. case wx.FieldCtype:
  42262. return m.OldCtype(ctx)
  42263. }
  42264. return nil, fmt.Errorf("unknown Wx field %s", name)
  42265. }
  42266. // SetField sets the value of a field with the given name. It returns an error if
  42267. // the field is not defined in the schema, or if the type mismatched the field
  42268. // type.
  42269. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42270. switch name {
  42271. case wx.FieldCreatedAt:
  42272. v, ok := value.(time.Time)
  42273. if !ok {
  42274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42275. }
  42276. m.SetCreatedAt(v)
  42277. return nil
  42278. case wx.FieldUpdatedAt:
  42279. v, ok := value.(time.Time)
  42280. if !ok {
  42281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42282. }
  42283. m.SetUpdatedAt(v)
  42284. return nil
  42285. case wx.FieldStatus:
  42286. v, ok := value.(uint8)
  42287. if !ok {
  42288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42289. }
  42290. m.SetStatus(v)
  42291. return nil
  42292. case wx.FieldDeletedAt:
  42293. v, ok := value.(time.Time)
  42294. if !ok {
  42295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42296. }
  42297. m.SetDeletedAt(v)
  42298. return nil
  42299. case wx.FieldServerID:
  42300. v, ok := value.(uint64)
  42301. if !ok {
  42302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42303. }
  42304. m.SetServerID(v)
  42305. return nil
  42306. case wx.FieldPort:
  42307. v, ok := value.(string)
  42308. if !ok {
  42309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42310. }
  42311. m.SetPort(v)
  42312. return nil
  42313. case wx.FieldProcessID:
  42314. v, ok := value.(string)
  42315. if !ok {
  42316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42317. }
  42318. m.SetProcessID(v)
  42319. return nil
  42320. case wx.FieldCallback:
  42321. v, ok := value.(string)
  42322. if !ok {
  42323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42324. }
  42325. m.SetCallback(v)
  42326. return nil
  42327. case wx.FieldWxid:
  42328. v, ok := value.(string)
  42329. if !ok {
  42330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42331. }
  42332. m.SetWxid(v)
  42333. return nil
  42334. case wx.FieldAccount:
  42335. v, ok := value.(string)
  42336. if !ok {
  42337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42338. }
  42339. m.SetAccount(v)
  42340. return nil
  42341. case wx.FieldNickname:
  42342. v, ok := value.(string)
  42343. if !ok {
  42344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42345. }
  42346. m.SetNickname(v)
  42347. return nil
  42348. case wx.FieldTel:
  42349. v, ok := value.(string)
  42350. if !ok {
  42351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42352. }
  42353. m.SetTel(v)
  42354. return nil
  42355. case wx.FieldHeadBig:
  42356. v, ok := value.(string)
  42357. if !ok {
  42358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42359. }
  42360. m.SetHeadBig(v)
  42361. return nil
  42362. case wx.FieldOrganizationID:
  42363. v, ok := value.(uint64)
  42364. if !ok {
  42365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42366. }
  42367. m.SetOrganizationID(v)
  42368. return nil
  42369. case wx.FieldAgentID:
  42370. v, ok := value.(uint64)
  42371. if !ok {
  42372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42373. }
  42374. m.SetAgentID(v)
  42375. return nil
  42376. case wx.FieldAPIBase:
  42377. v, ok := value.(string)
  42378. if !ok {
  42379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42380. }
  42381. m.SetAPIBase(v)
  42382. return nil
  42383. case wx.FieldAPIKey:
  42384. v, ok := value.(string)
  42385. if !ok {
  42386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42387. }
  42388. m.SetAPIKey(v)
  42389. return nil
  42390. case wx.FieldAllowList:
  42391. v, ok := value.([]string)
  42392. if !ok {
  42393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42394. }
  42395. m.SetAllowList(v)
  42396. return nil
  42397. case wx.FieldGroupAllowList:
  42398. v, ok := value.([]string)
  42399. if !ok {
  42400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42401. }
  42402. m.SetGroupAllowList(v)
  42403. return nil
  42404. case wx.FieldBlockList:
  42405. v, ok := value.([]string)
  42406. if !ok {
  42407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42408. }
  42409. m.SetBlockList(v)
  42410. return nil
  42411. case wx.FieldGroupBlockList:
  42412. v, ok := value.([]string)
  42413. if !ok {
  42414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42415. }
  42416. m.SetGroupBlockList(v)
  42417. return nil
  42418. case wx.FieldCtype:
  42419. v, ok := value.(uint64)
  42420. if !ok {
  42421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42422. }
  42423. m.SetCtype(v)
  42424. return nil
  42425. }
  42426. return fmt.Errorf("unknown Wx field %s", name)
  42427. }
  42428. // AddedFields returns all numeric fields that were incremented/decremented during
  42429. // this mutation.
  42430. func (m *WxMutation) AddedFields() []string {
  42431. var fields []string
  42432. if m.addstatus != nil {
  42433. fields = append(fields, wx.FieldStatus)
  42434. }
  42435. if m.addorganization_id != nil {
  42436. fields = append(fields, wx.FieldOrganizationID)
  42437. }
  42438. if m.addctype != nil {
  42439. fields = append(fields, wx.FieldCtype)
  42440. }
  42441. return fields
  42442. }
  42443. // AddedField returns the numeric value that was incremented/decremented on a field
  42444. // with the given name. The second boolean return value indicates that this field
  42445. // was not set, or was not defined in the schema.
  42446. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42447. switch name {
  42448. case wx.FieldStatus:
  42449. return m.AddedStatus()
  42450. case wx.FieldOrganizationID:
  42451. return m.AddedOrganizationID()
  42452. case wx.FieldCtype:
  42453. return m.AddedCtype()
  42454. }
  42455. return nil, false
  42456. }
  42457. // AddField adds the value to the field with the given name. It returns an error if
  42458. // the field is not defined in the schema, or if the type mismatched the field
  42459. // type.
  42460. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42461. switch name {
  42462. case wx.FieldStatus:
  42463. v, ok := value.(int8)
  42464. if !ok {
  42465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42466. }
  42467. m.AddStatus(v)
  42468. return nil
  42469. case wx.FieldOrganizationID:
  42470. v, ok := value.(int64)
  42471. if !ok {
  42472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42473. }
  42474. m.AddOrganizationID(v)
  42475. return nil
  42476. case wx.FieldCtype:
  42477. v, ok := value.(int64)
  42478. if !ok {
  42479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42480. }
  42481. m.AddCtype(v)
  42482. return nil
  42483. }
  42484. return fmt.Errorf("unknown Wx numeric field %s", name)
  42485. }
  42486. // ClearedFields returns all nullable fields that were cleared during this
  42487. // mutation.
  42488. func (m *WxMutation) ClearedFields() []string {
  42489. var fields []string
  42490. if m.FieldCleared(wx.FieldStatus) {
  42491. fields = append(fields, wx.FieldStatus)
  42492. }
  42493. if m.FieldCleared(wx.FieldDeletedAt) {
  42494. fields = append(fields, wx.FieldDeletedAt)
  42495. }
  42496. if m.FieldCleared(wx.FieldServerID) {
  42497. fields = append(fields, wx.FieldServerID)
  42498. }
  42499. if m.FieldCleared(wx.FieldOrganizationID) {
  42500. fields = append(fields, wx.FieldOrganizationID)
  42501. }
  42502. if m.FieldCleared(wx.FieldAPIBase) {
  42503. fields = append(fields, wx.FieldAPIBase)
  42504. }
  42505. if m.FieldCleared(wx.FieldAPIKey) {
  42506. fields = append(fields, wx.FieldAPIKey)
  42507. }
  42508. if m.FieldCleared(wx.FieldCtype) {
  42509. fields = append(fields, wx.FieldCtype)
  42510. }
  42511. return fields
  42512. }
  42513. // FieldCleared returns a boolean indicating if a field with the given name was
  42514. // cleared in this mutation.
  42515. func (m *WxMutation) FieldCleared(name string) bool {
  42516. _, ok := m.clearedFields[name]
  42517. return ok
  42518. }
  42519. // ClearField clears the value of the field with the given name. It returns an
  42520. // error if the field is not defined in the schema.
  42521. func (m *WxMutation) ClearField(name string) error {
  42522. switch name {
  42523. case wx.FieldStatus:
  42524. m.ClearStatus()
  42525. return nil
  42526. case wx.FieldDeletedAt:
  42527. m.ClearDeletedAt()
  42528. return nil
  42529. case wx.FieldServerID:
  42530. m.ClearServerID()
  42531. return nil
  42532. case wx.FieldOrganizationID:
  42533. m.ClearOrganizationID()
  42534. return nil
  42535. case wx.FieldAPIBase:
  42536. m.ClearAPIBase()
  42537. return nil
  42538. case wx.FieldAPIKey:
  42539. m.ClearAPIKey()
  42540. return nil
  42541. case wx.FieldCtype:
  42542. m.ClearCtype()
  42543. return nil
  42544. }
  42545. return fmt.Errorf("unknown Wx nullable field %s", name)
  42546. }
  42547. // ResetField resets all changes in the mutation for the field with the given name.
  42548. // It returns an error if the field is not defined in the schema.
  42549. func (m *WxMutation) ResetField(name string) error {
  42550. switch name {
  42551. case wx.FieldCreatedAt:
  42552. m.ResetCreatedAt()
  42553. return nil
  42554. case wx.FieldUpdatedAt:
  42555. m.ResetUpdatedAt()
  42556. return nil
  42557. case wx.FieldStatus:
  42558. m.ResetStatus()
  42559. return nil
  42560. case wx.FieldDeletedAt:
  42561. m.ResetDeletedAt()
  42562. return nil
  42563. case wx.FieldServerID:
  42564. m.ResetServerID()
  42565. return nil
  42566. case wx.FieldPort:
  42567. m.ResetPort()
  42568. return nil
  42569. case wx.FieldProcessID:
  42570. m.ResetProcessID()
  42571. return nil
  42572. case wx.FieldCallback:
  42573. m.ResetCallback()
  42574. return nil
  42575. case wx.FieldWxid:
  42576. m.ResetWxid()
  42577. return nil
  42578. case wx.FieldAccount:
  42579. m.ResetAccount()
  42580. return nil
  42581. case wx.FieldNickname:
  42582. m.ResetNickname()
  42583. return nil
  42584. case wx.FieldTel:
  42585. m.ResetTel()
  42586. return nil
  42587. case wx.FieldHeadBig:
  42588. m.ResetHeadBig()
  42589. return nil
  42590. case wx.FieldOrganizationID:
  42591. m.ResetOrganizationID()
  42592. return nil
  42593. case wx.FieldAgentID:
  42594. m.ResetAgentID()
  42595. return nil
  42596. case wx.FieldAPIBase:
  42597. m.ResetAPIBase()
  42598. return nil
  42599. case wx.FieldAPIKey:
  42600. m.ResetAPIKey()
  42601. return nil
  42602. case wx.FieldAllowList:
  42603. m.ResetAllowList()
  42604. return nil
  42605. case wx.FieldGroupAllowList:
  42606. m.ResetGroupAllowList()
  42607. return nil
  42608. case wx.FieldBlockList:
  42609. m.ResetBlockList()
  42610. return nil
  42611. case wx.FieldGroupBlockList:
  42612. m.ResetGroupBlockList()
  42613. return nil
  42614. case wx.FieldCtype:
  42615. m.ResetCtype()
  42616. return nil
  42617. }
  42618. return fmt.Errorf("unknown Wx field %s", name)
  42619. }
  42620. // AddedEdges returns all edge names that were set/added in this mutation.
  42621. func (m *WxMutation) AddedEdges() []string {
  42622. edges := make([]string, 0, 2)
  42623. if m.server != nil {
  42624. edges = append(edges, wx.EdgeServer)
  42625. }
  42626. if m.agent != nil {
  42627. edges = append(edges, wx.EdgeAgent)
  42628. }
  42629. return edges
  42630. }
  42631. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42632. // name in this mutation.
  42633. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  42634. switch name {
  42635. case wx.EdgeServer:
  42636. if id := m.server; id != nil {
  42637. return []ent.Value{*id}
  42638. }
  42639. case wx.EdgeAgent:
  42640. if id := m.agent; id != nil {
  42641. return []ent.Value{*id}
  42642. }
  42643. }
  42644. return nil
  42645. }
  42646. // RemovedEdges returns all edge names that were removed in this mutation.
  42647. func (m *WxMutation) RemovedEdges() []string {
  42648. edges := make([]string, 0, 2)
  42649. return edges
  42650. }
  42651. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42652. // the given name in this mutation.
  42653. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  42654. return nil
  42655. }
  42656. // ClearedEdges returns all edge names that were cleared in this mutation.
  42657. func (m *WxMutation) ClearedEdges() []string {
  42658. edges := make([]string, 0, 2)
  42659. if m.clearedserver {
  42660. edges = append(edges, wx.EdgeServer)
  42661. }
  42662. if m.clearedagent {
  42663. edges = append(edges, wx.EdgeAgent)
  42664. }
  42665. return edges
  42666. }
  42667. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42668. // was cleared in this mutation.
  42669. func (m *WxMutation) EdgeCleared(name string) bool {
  42670. switch name {
  42671. case wx.EdgeServer:
  42672. return m.clearedserver
  42673. case wx.EdgeAgent:
  42674. return m.clearedagent
  42675. }
  42676. return false
  42677. }
  42678. // ClearEdge clears the value of the edge with the given name. It returns an error
  42679. // if that edge is not defined in the schema.
  42680. func (m *WxMutation) ClearEdge(name string) error {
  42681. switch name {
  42682. case wx.EdgeServer:
  42683. m.ClearServer()
  42684. return nil
  42685. case wx.EdgeAgent:
  42686. m.ClearAgent()
  42687. return nil
  42688. }
  42689. return fmt.Errorf("unknown Wx unique edge %s", name)
  42690. }
  42691. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42692. // It returns an error if the edge is not defined in the schema.
  42693. func (m *WxMutation) ResetEdge(name string) error {
  42694. switch name {
  42695. case wx.EdgeServer:
  42696. m.ResetServer()
  42697. return nil
  42698. case wx.EdgeAgent:
  42699. m.ResetAgent()
  42700. return nil
  42701. }
  42702. return fmt.Errorf("unknown Wx edge %s", name)
  42703. }
  42704. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  42705. type WxCardMutation struct {
  42706. config
  42707. op Op
  42708. typ string
  42709. id *uint64
  42710. created_at *time.Time
  42711. updated_at *time.Time
  42712. deleted_at *time.Time
  42713. user_id *uint64
  42714. adduser_id *int64
  42715. wx_user_id *uint64
  42716. addwx_user_id *int64
  42717. avatar *string
  42718. logo *string
  42719. name *string
  42720. company *string
  42721. address *string
  42722. phone *string
  42723. official_account *string
  42724. wechat_account *string
  42725. email *string
  42726. api_base *string
  42727. api_key *string
  42728. ai_info *string
  42729. intro *string
  42730. clearedFields map[string]struct{}
  42731. done bool
  42732. oldValue func(context.Context) (*WxCard, error)
  42733. predicates []predicate.WxCard
  42734. }
  42735. var _ ent.Mutation = (*WxCardMutation)(nil)
  42736. // wxcardOption allows management of the mutation configuration using functional options.
  42737. type wxcardOption func(*WxCardMutation)
  42738. // newWxCardMutation creates new mutation for the WxCard entity.
  42739. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  42740. m := &WxCardMutation{
  42741. config: c,
  42742. op: op,
  42743. typ: TypeWxCard,
  42744. clearedFields: make(map[string]struct{}),
  42745. }
  42746. for _, opt := range opts {
  42747. opt(m)
  42748. }
  42749. return m
  42750. }
  42751. // withWxCardID sets the ID field of the mutation.
  42752. func withWxCardID(id uint64) wxcardOption {
  42753. return func(m *WxCardMutation) {
  42754. var (
  42755. err error
  42756. once sync.Once
  42757. value *WxCard
  42758. )
  42759. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  42760. once.Do(func() {
  42761. if m.done {
  42762. err = errors.New("querying old values post mutation is not allowed")
  42763. } else {
  42764. value, err = m.Client().WxCard.Get(ctx, id)
  42765. }
  42766. })
  42767. return value, err
  42768. }
  42769. m.id = &id
  42770. }
  42771. }
  42772. // withWxCard sets the old WxCard of the mutation.
  42773. func withWxCard(node *WxCard) wxcardOption {
  42774. return func(m *WxCardMutation) {
  42775. m.oldValue = func(context.Context) (*WxCard, error) {
  42776. return node, nil
  42777. }
  42778. m.id = &node.ID
  42779. }
  42780. }
  42781. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42782. // executed in a transaction (ent.Tx), a transactional client is returned.
  42783. func (m WxCardMutation) Client() *Client {
  42784. client := &Client{config: m.config}
  42785. client.init()
  42786. return client
  42787. }
  42788. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42789. // it returns an error otherwise.
  42790. func (m WxCardMutation) Tx() (*Tx, error) {
  42791. if _, ok := m.driver.(*txDriver); !ok {
  42792. return nil, errors.New("ent: mutation is not running in a transaction")
  42793. }
  42794. tx := &Tx{config: m.config}
  42795. tx.init()
  42796. return tx, nil
  42797. }
  42798. // SetID sets the value of the id field. Note that this
  42799. // operation is only accepted on creation of WxCard entities.
  42800. func (m *WxCardMutation) SetID(id uint64) {
  42801. m.id = &id
  42802. }
  42803. // ID returns the ID value in the mutation. Note that the ID is only available
  42804. // if it was provided to the builder or after it was returned from the database.
  42805. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  42806. if m.id == nil {
  42807. return
  42808. }
  42809. return *m.id, true
  42810. }
  42811. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42812. // That means, if the mutation is applied within a transaction with an isolation level such
  42813. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42814. // or updated by the mutation.
  42815. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  42816. switch {
  42817. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42818. id, exists := m.ID()
  42819. if exists {
  42820. return []uint64{id}, nil
  42821. }
  42822. fallthrough
  42823. case m.op.Is(OpUpdate | OpDelete):
  42824. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  42825. default:
  42826. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42827. }
  42828. }
  42829. // SetCreatedAt sets the "created_at" field.
  42830. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  42831. m.created_at = &t
  42832. }
  42833. // CreatedAt returns the value of the "created_at" field in the mutation.
  42834. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  42835. v := m.created_at
  42836. if v == nil {
  42837. return
  42838. }
  42839. return *v, true
  42840. }
  42841. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  42842. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42844. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42845. if !m.op.Is(OpUpdateOne) {
  42846. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42847. }
  42848. if m.id == nil || m.oldValue == nil {
  42849. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42850. }
  42851. oldValue, err := m.oldValue(ctx)
  42852. if err != nil {
  42853. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42854. }
  42855. return oldValue.CreatedAt, nil
  42856. }
  42857. // ResetCreatedAt resets all changes to the "created_at" field.
  42858. func (m *WxCardMutation) ResetCreatedAt() {
  42859. m.created_at = nil
  42860. }
  42861. // SetUpdatedAt sets the "updated_at" field.
  42862. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  42863. m.updated_at = &t
  42864. }
  42865. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42866. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  42867. v := m.updated_at
  42868. if v == nil {
  42869. return
  42870. }
  42871. return *v, true
  42872. }
  42873. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  42874. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42876. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42877. if !m.op.Is(OpUpdateOne) {
  42878. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42879. }
  42880. if m.id == nil || m.oldValue == nil {
  42881. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42882. }
  42883. oldValue, err := m.oldValue(ctx)
  42884. if err != nil {
  42885. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42886. }
  42887. return oldValue.UpdatedAt, nil
  42888. }
  42889. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42890. func (m *WxCardMutation) ResetUpdatedAt() {
  42891. m.updated_at = nil
  42892. }
  42893. // SetDeletedAt sets the "deleted_at" field.
  42894. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  42895. m.deleted_at = &t
  42896. }
  42897. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42898. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  42899. v := m.deleted_at
  42900. if v == nil {
  42901. return
  42902. }
  42903. return *v, true
  42904. }
  42905. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  42906. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42908. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42909. if !m.op.Is(OpUpdateOne) {
  42910. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42911. }
  42912. if m.id == nil || m.oldValue == nil {
  42913. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42914. }
  42915. oldValue, err := m.oldValue(ctx)
  42916. if err != nil {
  42917. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42918. }
  42919. return oldValue.DeletedAt, nil
  42920. }
  42921. // ClearDeletedAt clears the value of the "deleted_at" field.
  42922. func (m *WxCardMutation) ClearDeletedAt() {
  42923. m.deleted_at = nil
  42924. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  42925. }
  42926. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42927. func (m *WxCardMutation) DeletedAtCleared() bool {
  42928. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  42929. return ok
  42930. }
  42931. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42932. func (m *WxCardMutation) ResetDeletedAt() {
  42933. m.deleted_at = nil
  42934. delete(m.clearedFields, wxcard.FieldDeletedAt)
  42935. }
  42936. // SetUserID sets the "user_id" field.
  42937. func (m *WxCardMutation) SetUserID(u uint64) {
  42938. m.user_id = &u
  42939. m.adduser_id = nil
  42940. }
  42941. // UserID returns the value of the "user_id" field in the mutation.
  42942. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  42943. v := m.user_id
  42944. if v == nil {
  42945. return
  42946. }
  42947. return *v, true
  42948. }
  42949. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  42950. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42952. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42953. if !m.op.Is(OpUpdateOne) {
  42954. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42955. }
  42956. if m.id == nil || m.oldValue == nil {
  42957. return v, errors.New("OldUserID requires an ID field in the mutation")
  42958. }
  42959. oldValue, err := m.oldValue(ctx)
  42960. if err != nil {
  42961. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42962. }
  42963. return oldValue.UserID, nil
  42964. }
  42965. // AddUserID adds u to the "user_id" field.
  42966. func (m *WxCardMutation) AddUserID(u int64) {
  42967. if m.adduser_id != nil {
  42968. *m.adduser_id += u
  42969. } else {
  42970. m.adduser_id = &u
  42971. }
  42972. }
  42973. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42974. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  42975. v := m.adduser_id
  42976. if v == nil {
  42977. return
  42978. }
  42979. return *v, true
  42980. }
  42981. // ClearUserID clears the value of the "user_id" field.
  42982. func (m *WxCardMutation) ClearUserID() {
  42983. m.user_id = nil
  42984. m.adduser_id = nil
  42985. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  42986. }
  42987. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42988. func (m *WxCardMutation) UserIDCleared() bool {
  42989. _, ok := m.clearedFields[wxcard.FieldUserID]
  42990. return ok
  42991. }
  42992. // ResetUserID resets all changes to the "user_id" field.
  42993. func (m *WxCardMutation) ResetUserID() {
  42994. m.user_id = nil
  42995. m.adduser_id = nil
  42996. delete(m.clearedFields, wxcard.FieldUserID)
  42997. }
  42998. // SetWxUserID sets the "wx_user_id" field.
  42999. func (m *WxCardMutation) SetWxUserID(u uint64) {
  43000. m.wx_user_id = &u
  43001. m.addwx_user_id = nil
  43002. }
  43003. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  43004. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  43005. v := m.wx_user_id
  43006. if v == nil {
  43007. return
  43008. }
  43009. return *v, true
  43010. }
  43011. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  43012. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43014. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  43015. if !m.op.Is(OpUpdateOne) {
  43016. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  43017. }
  43018. if m.id == nil || m.oldValue == nil {
  43019. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  43020. }
  43021. oldValue, err := m.oldValue(ctx)
  43022. if err != nil {
  43023. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  43024. }
  43025. return oldValue.WxUserID, nil
  43026. }
  43027. // AddWxUserID adds u to the "wx_user_id" field.
  43028. func (m *WxCardMutation) AddWxUserID(u int64) {
  43029. if m.addwx_user_id != nil {
  43030. *m.addwx_user_id += u
  43031. } else {
  43032. m.addwx_user_id = &u
  43033. }
  43034. }
  43035. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  43036. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  43037. v := m.addwx_user_id
  43038. if v == nil {
  43039. return
  43040. }
  43041. return *v, true
  43042. }
  43043. // ClearWxUserID clears the value of the "wx_user_id" field.
  43044. func (m *WxCardMutation) ClearWxUserID() {
  43045. m.wx_user_id = nil
  43046. m.addwx_user_id = nil
  43047. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  43048. }
  43049. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  43050. func (m *WxCardMutation) WxUserIDCleared() bool {
  43051. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  43052. return ok
  43053. }
  43054. // ResetWxUserID resets all changes to the "wx_user_id" field.
  43055. func (m *WxCardMutation) ResetWxUserID() {
  43056. m.wx_user_id = nil
  43057. m.addwx_user_id = nil
  43058. delete(m.clearedFields, wxcard.FieldWxUserID)
  43059. }
  43060. // SetAvatar sets the "avatar" field.
  43061. func (m *WxCardMutation) SetAvatar(s string) {
  43062. m.avatar = &s
  43063. }
  43064. // Avatar returns the value of the "avatar" field in the mutation.
  43065. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  43066. v := m.avatar
  43067. if v == nil {
  43068. return
  43069. }
  43070. return *v, true
  43071. }
  43072. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  43073. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43075. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43076. if !m.op.Is(OpUpdateOne) {
  43077. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43078. }
  43079. if m.id == nil || m.oldValue == nil {
  43080. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43081. }
  43082. oldValue, err := m.oldValue(ctx)
  43083. if err != nil {
  43084. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43085. }
  43086. return oldValue.Avatar, nil
  43087. }
  43088. // ResetAvatar resets all changes to the "avatar" field.
  43089. func (m *WxCardMutation) ResetAvatar() {
  43090. m.avatar = nil
  43091. }
  43092. // SetLogo sets the "logo" field.
  43093. func (m *WxCardMutation) SetLogo(s string) {
  43094. m.logo = &s
  43095. }
  43096. // Logo returns the value of the "logo" field in the mutation.
  43097. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43098. v := m.logo
  43099. if v == nil {
  43100. return
  43101. }
  43102. return *v, true
  43103. }
  43104. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43105. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43107. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43108. if !m.op.Is(OpUpdateOne) {
  43109. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43110. }
  43111. if m.id == nil || m.oldValue == nil {
  43112. return v, errors.New("OldLogo requires an ID field in the mutation")
  43113. }
  43114. oldValue, err := m.oldValue(ctx)
  43115. if err != nil {
  43116. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43117. }
  43118. return oldValue.Logo, nil
  43119. }
  43120. // ResetLogo resets all changes to the "logo" field.
  43121. func (m *WxCardMutation) ResetLogo() {
  43122. m.logo = nil
  43123. }
  43124. // SetName sets the "name" field.
  43125. func (m *WxCardMutation) SetName(s string) {
  43126. m.name = &s
  43127. }
  43128. // Name returns the value of the "name" field in the mutation.
  43129. func (m *WxCardMutation) Name() (r string, exists bool) {
  43130. v := m.name
  43131. if v == nil {
  43132. return
  43133. }
  43134. return *v, true
  43135. }
  43136. // OldName returns the old "name" field's value of the WxCard entity.
  43137. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43139. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43140. if !m.op.Is(OpUpdateOne) {
  43141. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43142. }
  43143. if m.id == nil || m.oldValue == nil {
  43144. return v, errors.New("OldName requires an ID field in the mutation")
  43145. }
  43146. oldValue, err := m.oldValue(ctx)
  43147. if err != nil {
  43148. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43149. }
  43150. return oldValue.Name, nil
  43151. }
  43152. // ResetName resets all changes to the "name" field.
  43153. func (m *WxCardMutation) ResetName() {
  43154. m.name = nil
  43155. }
  43156. // SetCompany sets the "company" field.
  43157. func (m *WxCardMutation) SetCompany(s string) {
  43158. m.company = &s
  43159. }
  43160. // Company returns the value of the "company" field in the mutation.
  43161. func (m *WxCardMutation) Company() (r string, exists bool) {
  43162. v := m.company
  43163. if v == nil {
  43164. return
  43165. }
  43166. return *v, true
  43167. }
  43168. // OldCompany returns the old "company" field's value of the WxCard entity.
  43169. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43171. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43172. if !m.op.Is(OpUpdateOne) {
  43173. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43174. }
  43175. if m.id == nil || m.oldValue == nil {
  43176. return v, errors.New("OldCompany requires an ID field in the mutation")
  43177. }
  43178. oldValue, err := m.oldValue(ctx)
  43179. if err != nil {
  43180. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43181. }
  43182. return oldValue.Company, nil
  43183. }
  43184. // ResetCompany resets all changes to the "company" field.
  43185. func (m *WxCardMutation) ResetCompany() {
  43186. m.company = nil
  43187. }
  43188. // SetAddress sets the "address" field.
  43189. func (m *WxCardMutation) SetAddress(s string) {
  43190. m.address = &s
  43191. }
  43192. // Address returns the value of the "address" field in the mutation.
  43193. func (m *WxCardMutation) Address() (r string, exists bool) {
  43194. v := m.address
  43195. if v == nil {
  43196. return
  43197. }
  43198. return *v, true
  43199. }
  43200. // OldAddress returns the old "address" field's value of the WxCard entity.
  43201. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43203. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43204. if !m.op.Is(OpUpdateOne) {
  43205. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43206. }
  43207. if m.id == nil || m.oldValue == nil {
  43208. return v, errors.New("OldAddress requires an ID field in the mutation")
  43209. }
  43210. oldValue, err := m.oldValue(ctx)
  43211. if err != nil {
  43212. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43213. }
  43214. return oldValue.Address, nil
  43215. }
  43216. // ResetAddress resets all changes to the "address" field.
  43217. func (m *WxCardMutation) ResetAddress() {
  43218. m.address = nil
  43219. }
  43220. // SetPhone sets the "phone" field.
  43221. func (m *WxCardMutation) SetPhone(s string) {
  43222. m.phone = &s
  43223. }
  43224. // Phone returns the value of the "phone" field in the mutation.
  43225. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43226. v := m.phone
  43227. if v == nil {
  43228. return
  43229. }
  43230. return *v, true
  43231. }
  43232. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43233. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43235. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43236. if !m.op.Is(OpUpdateOne) {
  43237. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43238. }
  43239. if m.id == nil || m.oldValue == nil {
  43240. return v, errors.New("OldPhone requires an ID field in the mutation")
  43241. }
  43242. oldValue, err := m.oldValue(ctx)
  43243. if err != nil {
  43244. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43245. }
  43246. return oldValue.Phone, nil
  43247. }
  43248. // ResetPhone resets all changes to the "phone" field.
  43249. func (m *WxCardMutation) ResetPhone() {
  43250. m.phone = nil
  43251. }
  43252. // SetOfficialAccount sets the "official_account" field.
  43253. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43254. m.official_account = &s
  43255. }
  43256. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43257. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43258. v := m.official_account
  43259. if v == nil {
  43260. return
  43261. }
  43262. return *v, true
  43263. }
  43264. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43265. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43267. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43268. if !m.op.Is(OpUpdateOne) {
  43269. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43270. }
  43271. if m.id == nil || m.oldValue == nil {
  43272. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43273. }
  43274. oldValue, err := m.oldValue(ctx)
  43275. if err != nil {
  43276. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43277. }
  43278. return oldValue.OfficialAccount, nil
  43279. }
  43280. // ResetOfficialAccount resets all changes to the "official_account" field.
  43281. func (m *WxCardMutation) ResetOfficialAccount() {
  43282. m.official_account = nil
  43283. }
  43284. // SetWechatAccount sets the "wechat_account" field.
  43285. func (m *WxCardMutation) SetWechatAccount(s string) {
  43286. m.wechat_account = &s
  43287. }
  43288. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43289. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43290. v := m.wechat_account
  43291. if v == nil {
  43292. return
  43293. }
  43294. return *v, true
  43295. }
  43296. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43297. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43299. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43300. if !m.op.Is(OpUpdateOne) {
  43301. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43302. }
  43303. if m.id == nil || m.oldValue == nil {
  43304. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43305. }
  43306. oldValue, err := m.oldValue(ctx)
  43307. if err != nil {
  43308. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43309. }
  43310. return oldValue.WechatAccount, nil
  43311. }
  43312. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43313. func (m *WxCardMutation) ResetWechatAccount() {
  43314. m.wechat_account = nil
  43315. }
  43316. // SetEmail sets the "email" field.
  43317. func (m *WxCardMutation) SetEmail(s string) {
  43318. m.email = &s
  43319. }
  43320. // Email returns the value of the "email" field in the mutation.
  43321. func (m *WxCardMutation) Email() (r string, exists bool) {
  43322. v := m.email
  43323. if v == nil {
  43324. return
  43325. }
  43326. return *v, true
  43327. }
  43328. // OldEmail returns the old "email" field's value of the WxCard entity.
  43329. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43331. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43332. if !m.op.Is(OpUpdateOne) {
  43333. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43334. }
  43335. if m.id == nil || m.oldValue == nil {
  43336. return v, errors.New("OldEmail requires an ID field in the mutation")
  43337. }
  43338. oldValue, err := m.oldValue(ctx)
  43339. if err != nil {
  43340. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43341. }
  43342. return oldValue.Email, nil
  43343. }
  43344. // ClearEmail clears the value of the "email" field.
  43345. func (m *WxCardMutation) ClearEmail() {
  43346. m.email = nil
  43347. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43348. }
  43349. // EmailCleared returns if the "email" field was cleared in this mutation.
  43350. func (m *WxCardMutation) EmailCleared() bool {
  43351. _, ok := m.clearedFields[wxcard.FieldEmail]
  43352. return ok
  43353. }
  43354. // ResetEmail resets all changes to the "email" field.
  43355. func (m *WxCardMutation) ResetEmail() {
  43356. m.email = nil
  43357. delete(m.clearedFields, wxcard.FieldEmail)
  43358. }
  43359. // SetAPIBase sets the "api_base" field.
  43360. func (m *WxCardMutation) SetAPIBase(s string) {
  43361. m.api_base = &s
  43362. }
  43363. // APIBase returns the value of the "api_base" field in the mutation.
  43364. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43365. v := m.api_base
  43366. if v == nil {
  43367. return
  43368. }
  43369. return *v, true
  43370. }
  43371. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43372. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43374. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43375. if !m.op.Is(OpUpdateOne) {
  43376. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43377. }
  43378. if m.id == nil || m.oldValue == nil {
  43379. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43380. }
  43381. oldValue, err := m.oldValue(ctx)
  43382. if err != nil {
  43383. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43384. }
  43385. return oldValue.APIBase, nil
  43386. }
  43387. // ClearAPIBase clears the value of the "api_base" field.
  43388. func (m *WxCardMutation) ClearAPIBase() {
  43389. m.api_base = nil
  43390. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43391. }
  43392. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43393. func (m *WxCardMutation) APIBaseCleared() bool {
  43394. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43395. return ok
  43396. }
  43397. // ResetAPIBase resets all changes to the "api_base" field.
  43398. func (m *WxCardMutation) ResetAPIBase() {
  43399. m.api_base = nil
  43400. delete(m.clearedFields, wxcard.FieldAPIBase)
  43401. }
  43402. // SetAPIKey sets the "api_key" field.
  43403. func (m *WxCardMutation) SetAPIKey(s string) {
  43404. m.api_key = &s
  43405. }
  43406. // APIKey returns the value of the "api_key" field in the mutation.
  43407. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43408. v := m.api_key
  43409. if v == nil {
  43410. return
  43411. }
  43412. return *v, true
  43413. }
  43414. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43415. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43417. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43418. if !m.op.Is(OpUpdateOne) {
  43419. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43420. }
  43421. if m.id == nil || m.oldValue == nil {
  43422. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43423. }
  43424. oldValue, err := m.oldValue(ctx)
  43425. if err != nil {
  43426. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43427. }
  43428. return oldValue.APIKey, nil
  43429. }
  43430. // ClearAPIKey clears the value of the "api_key" field.
  43431. func (m *WxCardMutation) ClearAPIKey() {
  43432. m.api_key = nil
  43433. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43434. }
  43435. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43436. func (m *WxCardMutation) APIKeyCleared() bool {
  43437. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43438. return ok
  43439. }
  43440. // ResetAPIKey resets all changes to the "api_key" field.
  43441. func (m *WxCardMutation) ResetAPIKey() {
  43442. m.api_key = nil
  43443. delete(m.clearedFields, wxcard.FieldAPIKey)
  43444. }
  43445. // SetAiInfo sets the "ai_info" field.
  43446. func (m *WxCardMutation) SetAiInfo(s string) {
  43447. m.ai_info = &s
  43448. }
  43449. // AiInfo returns the value of the "ai_info" field in the mutation.
  43450. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43451. v := m.ai_info
  43452. if v == nil {
  43453. return
  43454. }
  43455. return *v, true
  43456. }
  43457. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43458. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43460. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43461. if !m.op.Is(OpUpdateOne) {
  43462. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43463. }
  43464. if m.id == nil || m.oldValue == nil {
  43465. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43466. }
  43467. oldValue, err := m.oldValue(ctx)
  43468. if err != nil {
  43469. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43470. }
  43471. return oldValue.AiInfo, nil
  43472. }
  43473. // ClearAiInfo clears the value of the "ai_info" field.
  43474. func (m *WxCardMutation) ClearAiInfo() {
  43475. m.ai_info = nil
  43476. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43477. }
  43478. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43479. func (m *WxCardMutation) AiInfoCleared() bool {
  43480. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43481. return ok
  43482. }
  43483. // ResetAiInfo resets all changes to the "ai_info" field.
  43484. func (m *WxCardMutation) ResetAiInfo() {
  43485. m.ai_info = nil
  43486. delete(m.clearedFields, wxcard.FieldAiInfo)
  43487. }
  43488. // SetIntro sets the "intro" field.
  43489. func (m *WxCardMutation) SetIntro(s string) {
  43490. m.intro = &s
  43491. }
  43492. // Intro returns the value of the "intro" field in the mutation.
  43493. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43494. v := m.intro
  43495. if v == nil {
  43496. return
  43497. }
  43498. return *v, true
  43499. }
  43500. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43501. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43503. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43504. if !m.op.Is(OpUpdateOne) {
  43505. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43506. }
  43507. if m.id == nil || m.oldValue == nil {
  43508. return v, errors.New("OldIntro requires an ID field in the mutation")
  43509. }
  43510. oldValue, err := m.oldValue(ctx)
  43511. if err != nil {
  43512. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43513. }
  43514. return oldValue.Intro, nil
  43515. }
  43516. // ClearIntro clears the value of the "intro" field.
  43517. func (m *WxCardMutation) ClearIntro() {
  43518. m.intro = nil
  43519. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43520. }
  43521. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43522. func (m *WxCardMutation) IntroCleared() bool {
  43523. _, ok := m.clearedFields[wxcard.FieldIntro]
  43524. return ok
  43525. }
  43526. // ResetIntro resets all changes to the "intro" field.
  43527. func (m *WxCardMutation) ResetIntro() {
  43528. m.intro = nil
  43529. delete(m.clearedFields, wxcard.FieldIntro)
  43530. }
  43531. // Where appends a list predicates to the WxCardMutation builder.
  43532. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43533. m.predicates = append(m.predicates, ps...)
  43534. }
  43535. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43536. // users can use type-assertion to append predicates that do not depend on any generated package.
  43537. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43538. p := make([]predicate.WxCard, len(ps))
  43539. for i := range ps {
  43540. p[i] = ps[i]
  43541. }
  43542. m.Where(p...)
  43543. }
  43544. // Op returns the operation name.
  43545. func (m *WxCardMutation) Op() Op {
  43546. return m.op
  43547. }
  43548. // SetOp allows setting the mutation operation.
  43549. func (m *WxCardMutation) SetOp(op Op) {
  43550. m.op = op
  43551. }
  43552. // Type returns the node type of this mutation (WxCard).
  43553. func (m *WxCardMutation) Type() string {
  43554. return m.typ
  43555. }
  43556. // Fields returns all fields that were changed during this mutation. Note that in
  43557. // order to get all numeric fields that were incremented/decremented, call
  43558. // AddedFields().
  43559. func (m *WxCardMutation) Fields() []string {
  43560. fields := make([]string, 0, 18)
  43561. if m.created_at != nil {
  43562. fields = append(fields, wxcard.FieldCreatedAt)
  43563. }
  43564. if m.updated_at != nil {
  43565. fields = append(fields, wxcard.FieldUpdatedAt)
  43566. }
  43567. if m.deleted_at != nil {
  43568. fields = append(fields, wxcard.FieldDeletedAt)
  43569. }
  43570. if m.user_id != nil {
  43571. fields = append(fields, wxcard.FieldUserID)
  43572. }
  43573. if m.wx_user_id != nil {
  43574. fields = append(fields, wxcard.FieldWxUserID)
  43575. }
  43576. if m.avatar != nil {
  43577. fields = append(fields, wxcard.FieldAvatar)
  43578. }
  43579. if m.logo != nil {
  43580. fields = append(fields, wxcard.FieldLogo)
  43581. }
  43582. if m.name != nil {
  43583. fields = append(fields, wxcard.FieldName)
  43584. }
  43585. if m.company != nil {
  43586. fields = append(fields, wxcard.FieldCompany)
  43587. }
  43588. if m.address != nil {
  43589. fields = append(fields, wxcard.FieldAddress)
  43590. }
  43591. if m.phone != nil {
  43592. fields = append(fields, wxcard.FieldPhone)
  43593. }
  43594. if m.official_account != nil {
  43595. fields = append(fields, wxcard.FieldOfficialAccount)
  43596. }
  43597. if m.wechat_account != nil {
  43598. fields = append(fields, wxcard.FieldWechatAccount)
  43599. }
  43600. if m.email != nil {
  43601. fields = append(fields, wxcard.FieldEmail)
  43602. }
  43603. if m.api_base != nil {
  43604. fields = append(fields, wxcard.FieldAPIBase)
  43605. }
  43606. if m.api_key != nil {
  43607. fields = append(fields, wxcard.FieldAPIKey)
  43608. }
  43609. if m.ai_info != nil {
  43610. fields = append(fields, wxcard.FieldAiInfo)
  43611. }
  43612. if m.intro != nil {
  43613. fields = append(fields, wxcard.FieldIntro)
  43614. }
  43615. return fields
  43616. }
  43617. // Field returns the value of a field with the given name. The second boolean
  43618. // return value indicates that this field was not set, or was not defined in the
  43619. // schema.
  43620. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43621. switch name {
  43622. case wxcard.FieldCreatedAt:
  43623. return m.CreatedAt()
  43624. case wxcard.FieldUpdatedAt:
  43625. return m.UpdatedAt()
  43626. case wxcard.FieldDeletedAt:
  43627. return m.DeletedAt()
  43628. case wxcard.FieldUserID:
  43629. return m.UserID()
  43630. case wxcard.FieldWxUserID:
  43631. return m.WxUserID()
  43632. case wxcard.FieldAvatar:
  43633. return m.Avatar()
  43634. case wxcard.FieldLogo:
  43635. return m.Logo()
  43636. case wxcard.FieldName:
  43637. return m.Name()
  43638. case wxcard.FieldCompany:
  43639. return m.Company()
  43640. case wxcard.FieldAddress:
  43641. return m.Address()
  43642. case wxcard.FieldPhone:
  43643. return m.Phone()
  43644. case wxcard.FieldOfficialAccount:
  43645. return m.OfficialAccount()
  43646. case wxcard.FieldWechatAccount:
  43647. return m.WechatAccount()
  43648. case wxcard.FieldEmail:
  43649. return m.Email()
  43650. case wxcard.FieldAPIBase:
  43651. return m.APIBase()
  43652. case wxcard.FieldAPIKey:
  43653. return m.APIKey()
  43654. case wxcard.FieldAiInfo:
  43655. return m.AiInfo()
  43656. case wxcard.FieldIntro:
  43657. return m.Intro()
  43658. }
  43659. return nil, false
  43660. }
  43661. // OldField returns the old value of the field from the database. An error is
  43662. // returned if the mutation operation is not UpdateOne, or the query to the
  43663. // database failed.
  43664. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43665. switch name {
  43666. case wxcard.FieldCreatedAt:
  43667. return m.OldCreatedAt(ctx)
  43668. case wxcard.FieldUpdatedAt:
  43669. return m.OldUpdatedAt(ctx)
  43670. case wxcard.FieldDeletedAt:
  43671. return m.OldDeletedAt(ctx)
  43672. case wxcard.FieldUserID:
  43673. return m.OldUserID(ctx)
  43674. case wxcard.FieldWxUserID:
  43675. return m.OldWxUserID(ctx)
  43676. case wxcard.FieldAvatar:
  43677. return m.OldAvatar(ctx)
  43678. case wxcard.FieldLogo:
  43679. return m.OldLogo(ctx)
  43680. case wxcard.FieldName:
  43681. return m.OldName(ctx)
  43682. case wxcard.FieldCompany:
  43683. return m.OldCompany(ctx)
  43684. case wxcard.FieldAddress:
  43685. return m.OldAddress(ctx)
  43686. case wxcard.FieldPhone:
  43687. return m.OldPhone(ctx)
  43688. case wxcard.FieldOfficialAccount:
  43689. return m.OldOfficialAccount(ctx)
  43690. case wxcard.FieldWechatAccount:
  43691. return m.OldWechatAccount(ctx)
  43692. case wxcard.FieldEmail:
  43693. return m.OldEmail(ctx)
  43694. case wxcard.FieldAPIBase:
  43695. return m.OldAPIBase(ctx)
  43696. case wxcard.FieldAPIKey:
  43697. return m.OldAPIKey(ctx)
  43698. case wxcard.FieldAiInfo:
  43699. return m.OldAiInfo(ctx)
  43700. case wxcard.FieldIntro:
  43701. return m.OldIntro(ctx)
  43702. }
  43703. return nil, fmt.Errorf("unknown WxCard field %s", name)
  43704. }
  43705. // SetField sets the value of a field with the given name. It returns an error if
  43706. // the field is not defined in the schema, or if the type mismatched the field
  43707. // type.
  43708. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  43709. switch name {
  43710. case wxcard.FieldCreatedAt:
  43711. v, ok := value.(time.Time)
  43712. if !ok {
  43713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43714. }
  43715. m.SetCreatedAt(v)
  43716. return nil
  43717. case wxcard.FieldUpdatedAt:
  43718. v, ok := value.(time.Time)
  43719. if !ok {
  43720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43721. }
  43722. m.SetUpdatedAt(v)
  43723. return nil
  43724. case wxcard.FieldDeletedAt:
  43725. v, ok := value.(time.Time)
  43726. if !ok {
  43727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43728. }
  43729. m.SetDeletedAt(v)
  43730. return nil
  43731. case wxcard.FieldUserID:
  43732. v, ok := value.(uint64)
  43733. if !ok {
  43734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43735. }
  43736. m.SetUserID(v)
  43737. return nil
  43738. case wxcard.FieldWxUserID:
  43739. v, ok := value.(uint64)
  43740. if !ok {
  43741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43742. }
  43743. m.SetWxUserID(v)
  43744. return nil
  43745. case wxcard.FieldAvatar:
  43746. v, ok := value.(string)
  43747. if !ok {
  43748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43749. }
  43750. m.SetAvatar(v)
  43751. return nil
  43752. case wxcard.FieldLogo:
  43753. v, ok := value.(string)
  43754. if !ok {
  43755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43756. }
  43757. m.SetLogo(v)
  43758. return nil
  43759. case wxcard.FieldName:
  43760. v, ok := value.(string)
  43761. if !ok {
  43762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43763. }
  43764. m.SetName(v)
  43765. return nil
  43766. case wxcard.FieldCompany:
  43767. v, ok := value.(string)
  43768. if !ok {
  43769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43770. }
  43771. m.SetCompany(v)
  43772. return nil
  43773. case wxcard.FieldAddress:
  43774. v, ok := value.(string)
  43775. if !ok {
  43776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43777. }
  43778. m.SetAddress(v)
  43779. return nil
  43780. case wxcard.FieldPhone:
  43781. v, ok := value.(string)
  43782. if !ok {
  43783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43784. }
  43785. m.SetPhone(v)
  43786. return nil
  43787. case wxcard.FieldOfficialAccount:
  43788. v, ok := value.(string)
  43789. if !ok {
  43790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43791. }
  43792. m.SetOfficialAccount(v)
  43793. return nil
  43794. case wxcard.FieldWechatAccount:
  43795. v, ok := value.(string)
  43796. if !ok {
  43797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43798. }
  43799. m.SetWechatAccount(v)
  43800. return nil
  43801. case wxcard.FieldEmail:
  43802. v, ok := value.(string)
  43803. if !ok {
  43804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43805. }
  43806. m.SetEmail(v)
  43807. return nil
  43808. case wxcard.FieldAPIBase:
  43809. v, ok := value.(string)
  43810. if !ok {
  43811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43812. }
  43813. m.SetAPIBase(v)
  43814. return nil
  43815. case wxcard.FieldAPIKey:
  43816. v, ok := value.(string)
  43817. if !ok {
  43818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43819. }
  43820. m.SetAPIKey(v)
  43821. return nil
  43822. case wxcard.FieldAiInfo:
  43823. v, ok := value.(string)
  43824. if !ok {
  43825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43826. }
  43827. m.SetAiInfo(v)
  43828. return nil
  43829. case wxcard.FieldIntro:
  43830. v, ok := value.(string)
  43831. if !ok {
  43832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43833. }
  43834. m.SetIntro(v)
  43835. return nil
  43836. }
  43837. return fmt.Errorf("unknown WxCard field %s", name)
  43838. }
  43839. // AddedFields returns all numeric fields that were incremented/decremented during
  43840. // this mutation.
  43841. func (m *WxCardMutation) AddedFields() []string {
  43842. var fields []string
  43843. if m.adduser_id != nil {
  43844. fields = append(fields, wxcard.FieldUserID)
  43845. }
  43846. if m.addwx_user_id != nil {
  43847. fields = append(fields, wxcard.FieldWxUserID)
  43848. }
  43849. return fields
  43850. }
  43851. // AddedField returns the numeric value that was incremented/decremented on a field
  43852. // with the given name. The second boolean return value indicates that this field
  43853. // was not set, or was not defined in the schema.
  43854. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  43855. switch name {
  43856. case wxcard.FieldUserID:
  43857. return m.AddedUserID()
  43858. case wxcard.FieldWxUserID:
  43859. return m.AddedWxUserID()
  43860. }
  43861. return nil, false
  43862. }
  43863. // AddField adds the value to the field with the given name. It returns an error if
  43864. // the field is not defined in the schema, or if the type mismatched the field
  43865. // type.
  43866. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  43867. switch name {
  43868. case wxcard.FieldUserID:
  43869. v, ok := value.(int64)
  43870. if !ok {
  43871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43872. }
  43873. m.AddUserID(v)
  43874. return nil
  43875. case wxcard.FieldWxUserID:
  43876. v, ok := value.(int64)
  43877. if !ok {
  43878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43879. }
  43880. m.AddWxUserID(v)
  43881. return nil
  43882. }
  43883. return fmt.Errorf("unknown WxCard numeric field %s", name)
  43884. }
  43885. // ClearedFields returns all nullable fields that were cleared during this
  43886. // mutation.
  43887. func (m *WxCardMutation) ClearedFields() []string {
  43888. var fields []string
  43889. if m.FieldCleared(wxcard.FieldDeletedAt) {
  43890. fields = append(fields, wxcard.FieldDeletedAt)
  43891. }
  43892. if m.FieldCleared(wxcard.FieldUserID) {
  43893. fields = append(fields, wxcard.FieldUserID)
  43894. }
  43895. if m.FieldCleared(wxcard.FieldWxUserID) {
  43896. fields = append(fields, wxcard.FieldWxUserID)
  43897. }
  43898. if m.FieldCleared(wxcard.FieldEmail) {
  43899. fields = append(fields, wxcard.FieldEmail)
  43900. }
  43901. if m.FieldCleared(wxcard.FieldAPIBase) {
  43902. fields = append(fields, wxcard.FieldAPIBase)
  43903. }
  43904. if m.FieldCleared(wxcard.FieldAPIKey) {
  43905. fields = append(fields, wxcard.FieldAPIKey)
  43906. }
  43907. if m.FieldCleared(wxcard.FieldAiInfo) {
  43908. fields = append(fields, wxcard.FieldAiInfo)
  43909. }
  43910. if m.FieldCleared(wxcard.FieldIntro) {
  43911. fields = append(fields, wxcard.FieldIntro)
  43912. }
  43913. return fields
  43914. }
  43915. // FieldCleared returns a boolean indicating if a field with the given name was
  43916. // cleared in this mutation.
  43917. func (m *WxCardMutation) FieldCleared(name string) bool {
  43918. _, ok := m.clearedFields[name]
  43919. return ok
  43920. }
  43921. // ClearField clears the value of the field with the given name. It returns an
  43922. // error if the field is not defined in the schema.
  43923. func (m *WxCardMutation) ClearField(name string) error {
  43924. switch name {
  43925. case wxcard.FieldDeletedAt:
  43926. m.ClearDeletedAt()
  43927. return nil
  43928. case wxcard.FieldUserID:
  43929. m.ClearUserID()
  43930. return nil
  43931. case wxcard.FieldWxUserID:
  43932. m.ClearWxUserID()
  43933. return nil
  43934. case wxcard.FieldEmail:
  43935. m.ClearEmail()
  43936. return nil
  43937. case wxcard.FieldAPIBase:
  43938. m.ClearAPIBase()
  43939. return nil
  43940. case wxcard.FieldAPIKey:
  43941. m.ClearAPIKey()
  43942. return nil
  43943. case wxcard.FieldAiInfo:
  43944. m.ClearAiInfo()
  43945. return nil
  43946. case wxcard.FieldIntro:
  43947. m.ClearIntro()
  43948. return nil
  43949. }
  43950. return fmt.Errorf("unknown WxCard nullable field %s", name)
  43951. }
  43952. // ResetField resets all changes in the mutation for the field with the given name.
  43953. // It returns an error if the field is not defined in the schema.
  43954. func (m *WxCardMutation) ResetField(name string) error {
  43955. switch name {
  43956. case wxcard.FieldCreatedAt:
  43957. m.ResetCreatedAt()
  43958. return nil
  43959. case wxcard.FieldUpdatedAt:
  43960. m.ResetUpdatedAt()
  43961. return nil
  43962. case wxcard.FieldDeletedAt:
  43963. m.ResetDeletedAt()
  43964. return nil
  43965. case wxcard.FieldUserID:
  43966. m.ResetUserID()
  43967. return nil
  43968. case wxcard.FieldWxUserID:
  43969. m.ResetWxUserID()
  43970. return nil
  43971. case wxcard.FieldAvatar:
  43972. m.ResetAvatar()
  43973. return nil
  43974. case wxcard.FieldLogo:
  43975. m.ResetLogo()
  43976. return nil
  43977. case wxcard.FieldName:
  43978. m.ResetName()
  43979. return nil
  43980. case wxcard.FieldCompany:
  43981. m.ResetCompany()
  43982. return nil
  43983. case wxcard.FieldAddress:
  43984. m.ResetAddress()
  43985. return nil
  43986. case wxcard.FieldPhone:
  43987. m.ResetPhone()
  43988. return nil
  43989. case wxcard.FieldOfficialAccount:
  43990. m.ResetOfficialAccount()
  43991. return nil
  43992. case wxcard.FieldWechatAccount:
  43993. m.ResetWechatAccount()
  43994. return nil
  43995. case wxcard.FieldEmail:
  43996. m.ResetEmail()
  43997. return nil
  43998. case wxcard.FieldAPIBase:
  43999. m.ResetAPIBase()
  44000. return nil
  44001. case wxcard.FieldAPIKey:
  44002. m.ResetAPIKey()
  44003. return nil
  44004. case wxcard.FieldAiInfo:
  44005. m.ResetAiInfo()
  44006. return nil
  44007. case wxcard.FieldIntro:
  44008. m.ResetIntro()
  44009. return nil
  44010. }
  44011. return fmt.Errorf("unknown WxCard field %s", name)
  44012. }
  44013. // AddedEdges returns all edge names that were set/added in this mutation.
  44014. func (m *WxCardMutation) AddedEdges() []string {
  44015. edges := make([]string, 0, 0)
  44016. return edges
  44017. }
  44018. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44019. // name in this mutation.
  44020. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  44021. return nil
  44022. }
  44023. // RemovedEdges returns all edge names that were removed in this mutation.
  44024. func (m *WxCardMutation) RemovedEdges() []string {
  44025. edges := make([]string, 0, 0)
  44026. return edges
  44027. }
  44028. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44029. // the given name in this mutation.
  44030. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  44031. return nil
  44032. }
  44033. // ClearedEdges returns all edge names that were cleared in this mutation.
  44034. func (m *WxCardMutation) ClearedEdges() []string {
  44035. edges := make([]string, 0, 0)
  44036. return edges
  44037. }
  44038. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44039. // was cleared in this mutation.
  44040. func (m *WxCardMutation) EdgeCleared(name string) bool {
  44041. return false
  44042. }
  44043. // ClearEdge clears the value of the edge with the given name. It returns an error
  44044. // if that edge is not defined in the schema.
  44045. func (m *WxCardMutation) ClearEdge(name string) error {
  44046. return fmt.Errorf("unknown WxCard unique edge %s", name)
  44047. }
  44048. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44049. // It returns an error if the edge is not defined in the schema.
  44050. func (m *WxCardMutation) ResetEdge(name string) error {
  44051. return fmt.Errorf("unknown WxCard edge %s", name)
  44052. }
  44053. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  44054. type WxCardUserMutation struct {
  44055. config
  44056. op Op
  44057. typ string
  44058. id *uint64
  44059. created_at *time.Time
  44060. updated_at *time.Time
  44061. deleted_at *time.Time
  44062. wxid *string
  44063. account *string
  44064. avatar *string
  44065. nickname *string
  44066. remark *string
  44067. phone *string
  44068. open_id *string
  44069. union_id *string
  44070. session_key *string
  44071. is_vip *int
  44072. addis_vip *int
  44073. clearedFields map[string]struct{}
  44074. done bool
  44075. oldValue func(context.Context) (*WxCardUser, error)
  44076. predicates []predicate.WxCardUser
  44077. }
  44078. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44079. // wxcarduserOption allows management of the mutation configuration using functional options.
  44080. type wxcarduserOption func(*WxCardUserMutation)
  44081. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44082. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44083. m := &WxCardUserMutation{
  44084. config: c,
  44085. op: op,
  44086. typ: TypeWxCardUser,
  44087. clearedFields: make(map[string]struct{}),
  44088. }
  44089. for _, opt := range opts {
  44090. opt(m)
  44091. }
  44092. return m
  44093. }
  44094. // withWxCardUserID sets the ID field of the mutation.
  44095. func withWxCardUserID(id uint64) wxcarduserOption {
  44096. return func(m *WxCardUserMutation) {
  44097. var (
  44098. err error
  44099. once sync.Once
  44100. value *WxCardUser
  44101. )
  44102. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44103. once.Do(func() {
  44104. if m.done {
  44105. err = errors.New("querying old values post mutation is not allowed")
  44106. } else {
  44107. value, err = m.Client().WxCardUser.Get(ctx, id)
  44108. }
  44109. })
  44110. return value, err
  44111. }
  44112. m.id = &id
  44113. }
  44114. }
  44115. // withWxCardUser sets the old WxCardUser of the mutation.
  44116. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44117. return func(m *WxCardUserMutation) {
  44118. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44119. return node, nil
  44120. }
  44121. m.id = &node.ID
  44122. }
  44123. }
  44124. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44125. // executed in a transaction (ent.Tx), a transactional client is returned.
  44126. func (m WxCardUserMutation) Client() *Client {
  44127. client := &Client{config: m.config}
  44128. client.init()
  44129. return client
  44130. }
  44131. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44132. // it returns an error otherwise.
  44133. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44134. if _, ok := m.driver.(*txDriver); !ok {
  44135. return nil, errors.New("ent: mutation is not running in a transaction")
  44136. }
  44137. tx := &Tx{config: m.config}
  44138. tx.init()
  44139. return tx, nil
  44140. }
  44141. // SetID sets the value of the id field. Note that this
  44142. // operation is only accepted on creation of WxCardUser entities.
  44143. func (m *WxCardUserMutation) SetID(id uint64) {
  44144. m.id = &id
  44145. }
  44146. // ID returns the ID value in the mutation. Note that the ID is only available
  44147. // if it was provided to the builder or after it was returned from the database.
  44148. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44149. if m.id == nil {
  44150. return
  44151. }
  44152. return *m.id, true
  44153. }
  44154. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44155. // That means, if the mutation is applied within a transaction with an isolation level such
  44156. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44157. // or updated by the mutation.
  44158. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44159. switch {
  44160. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44161. id, exists := m.ID()
  44162. if exists {
  44163. return []uint64{id}, nil
  44164. }
  44165. fallthrough
  44166. case m.op.Is(OpUpdate | OpDelete):
  44167. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44168. default:
  44169. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44170. }
  44171. }
  44172. // SetCreatedAt sets the "created_at" field.
  44173. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44174. m.created_at = &t
  44175. }
  44176. // CreatedAt returns the value of the "created_at" field in the mutation.
  44177. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44178. v := m.created_at
  44179. if v == nil {
  44180. return
  44181. }
  44182. return *v, true
  44183. }
  44184. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44185. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44187. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44188. if !m.op.Is(OpUpdateOne) {
  44189. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44190. }
  44191. if m.id == nil || m.oldValue == nil {
  44192. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44193. }
  44194. oldValue, err := m.oldValue(ctx)
  44195. if err != nil {
  44196. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44197. }
  44198. return oldValue.CreatedAt, nil
  44199. }
  44200. // ResetCreatedAt resets all changes to the "created_at" field.
  44201. func (m *WxCardUserMutation) ResetCreatedAt() {
  44202. m.created_at = nil
  44203. }
  44204. // SetUpdatedAt sets the "updated_at" field.
  44205. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44206. m.updated_at = &t
  44207. }
  44208. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44209. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44210. v := m.updated_at
  44211. if v == nil {
  44212. return
  44213. }
  44214. return *v, true
  44215. }
  44216. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44217. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44219. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44220. if !m.op.Is(OpUpdateOne) {
  44221. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44222. }
  44223. if m.id == nil || m.oldValue == nil {
  44224. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44225. }
  44226. oldValue, err := m.oldValue(ctx)
  44227. if err != nil {
  44228. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44229. }
  44230. return oldValue.UpdatedAt, nil
  44231. }
  44232. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44233. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44234. m.updated_at = nil
  44235. }
  44236. // SetDeletedAt sets the "deleted_at" field.
  44237. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44238. m.deleted_at = &t
  44239. }
  44240. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44241. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44242. v := m.deleted_at
  44243. if v == nil {
  44244. return
  44245. }
  44246. return *v, true
  44247. }
  44248. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44249. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44251. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44252. if !m.op.Is(OpUpdateOne) {
  44253. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44254. }
  44255. if m.id == nil || m.oldValue == nil {
  44256. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44257. }
  44258. oldValue, err := m.oldValue(ctx)
  44259. if err != nil {
  44260. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44261. }
  44262. return oldValue.DeletedAt, nil
  44263. }
  44264. // ClearDeletedAt clears the value of the "deleted_at" field.
  44265. func (m *WxCardUserMutation) ClearDeletedAt() {
  44266. m.deleted_at = nil
  44267. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44268. }
  44269. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44270. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44271. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44272. return ok
  44273. }
  44274. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44275. func (m *WxCardUserMutation) ResetDeletedAt() {
  44276. m.deleted_at = nil
  44277. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44278. }
  44279. // SetWxid sets the "wxid" field.
  44280. func (m *WxCardUserMutation) SetWxid(s string) {
  44281. m.wxid = &s
  44282. }
  44283. // Wxid returns the value of the "wxid" field in the mutation.
  44284. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44285. v := m.wxid
  44286. if v == nil {
  44287. return
  44288. }
  44289. return *v, true
  44290. }
  44291. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44292. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44294. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44295. if !m.op.Is(OpUpdateOne) {
  44296. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44297. }
  44298. if m.id == nil || m.oldValue == nil {
  44299. return v, errors.New("OldWxid requires an ID field in the mutation")
  44300. }
  44301. oldValue, err := m.oldValue(ctx)
  44302. if err != nil {
  44303. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44304. }
  44305. return oldValue.Wxid, nil
  44306. }
  44307. // ResetWxid resets all changes to the "wxid" field.
  44308. func (m *WxCardUserMutation) ResetWxid() {
  44309. m.wxid = nil
  44310. }
  44311. // SetAccount sets the "account" field.
  44312. func (m *WxCardUserMutation) SetAccount(s string) {
  44313. m.account = &s
  44314. }
  44315. // Account returns the value of the "account" field in the mutation.
  44316. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44317. v := m.account
  44318. if v == nil {
  44319. return
  44320. }
  44321. return *v, true
  44322. }
  44323. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44324. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44326. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44327. if !m.op.Is(OpUpdateOne) {
  44328. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44329. }
  44330. if m.id == nil || m.oldValue == nil {
  44331. return v, errors.New("OldAccount requires an ID field in the mutation")
  44332. }
  44333. oldValue, err := m.oldValue(ctx)
  44334. if err != nil {
  44335. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44336. }
  44337. return oldValue.Account, nil
  44338. }
  44339. // ResetAccount resets all changes to the "account" field.
  44340. func (m *WxCardUserMutation) ResetAccount() {
  44341. m.account = nil
  44342. }
  44343. // SetAvatar sets the "avatar" field.
  44344. func (m *WxCardUserMutation) SetAvatar(s string) {
  44345. m.avatar = &s
  44346. }
  44347. // Avatar returns the value of the "avatar" field in the mutation.
  44348. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44349. v := m.avatar
  44350. if v == nil {
  44351. return
  44352. }
  44353. return *v, true
  44354. }
  44355. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44356. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44358. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44359. if !m.op.Is(OpUpdateOne) {
  44360. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44361. }
  44362. if m.id == nil || m.oldValue == nil {
  44363. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44364. }
  44365. oldValue, err := m.oldValue(ctx)
  44366. if err != nil {
  44367. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44368. }
  44369. return oldValue.Avatar, nil
  44370. }
  44371. // ResetAvatar resets all changes to the "avatar" field.
  44372. func (m *WxCardUserMutation) ResetAvatar() {
  44373. m.avatar = nil
  44374. }
  44375. // SetNickname sets the "nickname" field.
  44376. func (m *WxCardUserMutation) SetNickname(s string) {
  44377. m.nickname = &s
  44378. }
  44379. // Nickname returns the value of the "nickname" field in the mutation.
  44380. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44381. v := m.nickname
  44382. if v == nil {
  44383. return
  44384. }
  44385. return *v, true
  44386. }
  44387. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44388. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44390. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44391. if !m.op.Is(OpUpdateOne) {
  44392. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44393. }
  44394. if m.id == nil || m.oldValue == nil {
  44395. return v, errors.New("OldNickname requires an ID field in the mutation")
  44396. }
  44397. oldValue, err := m.oldValue(ctx)
  44398. if err != nil {
  44399. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44400. }
  44401. return oldValue.Nickname, nil
  44402. }
  44403. // ResetNickname resets all changes to the "nickname" field.
  44404. func (m *WxCardUserMutation) ResetNickname() {
  44405. m.nickname = nil
  44406. }
  44407. // SetRemark sets the "remark" field.
  44408. func (m *WxCardUserMutation) SetRemark(s string) {
  44409. m.remark = &s
  44410. }
  44411. // Remark returns the value of the "remark" field in the mutation.
  44412. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44413. v := m.remark
  44414. if v == nil {
  44415. return
  44416. }
  44417. return *v, true
  44418. }
  44419. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44420. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44422. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44423. if !m.op.Is(OpUpdateOne) {
  44424. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44425. }
  44426. if m.id == nil || m.oldValue == nil {
  44427. return v, errors.New("OldRemark requires an ID field in the mutation")
  44428. }
  44429. oldValue, err := m.oldValue(ctx)
  44430. if err != nil {
  44431. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44432. }
  44433. return oldValue.Remark, nil
  44434. }
  44435. // ResetRemark resets all changes to the "remark" field.
  44436. func (m *WxCardUserMutation) ResetRemark() {
  44437. m.remark = nil
  44438. }
  44439. // SetPhone sets the "phone" field.
  44440. func (m *WxCardUserMutation) SetPhone(s string) {
  44441. m.phone = &s
  44442. }
  44443. // Phone returns the value of the "phone" field in the mutation.
  44444. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44445. v := m.phone
  44446. if v == nil {
  44447. return
  44448. }
  44449. return *v, true
  44450. }
  44451. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44452. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44454. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44455. if !m.op.Is(OpUpdateOne) {
  44456. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44457. }
  44458. if m.id == nil || m.oldValue == nil {
  44459. return v, errors.New("OldPhone requires an ID field in the mutation")
  44460. }
  44461. oldValue, err := m.oldValue(ctx)
  44462. if err != nil {
  44463. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44464. }
  44465. return oldValue.Phone, nil
  44466. }
  44467. // ResetPhone resets all changes to the "phone" field.
  44468. func (m *WxCardUserMutation) ResetPhone() {
  44469. m.phone = nil
  44470. }
  44471. // SetOpenID sets the "open_id" field.
  44472. func (m *WxCardUserMutation) SetOpenID(s string) {
  44473. m.open_id = &s
  44474. }
  44475. // OpenID returns the value of the "open_id" field in the mutation.
  44476. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44477. v := m.open_id
  44478. if v == nil {
  44479. return
  44480. }
  44481. return *v, true
  44482. }
  44483. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44484. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44486. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44487. if !m.op.Is(OpUpdateOne) {
  44488. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44489. }
  44490. if m.id == nil || m.oldValue == nil {
  44491. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44492. }
  44493. oldValue, err := m.oldValue(ctx)
  44494. if err != nil {
  44495. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44496. }
  44497. return oldValue.OpenID, nil
  44498. }
  44499. // ResetOpenID resets all changes to the "open_id" field.
  44500. func (m *WxCardUserMutation) ResetOpenID() {
  44501. m.open_id = nil
  44502. }
  44503. // SetUnionID sets the "union_id" field.
  44504. func (m *WxCardUserMutation) SetUnionID(s string) {
  44505. m.union_id = &s
  44506. }
  44507. // UnionID returns the value of the "union_id" field in the mutation.
  44508. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44509. v := m.union_id
  44510. if v == nil {
  44511. return
  44512. }
  44513. return *v, true
  44514. }
  44515. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44516. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44518. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44519. if !m.op.Is(OpUpdateOne) {
  44520. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44521. }
  44522. if m.id == nil || m.oldValue == nil {
  44523. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44524. }
  44525. oldValue, err := m.oldValue(ctx)
  44526. if err != nil {
  44527. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44528. }
  44529. return oldValue.UnionID, nil
  44530. }
  44531. // ResetUnionID resets all changes to the "union_id" field.
  44532. func (m *WxCardUserMutation) ResetUnionID() {
  44533. m.union_id = nil
  44534. }
  44535. // SetSessionKey sets the "session_key" field.
  44536. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44537. m.session_key = &s
  44538. }
  44539. // SessionKey returns the value of the "session_key" field in the mutation.
  44540. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44541. v := m.session_key
  44542. if v == nil {
  44543. return
  44544. }
  44545. return *v, true
  44546. }
  44547. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44548. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44550. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44551. if !m.op.Is(OpUpdateOne) {
  44552. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44553. }
  44554. if m.id == nil || m.oldValue == nil {
  44555. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44556. }
  44557. oldValue, err := m.oldValue(ctx)
  44558. if err != nil {
  44559. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44560. }
  44561. return oldValue.SessionKey, nil
  44562. }
  44563. // ResetSessionKey resets all changes to the "session_key" field.
  44564. func (m *WxCardUserMutation) ResetSessionKey() {
  44565. m.session_key = nil
  44566. }
  44567. // SetIsVip sets the "is_vip" field.
  44568. func (m *WxCardUserMutation) SetIsVip(i int) {
  44569. m.is_vip = &i
  44570. m.addis_vip = nil
  44571. }
  44572. // IsVip returns the value of the "is_vip" field in the mutation.
  44573. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44574. v := m.is_vip
  44575. if v == nil {
  44576. return
  44577. }
  44578. return *v, true
  44579. }
  44580. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44581. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44583. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44584. if !m.op.Is(OpUpdateOne) {
  44585. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44586. }
  44587. if m.id == nil || m.oldValue == nil {
  44588. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44589. }
  44590. oldValue, err := m.oldValue(ctx)
  44591. if err != nil {
  44592. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44593. }
  44594. return oldValue.IsVip, nil
  44595. }
  44596. // AddIsVip adds i to the "is_vip" field.
  44597. func (m *WxCardUserMutation) AddIsVip(i int) {
  44598. if m.addis_vip != nil {
  44599. *m.addis_vip += i
  44600. } else {
  44601. m.addis_vip = &i
  44602. }
  44603. }
  44604. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44605. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44606. v := m.addis_vip
  44607. if v == nil {
  44608. return
  44609. }
  44610. return *v, true
  44611. }
  44612. // ResetIsVip resets all changes to the "is_vip" field.
  44613. func (m *WxCardUserMutation) ResetIsVip() {
  44614. m.is_vip = nil
  44615. m.addis_vip = nil
  44616. }
  44617. // Where appends a list predicates to the WxCardUserMutation builder.
  44618. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44619. m.predicates = append(m.predicates, ps...)
  44620. }
  44621. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44622. // users can use type-assertion to append predicates that do not depend on any generated package.
  44623. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44624. p := make([]predicate.WxCardUser, len(ps))
  44625. for i := range ps {
  44626. p[i] = ps[i]
  44627. }
  44628. m.Where(p...)
  44629. }
  44630. // Op returns the operation name.
  44631. func (m *WxCardUserMutation) Op() Op {
  44632. return m.op
  44633. }
  44634. // SetOp allows setting the mutation operation.
  44635. func (m *WxCardUserMutation) SetOp(op Op) {
  44636. m.op = op
  44637. }
  44638. // Type returns the node type of this mutation (WxCardUser).
  44639. func (m *WxCardUserMutation) Type() string {
  44640. return m.typ
  44641. }
  44642. // Fields returns all fields that were changed during this mutation. Note that in
  44643. // order to get all numeric fields that were incremented/decremented, call
  44644. // AddedFields().
  44645. func (m *WxCardUserMutation) Fields() []string {
  44646. fields := make([]string, 0, 13)
  44647. if m.created_at != nil {
  44648. fields = append(fields, wxcarduser.FieldCreatedAt)
  44649. }
  44650. if m.updated_at != nil {
  44651. fields = append(fields, wxcarduser.FieldUpdatedAt)
  44652. }
  44653. if m.deleted_at != nil {
  44654. fields = append(fields, wxcarduser.FieldDeletedAt)
  44655. }
  44656. if m.wxid != nil {
  44657. fields = append(fields, wxcarduser.FieldWxid)
  44658. }
  44659. if m.account != nil {
  44660. fields = append(fields, wxcarduser.FieldAccount)
  44661. }
  44662. if m.avatar != nil {
  44663. fields = append(fields, wxcarduser.FieldAvatar)
  44664. }
  44665. if m.nickname != nil {
  44666. fields = append(fields, wxcarduser.FieldNickname)
  44667. }
  44668. if m.remark != nil {
  44669. fields = append(fields, wxcarduser.FieldRemark)
  44670. }
  44671. if m.phone != nil {
  44672. fields = append(fields, wxcarduser.FieldPhone)
  44673. }
  44674. if m.open_id != nil {
  44675. fields = append(fields, wxcarduser.FieldOpenID)
  44676. }
  44677. if m.union_id != nil {
  44678. fields = append(fields, wxcarduser.FieldUnionID)
  44679. }
  44680. if m.session_key != nil {
  44681. fields = append(fields, wxcarduser.FieldSessionKey)
  44682. }
  44683. if m.is_vip != nil {
  44684. fields = append(fields, wxcarduser.FieldIsVip)
  44685. }
  44686. return fields
  44687. }
  44688. // Field returns the value of a field with the given name. The second boolean
  44689. // return value indicates that this field was not set, or was not defined in the
  44690. // schema.
  44691. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  44692. switch name {
  44693. case wxcarduser.FieldCreatedAt:
  44694. return m.CreatedAt()
  44695. case wxcarduser.FieldUpdatedAt:
  44696. return m.UpdatedAt()
  44697. case wxcarduser.FieldDeletedAt:
  44698. return m.DeletedAt()
  44699. case wxcarduser.FieldWxid:
  44700. return m.Wxid()
  44701. case wxcarduser.FieldAccount:
  44702. return m.Account()
  44703. case wxcarduser.FieldAvatar:
  44704. return m.Avatar()
  44705. case wxcarduser.FieldNickname:
  44706. return m.Nickname()
  44707. case wxcarduser.FieldRemark:
  44708. return m.Remark()
  44709. case wxcarduser.FieldPhone:
  44710. return m.Phone()
  44711. case wxcarduser.FieldOpenID:
  44712. return m.OpenID()
  44713. case wxcarduser.FieldUnionID:
  44714. return m.UnionID()
  44715. case wxcarduser.FieldSessionKey:
  44716. return m.SessionKey()
  44717. case wxcarduser.FieldIsVip:
  44718. return m.IsVip()
  44719. }
  44720. return nil, false
  44721. }
  44722. // OldField returns the old value of the field from the database. An error is
  44723. // returned if the mutation operation is not UpdateOne, or the query to the
  44724. // database failed.
  44725. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44726. switch name {
  44727. case wxcarduser.FieldCreatedAt:
  44728. return m.OldCreatedAt(ctx)
  44729. case wxcarduser.FieldUpdatedAt:
  44730. return m.OldUpdatedAt(ctx)
  44731. case wxcarduser.FieldDeletedAt:
  44732. return m.OldDeletedAt(ctx)
  44733. case wxcarduser.FieldWxid:
  44734. return m.OldWxid(ctx)
  44735. case wxcarduser.FieldAccount:
  44736. return m.OldAccount(ctx)
  44737. case wxcarduser.FieldAvatar:
  44738. return m.OldAvatar(ctx)
  44739. case wxcarduser.FieldNickname:
  44740. return m.OldNickname(ctx)
  44741. case wxcarduser.FieldRemark:
  44742. return m.OldRemark(ctx)
  44743. case wxcarduser.FieldPhone:
  44744. return m.OldPhone(ctx)
  44745. case wxcarduser.FieldOpenID:
  44746. return m.OldOpenID(ctx)
  44747. case wxcarduser.FieldUnionID:
  44748. return m.OldUnionID(ctx)
  44749. case wxcarduser.FieldSessionKey:
  44750. return m.OldSessionKey(ctx)
  44751. case wxcarduser.FieldIsVip:
  44752. return m.OldIsVip(ctx)
  44753. }
  44754. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  44755. }
  44756. // SetField sets the value of a field with the given name. It returns an error if
  44757. // the field is not defined in the schema, or if the type mismatched the field
  44758. // type.
  44759. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  44760. switch name {
  44761. case wxcarduser.FieldCreatedAt:
  44762. v, ok := value.(time.Time)
  44763. if !ok {
  44764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44765. }
  44766. m.SetCreatedAt(v)
  44767. return nil
  44768. case wxcarduser.FieldUpdatedAt:
  44769. v, ok := value.(time.Time)
  44770. if !ok {
  44771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44772. }
  44773. m.SetUpdatedAt(v)
  44774. return nil
  44775. case wxcarduser.FieldDeletedAt:
  44776. v, ok := value.(time.Time)
  44777. if !ok {
  44778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44779. }
  44780. m.SetDeletedAt(v)
  44781. return nil
  44782. case wxcarduser.FieldWxid:
  44783. v, ok := value.(string)
  44784. if !ok {
  44785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44786. }
  44787. m.SetWxid(v)
  44788. return nil
  44789. case wxcarduser.FieldAccount:
  44790. v, ok := value.(string)
  44791. if !ok {
  44792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44793. }
  44794. m.SetAccount(v)
  44795. return nil
  44796. case wxcarduser.FieldAvatar:
  44797. v, ok := value.(string)
  44798. if !ok {
  44799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44800. }
  44801. m.SetAvatar(v)
  44802. return nil
  44803. case wxcarduser.FieldNickname:
  44804. v, ok := value.(string)
  44805. if !ok {
  44806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44807. }
  44808. m.SetNickname(v)
  44809. return nil
  44810. case wxcarduser.FieldRemark:
  44811. v, ok := value.(string)
  44812. if !ok {
  44813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44814. }
  44815. m.SetRemark(v)
  44816. return nil
  44817. case wxcarduser.FieldPhone:
  44818. v, ok := value.(string)
  44819. if !ok {
  44820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44821. }
  44822. m.SetPhone(v)
  44823. return nil
  44824. case wxcarduser.FieldOpenID:
  44825. v, ok := value.(string)
  44826. if !ok {
  44827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44828. }
  44829. m.SetOpenID(v)
  44830. return nil
  44831. case wxcarduser.FieldUnionID:
  44832. v, ok := value.(string)
  44833. if !ok {
  44834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44835. }
  44836. m.SetUnionID(v)
  44837. return nil
  44838. case wxcarduser.FieldSessionKey:
  44839. v, ok := value.(string)
  44840. if !ok {
  44841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44842. }
  44843. m.SetSessionKey(v)
  44844. return nil
  44845. case wxcarduser.FieldIsVip:
  44846. v, ok := value.(int)
  44847. if !ok {
  44848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44849. }
  44850. m.SetIsVip(v)
  44851. return nil
  44852. }
  44853. return fmt.Errorf("unknown WxCardUser field %s", name)
  44854. }
  44855. // AddedFields returns all numeric fields that were incremented/decremented during
  44856. // this mutation.
  44857. func (m *WxCardUserMutation) AddedFields() []string {
  44858. var fields []string
  44859. if m.addis_vip != nil {
  44860. fields = append(fields, wxcarduser.FieldIsVip)
  44861. }
  44862. return fields
  44863. }
  44864. // AddedField returns the numeric value that was incremented/decremented on a field
  44865. // with the given name. The second boolean return value indicates that this field
  44866. // was not set, or was not defined in the schema.
  44867. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  44868. switch name {
  44869. case wxcarduser.FieldIsVip:
  44870. return m.AddedIsVip()
  44871. }
  44872. return nil, false
  44873. }
  44874. // AddField adds the value to the field with the given name. It returns an error if
  44875. // the field is not defined in the schema, or if the type mismatched the field
  44876. // type.
  44877. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  44878. switch name {
  44879. case wxcarduser.FieldIsVip:
  44880. v, ok := value.(int)
  44881. if !ok {
  44882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44883. }
  44884. m.AddIsVip(v)
  44885. return nil
  44886. }
  44887. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  44888. }
  44889. // ClearedFields returns all nullable fields that were cleared during this
  44890. // mutation.
  44891. func (m *WxCardUserMutation) ClearedFields() []string {
  44892. var fields []string
  44893. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  44894. fields = append(fields, wxcarduser.FieldDeletedAt)
  44895. }
  44896. return fields
  44897. }
  44898. // FieldCleared returns a boolean indicating if a field with the given name was
  44899. // cleared in this mutation.
  44900. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  44901. _, ok := m.clearedFields[name]
  44902. return ok
  44903. }
  44904. // ClearField clears the value of the field with the given name. It returns an
  44905. // error if the field is not defined in the schema.
  44906. func (m *WxCardUserMutation) ClearField(name string) error {
  44907. switch name {
  44908. case wxcarduser.FieldDeletedAt:
  44909. m.ClearDeletedAt()
  44910. return nil
  44911. }
  44912. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  44913. }
  44914. // ResetField resets all changes in the mutation for the field with the given name.
  44915. // It returns an error if the field is not defined in the schema.
  44916. func (m *WxCardUserMutation) ResetField(name string) error {
  44917. switch name {
  44918. case wxcarduser.FieldCreatedAt:
  44919. m.ResetCreatedAt()
  44920. return nil
  44921. case wxcarduser.FieldUpdatedAt:
  44922. m.ResetUpdatedAt()
  44923. return nil
  44924. case wxcarduser.FieldDeletedAt:
  44925. m.ResetDeletedAt()
  44926. return nil
  44927. case wxcarduser.FieldWxid:
  44928. m.ResetWxid()
  44929. return nil
  44930. case wxcarduser.FieldAccount:
  44931. m.ResetAccount()
  44932. return nil
  44933. case wxcarduser.FieldAvatar:
  44934. m.ResetAvatar()
  44935. return nil
  44936. case wxcarduser.FieldNickname:
  44937. m.ResetNickname()
  44938. return nil
  44939. case wxcarduser.FieldRemark:
  44940. m.ResetRemark()
  44941. return nil
  44942. case wxcarduser.FieldPhone:
  44943. m.ResetPhone()
  44944. return nil
  44945. case wxcarduser.FieldOpenID:
  44946. m.ResetOpenID()
  44947. return nil
  44948. case wxcarduser.FieldUnionID:
  44949. m.ResetUnionID()
  44950. return nil
  44951. case wxcarduser.FieldSessionKey:
  44952. m.ResetSessionKey()
  44953. return nil
  44954. case wxcarduser.FieldIsVip:
  44955. m.ResetIsVip()
  44956. return nil
  44957. }
  44958. return fmt.Errorf("unknown WxCardUser field %s", name)
  44959. }
  44960. // AddedEdges returns all edge names that were set/added in this mutation.
  44961. func (m *WxCardUserMutation) AddedEdges() []string {
  44962. edges := make([]string, 0, 0)
  44963. return edges
  44964. }
  44965. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44966. // name in this mutation.
  44967. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  44968. return nil
  44969. }
  44970. // RemovedEdges returns all edge names that were removed in this mutation.
  44971. func (m *WxCardUserMutation) RemovedEdges() []string {
  44972. edges := make([]string, 0, 0)
  44973. return edges
  44974. }
  44975. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44976. // the given name in this mutation.
  44977. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  44978. return nil
  44979. }
  44980. // ClearedEdges returns all edge names that were cleared in this mutation.
  44981. func (m *WxCardUserMutation) ClearedEdges() []string {
  44982. edges := make([]string, 0, 0)
  44983. return edges
  44984. }
  44985. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44986. // was cleared in this mutation.
  44987. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  44988. return false
  44989. }
  44990. // ClearEdge clears the value of the edge with the given name. It returns an error
  44991. // if that edge is not defined in the schema.
  44992. func (m *WxCardUserMutation) ClearEdge(name string) error {
  44993. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  44994. }
  44995. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44996. // It returns an error if the edge is not defined in the schema.
  44997. func (m *WxCardUserMutation) ResetEdge(name string) error {
  44998. return fmt.Errorf("unknown WxCardUser edge %s", name)
  44999. }
  45000. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  45001. type WxCardVisitMutation struct {
  45002. config
  45003. op Op
  45004. typ string
  45005. id *uint64
  45006. created_at *time.Time
  45007. updated_at *time.Time
  45008. deleted_at *time.Time
  45009. user_id *uint64
  45010. adduser_id *int64
  45011. bot_id *uint64
  45012. addbot_id *int64
  45013. bot_type *uint8
  45014. addbot_type *int8
  45015. clearedFields map[string]struct{}
  45016. done bool
  45017. oldValue func(context.Context) (*WxCardVisit, error)
  45018. predicates []predicate.WxCardVisit
  45019. }
  45020. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  45021. // wxcardvisitOption allows management of the mutation configuration using functional options.
  45022. type wxcardvisitOption func(*WxCardVisitMutation)
  45023. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  45024. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  45025. m := &WxCardVisitMutation{
  45026. config: c,
  45027. op: op,
  45028. typ: TypeWxCardVisit,
  45029. clearedFields: make(map[string]struct{}),
  45030. }
  45031. for _, opt := range opts {
  45032. opt(m)
  45033. }
  45034. return m
  45035. }
  45036. // withWxCardVisitID sets the ID field of the mutation.
  45037. func withWxCardVisitID(id uint64) wxcardvisitOption {
  45038. return func(m *WxCardVisitMutation) {
  45039. var (
  45040. err error
  45041. once sync.Once
  45042. value *WxCardVisit
  45043. )
  45044. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  45045. once.Do(func() {
  45046. if m.done {
  45047. err = errors.New("querying old values post mutation is not allowed")
  45048. } else {
  45049. value, err = m.Client().WxCardVisit.Get(ctx, id)
  45050. }
  45051. })
  45052. return value, err
  45053. }
  45054. m.id = &id
  45055. }
  45056. }
  45057. // withWxCardVisit sets the old WxCardVisit of the mutation.
  45058. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  45059. return func(m *WxCardVisitMutation) {
  45060. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  45061. return node, nil
  45062. }
  45063. m.id = &node.ID
  45064. }
  45065. }
  45066. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45067. // executed in a transaction (ent.Tx), a transactional client is returned.
  45068. func (m WxCardVisitMutation) Client() *Client {
  45069. client := &Client{config: m.config}
  45070. client.init()
  45071. return client
  45072. }
  45073. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45074. // it returns an error otherwise.
  45075. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  45076. if _, ok := m.driver.(*txDriver); !ok {
  45077. return nil, errors.New("ent: mutation is not running in a transaction")
  45078. }
  45079. tx := &Tx{config: m.config}
  45080. tx.init()
  45081. return tx, nil
  45082. }
  45083. // SetID sets the value of the id field. Note that this
  45084. // operation is only accepted on creation of WxCardVisit entities.
  45085. func (m *WxCardVisitMutation) SetID(id uint64) {
  45086. m.id = &id
  45087. }
  45088. // ID returns the ID value in the mutation. Note that the ID is only available
  45089. // if it was provided to the builder or after it was returned from the database.
  45090. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45091. if m.id == nil {
  45092. return
  45093. }
  45094. return *m.id, true
  45095. }
  45096. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45097. // That means, if the mutation is applied within a transaction with an isolation level such
  45098. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45099. // or updated by the mutation.
  45100. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45101. switch {
  45102. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45103. id, exists := m.ID()
  45104. if exists {
  45105. return []uint64{id}, nil
  45106. }
  45107. fallthrough
  45108. case m.op.Is(OpUpdate | OpDelete):
  45109. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45110. default:
  45111. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45112. }
  45113. }
  45114. // SetCreatedAt sets the "created_at" field.
  45115. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45116. m.created_at = &t
  45117. }
  45118. // CreatedAt returns the value of the "created_at" field in the mutation.
  45119. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45120. v := m.created_at
  45121. if v == nil {
  45122. return
  45123. }
  45124. return *v, true
  45125. }
  45126. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45127. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45129. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45130. if !m.op.Is(OpUpdateOne) {
  45131. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45132. }
  45133. if m.id == nil || m.oldValue == nil {
  45134. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45135. }
  45136. oldValue, err := m.oldValue(ctx)
  45137. if err != nil {
  45138. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45139. }
  45140. return oldValue.CreatedAt, nil
  45141. }
  45142. // ResetCreatedAt resets all changes to the "created_at" field.
  45143. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45144. m.created_at = nil
  45145. }
  45146. // SetUpdatedAt sets the "updated_at" field.
  45147. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45148. m.updated_at = &t
  45149. }
  45150. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45151. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45152. v := m.updated_at
  45153. if v == nil {
  45154. return
  45155. }
  45156. return *v, true
  45157. }
  45158. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45159. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45161. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45162. if !m.op.Is(OpUpdateOne) {
  45163. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45164. }
  45165. if m.id == nil || m.oldValue == nil {
  45166. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45167. }
  45168. oldValue, err := m.oldValue(ctx)
  45169. if err != nil {
  45170. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45171. }
  45172. return oldValue.UpdatedAt, nil
  45173. }
  45174. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45175. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45176. m.updated_at = nil
  45177. }
  45178. // SetDeletedAt sets the "deleted_at" field.
  45179. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45180. m.deleted_at = &t
  45181. }
  45182. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45183. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45184. v := m.deleted_at
  45185. if v == nil {
  45186. return
  45187. }
  45188. return *v, true
  45189. }
  45190. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45191. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45193. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45194. if !m.op.Is(OpUpdateOne) {
  45195. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45196. }
  45197. if m.id == nil || m.oldValue == nil {
  45198. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45199. }
  45200. oldValue, err := m.oldValue(ctx)
  45201. if err != nil {
  45202. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45203. }
  45204. return oldValue.DeletedAt, nil
  45205. }
  45206. // ClearDeletedAt clears the value of the "deleted_at" field.
  45207. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45208. m.deleted_at = nil
  45209. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45210. }
  45211. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45212. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45213. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45214. return ok
  45215. }
  45216. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45217. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45218. m.deleted_at = nil
  45219. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45220. }
  45221. // SetUserID sets the "user_id" field.
  45222. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45223. m.user_id = &u
  45224. m.adduser_id = nil
  45225. }
  45226. // UserID returns the value of the "user_id" field in the mutation.
  45227. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45228. v := m.user_id
  45229. if v == nil {
  45230. return
  45231. }
  45232. return *v, true
  45233. }
  45234. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45235. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45237. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45238. if !m.op.Is(OpUpdateOne) {
  45239. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45240. }
  45241. if m.id == nil || m.oldValue == nil {
  45242. return v, errors.New("OldUserID requires an ID field in the mutation")
  45243. }
  45244. oldValue, err := m.oldValue(ctx)
  45245. if err != nil {
  45246. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45247. }
  45248. return oldValue.UserID, nil
  45249. }
  45250. // AddUserID adds u to the "user_id" field.
  45251. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45252. if m.adduser_id != nil {
  45253. *m.adduser_id += u
  45254. } else {
  45255. m.adduser_id = &u
  45256. }
  45257. }
  45258. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45259. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45260. v := m.adduser_id
  45261. if v == nil {
  45262. return
  45263. }
  45264. return *v, true
  45265. }
  45266. // ClearUserID clears the value of the "user_id" field.
  45267. func (m *WxCardVisitMutation) ClearUserID() {
  45268. m.user_id = nil
  45269. m.adduser_id = nil
  45270. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45271. }
  45272. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45273. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45274. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45275. return ok
  45276. }
  45277. // ResetUserID resets all changes to the "user_id" field.
  45278. func (m *WxCardVisitMutation) ResetUserID() {
  45279. m.user_id = nil
  45280. m.adduser_id = nil
  45281. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45282. }
  45283. // SetBotID sets the "bot_id" field.
  45284. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45285. m.bot_id = &u
  45286. m.addbot_id = nil
  45287. }
  45288. // BotID returns the value of the "bot_id" field in the mutation.
  45289. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45290. v := m.bot_id
  45291. if v == nil {
  45292. return
  45293. }
  45294. return *v, true
  45295. }
  45296. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45297. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45299. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45300. if !m.op.Is(OpUpdateOne) {
  45301. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45302. }
  45303. if m.id == nil || m.oldValue == nil {
  45304. return v, errors.New("OldBotID requires an ID field in the mutation")
  45305. }
  45306. oldValue, err := m.oldValue(ctx)
  45307. if err != nil {
  45308. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45309. }
  45310. return oldValue.BotID, nil
  45311. }
  45312. // AddBotID adds u to the "bot_id" field.
  45313. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45314. if m.addbot_id != nil {
  45315. *m.addbot_id += u
  45316. } else {
  45317. m.addbot_id = &u
  45318. }
  45319. }
  45320. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45321. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45322. v := m.addbot_id
  45323. if v == nil {
  45324. return
  45325. }
  45326. return *v, true
  45327. }
  45328. // ResetBotID resets all changes to the "bot_id" field.
  45329. func (m *WxCardVisitMutation) ResetBotID() {
  45330. m.bot_id = nil
  45331. m.addbot_id = nil
  45332. }
  45333. // SetBotType sets the "bot_type" field.
  45334. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45335. m.bot_type = &u
  45336. m.addbot_type = nil
  45337. }
  45338. // BotType returns the value of the "bot_type" field in the mutation.
  45339. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45340. v := m.bot_type
  45341. if v == nil {
  45342. return
  45343. }
  45344. return *v, true
  45345. }
  45346. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  45347. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45349. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  45350. if !m.op.Is(OpUpdateOne) {
  45351. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45352. }
  45353. if m.id == nil || m.oldValue == nil {
  45354. return v, errors.New("OldBotType requires an ID field in the mutation")
  45355. }
  45356. oldValue, err := m.oldValue(ctx)
  45357. if err != nil {
  45358. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  45359. }
  45360. return oldValue.BotType, nil
  45361. }
  45362. // AddBotType adds u to the "bot_type" field.
  45363. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45364. if m.addbot_type != nil {
  45365. *m.addbot_type += u
  45366. } else {
  45367. m.addbot_type = &u
  45368. }
  45369. }
  45370. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45371. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45372. v := m.addbot_type
  45373. if v == nil {
  45374. return
  45375. }
  45376. return *v, true
  45377. }
  45378. // ResetBotType resets all changes to the "bot_type" field.
  45379. func (m *WxCardVisitMutation) ResetBotType() {
  45380. m.bot_type = nil
  45381. m.addbot_type = nil
  45382. }
  45383. // Where appends a list predicates to the WxCardVisitMutation builder.
  45384. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45385. m.predicates = append(m.predicates, ps...)
  45386. }
  45387. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45388. // users can use type-assertion to append predicates that do not depend on any generated package.
  45389. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45390. p := make([]predicate.WxCardVisit, len(ps))
  45391. for i := range ps {
  45392. p[i] = ps[i]
  45393. }
  45394. m.Where(p...)
  45395. }
  45396. // Op returns the operation name.
  45397. func (m *WxCardVisitMutation) Op() Op {
  45398. return m.op
  45399. }
  45400. // SetOp allows setting the mutation operation.
  45401. func (m *WxCardVisitMutation) SetOp(op Op) {
  45402. m.op = op
  45403. }
  45404. // Type returns the node type of this mutation (WxCardVisit).
  45405. func (m *WxCardVisitMutation) Type() string {
  45406. return m.typ
  45407. }
  45408. // Fields returns all fields that were changed during this mutation. Note that in
  45409. // order to get all numeric fields that were incremented/decremented, call
  45410. // AddedFields().
  45411. func (m *WxCardVisitMutation) Fields() []string {
  45412. fields := make([]string, 0, 6)
  45413. if m.created_at != nil {
  45414. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45415. }
  45416. if m.updated_at != nil {
  45417. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45418. }
  45419. if m.deleted_at != nil {
  45420. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45421. }
  45422. if m.user_id != nil {
  45423. fields = append(fields, wxcardvisit.FieldUserID)
  45424. }
  45425. if m.bot_id != nil {
  45426. fields = append(fields, wxcardvisit.FieldBotID)
  45427. }
  45428. if m.bot_type != nil {
  45429. fields = append(fields, wxcardvisit.FieldBotType)
  45430. }
  45431. return fields
  45432. }
  45433. // Field returns the value of a field with the given name. The second boolean
  45434. // return value indicates that this field was not set, or was not defined in the
  45435. // schema.
  45436. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45437. switch name {
  45438. case wxcardvisit.FieldCreatedAt:
  45439. return m.CreatedAt()
  45440. case wxcardvisit.FieldUpdatedAt:
  45441. return m.UpdatedAt()
  45442. case wxcardvisit.FieldDeletedAt:
  45443. return m.DeletedAt()
  45444. case wxcardvisit.FieldUserID:
  45445. return m.UserID()
  45446. case wxcardvisit.FieldBotID:
  45447. return m.BotID()
  45448. case wxcardvisit.FieldBotType:
  45449. return m.BotType()
  45450. }
  45451. return nil, false
  45452. }
  45453. // OldField returns the old value of the field from the database. An error is
  45454. // returned if the mutation operation is not UpdateOne, or the query to the
  45455. // database failed.
  45456. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45457. switch name {
  45458. case wxcardvisit.FieldCreatedAt:
  45459. return m.OldCreatedAt(ctx)
  45460. case wxcardvisit.FieldUpdatedAt:
  45461. return m.OldUpdatedAt(ctx)
  45462. case wxcardvisit.FieldDeletedAt:
  45463. return m.OldDeletedAt(ctx)
  45464. case wxcardvisit.FieldUserID:
  45465. return m.OldUserID(ctx)
  45466. case wxcardvisit.FieldBotID:
  45467. return m.OldBotID(ctx)
  45468. case wxcardvisit.FieldBotType:
  45469. return m.OldBotType(ctx)
  45470. }
  45471. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45472. }
  45473. // SetField sets the value of a field with the given name. It returns an error if
  45474. // the field is not defined in the schema, or if the type mismatched the field
  45475. // type.
  45476. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45477. switch name {
  45478. case wxcardvisit.FieldCreatedAt:
  45479. v, ok := value.(time.Time)
  45480. if !ok {
  45481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45482. }
  45483. m.SetCreatedAt(v)
  45484. return nil
  45485. case wxcardvisit.FieldUpdatedAt:
  45486. v, ok := value.(time.Time)
  45487. if !ok {
  45488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45489. }
  45490. m.SetUpdatedAt(v)
  45491. return nil
  45492. case wxcardvisit.FieldDeletedAt:
  45493. v, ok := value.(time.Time)
  45494. if !ok {
  45495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45496. }
  45497. m.SetDeletedAt(v)
  45498. return nil
  45499. case wxcardvisit.FieldUserID:
  45500. v, ok := value.(uint64)
  45501. if !ok {
  45502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45503. }
  45504. m.SetUserID(v)
  45505. return nil
  45506. case wxcardvisit.FieldBotID:
  45507. v, ok := value.(uint64)
  45508. if !ok {
  45509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45510. }
  45511. m.SetBotID(v)
  45512. return nil
  45513. case wxcardvisit.FieldBotType:
  45514. v, ok := value.(uint8)
  45515. if !ok {
  45516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45517. }
  45518. m.SetBotType(v)
  45519. return nil
  45520. }
  45521. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45522. }
  45523. // AddedFields returns all numeric fields that were incremented/decremented during
  45524. // this mutation.
  45525. func (m *WxCardVisitMutation) AddedFields() []string {
  45526. var fields []string
  45527. if m.adduser_id != nil {
  45528. fields = append(fields, wxcardvisit.FieldUserID)
  45529. }
  45530. if m.addbot_id != nil {
  45531. fields = append(fields, wxcardvisit.FieldBotID)
  45532. }
  45533. if m.addbot_type != nil {
  45534. fields = append(fields, wxcardvisit.FieldBotType)
  45535. }
  45536. return fields
  45537. }
  45538. // AddedField returns the numeric value that was incremented/decremented on a field
  45539. // with the given name. The second boolean return value indicates that this field
  45540. // was not set, or was not defined in the schema.
  45541. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45542. switch name {
  45543. case wxcardvisit.FieldUserID:
  45544. return m.AddedUserID()
  45545. case wxcardvisit.FieldBotID:
  45546. return m.AddedBotID()
  45547. case wxcardvisit.FieldBotType:
  45548. return m.AddedBotType()
  45549. }
  45550. return nil, false
  45551. }
  45552. // AddField adds the value to the field with the given name. It returns an error if
  45553. // the field is not defined in the schema, or if the type mismatched the field
  45554. // type.
  45555. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45556. switch name {
  45557. case wxcardvisit.FieldUserID:
  45558. v, ok := value.(int64)
  45559. if !ok {
  45560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45561. }
  45562. m.AddUserID(v)
  45563. return nil
  45564. case wxcardvisit.FieldBotID:
  45565. v, ok := value.(int64)
  45566. if !ok {
  45567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45568. }
  45569. m.AddBotID(v)
  45570. return nil
  45571. case wxcardvisit.FieldBotType:
  45572. v, ok := value.(int8)
  45573. if !ok {
  45574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45575. }
  45576. m.AddBotType(v)
  45577. return nil
  45578. }
  45579. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45580. }
  45581. // ClearedFields returns all nullable fields that were cleared during this
  45582. // mutation.
  45583. func (m *WxCardVisitMutation) ClearedFields() []string {
  45584. var fields []string
  45585. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45586. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45587. }
  45588. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45589. fields = append(fields, wxcardvisit.FieldUserID)
  45590. }
  45591. return fields
  45592. }
  45593. // FieldCleared returns a boolean indicating if a field with the given name was
  45594. // cleared in this mutation.
  45595. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45596. _, ok := m.clearedFields[name]
  45597. return ok
  45598. }
  45599. // ClearField clears the value of the field with the given name. It returns an
  45600. // error if the field is not defined in the schema.
  45601. func (m *WxCardVisitMutation) ClearField(name string) error {
  45602. switch name {
  45603. case wxcardvisit.FieldDeletedAt:
  45604. m.ClearDeletedAt()
  45605. return nil
  45606. case wxcardvisit.FieldUserID:
  45607. m.ClearUserID()
  45608. return nil
  45609. }
  45610. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45611. }
  45612. // ResetField resets all changes in the mutation for the field with the given name.
  45613. // It returns an error if the field is not defined in the schema.
  45614. func (m *WxCardVisitMutation) ResetField(name string) error {
  45615. switch name {
  45616. case wxcardvisit.FieldCreatedAt:
  45617. m.ResetCreatedAt()
  45618. return nil
  45619. case wxcardvisit.FieldUpdatedAt:
  45620. m.ResetUpdatedAt()
  45621. return nil
  45622. case wxcardvisit.FieldDeletedAt:
  45623. m.ResetDeletedAt()
  45624. return nil
  45625. case wxcardvisit.FieldUserID:
  45626. m.ResetUserID()
  45627. return nil
  45628. case wxcardvisit.FieldBotID:
  45629. m.ResetBotID()
  45630. return nil
  45631. case wxcardvisit.FieldBotType:
  45632. m.ResetBotType()
  45633. return nil
  45634. }
  45635. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45636. }
  45637. // AddedEdges returns all edge names that were set/added in this mutation.
  45638. func (m *WxCardVisitMutation) AddedEdges() []string {
  45639. edges := make([]string, 0, 0)
  45640. return edges
  45641. }
  45642. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45643. // name in this mutation.
  45644. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  45645. return nil
  45646. }
  45647. // RemovedEdges returns all edge names that were removed in this mutation.
  45648. func (m *WxCardVisitMutation) RemovedEdges() []string {
  45649. edges := make([]string, 0, 0)
  45650. return edges
  45651. }
  45652. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45653. // the given name in this mutation.
  45654. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  45655. return nil
  45656. }
  45657. // ClearedEdges returns all edge names that were cleared in this mutation.
  45658. func (m *WxCardVisitMutation) ClearedEdges() []string {
  45659. edges := make([]string, 0, 0)
  45660. return edges
  45661. }
  45662. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45663. // was cleared in this mutation.
  45664. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  45665. return false
  45666. }
  45667. // ClearEdge clears the value of the edge with the given name. It returns an error
  45668. // if that edge is not defined in the schema.
  45669. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  45670. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  45671. }
  45672. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45673. // It returns an error if the edge is not defined in the schema.
  45674. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  45675. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  45676. }
  45677. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  45678. type XunjiMutation struct {
  45679. config
  45680. op Op
  45681. typ string
  45682. id *uint64
  45683. created_at *time.Time
  45684. updated_at *time.Time
  45685. status *uint8
  45686. addstatus *int8
  45687. deleted_at *time.Time
  45688. app_key *string
  45689. app_secret *string
  45690. token *string
  45691. encoding_key *string
  45692. agent_id *uint64
  45693. addagent_id *int64
  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. // ResetAppKey resets all changes to the "app_key" field.
  45993. func (m *XunjiMutation) ResetAppKey() {
  45994. m.app_key = nil
  45995. }
  45996. // SetAppSecret sets the "app_secret" field.
  45997. func (m *XunjiMutation) SetAppSecret(s string) {
  45998. m.app_secret = &s
  45999. }
  46000. // AppSecret returns the value of the "app_secret" field in the mutation.
  46001. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  46002. v := m.app_secret
  46003. if v == nil {
  46004. return
  46005. }
  46006. return *v, true
  46007. }
  46008. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  46009. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46011. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  46012. if !m.op.Is(OpUpdateOne) {
  46013. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  46014. }
  46015. if m.id == nil || m.oldValue == nil {
  46016. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  46017. }
  46018. oldValue, err := m.oldValue(ctx)
  46019. if err != nil {
  46020. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  46021. }
  46022. return oldValue.AppSecret, nil
  46023. }
  46024. // ResetAppSecret resets all changes to the "app_secret" field.
  46025. func (m *XunjiMutation) ResetAppSecret() {
  46026. m.app_secret = nil
  46027. }
  46028. // SetToken sets the "token" field.
  46029. func (m *XunjiMutation) SetToken(s string) {
  46030. m.token = &s
  46031. }
  46032. // Token returns the value of the "token" field in the mutation.
  46033. func (m *XunjiMutation) Token() (r string, exists bool) {
  46034. v := m.token
  46035. if v == nil {
  46036. return
  46037. }
  46038. return *v, true
  46039. }
  46040. // OldToken returns the old "token" field's value of the Xunji entity.
  46041. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46043. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  46044. if !m.op.Is(OpUpdateOne) {
  46045. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  46046. }
  46047. if m.id == nil || m.oldValue == nil {
  46048. return v, errors.New("OldToken requires an ID field in the mutation")
  46049. }
  46050. oldValue, err := m.oldValue(ctx)
  46051. if err != nil {
  46052. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  46053. }
  46054. return oldValue.Token, nil
  46055. }
  46056. // ResetToken resets all changes to the "token" field.
  46057. func (m *XunjiMutation) ResetToken() {
  46058. m.token = nil
  46059. }
  46060. // SetEncodingKey sets the "encoding_key" field.
  46061. func (m *XunjiMutation) SetEncodingKey(s string) {
  46062. m.encoding_key = &s
  46063. }
  46064. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  46065. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  46066. v := m.encoding_key
  46067. if v == nil {
  46068. return
  46069. }
  46070. return *v, true
  46071. }
  46072. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  46073. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46075. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  46076. if !m.op.Is(OpUpdateOne) {
  46077. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  46078. }
  46079. if m.id == nil || m.oldValue == nil {
  46080. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  46081. }
  46082. oldValue, err := m.oldValue(ctx)
  46083. if err != nil {
  46084. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  46085. }
  46086. return oldValue.EncodingKey, nil
  46087. }
  46088. // ResetEncodingKey resets all changes to the "encoding_key" field.
  46089. func (m *XunjiMutation) ResetEncodingKey() {
  46090. m.encoding_key = nil
  46091. }
  46092. // SetAgentID sets the "agent_id" field.
  46093. func (m *XunjiMutation) SetAgentID(u uint64) {
  46094. m.agent_id = &u
  46095. m.addagent_id = nil
  46096. }
  46097. // AgentID returns the value of the "agent_id" field in the mutation.
  46098. func (m *XunjiMutation) AgentID() (r uint64, exists bool) {
  46099. v := m.agent_id
  46100. if v == nil {
  46101. return
  46102. }
  46103. return *v, true
  46104. }
  46105. // OldAgentID returns the old "agent_id" 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) OldAgentID(ctx context.Context) (v uint64, err error) {
  46109. if !m.op.Is(OpUpdateOne) {
  46110. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46111. }
  46112. if m.id == nil || m.oldValue == nil {
  46113. return v, errors.New("OldAgentID 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 OldAgentID: %w", err)
  46118. }
  46119. return oldValue.AgentID, nil
  46120. }
  46121. // AddAgentID adds u to the "agent_id" field.
  46122. func (m *XunjiMutation) AddAgentID(u int64) {
  46123. if m.addagent_id != nil {
  46124. *m.addagent_id += u
  46125. } else {
  46126. m.addagent_id = &u
  46127. }
  46128. }
  46129. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  46130. func (m *XunjiMutation) AddedAgentID() (r int64, exists bool) {
  46131. v := m.addagent_id
  46132. if v == nil {
  46133. return
  46134. }
  46135. return *v, true
  46136. }
  46137. // ResetAgentID resets all changes to the "agent_id" field.
  46138. func (m *XunjiMutation) ResetAgentID() {
  46139. m.agent_id = nil
  46140. m.addagent_id = nil
  46141. }
  46142. // SetOrganizationID sets the "organization_id" field.
  46143. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  46144. m.organization_id = &u
  46145. m.addorganization_id = nil
  46146. }
  46147. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46148. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  46149. v := m.organization_id
  46150. if v == nil {
  46151. return
  46152. }
  46153. return *v, true
  46154. }
  46155. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  46156. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46158. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46159. if !m.op.Is(OpUpdateOne) {
  46160. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46161. }
  46162. if m.id == nil || m.oldValue == nil {
  46163. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46164. }
  46165. oldValue, err := m.oldValue(ctx)
  46166. if err != nil {
  46167. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46168. }
  46169. return oldValue.OrganizationID, nil
  46170. }
  46171. // AddOrganizationID adds u to the "organization_id" field.
  46172. func (m *XunjiMutation) AddOrganizationID(u int64) {
  46173. if m.addorganization_id != nil {
  46174. *m.addorganization_id += u
  46175. } else {
  46176. m.addorganization_id = &u
  46177. }
  46178. }
  46179. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46180. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  46181. v := m.addorganization_id
  46182. if v == nil {
  46183. return
  46184. }
  46185. return *v, true
  46186. }
  46187. // ResetOrganizationID resets all changes to the "organization_id" field.
  46188. func (m *XunjiMutation) ResetOrganizationID() {
  46189. m.organization_id = nil
  46190. m.addorganization_id = nil
  46191. }
  46192. // Where appends a list predicates to the XunjiMutation builder.
  46193. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  46194. m.predicates = append(m.predicates, ps...)
  46195. }
  46196. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  46197. // users can use type-assertion to append predicates that do not depend on any generated package.
  46198. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  46199. p := make([]predicate.Xunji, len(ps))
  46200. for i := range ps {
  46201. p[i] = ps[i]
  46202. }
  46203. m.Where(p...)
  46204. }
  46205. // Op returns the operation name.
  46206. func (m *XunjiMutation) Op() Op {
  46207. return m.op
  46208. }
  46209. // SetOp allows setting the mutation operation.
  46210. func (m *XunjiMutation) SetOp(op Op) {
  46211. m.op = op
  46212. }
  46213. // Type returns the node type of this mutation (Xunji).
  46214. func (m *XunjiMutation) Type() string {
  46215. return m.typ
  46216. }
  46217. // Fields returns all fields that were changed during this mutation. Note that in
  46218. // order to get all numeric fields that were incremented/decremented, call
  46219. // AddedFields().
  46220. func (m *XunjiMutation) Fields() []string {
  46221. fields := make([]string, 0, 10)
  46222. if m.created_at != nil {
  46223. fields = append(fields, xunji.FieldCreatedAt)
  46224. }
  46225. if m.updated_at != nil {
  46226. fields = append(fields, xunji.FieldUpdatedAt)
  46227. }
  46228. if m.status != nil {
  46229. fields = append(fields, xunji.FieldStatus)
  46230. }
  46231. if m.deleted_at != nil {
  46232. fields = append(fields, xunji.FieldDeletedAt)
  46233. }
  46234. if m.app_key != nil {
  46235. fields = append(fields, xunji.FieldAppKey)
  46236. }
  46237. if m.app_secret != nil {
  46238. fields = append(fields, xunji.FieldAppSecret)
  46239. }
  46240. if m.token != nil {
  46241. fields = append(fields, xunji.FieldToken)
  46242. }
  46243. if m.encoding_key != nil {
  46244. fields = append(fields, xunji.FieldEncodingKey)
  46245. }
  46246. if m.agent_id != nil {
  46247. fields = append(fields, xunji.FieldAgentID)
  46248. }
  46249. if m.organization_id != nil {
  46250. fields = append(fields, xunji.FieldOrganizationID)
  46251. }
  46252. return fields
  46253. }
  46254. // Field returns the value of a field with the given name. The second boolean
  46255. // return value indicates that this field was not set, or was not defined in the
  46256. // schema.
  46257. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  46258. switch name {
  46259. case xunji.FieldCreatedAt:
  46260. return m.CreatedAt()
  46261. case xunji.FieldUpdatedAt:
  46262. return m.UpdatedAt()
  46263. case xunji.FieldStatus:
  46264. return m.Status()
  46265. case xunji.FieldDeletedAt:
  46266. return m.DeletedAt()
  46267. case xunji.FieldAppKey:
  46268. return m.AppKey()
  46269. case xunji.FieldAppSecret:
  46270. return m.AppSecret()
  46271. case xunji.FieldToken:
  46272. return m.Token()
  46273. case xunji.FieldEncodingKey:
  46274. return m.EncodingKey()
  46275. case xunji.FieldAgentID:
  46276. return m.AgentID()
  46277. case xunji.FieldOrganizationID:
  46278. return m.OrganizationID()
  46279. }
  46280. return nil, false
  46281. }
  46282. // OldField returns the old value of the field from the database. An error is
  46283. // returned if the mutation operation is not UpdateOne, or the query to the
  46284. // database failed.
  46285. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46286. switch name {
  46287. case xunji.FieldCreatedAt:
  46288. return m.OldCreatedAt(ctx)
  46289. case xunji.FieldUpdatedAt:
  46290. return m.OldUpdatedAt(ctx)
  46291. case xunji.FieldStatus:
  46292. return m.OldStatus(ctx)
  46293. case xunji.FieldDeletedAt:
  46294. return m.OldDeletedAt(ctx)
  46295. case xunji.FieldAppKey:
  46296. return m.OldAppKey(ctx)
  46297. case xunji.FieldAppSecret:
  46298. return m.OldAppSecret(ctx)
  46299. case xunji.FieldToken:
  46300. return m.OldToken(ctx)
  46301. case xunji.FieldEncodingKey:
  46302. return m.OldEncodingKey(ctx)
  46303. case xunji.FieldAgentID:
  46304. return m.OldAgentID(ctx)
  46305. case xunji.FieldOrganizationID:
  46306. return m.OldOrganizationID(ctx)
  46307. }
  46308. return nil, fmt.Errorf("unknown Xunji field %s", name)
  46309. }
  46310. // SetField sets the value of a field with the given name. It returns an error if
  46311. // the field is not defined in the schema, or if the type mismatched the field
  46312. // type.
  46313. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  46314. switch name {
  46315. case xunji.FieldCreatedAt:
  46316. v, ok := value.(time.Time)
  46317. if !ok {
  46318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46319. }
  46320. m.SetCreatedAt(v)
  46321. return nil
  46322. case xunji.FieldUpdatedAt:
  46323. v, ok := value.(time.Time)
  46324. if !ok {
  46325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46326. }
  46327. m.SetUpdatedAt(v)
  46328. return nil
  46329. case xunji.FieldStatus:
  46330. v, ok := value.(uint8)
  46331. if !ok {
  46332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46333. }
  46334. m.SetStatus(v)
  46335. return nil
  46336. case xunji.FieldDeletedAt:
  46337. v, ok := value.(time.Time)
  46338. if !ok {
  46339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46340. }
  46341. m.SetDeletedAt(v)
  46342. return nil
  46343. case xunji.FieldAppKey:
  46344. v, ok := value.(string)
  46345. if !ok {
  46346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46347. }
  46348. m.SetAppKey(v)
  46349. return nil
  46350. case xunji.FieldAppSecret:
  46351. v, ok := value.(string)
  46352. if !ok {
  46353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46354. }
  46355. m.SetAppSecret(v)
  46356. return nil
  46357. case xunji.FieldToken:
  46358. v, ok := value.(string)
  46359. if !ok {
  46360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46361. }
  46362. m.SetToken(v)
  46363. return nil
  46364. case xunji.FieldEncodingKey:
  46365. v, ok := value.(string)
  46366. if !ok {
  46367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46368. }
  46369. m.SetEncodingKey(v)
  46370. return nil
  46371. case xunji.FieldAgentID:
  46372. v, ok := value.(uint64)
  46373. if !ok {
  46374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46375. }
  46376. m.SetAgentID(v)
  46377. return nil
  46378. case xunji.FieldOrganizationID:
  46379. v, ok := value.(uint64)
  46380. if !ok {
  46381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46382. }
  46383. m.SetOrganizationID(v)
  46384. return nil
  46385. }
  46386. return fmt.Errorf("unknown Xunji field %s", name)
  46387. }
  46388. // AddedFields returns all numeric fields that were incremented/decremented during
  46389. // this mutation.
  46390. func (m *XunjiMutation) AddedFields() []string {
  46391. var fields []string
  46392. if m.addstatus != nil {
  46393. fields = append(fields, xunji.FieldStatus)
  46394. }
  46395. if m.addagent_id != nil {
  46396. fields = append(fields, xunji.FieldAgentID)
  46397. }
  46398. if m.addorganization_id != nil {
  46399. fields = append(fields, xunji.FieldOrganizationID)
  46400. }
  46401. return fields
  46402. }
  46403. // AddedField returns the numeric value that was incremented/decremented on a field
  46404. // with the given name. The second boolean return value indicates that this field
  46405. // was not set, or was not defined in the schema.
  46406. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  46407. switch name {
  46408. case xunji.FieldStatus:
  46409. return m.AddedStatus()
  46410. case xunji.FieldAgentID:
  46411. return m.AddedAgentID()
  46412. case xunji.FieldOrganizationID:
  46413. return m.AddedOrganizationID()
  46414. }
  46415. return nil, false
  46416. }
  46417. // AddField adds the value to the field with the given name. It returns an error if
  46418. // the field is not defined in the schema, or if the type mismatched the field
  46419. // type.
  46420. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  46421. switch name {
  46422. case xunji.FieldStatus:
  46423. v, ok := value.(int8)
  46424. if !ok {
  46425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46426. }
  46427. m.AddStatus(v)
  46428. return nil
  46429. case xunji.FieldAgentID:
  46430. v, ok := value.(int64)
  46431. if !ok {
  46432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46433. }
  46434. m.AddAgentID(v)
  46435. return nil
  46436. case xunji.FieldOrganizationID:
  46437. v, ok := value.(int64)
  46438. if !ok {
  46439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46440. }
  46441. m.AddOrganizationID(v)
  46442. return nil
  46443. }
  46444. return fmt.Errorf("unknown Xunji numeric field %s", name)
  46445. }
  46446. // ClearedFields returns all nullable fields that were cleared during this
  46447. // mutation.
  46448. func (m *XunjiMutation) ClearedFields() []string {
  46449. var fields []string
  46450. if m.FieldCleared(xunji.FieldStatus) {
  46451. fields = append(fields, xunji.FieldStatus)
  46452. }
  46453. if m.FieldCleared(xunji.FieldDeletedAt) {
  46454. fields = append(fields, xunji.FieldDeletedAt)
  46455. }
  46456. return fields
  46457. }
  46458. // FieldCleared returns a boolean indicating if a field with the given name was
  46459. // cleared in this mutation.
  46460. func (m *XunjiMutation) FieldCleared(name string) bool {
  46461. _, ok := m.clearedFields[name]
  46462. return ok
  46463. }
  46464. // ClearField clears the value of the field with the given name. It returns an
  46465. // error if the field is not defined in the schema.
  46466. func (m *XunjiMutation) ClearField(name string) error {
  46467. switch name {
  46468. case xunji.FieldStatus:
  46469. m.ClearStatus()
  46470. return nil
  46471. case xunji.FieldDeletedAt:
  46472. m.ClearDeletedAt()
  46473. return nil
  46474. }
  46475. return fmt.Errorf("unknown Xunji nullable field %s", name)
  46476. }
  46477. // ResetField resets all changes in the mutation for the field with the given name.
  46478. // It returns an error if the field is not defined in the schema.
  46479. func (m *XunjiMutation) ResetField(name string) error {
  46480. switch name {
  46481. case xunji.FieldCreatedAt:
  46482. m.ResetCreatedAt()
  46483. return nil
  46484. case xunji.FieldUpdatedAt:
  46485. m.ResetUpdatedAt()
  46486. return nil
  46487. case xunji.FieldStatus:
  46488. m.ResetStatus()
  46489. return nil
  46490. case xunji.FieldDeletedAt:
  46491. m.ResetDeletedAt()
  46492. return nil
  46493. case xunji.FieldAppKey:
  46494. m.ResetAppKey()
  46495. return nil
  46496. case xunji.FieldAppSecret:
  46497. m.ResetAppSecret()
  46498. return nil
  46499. case xunji.FieldToken:
  46500. m.ResetToken()
  46501. return nil
  46502. case xunji.FieldEncodingKey:
  46503. m.ResetEncodingKey()
  46504. return nil
  46505. case xunji.FieldAgentID:
  46506. m.ResetAgentID()
  46507. return nil
  46508. case xunji.FieldOrganizationID:
  46509. m.ResetOrganizationID()
  46510. return nil
  46511. }
  46512. return fmt.Errorf("unknown Xunji field %s", name)
  46513. }
  46514. // AddedEdges returns all edge names that were set/added in this mutation.
  46515. func (m *XunjiMutation) AddedEdges() []string {
  46516. edges := make([]string, 0, 0)
  46517. return edges
  46518. }
  46519. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46520. // name in this mutation.
  46521. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  46522. return nil
  46523. }
  46524. // RemovedEdges returns all edge names that were removed in this mutation.
  46525. func (m *XunjiMutation) RemovedEdges() []string {
  46526. edges := make([]string, 0, 0)
  46527. return edges
  46528. }
  46529. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46530. // the given name in this mutation.
  46531. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  46532. return nil
  46533. }
  46534. // ClearedEdges returns all edge names that were cleared in this mutation.
  46535. func (m *XunjiMutation) ClearedEdges() []string {
  46536. edges := make([]string, 0, 0)
  46537. return edges
  46538. }
  46539. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46540. // was cleared in this mutation.
  46541. func (m *XunjiMutation) EdgeCleared(name string) bool {
  46542. return false
  46543. }
  46544. // ClearEdge clears the value of the edge with the given name. It returns an error
  46545. // if that edge is not defined in the schema.
  46546. func (m *XunjiMutation) ClearEdge(name string) error {
  46547. return fmt.Errorf("unknown Xunji unique edge %s", name)
  46548. }
  46549. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46550. // It returns an error if the edge is not defined in the schema.
  46551. func (m *XunjiMutation) ResetEdge(name string) error {
  46552. return fmt.Errorf("unknown Xunji edge %s", name)
  46553. }
  46554. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  46555. type XunjiServiceMutation struct {
  46556. config
  46557. op Op
  46558. typ string
  46559. id *uint64
  46560. created_at *time.Time
  46561. updated_at *time.Time
  46562. status *uint8
  46563. addstatus *int8
  46564. deleted_at *time.Time
  46565. xunji_id *uint64
  46566. addxunji_id *int64
  46567. organization_id *uint64
  46568. addorganization_id *int64
  46569. wxid *string
  46570. api_base *string
  46571. api_key *string
  46572. clearedFields map[string]struct{}
  46573. agent *uint64
  46574. clearedagent bool
  46575. done bool
  46576. oldValue func(context.Context) (*XunjiService, error)
  46577. predicates []predicate.XunjiService
  46578. }
  46579. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  46580. // xunjiserviceOption allows management of the mutation configuration using functional options.
  46581. type xunjiserviceOption func(*XunjiServiceMutation)
  46582. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  46583. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  46584. m := &XunjiServiceMutation{
  46585. config: c,
  46586. op: op,
  46587. typ: TypeXunjiService,
  46588. clearedFields: make(map[string]struct{}),
  46589. }
  46590. for _, opt := range opts {
  46591. opt(m)
  46592. }
  46593. return m
  46594. }
  46595. // withXunjiServiceID sets the ID field of the mutation.
  46596. func withXunjiServiceID(id uint64) xunjiserviceOption {
  46597. return func(m *XunjiServiceMutation) {
  46598. var (
  46599. err error
  46600. once sync.Once
  46601. value *XunjiService
  46602. )
  46603. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  46604. once.Do(func() {
  46605. if m.done {
  46606. err = errors.New("querying old values post mutation is not allowed")
  46607. } else {
  46608. value, err = m.Client().XunjiService.Get(ctx, id)
  46609. }
  46610. })
  46611. return value, err
  46612. }
  46613. m.id = &id
  46614. }
  46615. }
  46616. // withXunjiService sets the old XunjiService of the mutation.
  46617. func withXunjiService(node *XunjiService) xunjiserviceOption {
  46618. return func(m *XunjiServiceMutation) {
  46619. m.oldValue = func(context.Context) (*XunjiService, error) {
  46620. return node, nil
  46621. }
  46622. m.id = &node.ID
  46623. }
  46624. }
  46625. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46626. // executed in a transaction (ent.Tx), a transactional client is returned.
  46627. func (m XunjiServiceMutation) Client() *Client {
  46628. client := &Client{config: m.config}
  46629. client.init()
  46630. return client
  46631. }
  46632. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46633. // it returns an error otherwise.
  46634. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  46635. if _, ok := m.driver.(*txDriver); !ok {
  46636. return nil, errors.New("ent: mutation is not running in a transaction")
  46637. }
  46638. tx := &Tx{config: m.config}
  46639. tx.init()
  46640. return tx, nil
  46641. }
  46642. // SetID sets the value of the id field. Note that this
  46643. // operation is only accepted on creation of XunjiService entities.
  46644. func (m *XunjiServiceMutation) SetID(id uint64) {
  46645. m.id = &id
  46646. }
  46647. // ID returns the ID value in the mutation. Note that the ID is only available
  46648. // if it was provided to the builder or after it was returned from the database.
  46649. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  46650. if m.id == nil {
  46651. return
  46652. }
  46653. return *m.id, true
  46654. }
  46655. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46656. // That means, if the mutation is applied within a transaction with an isolation level such
  46657. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46658. // or updated by the mutation.
  46659. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  46660. switch {
  46661. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46662. id, exists := m.ID()
  46663. if exists {
  46664. return []uint64{id}, nil
  46665. }
  46666. fallthrough
  46667. case m.op.Is(OpUpdate | OpDelete):
  46668. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  46669. default:
  46670. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46671. }
  46672. }
  46673. // SetCreatedAt sets the "created_at" field.
  46674. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  46675. m.created_at = &t
  46676. }
  46677. // CreatedAt returns the value of the "created_at" field in the mutation.
  46678. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  46679. v := m.created_at
  46680. if v == nil {
  46681. return
  46682. }
  46683. return *v, true
  46684. }
  46685. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  46686. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46688. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46689. if !m.op.Is(OpUpdateOne) {
  46690. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46691. }
  46692. if m.id == nil || m.oldValue == nil {
  46693. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46694. }
  46695. oldValue, err := m.oldValue(ctx)
  46696. if err != nil {
  46697. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46698. }
  46699. return oldValue.CreatedAt, nil
  46700. }
  46701. // ResetCreatedAt resets all changes to the "created_at" field.
  46702. func (m *XunjiServiceMutation) ResetCreatedAt() {
  46703. m.created_at = nil
  46704. }
  46705. // SetUpdatedAt sets the "updated_at" field.
  46706. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  46707. m.updated_at = &t
  46708. }
  46709. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46710. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  46711. v := m.updated_at
  46712. if v == nil {
  46713. return
  46714. }
  46715. return *v, true
  46716. }
  46717. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  46718. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46720. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46721. if !m.op.Is(OpUpdateOne) {
  46722. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46723. }
  46724. if m.id == nil || m.oldValue == nil {
  46725. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46726. }
  46727. oldValue, err := m.oldValue(ctx)
  46728. if err != nil {
  46729. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46730. }
  46731. return oldValue.UpdatedAt, nil
  46732. }
  46733. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46734. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  46735. m.updated_at = nil
  46736. }
  46737. // SetStatus sets the "status" field.
  46738. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  46739. m.status = &u
  46740. m.addstatus = nil
  46741. }
  46742. // Status returns the value of the "status" field in the mutation.
  46743. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  46744. v := m.status
  46745. if v == nil {
  46746. return
  46747. }
  46748. return *v, true
  46749. }
  46750. // OldStatus returns the old "status" field's value of the XunjiService entity.
  46751. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46753. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46754. if !m.op.Is(OpUpdateOne) {
  46755. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46756. }
  46757. if m.id == nil || m.oldValue == nil {
  46758. return v, errors.New("OldStatus requires an ID field in the mutation")
  46759. }
  46760. oldValue, err := m.oldValue(ctx)
  46761. if err != nil {
  46762. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46763. }
  46764. return oldValue.Status, nil
  46765. }
  46766. // AddStatus adds u to the "status" field.
  46767. func (m *XunjiServiceMutation) AddStatus(u int8) {
  46768. if m.addstatus != nil {
  46769. *m.addstatus += u
  46770. } else {
  46771. m.addstatus = &u
  46772. }
  46773. }
  46774. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46775. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  46776. v := m.addstatus
  46777. if v == nil {
  46778. return
  46779. }
  46780. return *v, true
  46781. }
  46782. // ClearStatus clears the value of the "status" field.
  46783. func (m *XunjiServiceMutation) ClearStatus() {
  46784. m.status = nil
  46785. m.addstatus = nil
  46786. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  46787. }
  46788. // StatusCleared returns if the "status" field was cleared in this mutation.
  46789. func (m *XunjiServiceMutation) StatusCleared() bool {
  46790. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  46791. return ok
  46792. }
  46793. // ResetStatus resets all changes to the "status" field.
  46794. func (m *XunjiServiceMutation) ResetStatus() {
  46795. m.status = nil
  46796. m.addstatus = nil
  46797. delete(m.clearedFields, xunjiservice.FieldStatus)
  46798. }
  46799. // SetDeletedAt sets the "deleted_at" field.
  46800. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  46801. m.deleted_at = &t
  46802. }
  46803. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46804. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  46805. v := m.deleted_at
  46806. if v == nil {
  46807. return
  46808. }
  46809. return *v, true
  46810. }
  46811. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  46812. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46814. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46815. if !m.op.Is(OpUpdateOne) {
  46816. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46817. }
  46818. if m.id == nil || m.oldValue == nil {
  46819. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46820. }
  46821. oldValue, err := m.oldValue(ctx)
  46822. if err != nil {
  46823. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46824. }
  46825. return oldValue.DeletedAt, nil
  46826. }
  46827. // ClearDeletedAt clears the value of the "deleted_at" field.
  46828. func (m *XunjiServiceMutation) ClearDeletedAt() {
  46829. m.deleted_at = nil
  46830. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  46831. }
  46832. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46833. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  46834. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  46835. return ok
  46836. }
  46837. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46838. func (m *XunjiServiceMutation) ResetDeletedAt() {
  46839. m.deleted_at = nil
  46840. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  46841. }
  46842. // SetXunjiID sets the "xunji_id" field.
  46843. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  46844. m.xunji_id = &u
  46845. m.addxunji_id = nil
  46846. }
  46847. // XunjiID returns the value of the "xunji_id" field in the mutation.
  46848. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  46849. v := m.xunji_id
  46850. if v == nil {
  46851. return
  46852. }
  46853. return *v, true
  46854. }
  46855. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  46856. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46858. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  46859. if !m.op.Is(OpUpdateOne) {
  46860. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  46861. }
  46862. if m.id == nil || m.oldValue == nil {
  46863. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  46864. }
  46865. oldValue, err := m.oldValue(ctx)
  46866. if err != nil {
  46867. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  46868. }
  46869. return oldValue.XunjiID, nil
  46870. }
  46871. // AddXunjiID adds u to the "xunji_id" field.
  46872. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  46873. if m.addxunji_id != nil {
  46874. *m.addxunji_id += u
  46875. } else {
  46876. m.addxunji_id = &u
  46877. }
  46878. }
  46879. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  46880. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  46881. v := m.addxunji_id
  46882. if v == nil {
  46883. return
  46884. }
  46885. return *v, true
  46886. }
  46887. // ResetXunjiID resets all changes to the "xunji_id" field.
  46888. func (m *XunjiServiceMutation) ResetXunjiID() {
  46889. m.xunji_id = nil
  46890. m.addxunji_id = nil
  46891. }
  46892. // SetAgentID sets the "agent_id" field.
  46893. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  46894. m.agent = &u
  46895. }
  46896. // AgentID returns the value of the "agent_id" field in the mutation.
  46897. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  46898. v := m.agent
  46899. if v == nil {
  46900. return
  46901. }
  46902. return *v, true
  46903. }
  46904. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  46905. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46907. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46908. if !m.op.Is(OpUpdateOne) {
  46909. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46910. }
  46911. if m.id == nil || m.oldValue == nil {
  46912. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46913. }
  46914. oldValue, err := m.oldValue(ctx)
  46915. if err != nil {
  46916. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46917. }
  46918. return oldValue.AgentID, nil
  46919. }
  46920. // ResetAgentID resets all changes to the "agent_id" field.
  46921. func (m *XunjiServiceMutation) ResetAgentID() {
  46922. m.agent = nil
  46923. }
  46924. // SetOrganizationID sets the "organization_id" field.
  46925. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  46926. m.organization_id = &u
  46927. m.addorganization_id = nil
  46928. }
  46929. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46930. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  46931. v := m.organization_id
  46932. if v == nil {
  46933. return
  46934. }
  46935. return *v, true
  46936. }
  46937. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  46938. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46940. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46941. if !m.op.Is(OpUpdateOne) {
  46942. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46943. }
  46944. if m.id == nil || m.oldValue == nil {
  46945. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46946. }
  46947. oldValue, err := m.oldValue(ctx)
  46948. if err != nil {
  46949. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46950. }
  46951. return oldValue.OrganizationID, nil
  46952. }
  46953. // AddOrganizationID adds u to the "organization_id" field.
  46954. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  46955. if m.addorganization_id != nil {
  46956. *m.addorganization_id += u
  46957. } else {
  46958. m.addorganization_id = &u
  46959. }
  46960. }
  46961. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46962. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  46963. v := m.addorganization_id
  46964. if v == nil {
  46965. return
  46966. }
  46967. return *v, true
  46968. }
  46969. // ResetOrganizationID resets all changes to the "organization_id" field.
  46970. func (m *XunjiServiceMutation) ResetOrganizationID() {
  46971. m.organization_id = nil
  46972. m.addorganization_id = nil
  46973. }
  46974. // SetWxid sets the "wxid" field.
  46975. func (m *XunjiServiceMutation) SetWxid(s string) {
  46976. m.wxid = &s
  46977. }
  46978. // Wxid returns the value of the "wxid" field in the mutation.
  46979. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  46980. v := m.wxid
  46981. if v == nil {
  46982. return
  46983. }
  46984. return *v, true
  46985. }
  46986. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  46987. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46989. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  46990. if !m.op.Is(OpUpdateOne) {
  46991. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46992. }
  46993. if m.id == nil || m.oldValue == nil {
  46994. return v, errors.New("OldWxid requires an ID field in the mutation")
  46995. }
  46996. oldValue, err := m.oldValue(ctx)
  46997. if err != nil {
  46998. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46999. }
  47000. return oldValue.Wxid, nil
  47001. }
  47002. // ResetWxid resets all changes to the "wxid" field.
  47003. func (m *XunjiServiceMutation) ResetWxid() {
  47004. m.wxid = nil
  47005. }
  47006. // SetAPIBase sets the "api_base" field.
  47007. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  47008. m.api_base = &s
  47009. }
  47010. // APIBase returns the value of the "api_base" field in the mutation.
  47011. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  47012. v := m.api_base
  47013. if v == nil {
  47014. return
  47015. }
  47016. return *v, true
  47017. }
  47018. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  47019. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47021. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47022. if !m.op.Is(OpUpdateOne) {
  47023. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47024. }
  47025. if m.id == nil || m.oldValue == nil {
  47026. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47027. }
  47028. oldValue, err := m.oldValue(ctx)
  47029. if err != nil {
  47030. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47031. }
  47032. return oldValue.APIBase, nil
  47033. }
  47034. // ClearAPIBase clears the value of the "api_base" field.
  47035. func (m *XunjiServiceMutation) ClearAPIBase() {
  47036. m.api_base = nil
  47037. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  47038. }
  47039. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47040. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  47041. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  47042. return ok
  47043. }
  47044. // ResetAPIBase resets all changes to the "api_base" field.
  47045. func (m *XunjiServiceMutation) ResetAPIBase() {
  47046. m.api_base = nil
  47047. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  47048. }
  47049. // SetAPIKey sets the "api_key" field.
  47050. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  47051. m.api_key = &s
  47052. }
  47053. // APIKey returns the value of the "api_key" field in the mutation.
  47054. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  47055. v := m.api_key
  47056. if v == nil {
  47057. return
  47058. }
  47059. return *v, true
  47060. }
  47061. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  47062. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47064. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47065. if !m.op.Is(OpUpdateOne) {
  47066. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47067. }
  47068. if m.id == nil || m.oldValue == nil {
  47069. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47070. }
  47071. oldValue, err := m.oldValue(ctx)
  47072. if err != nil {
  47073. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47074. }
  47075. return oldValue.APIKey, nil
  47076. }
  47077. // ClearAPIKey clears the value of the "api_key" field.
  47078. func (m *XunjiServiceMutation) ClearAPIKey() {
  47079. m.api_key = nil
  47080. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  47081. }
  47082. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47083. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  47084. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  47085. return ok
  47086. }
  47087. // ResetAPIKey resets all changes to the "api_key" field.
  47088. func (m *XunjiServiceMutation) ResetAPIKey() {
  47089. m.api_key = nil
  47090. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  47091. }
  47092. // ClearAgent clears the "agent" edge to the Agent entity.
  47093. func (m *XunjiServiceMutation) ClearAgent() {
  47094. m.clearedagent = true
  47095. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  47096. }
  47097. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47098. func (m *XunjiServiceMutation) AgentCleared() bool {
  47099. return m.clearedagent
  47100. }
  47101. // AgentIDs returns the "agent" edge IDs in the mutation.
  47102. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47103. // AgentID instead. It exists only for internal usage by the builders.
  47104. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  47105. if id := m.agent; id != nil {
  47106. ids = append(ids, *id)
  47107. }
  47108. return
  47109. }
  47110. // ResetAgent resets all changes to the "agent" edge.
  47111. func (m *XunjiServiceMutation) ResetAgent() {
  47112. m.agent = nil
  47113. m.clearedagent = false
  47114. }
  47115. // Where appends a list predicates to the XunjiServiceMutation builder.
  47116. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  47117. m.predicates = append(m.predicates, ps...)
  47118. }
  47119. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  47120. // users can use type-assertion to append predicates that do not depend on any generated package.
  47121. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  47122. p := make([]predicate.XunjiService, len(ps))
  47123. for i := range ps {
  47124. p[i] = ps[i]
  47125. }
  47126. m.Where(p...)
  47127. }
  47128. // Op returns the operation name.
  47129. func (m *XunjiServiceMutation) Op() Op {
  47130. return m.op
  47131. }
  47132. // SetOp allows setting the mutation operation.
  47133. func (m *XunjiServiceMutation) SetOp(op Op) {
  47134. m.op = op
  47135. }
  47136. // Type returns the node type of this mutation (XunjiService).
  47137. func (m *XunjiServiceMutation) Type() string {
  47138. return m.typ
  47139. }
  47140. // Fields returns all fields that were changed during this mutation. Note that in
  47141. // order to get all numeric fields that were incremented/decremented, call
  47142. // AddedFields().
  47143. func (m *XunjiServiceMutation) Fields() []string {
  47144. fields := make([]string, 0, 10)
  47145. if m.created_at != nil {
  47146. fields = append(fields, xunjiservice.FieldCreatedAt)
  47147. }
  47148. if m.updated_at != nil {
  47149. fields = append(fields, xunjiservice.FieldUpdatedAt)
  47150. }
  47151. if m.status != nil {
  47152. fields = append(fields, xunjiservice.FieldStatus)
  47153. }
  47154. if m.deleted_at != nil {
  47155. fields = append(fields, xunjiservice.FieldDeletedAt)
  47156. }
  47157. if m.xunji_id != nil {
  47158. fields = append(fields, xunjiservice.FieldXunjiID)
  47159. }
  47160. if m.agent != nil {
  47161. fields = append(fields, xunjiservice.FieldAgentID)
  47162. }
  47163. if m.organization_id != nil {
  47164. fields = append(fields, xunjiservice.FieldOrganizationID)
  47165. }
  47166. if m.wxid != nil {
  47167. fields = append(fields, xunjiservice.FieldWxid)
  47168. }
  47169. if m.api_base != nil {
  47170. fields = append(fields, xunjiservice.FieldAPIBase)
  47171. }
  47172. if m.api_key != nil {
  47173. fields = append(fields, xunjiservice.FieldAPIKey)
  47174. }
  47175. return fields
  47176. }
  47177. // Field returns the value of a field with the given name. The second boolean
  47178. // return value indicates that this field was not set, or was not defined in the
  47179. // schema.
  47180. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  47181. switch name {
  47182. case xunjiservice.FieldCreatedAt:
  47183. return m.CreatedAt()
  47184. case xunjiservice.FieldUpdatedAt:
  47185. return m.UpdatedAt()
  47186. case xunjiservice.FieldStatus:
  47187. return m.Status()
  47188. case xunjiservice.FieldDeletedAt:
  47189. return m.DeletedAt()
  47190. case xunjiservice.FieldXunjiID:
  47191. return m.XunjiID()
  47192. case xunjiservice.FieldAgentID:
  47193. return m.AgentID()
  47194. case xunjiservice.FieldOrganizationID:
  47195. return m.OrganizationID()
  47196. case xunjiservice.FieldWxid:
  47197. return m.Wxid()
  47198. case xunjiservice.FieldAPIBase:
  47199. return m.APIBase()
  47200. case xunjiservice.FieldAPIKey:
  47201. return m.APIKey()
  47202. }
  47203. return nil, false
  47204. }
  47205. // OldField returns the old value of the field from the database. An error is
  47206. // returned if the mutation operation is not UpdateOne, or the query to the
  47207. // database failed.
  47208. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47209. switch name {
  47210. case xunjiservice.FieldCreatedAt:
  47211. return m.OldCreatedAt(ctx)
  47212. case xunjiservice.FieldUpdatedAt:
  47213. return m.OldUpdatedAt(ctx)
  47214. case xunjiservice.FieldStatus:
  47215. return m.OldStatus(ctx)
  47216. case xunjiservice.FieldDeletedAt:
  47217. return m.OldDeletedAt(ctx)
  47218. case xunjiservice.FieldXunjiID:
  47219. return m.OldXunjiID(ctx)
  47220. case xunjiservice.FieldAgentID:
  47221. return m.OldAgentID(ctx)
  47222. case xunjiservice.FieldOrganizationID:
  47223. return m.OldOrganizationID(ctx)
  47224. case xunjiservice.FieldWxid:
  47225. return m.OldWxid(ctx)
  47226. case xunjiservice.FieldAPIBase:
  47227. return m.OldAPIBase(ctx)
  47228. case xunjiservice.FieldAPIKey:
  47229. return m.OldAPIKey(ctx)
  47230. }
  47231. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  47232. }
  47233. // SetField sets the value of a field with the given name. It returns an error if
  47234. // the field is not defined in the schema, or if the type mismatched the field
  47235. // type.
  47236. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  47237. switch name {
  47238. case xunjiservice.FieldCreatedAt:
  47239. v, ok := value.(time.Time)
  47240. if !ok {
  47241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47242. }
  47243. m.SetCreatedAt(v)
  47244. return nil
  47245. case xunjiservice.FieldUpdatedAt:
  47246. v, ok := value.(time.Time)
  47247. if !ok {
  47248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47249. }
  47250. m.SetUpdatedAt(v)
  47251. return nil
  47252. case xunjiservice.FieldStatus:
  47253. v, ok := value.(uint8)
  47254. if !ok {
  47255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47256. }
  47257. m.SetStatus(v)
  47258. return nil
  47259. case xunjiservice.FieldDeletedAt:
  47260. v, ok := value.(time.Time)
  47261. if !ok {
  47262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47263. }
  47264. m.SetDeletedAt(v)
  47265. return nil
  47266. case xunjiservice.FieldXunjiID:
  47267. v, ok := value.(uint64)
  47268. if !ok {
  47269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47270. }
  47271. m.SetXunjiID(v)
  47272. return nil
  47273. case xunjiservice.FieldAgentID:
  47274. v, ok := value.(uint64)
  47275. if !ok {
  47276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47277. }
  47278. m.SetAgentID(v)
  47279. return nil
  47280. case xunjiservice.FieldOrganizationID:
  47281. v, ok := value.(uint64)
  47282. if !ok {
  47283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47284. }
  47285. m.SetOrganizationID(v)
  47286. return nil
  47287. case xunjiservice.FieldWxid:
  47288. v, ok := value.(string)
  47289. if !ok {
  47290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47291. }
  47292. m.SetWxid(v)
  47293. return nil
  47294. case xunjiservice.FieldAPIBase:
  47295. v, ok := value.(string)
  47296. if !ok {
  47297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47298. }
  47299. m.SetAPIBase(v)
  47300. return nil
  47301. case xunjiservice.FieldAPIKey:
  47302. v, ok := value.(string)
  47303. if !ok {
  47304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47305. }
  47306. m.SetAPIKey(v)
  47307. return nil
  47308. }
  47309. return fmt.Errorf("unknown XunjiService field %s", name)
  47310. }
  47311. // AddedFields returns all numeric fields that were incremented/decremented during
  47312. // this mutation.
  47313. func (m *XunjiServiceMutation) AddedFields() []string {
  47314. var fields []string
  47315. if m.addstatus != nil {
  47316. fields = append(fields, xunjiservice.FieldStatus)
  47317. }
  47318. if m.addxunji_id != nil {
  47319. fields = append(fields, xunjiservice.FieldXunjiID)
  47320. }
  47321. if m.addorganization_id != nil {
  47322. fields = append(fields, xunjiservice.FieldOrganizationID)
  47323. }
  47324. return fields
  47325. }
  47326. // AddedField returns the numeric value that was incremented/decremented on a field
  47327. // with the given name. The second boolean return value indicates that this field
  47328. // was not set, or was not defined in the schema.
  47329. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  47330. switch name {
  47331. case xunjiservice.FieldStatus:
  47332. return m.AddedStatus()
  47333. case xunjiservice.FieldXunjiID:
  47334. return m.AddedXunjiID()
  47335. case xunjiservice.FieldOrganizationID:
  47336. return m.AddedOrganizationID()
  47337. }
  47338. return nil, false
  47339. }
  47340. // AddField adds the value to the field with the given name. It returns an error if
  47341. // the field is not defined in the schema, or if the type mismatched the field
  47342. // type.
  47343. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  47344. switch name {
  47345. case xunjiservice.FieldStatus:
  47346. v, ok := value.(int8)
  47347. if !ok {
  47348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47349. }
  47350. m.AddStatus(v)
  47351. return nil
  47352. case xunjiservice.FieldXunjiID:
  47353. v, ok := value.(int64)
  47354. if !ok {
  47355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47356. }
  47357. m.AddXunjiID(v)
  47358. return nil
  47359. case xunjiservice.FieldOrganizationID:
  47360. v, ok := value.(int64)
  47361. if !ok {
  47362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47363. }
  47364. m.AddOrganizationID(v)
  47365. return nil
  47366. }
  47367. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  47368. }
  47369. // ClearedFields returns all nullable fields that were cleared during this
  47370. // mutation.
  47371. func (m *XunjiServiceMutation) ClearedFields() []string {
  47372. var fields []string
  47373. if m.FieldCleared(xunjiservice.FieldStatus) {
  47374. fields = append(fields, xunjiservice.FieldStatus)
  47375. }
  47376. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  47377. fields = append(fields, xunjiservice.FieldDeletedAt)
  47378. }
  47379. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  47380. fields = append(fields, xunjiservice.FieldAPIBase)
  47381. }
  47382. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  47383. fields = append(fields, xunjiservice.FieldAPIKey)
  47384. }
  47385. return fields
  47386. }
  47387. // FieldCleared returns a boolean indicating if a field with the given name was
  47388. // cleared in this mutation.
  47389. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  47390. _, ok := m.clearedFields[name]
  47391. return ok
  47392. }
  47393. // ClearField clears the value of the field with the given name. It returns an
  47394. // error if the field is not defined in the schema.
  47395. func (m *XunjiServiceMutation) ClearField(name string) error {
  47396. switch name {
  47397. case xunjiservice.FieldStatus:
  47398. m.ClearStatus()
  47399. return nil
  47400. case xunjiservice.FieldDeletedAt:
  47401. m.ClearDeletedAt()
  47402. return nil
  47403. case xunjiservice.FieldAPIBase:
  47404. m.ClearAPIBase()
  47405. return nil
  47406. case xunjiservice.FieldAPIKey:
  47407. m.ClearAPIKey()
  47408. return nil
  47409. }
  47410. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  47411. }
  47412. // ResetField resets all changes in the mutation for the field with the given name.
  47413. // It returns an error if the field is not defined in the schema.
  47414. func (m *XunjiServiceMutation) ResetField(name string) error {
  47415. switch name {
  47416. case xunjiservice.FieldCreatedAt:
  47417. m.ResetCreatedAt()
  47418. return nil
  47419. case xunjiservice.FieldUpdatedAt:
  47420. m.ResetUpdatedAt()
  47421. return nil
  47422. case xunjiservice.FieldStatus:
  47423. m.ResetStatus()
  47424. return nil
  47425. case xunjiservice.FieldDeletedAt:
  47426. m.ResetDeletedAt()
  47427. return nil
  47428. case xunjiservice.FieldXunjiID:
  47429. m.ResetXunjiID()
  47430. return nil
  47431. case xunjiservice.FieldAgentID:
  47432. m.ResetAgentID()
  47433. return nil
  47434. case xunjiservice.FieldOrganizationID:
  47435. m.ResetOrganizationID()
  47436. return nil
  47437. case xunjiservice.FieldWxid:
  47438. m.ResetWxid()
  47439. return nil
  47440. case xunjiservice.FieldAPIBase:
  47441. m.ResetAPIBase()
  47442. return nil
  47443. case xunjiservice.FieldAPIKey:
  47444. m.ResetAPIKey()
  47445. return nil
  47446. }
  47447. return fmt.Errorf("unknown XunjiService field %s", name)
  47448. }
  47449. // AddedEdges returns all edge names that were set/added in this mutation.
  47450. func (m *XunjiServiceMutation) AddedEdges() []string {
  47451. edges := make([]string, 0, 1)
  47452. if m.agent != nil {
  47453. edges = append(edges, xunjiservice.EdgeAgent)
  47454. }
  47455. return edges
  47456. }
  47457. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47458. // name in this mutation.
  47459. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  47460. switch name {
  47461. case xunjiservice.EdgeAgent:
  47462. if id := m.agent; id != nil {
  47463. return []ent.Value{*id}
  47464. }
  47465. }
  47466. return nil
  47467. }
  47468. // RemovedEdges returns all edge names that were removed in this mutation.
  47469. func (m *XunjiServiceMutation) RemovedEdges() []string {
  47470. edges := make([]string, 0, 1)
  47471. return edges
  47472. }
  47473. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47474. // the given name in this mutation.
  47475. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  47476. return nil
  47477. }
  47478. // ClearedEdges returns all edge names that were cleared in this mutation.
  47479. func (m *XunjiServiceMutation) ClearedEdges() []string {
  47480. edges := make([]string, 0, 1)
  47481. if m.clearedagent {
  47482. edges = append(edges, xunjiservice.EdgeAgent)
  47483. }
  47484. return edges
  47485. }
  47486. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47487. // was cleared in this mutation.
  47488. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  47489. switch name {
  47490. case xunjiservice.EdgeAgent:
  47491. return m.clearedagent
  47492. }
  47493. return false
  47494. }
  47495. // ClearEdge clears the value of the edge with the given name. It returns an error
  47496. // if that edge is not defined in the schema.
  47497. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  47498. switch name {
  47499. case xunjiservice.EdgeAgent:
  47500. m.ClearAgent()
  47501. return nil
  47502. }
  47503. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  47504. }
  47505. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47506. // It returns an error if the edge is not defined in the schema.
  47507. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  47508. switch name {
  47509. case xunjiservice.EdgeAgent:
  47510. m.ResetAgent()
  47511. return nil
  47512. }
  47513. return fmt.Errorf("unknown XunjiService edge %s", name)
  47514. }