mutation.go 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/contact"
  19. "wechat-api/ent/creditbalance"
  20. "wechat-api/ent/creditusage"
  21. "wechat-api/ent/custom_types"
  22. "wechat-api/ent/employee"
  23. "wechat-api/ent/employeeconfig"
  24. "wechat-api/ent/label"
  25. "wechat-api/ent/labelrelationship"
  26. "wechat-api/ent/labeltagging"
  27. "wechat-api/ent/message"
  28. "wechat-api/ent/messagerecords"
  29. "wechat-api/ent/msg"
  30. "wechat-api/ent/payrecharge"
  31. "wechat-api/ent/predicate"
  32. "wechat-api/ent/server"
  33. "wechat-api/ent/sopnode"
  34. "wechat-api/ent/sopstage"
  35. "wechat-api/ent/soptask"
  36. "wechat-api/ent/token"
  37. "wechat-api/ent/tutorial"
  38. "wechat-api/ent/usagedetail"
  39. "wechat-api/ent/usagestatisticday"
  40. "wechat-api/ent/usagestatistichour"
  41. "wechat-api/ent/usagestatisticmonth"
  42. "wechat-api/ent/usagetotal"
  43. "wechat-api/ent/whatsapp"
  44. "wechat-api/ent/whatsappchannel"
  45. "wechat-api/ent/workexperience"
  46. "wechat-api/ent/wpchatroom"
  47. "wechat-api/ent/wpchatroommember"
  48. "wechat-api/ent/wx"
  49. "wechat-api/ent/wxcard"
  50. "wechat-api/ent/wxcarduser"
  51. "wechat-api/ent/wxcardvisit"
  52. "wechat-api/ent/xunji"
  53. "wechat-api/ent/xunjiservice"
  54. "entgo.io/ent"
  55. "entgo.io/ent/dialect/sql"
  56. )
  57. const (
  58. // Operation types.
  59. OpCreate = ent.OpCreate
  60. OpDelete = ent.OpDelete
  61. OpDeleteOne = ent.OpDeleteOne
  62. OpUpdate = ent.OpUpdate
  63. OpUpdateOne = ent.OpUpdateOne
  64. // Node types.
  65. TypeAgent = "Agent"
  66. TypeAgentBase = "AgentBase"
  67. TypeAliyunAvatar = "AliyunAvatar"
  68. TypeAllocAgent = "AllocAgent"
  69. TypeApiKey = "ApiKey"
  70. TypeBatchMsg = "BatchMsg"
  71. TypeCategory = "Category"
  72. TypeChatRecords = "ChatRecords"
  73. TypeChatSession = "ChatSession"
  74. TypeContact = "Contact"
  75. TypeCreditBalance = "CreditBalance"
  76. TypeCreditUsage = "CreditUsage"
  77. TypeEmployee = "Employee"
  78. TypeEmployeeConfig = "EmployeeConfig"
  79. TypeLabel = "Label"
  80. TypeLabelRelationship = "LabelRelationship"
  81. TypeLabelTagging = "LabelTagging"
  82. TypeMessage = "Message"
  83. TypeMessageRecords = "MessageRecords"
  84. TypeMsg = "Msg"
  85. TypePayRecharge = "PayRecharge"
  86. TypeServer = "Server"
  87. TypeSopNode = "SopNode"
  88. TypeSopStage = "SopStage"
  89. TypeSopTask = "SopTask"
  90. TypeToken = "Token"
  91. TypeTutorial = "Tutorial"
  92. TypeUsageDetail = "UsageDetail"
  93. TypeUsageStatisticDay = "UsageStatisticDay"
  94. TypeUsageStatisticHour = "UsageStatisticHour"
  95. TypeUsageStatisticMonth = "UsageStatisticMonth"
  96. TypeUsageTotal = "UsageTotal"
  97. TypeWhatsapp = "Whatsapp"
  98. TypeWhatsappChannel = "WhatsappChannel"
  99. TypeWorkExperience = "WorkExperience"
  100. TypeWpChatroom = "WpChatroom"
  101. TypeWpChatroomMember = "WpChatroomMember"
  102. TypeWx = "Wx"
  103. TypeWxCard = "WxCard"
  104. TypeWxCardUser = "WxCardUser"
  105. TypeWxCardVisit = "WxCardVisit"
  106. TypeXunji = "Xunji"
  107. TypeXunjiService = "XunjiService"
  108. )
  109. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  110. type AgentMutation struct {
  111. config
  112. op Op
  113. typ string
  114. id *uint64
  115. created_at *time.Time
  116. updated_at *time.Time
  117. deleted_at *time.Time
  118. name *string
  119. role *string
  120. status *int
  121. addstatus *int
  122. background *string
  123. examples *string
  124. organization_id *uint64
  125. addorganization_id *int64
  126. dataset_id *string
  127. collection_id *string
  128. clearedFields map[string]struct{}
  129. wx_agent map[uint64]struct{}
  130. removedwx_agent map[uint64]struct{}
  131. clearedwx_agent bool
  132. token_agent map[uint64]struct{}
  133. removedtoken_agent map[uint64]struct{}
  134. clearedtoken_agent bool
  135. wa_agent map[uint64]struct{}
  136. removedwa_agent map[uint64]struct{}
  137. clearedwa_agent bool
  138. xjs_agent map[uint64]struct{}
  139. removedxjs_agent map[uint64]struct{}
  140. clearedxjs_agent bool
  141. key_agent map[uint64]struct{}
  142. removedkey_agent map[uint64]struct{}
  143. clearedkey_agent bool
  144. done bool
  145. oldValue func(context.Context) (*Agent, error)
  146. predicates []predicate.Agent
  147. }
  148. var _ ent.Mutation = (*AgentMutation)(nil)
  149. // agentOption allows management of the mutation configuration using functional options.
  150. type agentOption func(*AgentMutation)
  151. // newAgentMutation creates new mutation for the Agent entity.
  152. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  153. m := &AgentMutation{
  154. config: c,
  155. op: op,
  156. typ: TypeAgent,
  157. clearedFields: make(map[string]struct{}),
  158. }
  159. for _, opt := range opts {
  160. opt(m)
  161. }
  162. return m
  163. }
  164. // withAgentID sets the ID field of the mutation.
  165. func withAgentID(id uint64) agentOption {
  166. return func(m *AgentMutation) {
  167. var (
  168. err error
  169. once sync.Once
  170. value *Agent
  171. )
  172. m.oldValue = func(ctx context.Context) (*Agent, error) {
  173. once.Do(func() {
  174. if m.done {
  175. err = errors.New("querying old values post mutation is not allowed")
  176. } else {
  177. value, err = m.Client().Agent.Get(ctx, id)
  178. }
  179. })
  180. return value, err
  181. }
  182. m.id = &id
  183. }
  184. }
  185. // withAgent sets the old Agent of the mutation.
  186. func withAgent(node *Agent) agentOption {
  187. return func(m *AgentMutation) {
  188. m.oldValue = func(context.Context) (*Agent, error) {
  189. return node, nil
  190. }
  191. m.id = &node.ID
  192. }
  193. }
  194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  195. // executed in a transaction (ent.Tx), a transactional client is returned.
  196. func (m AgentMutation) Client() *Client {
  197. client := &Client{config: m.config}
  198. client.init()
  199. return client
  200. }
  201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  202. // it returns an error otherwise.
  203. func (m AgentMutation) Tx() (*Tx, error) {
  204. if _, ok := m.driver.(*txDriver); !ok {
  205. return nil, errors.New("ent: mutation is not running in a transaction")
  206. }
  207. tx := &Tx{config: m.config}
  208. tx.init()
  209. return tx, nil
  210. }
  211. // SetID sets the value of the id field. Note that this
  212. // operation is only accepted on creation of Agent entities.
  213. func (m *AgentMutation) SetID(id uint64) {
  214. m.id = &id
  215. }
  216. // ID returns the ID value in the mutation. Note that the ID is only available
  217. // if it was provided to the builder or after it was returned from the database.
  218. func (m *AgentMutation) ID() (id uint64, exists bool) {
  219. if m.id == nil {
  220. return
  221. }
  222. return *m.id, true
  223. }
  224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  225. // That means, if the mutation is applied within a transaction with an isolation level such
  226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  227. // or updated by the mutation.
  228. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  229. switch {
  230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  231. id, exists := m.ID()
  232. if exists {
  233. return []uint64{id}, nil
  234. }
  235. fallthrough
  236. case m.op.Is(OpUpdate | OpDelete):
  237. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  238. default:
  239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  240. }
  241. }
  242. // SetCreatedAt sets the "created_at" field.
  243. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  244. m.created_at = &t
  245. }
  246. // CreatedAt returns the value of the "created_at" field in the mutation.
  247. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  248. v := m.created_at
  249. if v == nil {
  250. return
  251. }
  252. return *v, true
  253. }
  254. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  255. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  257. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  258. if !m.op.Is(OpUpdateOne) {
  259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  260. }
  261. if m.id == nil || m.oldValue == nil {
  262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  263. }
  264. oldValue, err := m.oldValue(ctx)
  265. if err != nil {
  266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  267. }
  268. return oldValue.CreatedAt, nil
  269. }
  270. // ResetCreatedAt resets all changes to the "created_at" field.
  271. func (m *AgentMutation) ResetCreatedAt() {
  272. m.created_at = nil
  273. }
  274. // SetUpdatedAt sets the "updated_at" field.
  275. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  276. m.updated_at = &t
  277. }
  278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  279. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  280. v := m.updated_at
  281. if v == nil {
  282. return
  283. }
  284. return *v, true
  285. }
  286. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  287. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  289. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  290. if !m.op.Is(OpUpdateOne) {
  291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  292. }
  293. if m.id == nil || m.oldValue == nil {
  294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  295. }
  296. oldValue, err := m.oldValue(ctx)
  297. if err != nil {
  298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  299. }
  300. return oldValue.UpdatedAt, nil
  301. }
  302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  303. func (m *AgentMutation) ResetUpdatedAt() {
  304. m.updated_at = nil
  305. }
  306. // SetDeletedAt sets the "deleted_at" field.
  307. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  308. m.deleted_at = &t
  309. }
  310. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  311. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  312. v := m.deleted_at
  313. if v == nil {
  314. return
  315. }
  316. return *v, true
  317. }
  318. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  319. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  321. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  322. if !m.op.Is(OpUpdateOne) {
  323. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  324. }
  325. if m.id == nil || m.oldValue == nil {
  326. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  327. }
  328. oldValue, err := m.oldValue(ctx)
  329. if err != nil {
  330. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  331. }
  332. return oldValue.DeletedAt, nil
  333. }
  334. // ClearDeletedAt clears the value of the "deleted_at" field.
  335. func (m *AgentMutation) ClearDeletedAt() {
  336. m.deleted_at = nil
  337. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  338. }
  339. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  340. func (m *AgentMutation) DeletedAtCleared() bool {
  341. _, ok := m.clearedFields[agent.FieldDeletedAt]
  342. return ok
  343. }
  344. // ResetDeletedAt resets all changes to the "deleted_at" field.
  345. func (m *AgentMutation) ResetDeletedAt() {
  346. m.deleted_at = nil
  347. delete(m.clearedFields, agent.FieldDeletedAt)
  348. }
  349. // SetName sets the "name" field.
  350. func (m *AgentMutation) SetName(s string) {
  351. m.name = &s
  352. }
  353. // Name returns the value of the "name" field in the mutation.
  354. func (m *AgentMutation) Name() (r string, exists bool) {
  355. v := m.name
  356. if v == nil {
  357. return
  358. }
  359. return *v, true
  360. }
  361. // OldName returns the old "name" field's value of the Agent entity.
  362. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  364. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  365. if !m.op.Is(OpUpdateOne) {
  366. return v, errors.New("OldName is only allowed on UpdateOne operations")
  367. }
  368. if m.id == nil || m.oldValue == nil {
  369. return v, errors.New("OldName requires an ID field in the mutation")
  370. }
  371. oldValue, err := m.oldValue(ctx)
  372. if err != nil {
  373. return v, fmt.Errorf("querying old value for OldName: %w", err)
  374. }
  375. return oldValue.Name, nil
  376. }
  377. // ResetName resets all changes to the "name" field.
  378. func (m *AgentMutation) ResetName() {
  379. m.name = nil
  380. }
  381. // SetRole sets the "role" field.
  382. func (m *AgentMutation) SetRole(s string) {
  383. m.role = &s
  384. }
  385. // Role returns the value of the "role" field in the mutation.
  386. func (m *AgentMutation) Role() (r string, exists bool) {
  387. v := m.role
  388. if v == nil {
  389. return
  390. }
  391. return *v, true
  392. }
  393. // OldRole returns the old "role" field's value of the Agent entity.
  394. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  396. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  397. if !m.op.Is(OpUpdateOne) {
  398. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  399. }
  400. if m.id == nil || m.oldValue == nil {
  401. return v, errors.New("OldRole requires an ID field in the mutation")
  402. }
  403. oldValue, err := m.oldValue(ctx)
  404. if err != nil {
  405. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  406. }
  407. return oldValue.Role, nil
  408. }
  409. // ResetRole resets all changes to the "role" field.
  410. func (m *AgentMutation) ResetRole() {
  411. m.role = nil
  412. }
  413. // SetStatus sets the "status" field.
  414. func (m *AgentMutation) SetStatus(i int) {
  415. m.status = &i
  416. m.addstatus = nil
  417. }
  418. // Status returns the value of the "status" field in the mutation.
  419. func (m *AgentMutation) Status() (r int, exists bool) {
  420. v := m.status
  421. if v == nil {
  422. return
  423. }
  424. return *v, true
  425. }
  426. // OldStatus returns the old "status" field's value of the Agent entity.
  427. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  429. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  430. if !m.op.Is(OpUpdateOne) {
  431. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  432. }
  433. if m.id == nil || m.oldValue == nil {
  434. return v, errors.New("OldStatus requires an ID field in the mutation")
  435. }
  436. oldValue, err := m.oldValue(ctx)
  437. if err != nil {
  438. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  439. }
  440. return oldValue.Status, nil
  441. }
  442. // AddStatus adds i to the "status" field.
  443. func (m *AgentMutation) AddStatus(i int) {
  444. if m.addstatus != nil {
  445. *m.addstatus += i
  446. } else {
  447. m.addstatus = &i
  448. }
  449. }
  450. // AddedStatus returns the value that was added to the "status" field in this mutation.
  451. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  452. v := m.addstatus
  453. if v == nil {
  454. return
  455. }
  456. return *v, true
  457. }
  458. // ClearStatus clears the value of the "status" field.
  459. func (m *AgentMutation) ClearStatus() {
  460. m.status = nil
  461. m.addstatus = nil
  462. m.clearedFields[agent.FieldStatus] = struct{}{}
  463. }
  464. // StatusCleared returns if the "status" field was cleared in this mutation.
  465. func (m *AgentMutation) StatusCleared() bool {
  466. _, ok := m.clearedFields[agent.FieldStatus]
  467. return ok
  468. }
  469. // ResetStatus resets all changes to the "status" field.
  470. func (m *AgentMutation) ResetStatus() {
  471. m.status = nil
  472. m.addstatus = nil
  473. delete(m.clearedFields, agent.FieldStatus)
  474. }
  475. // SetBackground sets the "background" field.
  476. func (m *AgentMutation) SetBackground(s string) {
  477. m.background = &s
  478. }
  479. // Background returns the value of the "background" field in the mutation.
  480. func (m *AgentMutation) Background() (r string, exists bool) {
  481. v := m.background
  482. if v == nil {
  483. return
  484. }
  485. return *v, true
  486. }
  487. // OldBackground returns the old "background" field's value of the Agent entity.
  488. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  490. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  491. if !m.op.Is(OpUpdateOne) {
  492. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  493. }
  494. if m.id == nil || m.oldValue == nil {
  495. return v, errors.New("OldBackground requires an ID field in the mutation")
  496. }
  497. oldValue, err := m.oldValue(ctx)
  498. if err != nil {
  499. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  500. }
  501. return oldValue.Background, nil
  502. }
  503. // ClearBackground clears the value of the "background" field.
  504. func (m *AgentMutation) ClearBackground() {
  505. m.background = nil
  506. m.clearedFields[agent.FieldBackground] = struct{}{}
  507. }
  508. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  509. func (m *AgentMutation) BackgroundCleared() bool {
  510. _, ok := m.clearedFields[agent.FieldBackground]
  511. return ok
  512. }
  513. // ResetBackground resets all changes to the "background" field.
  514. func (m *AgentMutation) ResetBackground() {
  515. m.background = nil
  516. delete(m.clearedFields, agent.FieldBackground)
  517. }
  518. // SetExamples sets the "examples" field.
  519. func (m *AgentMutation) SetExamples(s string) {
  520. m.examples = &s
  521. }
  522. // Examples returns the value of the "examples" field in the mutation.
  523. func (m *AgentMutation) Examples() (r string, exists bool) {
  524. v := m.examples
  525. if v == nil {
  526. return
  527. }
  528. return *v, true
  529. }
  530. // OldExamples returns the old "examples" field's value of the Agent entity.
  531. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  533. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  534. if !m.op.Is(OpUpdateOne) {
  535. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  536. }
  537. if m.id == nil || m.oldValue == nil {
  538. return v, errors.New("OldExamples requires an ID field in the mutation")
  539. }
  540. oldValue, err := m.oldValue(ctx)
  541. if err != nil {
  542. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  543. }
  544. return oldValue.Examples, nil
  545. }
  546. // ClearExamples clears the value of the "examples" field.
  547. func (m *AgentMutation) ClearExamples() {
  548. m.examples = nil
  549. m.clearedFields[agent.FieldExamples] = struct{}{}
  550. }
  551. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  552. func (m *AgentMutation) ExamplesCleared() bool {
  553. _, ok := m.clearedFields[agent.FieldExamples]
  554. return ok
  555. }
  556. // ResetExamples resets all changes to the "examples" field.
  557. func (m *AgentMutation) ResetExamples() {
  558. m.examples = nil
  559. delete(m.clearedFields, agent.FieldExamples)
  560. }
  561. // SetOrganizationID sets the "organization_id" field.
  562. func (m *AgentMutation) SetOrganizationID(u uint64) {
  563. m.organization_id = &u
  564. m.addorganization_id = nil
  565. }
  566. // OrganizationID returns the value of the "organization_id" field in the mutation.
  567. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  568. v := m.organization_id
  569. if v == nil {
  570. return
  571. }
  572. return *v, true
  573. }
  574. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  575. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  577. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  578. if !m.op.Is(OpUpdateOne) {
  579. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  580. }
  581. if m.id == nil || m.oldValue == nil {
  582. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  583. }
  584. oldValue, err := m.oldValue(ctx)
  585. if err != nil {
  586. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  587. }
  588. return oldValue.OrganizationID, nil
  589. }
  590. // AddOrganizationID adds u to the "organization_id" field.
  591. func (m *AgentMutation) AddOrganizationID(u int64) {
  592. if m.addorganization_id != nil {
  593. *m.addorganization_id += u
  594. } else {
  595. m.addorganization_id = &u
  596. }
  597. }
  598. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  599. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  600. v := m.addorganization_id
  601. if v == nil {
  602. return
  603. }
  604. return *v, true
  605. }
  606. // ResetOrganizationID resets all changes to the "organization_id" field.
  607. func (m *AgentMutation) ResetOrganizationID() {
  608. m.organization_id = nil
  609. m.addorganization_id = nil
  610. }
  611. // SetDatasetID sets the "dataset_id" field.
  612. func (m *AgentMutation) SetDatasetID(s string) {
  613. m.dataset_id = &s
  614. }
  615. // DatasetID returns the value of the "dataset_id" field in the mutation.
  616. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  617. v := m.dataset_id
  618. if v == nil {
  619. return
  620. }
  621. return *v, true
  622. }
  623. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  624. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  626. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  627. if !m.op.Is(OpUpdateOne) {
  628. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  629. }
  630. if m.id == nil || m.oldValue == nil {
  631. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  632. }
  633. oldValue, err := m.oldValue(ctx)
  634. if err != nil {
  635. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  636. }
  637. return oldValue.DatasetID, nil
  638. }
  639. // ResetDatasetID resets all changes to the "dataset_id" field.
  640. func (m *AgentMutation) ResetDatasetID() {
  641. m.dataset_id = nil
  642. }
  643. // SetCollectionID sets the "collection_id" field.
  644. func (m *AgentMutation) SetCollectionID(s string) {
  645. m.collection_id = &s
  646. }
  647. // CollectionID returns the value of the "collection_id" field in the mutation.
  648. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  649. v := m.collection_id
  650. if v == nil {
  651. return
  652. }
  653. return *v, true
  654. }
  655. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  656. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  658. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  659. if !m.op.Is(OpUpdateOne) {
  660. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  661. }
  662. if m.id == nil || m.oldValue == nil {
  663. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  664. }
  665. oldValue, err := m.oldValue(ctx)
  666. if err != nil {
  667. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  668. }
  669. return oldValue.CollectionID, nil
  670. }
  671. // ResetCollectionID resets all changes to the "collection_id" field.
  672. func (m *AgentMutation) ResetCollectionID() {
  673. m.collection_id = nil
  674. }
  675. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  676. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  677. if m.wx_agent == nil {
  678. m.wx_agent = make(map[uint64]struct{})
  679. }
  680. for i := range ids {
  681. m.wx_agent[ids[i]] = struct{}{}
  682. }
  683. }
  684. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  685. func (m *AgentMutation) ClearWxAgent() {
  686. m.clearedwx_agent = true
  687. }
  688. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  689. func (m *AgentMutation) WxAgentCleared() bool {
  690. return m.clearedwx_agent
  691. }
  692. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  693. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  694. if m.removedwx_agent == nil {
  695. m.removedwx_agent = make(map[uint64]struct{})
  696. }
  697. for i := range ids {
  698. delete(m.wx_agent, ids[i])
  699. m.removedwx_agent[ids[i]] = struct{}{}
  700. }
  701. }
  702. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  703. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  704. for id := range m.removedwx_agent {
  705. ids = append(ids, id)
  706. }
  707. return
  708. }
  709. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  710. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  711. for id := range m.wx_agent {
  712. ids = append(ids, id)
  713. }
  714. return
  715. }
  716. // ResetWxAgent resets all changes to the "wx_agent" edge.
  717. func (m *AgentMutation) ResetWxAgent() {
  718. m.wx_agent = nil
  719. m.clearedwx_agent = false
  720. m.removedwx_agent = nil
  721. }
  722. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  723. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  724. if m.token_agent == nil {
  725. m.token_agent = make(map[uint64]struct{})
  726. }
  727. for i := range ids {
  728. m.token_agent[ids[i]] = struct{}{}
  729. }
  730. }
  731. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  732. func (m *AgentMutation) ClearTokenAgent() {
  733. m.clearedtoken_agent = true
  734. }
  735. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  736. func (m *AgentMutation) TokenAgentCleared() bool {
  737. return m.clearedtoken_agent
  738. }
  739. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  740. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  741. if m.removedtoken_agent == nil {
  742. m.removedtoken_agent = make(map[uint64]struct{})
  743. }
  744. for i := range ids {
  745. delete(m.token_agent, ids[i])
  746. m.removedtoken_agent[ids[i]] = struct{}{}
  747. }
  748. }
  749. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  750. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  751. for id := range m.removedtoken_agent {
  752. ids = append(ids, id)
  753. }
  754. return
  755. }
  756. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  757. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  758. for id := range m.token_agent {
  759. ids = append(ids, id)
  760. }
  761. return
  762. }
  763. // ResetTokenAgent resets all changes to the "token_agent" edge.
  764. func (m *AgentMutation) ResetTokenAgent() {
  765. m.token_agent = nil
  766. m.clearedtoken_agent = false
  767. m.removedtoken_agent = nil
  768. }
  769. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  770. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  771. if m.wa_agent == nil {
  772. m.wa_agent = make(map[uint64]struct{})
  773. }
  774. for i := range ids {
  775. m.wa_agent[ids[i]] = struct{}{}
  776. }
  777. }
  778. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  779. func (m *AgentMutation) ClearWaAgent() {
  780. m.clearedwa_agent = true
  781. }
  782. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  783. func (m *AgentMutation) WaAgentCleared() bool {
  784. return m.clearedwa_agent
  785. }
  786. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  787. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  788. if m.removedwa_agent == nil {
  789. m.removedwa_agent = make(map[uint64]struct{})
  790. }
  791. for i := range ids {
  792. delete(m.wa_agent, ids[i])
  793. m.removedwa_agent[ids[i]] = struct{}{}
  794. }
  795. }
  796. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  797. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  798. for id := range m.removedwa_agent {
  799. ids = append(ids, id)
  800. }
  801. return
  802. }
  803. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  804. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  805. for id := range m.wa_agent {
  806. ids = append(ids, id)
  807. }
  808. return
  809. }
  810. // ResetWaAgent resets all changes to the "wa_agent" edge.
  811. func (m *AgentMutation) ResetWaAgent() {
  812. m.wa_agent = nil
  813. m.clearedwa_agent = false
  814. m.removedwa_agent = nil
  815. }
  816. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  817. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  818. if m.xjs_agent == nil {
  819. m.xjs_agent = make(map[uint64]struct{})
  820. }
  821. for i := range ids {
  822. m.xjs_agent[ids[i]] = struct{}{}
  823. }
  824. }
  825. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  826. func (m *AgentMutation) ClearXjsAgent() {
  827. m.clearedxjs_agent = true
  828. }
  829. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  830. func (m *AgentMutation) XjsAgentCleared() bool {
  831. return m.clearedxjs_agent
  832. }
  833. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  834. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  835. if m.removedxjs_agent == nil {
  836. m.removedxjs_agent = make(map[uint64]struct{})
  837. }
  838. for i := range ids {
  839. delete(m.xjs_agent, ids[i])
  840. m.removedxjs_agent[ids[i]] = struct{}{}
  841. }
  842. }
  843. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  844. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  845. for id := range m.removedxjs_agent {
  846. ids = append(ids, id)
  847. }
  848. return
  849. }
  850. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  851. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  852. for id := range m.xjs_agent {
  853. ids = append(ids, id)
  854. }
  855. return
  856. }
  857. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  858. func (m *AgentMutation) ResetXjsAgent() {
  859. m.xjs_agent = nil
  860. m.clearedxjs_agent = false
  861. m.removedxjs_agent = nil
  862. }
  863. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  864. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  865. if m.key_agent == nil {
  866. m.key_agent = make(map[uint64]struct{})
  867. }
  868. for i := range ids {
  869. m.key_agent[ids[i]] = struct{}{}
  870. }
  871. }
  872. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  873. func (m *AgentMutation) ClearKeyAgent() {
  874. m.clearedkey_agent = true
  875. }
  876. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  877. func (m *AgentMutation) KeyAgentCleared() bool {
  878. return m.clearedkey_agent
  879. }
  880. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  881. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  882. if m.removedkey_agent == nil {
  883. m.removedkey_agent = make(map[uint64]struct{})
  884. }
  885. for i := range ids {
  886. delete(m.key_agent, ids[i])
  887. m.removedkey_agent[ids[i]] = struct{}{}
  888. }
  889. }
  890. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  891. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  892. for id := range m.removedkey_agent {
  893. ids = append(ids, id)
  894. }
  895. return
  896. }
  897. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  898. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  899. for id := range m.key_agent {
  900. ids = append(ids, id)
  901. }
  902. return
  903. }
  904. // ResetKeyAgent resets all changes to the "key_agent" edge.
  905. func (m *AgentMutation) ResetKeyAgent() {
  906. m.key_agent = nil
  907. m.clearedkey_agent = false
  908. m.removedkey_agent = nil
  909. }
  910. // Where appends a list predicates to the AgentMutation builder.
  911. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  912. m.predicates = append(m.predicates, ps...)
  913. }
  914. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  915. // users can use type-assertion to append predicates that do not depend on any generated package.
  916. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  917. p := make([]predicate.Agent, len(ps))
  918. for i := range ps {
  919. p[i] = ps[i]
  920. }
  921. m.Where(p...)
  922. }
  923. // Op returns the operation name.
  924. func (m *AgentMutation) Op() Op {
  925. return m.op
  926. }
  927. // SetOp allows setting the mutation operation.
  928. func (m *AgentMutation) SetOp(op Op) {
  929. m.op = op
  930. }
  931. // Type returns the node type of this mutation (Agent).
  932. func (m *AgentMutation) Type() string {
  933. return m.typ
  934. }
  935. // Fields returns all fields that were changed during this mutation. Note that in
  936. // order to get all numeric fields that were incremented/decremented, call
  937. // AddedFields().
  938. func (m *AgentMutation) Fields() []string {
  939. fields := make([]string, 0, 11)
  940. if m.created_at != nil {
  941. fields = append(fields, agent.FieldCreatedAt)
  942. }
  943. if m.updated_at != nil {
  944. fields = append(fields, agent.FieldUpdatedAt)
  945. }
  946. if m.deleted_at != nil {
  947. fields = append(fields, agent.FieldDeletedAt)
  948. }
  949. if m.name != nil {
  950. fields = append(fields, agent.FieldName)
  951. }
  952. if m.role != nil {
  953. fields = append(fields, agent.FieldRole)
  954. }
  955. if m.status != nil {
  956. fields = append(fields, agent.FieldStatus)
  957. }
  958. if m.background != nil {
  959. fields = append(fields, agent.FieldBackground)
  960. }
  961. if m.examples != nil {
  962. fields = append(fields, agent.FieldExamples)
  963. }
  964. if m.organization_id != nil {
  965. fields = append(fields, agent.FieldOrganizationID)
  966. }
  967. if m.dataset_id != nil {
  968. fields = append(fields, agent.FieldDatasetID)
  969. }
  970. if m.collection_id != nil {
  971. fields = append(fields, agent.FieldCollectionID)
  972. }
  973. return fields
  974. }
  975. // Field returns the value of a field with the given name. The second boolean
  976. // return value indicates that this field was not set, or was not defined in the
  977. // schema.
  978. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  979. switch name {
  980. case agent.FieldCreatedAt:
  981. return m.CreatedAt()
  982. case agent.FieldUpdatedAt:
  983. return m.UpdatedAt()
  984. case agent.FieldDeletedAt:
  985. return m.DeletedAt()
  986. case agent.FieldName:
  987. return m.Name()
  988. case agent.FieldRole:
  989. return m.Role()
  990. case agent.FieldStatus:
  991. return m.Status()
  992. case agent.FieldBackground:
  993. return m.Background()
  994. case agent.FieldExamples:
  995. return m.Examples()
  996. case agent.FieldOrganizationID:
  997. return m.OrganizationID()
  998. case agent.FieldDatasetID:
  999. return m.DatasetID()
  1000. case agent.FieldCollectionID:
  1001. return m.CollectionID()
  1002. }
  1003. return nil, false
  1004. }
  1005. // OldField returns the old value of the field from the database. An error is
  1006. // returned if the mutation operation is not UpdateOne, or the query to the
  1007. // database failed.
  1008. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1009. switch name {
  1010. case agent.FieldCreatedAt:
  1011. return m.OldCreatedAt(ctx)
  1012. case agent.FieldUpdatedAt:
  1013. return m.OldUpdatedAt(ctx)
  1014. case agent.FieldDeletedAt:
  1015. return m.OldDeletedAt(ctx)
  1016. case agent.FieldName:
  1017. return m.OldName(ctx)
  1018. case agent.FieldRole:
  1019. return m.OldRole(ctx)
  1020. case agent.FieldStatus:
  1021. return m.OldStatus(ctx)
  1022. case agent.FieldBackground:
  1023. return m.OldBackground(ctx)
  1024. case agent.FieldExamples:
  1025. return m.OldExamples(ctx)
  1026. case agent.FieldOrganizationID:
  1027. return m.OldOrganizationID(ctx)
  1028. case agent.FieldDatasetID:
  1029. return m.OldDatasetID(ctx)
  1030. case agent.FieldCollectionID:
  1031. return m.OldCollectionID(ctx)
  1032. }
  1033. return nil, fmt.Errorf("unknown Agent field %s", name)
  1034. }
  1035. // SetField sets the value of a field with the given name. It returns an error if
  1036. // the field is not defined in the schema, or if the type mismatched the field
  1037. // type.
  1038. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1039. switch name {
  1040. case agent.FieldCreatedAt:
  1041. v, ok := value.(time.Time)
  1042. if !ok {
  1043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1044. }
  1045. m.SetCreatedAt(v)
  1046. return nil
  1047. case agent.FieldUpdatedAt:
  1048. v, ok := value.(time.Time)
  1049. if !ok {
  1050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1051. }
  1052. m.SetUpdatedAt(v)
  1053. return nil
  1054. case agent.FieldDeletedAt:
  1055. v, ok := value.(time.Time)
  1056. if !ok {
  1057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1058. }
  1059. m.SetDeletedAt(v)
  1060. return nil
  1061. case agent.FieldName:
  1062. v, ok := value.(string)
  1063. if !ok {
  1064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1065. }
  1066. m.SetName(v)
  1067. return nil
  1068. case agent.FieldRole:
  1069. v, ok := value.(string)
  1070. if !ok {
  1071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1072. }
  1073. m.SetRole(v)
  1074. return nil
  1075. case agent.FieldStatus:
  1076. v, ok := value.(int)
  1077. if !ok {
  1078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1079. }
  1080. m.SetStatus(v)
  1081. return nil
  1082. case agent.FieldBackground:
  1083. v, ok := value.(string)
  1084. if !ok {
  1085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1086. }
  1087. m.SetBackground(v)
  1088. return nil
  1089. case agent.FieldExamples:
  1090. v, ok := value.(string)
  1091. if !ok {
  1092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1093. }
  1094. m.SetExamples(v)
  1095. return nil
  1096. case agent.FieldOrganizationID:
  1097. v, ok := value.(uint64)
  1098. if !ok {
  1099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1100. }
  1101. m.SetOrganizationID(v)
  1102. return nil
  1103. case agent.FieldDatasetID:
  1104. v, ok := value.(string)
  1105. if !ok {
  1106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1107. }
  1108. m.SetDatasetID(v)
  1109. return nil
  1110. case agent.FieldCollectionID:
  1111. v, ok := value.(string)
  1112. if !ok {
  1113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1114. }
  1115. m.SetCollectionID(v)
  1116. return nil
  1117. }
  1118. return fmt.Errorf("unknown Agent field %s", name)
  1119. }
  1120. // AddedFields returns all numeric fields that were incremented/decremented during
  1121. // this mutation.
  1122. func (m *AgentMutation) AddedFields() []string {
  1123. var fields []string
  1124. if m.addstatus != nil {
  1125. fields = append(fields, agent.FieldStatus)
  1126. }
  1127. if m.addorganization_id != nil {
  1128. fields = append(fields, agent.FieldOrganizationID)
  1129. }
  1130. return fields
  1131. }
  1132. // AddedField returns the numeric value that was incremented/decremented on a field
  1133. // with the given name. The second boolean return value indicates that this field
  1134. // was not set, or was not defined in the schema.
  1135. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1136. switch name {
  1137. case agent.FieldStatus:
  1138. return m.AddedStatus()
  1139. case agent.FieldOrganizationID:
  1140. return m.AddedOrganizationID()
  1141. }
  1142. return nil, false
  1143. }
  1144. // AddField adds the value to the field with the given name. It returns an error if
  1145. // the field is not defined in the schema, or if the type mismatched the field
  1146. // type.
  1147. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1148. switch name {
  1149. case agent.FieldStatus:
  1150. v, ok := value.(int)
  1151. if !ok {
  1152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1153. }
  1154. m.AddStatus(v)
  1155. return nil
  1156. case agent.FieldOrganizationID:
  1157. v, ok := value.(int64)
  1158. if !ok {
  1159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1160. }
  1161. m.AddOrganizationID(v)
  1162. return nil
  1163. }
  1164. return fmt.Errorf("unknown Agent numeric field %s", name)
  1165. }
  1166. // ClearedFields returns all nullable fields that were cleared during this
  1167. // mutation.
  1168. func (m *AgentMutation) ClearedFields() []string {
  1169. var fields []string
  1170. if m.FieldCleared(agent.FieldDeletedAt) {
  1171. fields = append(fields, agent.FieldDeletedAt)
  1172. }
  1173. if m.FieldCleared(agent.FieldStatus) {
  1174. fields = append(fields, agent.FieldStatus)
  1175. }
  1176. if m.FieldCleared(agent.FieldBackground) {
  1177. fields = append(fields, agent.FieldBackground)
  1178. }
  1179. if m.FieldCleared(agent.FieldExamples) {
  1180. fields = append(fields, agent.FieldExamples)
  1181. }
  1182. return fields
  1183. }
  1184. // FieldCleared returns a boolean indicating if a field with the given name was
  1185. // cleared in this mutation.
  1186. func (m *AgentMutation) FieldCleared(name string) bool {
  1187. _, ok := m.clearedFields[name]
  1188. return ok
  1189. }
  1190. // ClearField clears the value of the field with the given name. It returns an
  1191. // error if the field is not defined in the schema.
  1192. func (m *AgentMutation) ClearField(name string) error {
  1193. switch name {
  1194. case agent.FieldDeletedAt:
  1195. m.ClearDeletedAt()
  1196. return nil
  1197. case agent.FieldStatus:
  1198. m.ClearStatus()
  1199. return nil
  1200. case agent.FieldBackground:
  1201. m.ClearBackground()
  1202. return nil
  1203. case agent.FieldExamples:
  1204. m.ClearExamples()
  1205. return nil
  1206. }
  1207. return fmt.Errorf("unknown Agent nullable field %s", name)
  1208. }
  1209. // ResetField resets all changes in the mutation for the field with the given name.
  1210. // It returns an error if the field is not defined in the schema.
  1211. func (m *AgentMutation) ResetField(name string) error {
  1212. switch name {
  1213. case agent.FieldCreatedAt:
  1214. m.ResetCreatedAt()
  1215. return nil
  1216. case agent.FieldUpdatedAt:
  1217. m.ResetUpdatedAt()
  1218. return nil
  1219. case agent.FieldDeletedAt:
  1220. m.ResetDeletedAt()
  1221. return nil
  1222. case agent.FieldName:
  1223. m.ResetName()
  1224. return nil
  1225. case agent.FieldRole:
  1226. m.ResetRole()
  1227. return nil
  1228. case agent.FieldStatus:
  1229. m.ResetStatus()
  1230. return nil
  1231. case agent.FieldBackground:
  1232. m.ResetBackground()
  1233. return nil
  1234. case agent.FieldExamples:
  1235. m.ResetExamples()
  1236. return nil
  1237. case agent.FieldOrganizationID:
  1238. m.ResetOrganizationID()
  1239. return nil
  1240. case agent.FieldDatasetID:
  1241. m.ResetDatasetID()
  1242. return nil
  1243. case agent.FieldCollectionID:
  1244. m.ResetCollectionID()
  1245. return nil
  1246. }
  1247. return fmt.Errorf("unknown Agent field %s", name)
  1248. }
  1249. // AddedEdges returns all edge names that were set/added in this mutation.
  1250. func (m *AgentMutation) AddedEdges() []string {
  1251. edges := make([]string, 0, 5)
  1252. if m.wx_agent != nil {
  1253. edges = append(edges, agent.EdgeWxAgent)
  1254. }
  1255. if m.token_agent != nil {
  1256. edges = append(edges, agent.EdgeTokenAgent)
  1257. }
  1258. if m.wa_agent != nil {
  1259. edges = append(edges, agent.EdgeWaAgent)
  1260. }
  1261. if m.xjs_agent != nil {
  1262. edges = append(edges, agent.EdgeXjsAgent)
  1263. }
  1264. if m.key_agent != nil {
  1265. edges = append(edges, agent.EdgeKeyAgent)
  1266. }
  1267. return edges
  1268. }
  1269. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1270. // name in this mutation.
  1271. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1272. switch name {
  1273. case agent.EdgeWxAgent:
  1274. ids := make([]ent.Value, 0, len(m.wx_agent))
  1275. for id := range m.wx_agent {
  1276. ids = append(ids, id)
  1277. }
  1278. return ids
  1279. case agent.EdgeTokenAgent:
  1280. ids := make([]ent.Value, 0, len(m.token_agent))
  1281. for id := range m.token_agent {
  1282. ids = append(ids, id)
  1283. }
  1284. return ids
  1285. case agent.EdgeWaAgent:
  1286. ids := make([]ent.Value, 0, len(m.wa_agent))
  1287. for id := range m.wa_agent {
  1288. ids = append(ids, id)
  1289. }
  1290. return ids
  1291. case agent.EdgeXjsAgent:
  1292. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1293. for id := range m.xjs_agent {
  1294. ids = append(ids, id)
  1295. }
  1296. return ids
  1297. case agent.EdgeKeyAgent:
  1298. ids := make([]ent.Value, 0, len(m.key_agent))
  1299. for id := range m.key_agent {
  1300. ids = append(ids, id)
  1301. }
  1302. return ids
  1303. }
  1304. return nil
  1305. }
  1306. // RemovedEdges returns all edge names that were removed in this mutation.
  1307. func (m *AgentMutation) RemovedEdges() []string {
  1308. edges := make([]string, 0, 5)
  1309. if m.removedwx_agent != nil {
  1310. edges = append(edges, agent.EdgeWxAgent)
  1311. }
  1312. if m.removedtoken_agent != nil {
  1313. edges = append(edges, agent.EdgeTokenAgent)
  1314. }
  1315. if m.removedwa_agent != nil {
  1316. edges = append(edges, agent.EdgeWaAgent)
  1317. }
  1318. if m.removedxjs_agent != nil {
  1319. edges = append(edges, agent.EdgeXjsAgent)
  1320. }
  1321. if m.removedkey_agent != nil {
  1322. edges = append(edges, agent.EdgeKeyAgent)
  1323. }
  1324. return edges
  1325. }
  1326. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1327. // the given name in this mutation.
  1328. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1329. switch name {
  1330. case agent.EdgeWxAgent:
  1331. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1332. for id := range m.removedwx_agent {
  1333. ids = append(ids, id)
  1334. }
  1335. return ids
  1336. case agent.EdgeTokenAgent:
  1337. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1338. for id := range m.removedtoken_agent {
  1339. ids = append(ids, id)
  1340. }
  1341. return ids
  1342. case agent.EdgeWaAgent:
  1343. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1344. for id := range m.removedwa_agent {
  1345. ids = append(ids, id)
  1346. }
  1347. return ids
  1348. case agent.EdgeXjsAgent:
  1349. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1350. for id := range m.removedxjs_agent {
  1351. ids = append(ids, id)
  1352. }
  1353. return ids
  1354. case agent.EdgeKeyAgent:
  1355. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1356. for id := range m.removedkey_agent {
  1357. ids = append(ids, id)
  1358. }
  1359. return ids
  1360. }
  1361. return nil
  1362. }
  1363. // ClearedEdges returns all edge names that were cleared in this mutation.
  1364. func (m *AgentMutation) ClearedEdges() []string {
  1365. edges := make([]string, 0, 5)
  1366. if m.clearedwx_agent {
  1367. edges = append(edges, agent.EdgeWxAgent)
  1368. }
  1369. if m.clearedtoken_agent {
  1370. edges = append(edges, agent.EdgeTokenAgent)
  1371. }
  1372. if m.clearedwa_agent {
  1373. edges = append(edges, agent.EdgeWaAgent)
  1374. }
  1375. if m.clearedxjs_agent {
  1376. edges = append(edges, agent.EdgeXjsAgent)
  1377. }
  1378. if m.clearedkey_agent {
  1379. edges = append(edges, agent.EdgeKeyAgent)
  1380. }
  1381. return edges
  1382. }
  1383. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1384. // was cleared in this mutation.
  1385. func (m *AgentMutation) EdgeCleared(name string) bool {
  1386. switch name {
  1387. case agent.EdgeWxAgent:
  1388. return m.clearedwx_agent
  1389. case agent.EdgeTokenAgent:
  1390. return m.clearedtoken_agent
  1391. case agent.EdgeWaAgent:
  1392. return m.clearedwa_agent
  1393. case agent.EdgeXjsAgent:
  1394. return m.clearedxjs_agent
  1395. case agent.EdgeKeyAgent:
  1396. return m.clearedkey_agent
  1397. }
  1398. return false
  1399. }
  1400. // ClearEdge clears the value of the edge with the given name. It returns an error
  1401. // if that edge is not defined in the schema.
  1402. func (m *AgentMutation) ClearEdge(name string) error {
  1403. switch name {
  1404. }
  1405. return fmt.Errorf("unknown Agent unique edge %s", name)
  1406. }
  1407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1408. // It returns an error if the edge is not defined in the schema.
  1409. func (m *AgentMutation) ResetEdge(name string) error {
  1410. switch name {
  1411. case agent.EdgeWxAgent:
  1412. m.ResetWxAgent()
  1413. return nil
  1414. case agent.EdgeTokenAgent:
  1415. m.ResetTokenAgent()
  1416. return nil
  1417. case agent.EdgeWaAgent:
  1418. m.ResetWaAgent()
  1419. return nil
  1420. case agent.EdgeXjsAgent:
  1421. m.ResetXjsAgent()
  1422. return nil
  1423. case agent.EdgeKeyAgent:
  1424. m.ResetKeyAgent()
  1425. return nil
  1426. }
  1427. return fmt.Errorf("unknown Agent edge %s", name)
  1428. }
  1429. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1430. type AgentBaseMutation struct {
  1431. config
  1432. op Op
  1433. typ string
  1434. id *string
  1435. q *string
  1436. a *string
  1437. chunk_index *uint64
  1438. addchunk_index *int64
  1439. indexes *[]string
  1440. appendindexes []string
  1441. dataset_id *string
  1442. collection_id *string
  1443. source_name *string
  1444. can_write *[]bool
  1445. appendcan_write []bool
  1446. is_owner *[]bool
  1447. appendis_owner []bool
  1448. clearedFields map[string]struct{}
  1449. wx_agent map[uint64]struct{}
  1450. removedwx_agent map[uint64]struct{}
  1451. clearedwx_agent bool
  1452. done bool
  1453. oldValue func(context.Context) (*AgentBase, error)
  1454. predicates []predicate.AgentBase
  1455. }
  1456. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1457. // agentbaseOption allows management of the mutation configuration using functional options.
  1458. type agentbaseOption func(*AgentBaseMutation)
  1459. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1460. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1461. m := &AgentBaseMutation{
  1462. config: c,
  1463. op: op,
  1464. typ: TypeAgentBase,
  1465. clearedFields: make(map[string]struct{}),
  1466. }
  1467. for _, opt := range opts {
  1468. opt(m)
  1469. }
  1470. return m
  1471. }
  1472. // withAgentBaseID sets the ID field of the mutation.
  1473. func withAgentBaseID(id string) agentbaseOption {
  1474. return func(m *AgentBaseMutation) {
  1475. var (
  1476. err error
  1477. once sync.Once
  1478. value *AgentBase
  1479. )
  1480. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1481. once.Do(func() {
  1482. if m.done {
  1483. err = errors.New("querying old values post mutation is not allowed")
  1484. } else {
  1485. value, err = m.Client().AgentBase.Get(ctx, id)
  1486. }
  1487. })
  1488. return value, err
  1489. }
  1490. m.id = &id
  1491. }
  1492. }
  1493. // withAgentBase sets the old AgentBase of the mutation.
  1494. func withAgentBase(node *AgentBase) agentbaseOption {
  1495. return func(m *AgentBaseMutation) {
  1496. m.oldValue = func(context.Context) (*AgentBase, error) {
  1497. return node, nil
  1498. }
  1499. m.id = &node.ID
  1500. }
  1501. }
  1502. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1503. // executed in a transaction (ent.Tx), a transactional client is returned.
  1504. func (m AgentBaseMutation) Client() *Client {
  1505. client := &Client{config: m.config}
  1506. client.init()
  1507. return client
  1508. }
  1509. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1510. // it returns an error otherwise.
  1511. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1512. if _, ok := m.driver.(*txDriver); !ok {
  1513. return nil, errors.New("ent: mutation is not running in a transaction")
  1514. }
  1515. tx := &Tx{config: m.config}
  1516. tx.init()
  1517. return tx, nil
  1518. }
  1519. // SetID sets the value of the id field. Note that this
  1520. // operation is only accepted on creation of AgentBase entities.
  1521. func (m *AgentBaseMutation) SetID(id string) {
  1522. m.id = &id
  1523. }
  1524. // ID returns the ID value in the mutation. Note that the ID is only available
  1525. // if it was provided to the builder or after it was returned from the database.
  1526. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1527. if m.id == nil {
  1528. return
  1529. }
  1530. return *m.id, true
  1531. }
  1532. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1533. // That means, if the mutation is applied within a transaction with an isolation level such
  1534. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1535. // or updated by the mutation.
  1536. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1537. switch {
  1538. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1539. id, exists := m.ID()
  1540. if exists {
  1541. return []string{id}, nil
  1542. }
  1543. fallthrough
  1544. case m.op.Is(OpUpdate | OpDelete):
  1545. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1546. default:
  1547. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1548. }
  1549. }
  1550. // SetQ sets the "q" field.
  1551. func (m *AgentBaseMutation) SetQ(s string) {
  1552. m.q = &s
  1553. }
  1554. // Q returns the value of the "q" field in the mutation.
  1555. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1556. v := m.q
  1557. if v == nil {
  1558. return
  1559. }
  1560. return *v, true
  1561. }
  1562. // OldQ returns the old "q" field's value of the AgentBase entity.
  1563. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1565. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1566. if !m.op.Is(OpUpdateOne) {
  1567. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1568. }
  1569. if m.id == nil || m.oldValue == nil {
  1570. return v, errors.New("OldQ requires an ID field in the mutation")
  1571. }
  1572. oldValue, err := m.oldValue(ctx)
  1573. if err != nil {
  1574. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1575. }
  1576. return oldValue.Q, nil
  1577. }
  1578. // ClearQ clears the value of the "q" field.
  1579. func (m *AgentBaseMutation) ClearQ() {
  1580. m.q = nil
  1581. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1582. }
  1583. // QCleared returns if the "q" field was cleared in this mutation.
  1584. func (m *AgentBaseMutation) QCleared() bool {
  1585. _, ok := m.clearedFields[agentbase.FieldQ]
  1586. return ok
  1587. }
  1588. // ResetQ resets all changes to the "q" field.
  1589. func (m *AgentBaseMutation) ResetQ() {
  1590. m.q = nil
  1591. delete(m.clearedFields, agentbase.FieldQ)
  1592. }
  1593. // SetA sets the "a" field.
  1594. func (m *AgentBaseMutation) SetA(s string) {
  1595. m.a = &s
  1596. }
  1597. // A returns the value of the "a" field in the mutation.
  1598. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1599. v := m.a
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldA returns the old "a" field's value of the AgentBase entity.
  1606. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldA requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1618. }
  1619. return oldValue.A, nil
  1620. }
  1621. // ClearA clears the value of the "a" field.
  1622. func (m *AgentBaseMutation) ClearA() {
  1623. m.a = nil
  1624. m.clearedFields[agentbase.FieldA] = struct{}{}
  1625. }
  1626. // ACleared returns if the "a" field was cleared in this mutation.
  1627. func (m *AgentBaseMutation) ACleared() bool {
  1628. _, ok := m.clearedFields[agentbase.FieldA]
  1629. return ok
  1630. }
  1631. // ResetA resets all changes to the "a" field.
  1632. func (m *AgentBaseMutation) ResetA() {
  1633. m.a = nil
  1634. delete(m.clearedFields, agentbase.FieldA)
  1635. }
  1636. // SetChunkIndex sets the "chunk_index" field.
  1637. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1638. m.chunk_index = &u
  1639. m.addchunk_index = nil
  1640. }
  1641. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1642. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1643. v := m.chunk_index
  1644. if v == nil {
  1645. return
  1646. }
  1647. return *v, true
  1648. }
  1649. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1650. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1652. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1653. if !m.op.Is(OpUpdateOne) {
  1654. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1655. }
  1656. if m.id == nil || m.oldValue == nil {
  1657. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1658. }
  1659. oldValue, err := m.oldValue(ctx)
  1660. if err != nil {
  1661. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1662. }
  1663. return oldValue.ChunkIndex, nil
  1664. }
  1665. // AddChunkIndex adds u to the "chunk_index" field.
  1666. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1667. if m.addchunk_index != nil {
  1668. *m.addchunk_index += u
  1669. } else {
  1670. m.addchunk_index = &u
  1671. }
  1672. }
  1673. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1674. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1675. v := m.addchunk_index
  1676. if v == nil {
  1677. return
  1678. }
  1679. return *v, true
  1680. }
  1681. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1682. func (m *AgentBaseMutation) ResetChunkIndex() {
  1683. m.chunk_index = nil
  1684. m.addchunk_index = nil
  1685. }
  1686. // SetIndexes sets the "indexes" field.
  1687. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1688. m.indexes = &s
  1689. m.appendindexes = nil
  1690. }
  1691. // Indexes returns the value of the "indexes" field in the mutation.
  1692. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1693. v := m.indexes
  1694. if v == nil {
  1695. return
  1696. }
  1697. return *v, true
  1698. }
  1699. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1700. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1702. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1703. if !m.op.Is(OpUpdateOne) {
  1704. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1705. }
  1706. if m.id == nil || m.oldValue == nil {
  1707. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1708. }
  1709. oldValue, err := m.oldValue(ctx)
  1710. if err != nil {
  1711. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1712. }
  1713. return oldValue.Indexes, nil
  1714. }
  1715. // AppendIndexes adds s to the "indexes" field.
  1716. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1717. m.appendindexes = append(m.appendindexes, s...)
  1718. }
  1719. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1720. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1721. if len(m.appendindexes) == 0 {
  1722. return nil, false
  1723. }
  1724. return m.appendindexes, true
  1725. }
  1726. // ClearIndexes clears the value of the "indexes" field.
  1727. func (m *AgentBaseMutation) ClearIndexes() {
  1728. m.indexes = nil
  1729. m.appendindexes = nil
  1730. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1731. }
  1732. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1733. func (m *AgentBaseMutation) IndexesCleared() bool {
  1734. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1735. return ok
  1736. }
  1737. // ResetIndexes resets all changes to the "indexes" field.
  1738. func (m *AgentBaseMutation) ResetIndexes() {
  1739. m.indexes = nil
  1740. m.appendindexes = nil
  1741. delete(m.clearedFields, agentbase.FieldIndexes)
  1742. }
  1743. // SetDatasetID sets the "dataset_id" field.
  1744. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1745. m.dataset_id = &s
  1746. }
  1747. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1748. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1749. v := m.dataset_id
  1750. if v == nil {
  1751. return
  1752. }
  1753. return *v, true
  1754. }
  1755. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1756. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1758. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1759. if !m.op.Is(OpUpdateOne) {
  1760. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1761. }
  1762. if m.id == nil || m.oldValue == nil {
  1763. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1764. }
  1765. oldValue, err := m.oldValue(ctx)
  1766. if err != nil {
  1767. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1768. }
  1769. return oldValue.DatasetID, nil
  1770. }
  1771. // ClearDatasetID clears the value of the "dataset_id" field.
  1772. func (m *AgentBaseMutation) ClearDatasetID() {
  1773. m.dataset_id = nil
  1774. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1775. }
  1776. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1777. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1778. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1779. return ok
  1780. }
  1781. // ResetDatasetID resets all changes to the "dataset_id" field.
  1782. func (m *AgentBaseMutation) ResetDatasetID() {
  1783. m.dataset_id = nil
  1784. delete(m.clearedFields, agentbase.FieldDatasetID)
  1785. }
  1786. // SetCollectionID sets the "collection_id" field.
  1787. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1788. m.collection_id = &s
  1789. }
  1790. // CollectionID returns the value of the "collection_id" field in the mutation.
  1791. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1792. v := m.collection_id
  1793. if v == nil {
  1794. return
  1795. }
  1796. return *v, true
  1797. }
  1798. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1799. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1801. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1802. if !m.op.Is(OpUpdateOne) {
  1803. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1804. }
  1805. if m.id == nil || m.oldValue == nil {
  1806. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1807. }
  1808. oldValue, err := m.oldValue(ctx)
  1809. if err != nil {
  1810. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1811. }
  1812. return oldValue.CollectionID, nil
  1813. }
  1814. // ClearCollectionID clears the value of the "collection_id" field.
  1815. func (m *AgentBaseMutation) ClearCollectionID() {
  1816. m.collection_id = nil
  1817. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1818. }
  1819. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1820. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1821. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1822. return ok
  1823. }
  1824. // ResetCollectionID resets all changes to the "collection_id" field.
  1825. func (m *AgentBaseMutation) ResetCollectionID() {
  1826. m.collection_id = nil
  1827. delete(m.clearedFields, agentbase.FieldCollectionID)
  1828. }
  1829. // SetSourceName sets the "source_name" field.
  1830. func (m *AgentBaseMutation) SetSourceName(s string) {
  1831. m.source_name = &s
  1832. }
  1833. // SourceName returns the value of the "source_name" field in the mutation.
  1834. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1835. v := m.source_name
  1836. if v == nil {
  1837. return
  1838. }
  1839. return *v, true
  1840. }
  1841. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1842. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1844. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1845. if !m.op.Is(OpUpdateOne) {
  1846. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1847. }
  1848. if m.id == nil || m.oldValue == nil {
  1849. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1850. }
  1851. oldValue, err := m.oldValue(ctx)
  1852. if err != nil {
  1853. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1854. }
  1855. return oldValue.SourceName, nil
  1856. }
  1857. // ClearSourceName clears the value of the "source_name" field.
  1858. func (m *AgentBaseMutation) ClearSourceName() {
  1859. m.source_name = nil
  1860. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1861. }
  1862. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1863. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1864. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1865. return ok
  1866. }
  1867. // ResetSourceName resets all changes to the "source_name" field.
  1868. func (m *AgentBaseMutation) ResetSourceName() {
  1869. m.source_name = nil
  1870. delete(m.clearedFields, agentbase.FieldSourceName)
  1871. }
  1872. // SetCanWrite sets the "can_write" field.
  1873. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1874. m.can_write = &b
  1875. m.appendcan_write = nil
  1876. }
  1877. // CanWrite returns the value of the "can_write" field in the mutation.
  1878. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1879. v := m.can_write
  1880. if v == nil {
  1881. return
  1882. }
  1883. return *v, true
  1884. }
  1885. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1886. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1888. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1889. if !m.op.Is(OpUpdateOne) {
  1890. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1891. }
  1892. if m.id == nil || m.oldValue == nil {
  1893. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1894. }
  1895. oldValue, err := m.oldValue(ctx)
  1896. if err != nil {
  1897. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1898. }
  1899. return oldValue.CanWrite, nil
  1900. }
  1901. // AppendCanWrite adds b to the "can_write" field.
  1902. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1903. m.appendcan_write = append(m.appendcan_write, b...)
  1904. }
  1905. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1906. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1907. if len(m.appendcan_write) == 0 {
  1908. return nil, false
  1909. }
  1910. return m.appendcan_write, true
  1911. }
  1912. // ClearCanWrite clears the value of the "can_write" field.
  1913. func (m *AgentBaseMutation) ClearCanWrite() {
  1914. m.can_write = nil
  1915. m.appendcan_write = nil
  1916. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1917. }
  1918. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1919. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1920. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1921. return ok
  1922. }
  1923. // ResetCanWrite resets all changes to the "can_write" field.
  1924. func (m *AgentBaseMutation) ResetCanWrite() {
  1925. m.can_write = nil
  1926. m.appendcan_write = nil
  1927. delete(m.clearedFields, agentbase.FieldCanWrite)
  1928. }
  1929. // SetIsOwner sets the "is_owner" field.
  1930. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1931. m.is_owner = &b
  1932. m.appendis_owner = nil
  1933. }
  1934. // IsOwner returns the value of the "is_owner" field in the mutation.
  1935. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1936. v := m.is_owner
  1937. if v == nil {
  1938. return
  1939. }
  1940. return *v, true
  1941. }
  1942. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1943. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1945. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1946. if !m.op.Is(OpUpdateOne) {
  1947. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1948. }
  1949. if m.id == nil || m.oldValue == nil {
  1950. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1951. }
  1952. oldValue, err := m.oldValue(ctx)
  1953. if err != nil {
  1954. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1955. }
  1956. return oldValue.IsOwner, nil
  1957. }
  1958. // AppendIsOwner adds b to the "is_owner" field.
  1959. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1960. m.appendis_owner = append(m.appendis_owner, b...)
  1961. }
  1962. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1963. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1964. if len(m.appendis_owner) == 0 {
  1965. return nil, false
  1966. }
  1967. return m.appendis_owner, true
  1968. }
  1969. // ClearIsOwner clears the value of the "is_owner" field.
  1970. func (m *AgentBaseMutation) ClearIsOwner() {
  1971. m.is_owner = nil
  1972. m.appendis_owner = nil
  1973. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1974. }
  1975. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1976. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1977. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1978. return ok
  1979. }
  1980. // ResetIsOwner resets all changes to the "is_owner" field.
  1981. func (m *AgentBaseMutation) ResetIsOwner() {
  1982. m.is_owner = nil
  1983. m.appendis_owner = nil
  1984. delete(m.clearedFields, agentbase.FieldIsOwner)
  1985. }
  1986. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1987. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1988. if m.wx_agent == nil {
  1989. m.wx_agent = make(map[uint64]struct{})
  1990. }
  1991. for i := range ids {
  1992. m.wx_agent[ids[i]] = struct{}{}
  1993. }
  1994. }
  1995. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1996. func (m *AgentBaseMutation) ClearWxAgent() {
  1997. m.clearedwx_agent = true
  1998. }
  1999. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2000. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2001. return m.clearedwx_agent
  2002. }
  2003. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2004. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2005. if m.removedwx_agent == nil {
  2006. m.removedwx_agent = make(map[uint64]struct{})
  2007. }
  2008. for i := range ids {
  2009. delete(m.wx_agent, ids[i])
  2010. m.removedwx_agent[ids[i]] = struct{}{}
  2011. }
  2012. }
  2013. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2014. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2015. for id := range m.removedwx_agent {
  2016. ids = append(ids, id)
  2017. }
  2018. return
  2019. }
  2020. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2021. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2022. for id := range m.wx_agent {
  2023. ids = append(ids, id)
  2024. }
  2025. return
  2026. }
  2027. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2028. func (m *AgentBaseMutation) ResetWxAgent() {
  2029. m.wx_agent = nil
  2030. m.clearedwx_agent = false
  2031. m.removedwx_agent = nil
  2032. }
  2033. // Where appends a list predicates to the AgentBaseMutation builder.
  2034. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2035. m.predicates = append(m.predicates, ps...)
  2036. }
  2037. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2038. // users can use type-assertion to append predicates that do not depend on any generated package.
  2039. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2040. p := make([]predicate.AgentBase, len(ps))
  2041. for i := range ps {
  2042. p[i] = ps[i]
  2043. }
  2044. m.Where(p...)
  2045. }
  2046. // Op returns the operation name.
  2047. func (m *AgentBaseMutation) Op() Op {
  2048. return m.op
  2049. }
  2050. // SetOp allows setting the mutation operation.
  2051. func (m *AgentBaseMutation) SetOp(op Op) {
  2052. m.op = op
  2053. }
  2054. // Type returns the node type of this mutation (AgentBase).
  2055. func (m *AgentBaseMutation) Type() string {
  2056. return m.typ
  2057. }
  2058. // Fields returns all fields that were changed during this mutation. Note that in
  2059. // order to get all numeric fields that were incremented/decremented, call
  2060. // AddedFields().
  2061. func (m *AgentBaseMutation) Fields() []string {
  2062. fields := make([]string, 0, 9)
  2063. if m.q != nil {
  2064. fields = append(fields, agentbase.FieldQ)
  2065. }
  2066. if m.a != nil {
  2067. fields = append(fields, agentbase.FieldA)
  2068. }
  2069. if m.chunk_index != nil {
  2070. fields = append(fields, agentbase.FieldChunkIndex)
  2071. }
  2072. if m.indexes != nil {
  2073. fields = append(fields, agentbase.FieldIndexes)
  2074. }
  2075. if m.dataset_id != nil {
  2076. fields = append(fields, agentbase.FieldDatasetID)
  2077. }
  2078. if m.collection_id != nil {
  2079. fields = append(fields, agentbase.FieldCollectionID)
  2080. }
  2081. if m.source_name != nil {
  2082. fields = append(fields, agentbase.FieldSourceName)
  2083. }
  2084. if m.can_write != nil {
  2085. fields = append(fields, agentbase.FieldCanWrite)
  2086. }
  2087. if m.is_owner != nil {
  2088. fields = append(fields, agentbase.FieldIsOwner)
  2089. }
  2090. return fields
  2091. }
  2092. // Field returns the value of a field with the given name. The second boolean
  2093. // return value indicates that this field was not set, or was not defined in the
  2094. // schema.
  2095. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2096. switch name {
  2097. case agentbase.FieldQ:
  2098. return m.Q()
  2099. case agentbase.FieldA:
  2100. return m.A()
  2101. case agentbase.FieldChunkIndex:
  2102. return m.ChunkIndex()
  2103. case agentbase.FieldIndexes:
  2104. return m.Indexes()
  2105. case agentbase.FieldDatasetID:
  2106. return m.DatasetID()
  2107. case agentbase.FieldCollectionID:
  2108. return m.CollectionID()
  2109. case agentbase.FieldSourceName:
  2110. return m.SourceName()
  2111. case agentbase.FieldCanWrite:
  2112. return m.CanWrite()
  2113. case agentbase.FieldIsOwner:
  2114. return m.IsOwner()
  2115. }
  2116. return nil, false
  2117. }
  2118. // OldField returns the old value of the field from the database. An error is
  2119. // returned if the mutation operation is not UpdateOne, or the query to the
  2120. // database failed.
  2121. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2122. switch name {
  2123. case agentbase.FieldQ:
  2124. return m.OldQ(ctx)
  2125. case agentbase.FieldA:
  2126. return m.OldA(ctx)
  2127. case agentbase.FieldChunkIndex:
  2128. return m.OldChunkIndex(ctx)
  2129. case agentbase.FieldIndexes:
  2130. return m.OldIndexes(ctx)
  2131. case agentbase.FieldDatasetID:
  2132. return m.OldDatasetID(ctx)
  2133. case agentbase.FieldCollectionID:
  2134. return m.OldCollectionID(ctx)
  2135. case agentbase.FieldSourceName:
  2136. return m.OldSourceName(ctx)
  2137. case agentbase.FieldCanWrite:
  2138. return m.OldCanWrite(ctx)
  2139. case agentbase.FieldIsOwner:
  2140. return m.OldIsOwner(ctx)
  2141. }
  2142. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2143. }
  2144. // SetField sets the value of a field with the given name. It returns an error if
  2145. // the field is not defined in the schema, or if the type mismatched the field
  2146. // type.
  2147. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2148. switch name {
  2149. case agentbase.FieldQ:
  2150. v, ok := value.(string)
  2151. if !ok {
  2152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2153. }
  2154. m.SetQ(v)
  2155. return nil
  2156. case agentbase.FieldA:
  2157. v, ok := value.(string)
  2158. if !ok {
  2159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2160. }
  2161. m.SetA(v)
  2162. return nil
  2163. case agentbase.FieldChunkIndex:
  2164. v, ok := value.(uint64)
  2165. if !ok {
  2166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2167. }
  2168. m.SetChunkIndex(v)
  2169. return nil
  2170. case agentbase.FieldIndexes:
  2171. v, ok := value.([]string)
  2172. if !ok {
  2173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2174. }
  2175. m.SetIndexes(v)
  2176. return nil
  2177. case agentbase.FieldDatasetID:
  2178. v, ok := value.(string)
  2179. if !ok {
  2180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2181. }
  2182. m.SetDatasetID(v)
  2183. return nil
  2184. case agentbase.FieldCollectionID:
  2185. v, ok := value.(string)
  2186. if !ok {
  2187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2188. }
  2189. m.SetCollectionID(v)
  2190. return nil
  2191. case agentbase.FieldSourceName:
  2192. v, ok := value.(string)
  2193. if !ok {
  2194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2195. }
  2196. m.SetSourceName(v)
  2197. return nil
  2198. case agentbase.FieldCanWrite:
  2199. v, ok := value.([]bool)
  2200. if !ok {
  2201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2202. }
  2203. m.SetCanWrite(v)
  2204. return nil
  2205. case agentbase.FieldIsOwner:
  2206. v, ok := value.([]bool)
  2207. if !ok {
  2208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2209. }
  2210. m.SetIsOwner(v)
  2211. return nil
  2212. }
  2213. return fmt.Errorf("unknown AgentBase field %s", name)
  2214. }
  2215. // AddedFields returns all numeric fields that were incremented/decremented during
  2216. // this mutation.
  2217. func (m *AgentBaseMutation) AddedFields() []string {
  2218. var fields []string
  2219. if m.addchunk_index != nil {
  2220. fields = append(fields, agentbase.FieldChunkIndex)
  2221. }
  2222. return fields
  2223. }
  2224. // AddedField returns the numeric value that was incremented/decremented on a field
  2225. // with the given name. The second boolean return value indicates that this field
  2226. // was not set, or was not defined in the schema.
  2227. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2228. switch name {
  2229. case agentbase.FieldChunkIndex:
  2230. return m.AddedChunkIndex()
  2231. }
  2232. return nil, false
  2233. }
  2234. // AddField adds the value to the field with the given name. It returns an error if
  2235. // the field is not defined in the schema, or if the type mismatched the field
  2236. // type.
  2237. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2238. switch name {
  2239. case agentbase.FieldChunkIndex:
  2240. v, ok := value.(int64)
  2241. if !ok {
  2242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2243. }
  2244. m.AddChunkIndex(v)
  2245. return nil
  2246. }
  2247. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2248. }
  2249. // ClearedFields returns all nullable fields that were cleared during this
  2250. // mutation.
  2251. func (m *AgentBaseMutation) ClearedFields() []string {
  2252. var fields []string
  2253. if m.FieldCleared(agentbase.FieldQ) {
  2254. fields = append(fields, agentbase.FieldQ)
  2255. }
  2256. if m.FieldCleared(agentbase.FieldA) {
  2257. fields = append(fields, agentbase.FieldA)
  2258. }
  2259. if m.FieldCleared(agentbase.FieldIndexes) {
  2260. fields = append(fields, agentbase.FieldIndexes)
  2261. }
  2262. if m.FieldCleared(agentbase.FieldDatasetID) {
  2263. fields = append(fields, agentbase.FieldDatasetID)
  2264. }
  2265. if m.FieldCleared(agentbase.FieldCollectionID) {
  2266. fields = append(fields, agentbase.FieldCollectionID)
  2267. }
  2268. if m.FieldCleared(agentbase.FieldSourceName) {
  2269. fields = append(fields, agentbase.FieldSourceName)
  2270. }
  2271. if m.FieldCleared(agentbase.FieldCanWrite) {
  2272. fields = append(fields, agentbase.FieldCanWrite)
  2273. }
  2274. if m.FieldCleared(agentbase.FieldIsOwner) {
  2275. fields = append(fields, agentbase.FieldIsOwner)
  2276. }
  2277. return fields
  2278. }
  2279. // FieldCleared returns a boolean indicating if a field with the given name was
  2280. // cleared in this mutation.
  2281. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2282. _, ok := m.clearedFields[name]
  2283. return ok
  2284. }
  2285. // ClearField clears the value of the field with the given name. It returns an
  2286. // error if the field is not defined in the schema.
  2287. func (m *AgentBaseMutation) ClearField(name string) error {
  2288. switch name {
  2289. case agentbase.FieldQ:
  2290. m.ClearQ()
  2291. return nil
  2292. case agentbase.FieldA:
  2293. m.ClearA()
  2294. return nil
  2295. case agentbase.FieldIndexes:
  2296. m.ClearIndexes()
  2297. return nil
  2298. case agentbase.FieldDatasetID:
  2299. m.ClearDatasetID()
  2300. return nil
  2301. case agentbase.FieldCollectionID:
  2302. m.ClearCollectionID()
  2303. return nil
  2304. case agentbase.FieldSourceName:
  2305. m.ClearSourceName()
  2306. return nil
  2307. case agentbase.FieldCanWrite:
  2308. m.ClearCanWrite()
  2309. return nil
  2310. case agentbase.FieldIsOwner:
  2311. m.ClearIsOwner()
  2312. return nil
  2313. }
  2314. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2315. }
  2316. // ResetField resets all changes in the mutation for the field with the given name.
  2317. // It returns an error if the field is not defined in the schema.
  2318. func (m *AgentBaseMutation) ResetField(name string) error {
  2319. switch name {
  2320. case agentbase.FieldQ:
  2321. m.ResetQ()
  2322. return nil
  2323. case agentbase.FieldA:
  2324. m.ResetA()
  2325. return nil
  2326. case agentbase.FieldChunkIndex:
  2327. m.ResetChunkIndex()
  2328. return nil
  2329. case agentbase.FieldIndexes:
  2330. m.ResetIndexes()
  2331. return nil
  2332. case agentbase.FieldDatasetID:
  2333. m.ResetDatasetID()
  2334. return nil
  2335. case agentbase.FieldCollectionID:
  2336. m.ResetCollectionID()
  2337. return nil
  2338. case agentbase.FieldSourceName:
  2339. m.ResetSourceName()
  2340. return nil
  2341. case agentbase.FieldCanWrite:
  2342. m.ResetCanWrite()
  2343. return nil
  2344. case agentbase.FieldIsOwner:
  2345. m.ResetIsOwner()
  2346. return nil
  2347. }
  2348. return fmt.Errorf("unknown AgentBase field %s", name)
  2349. }
  2350. // AddedEdges returns all edge names that were set/added in this mutation.
  2351. func (m *AgentBaseMutation) AddedEdges() []string {
  2352. edges := make([]string, 0, 1)
  2353. if m.wx_agent != nil {
  2354. edges = append(edges, agentbase.EdgeWxAgent)
  2355. }
  2356. return edges
  2357. }
  2358. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2359. // name in this mutation.
  2360. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2361. switch name {
  2362. case agentbase.EdgeWxAgent:
  2363. ids := make([]ent.Value, 0, len(m.wx_agent))
  2364. for id := range m.wx_agent {
  2365. ids = append(ids, id)
  2366. }
  2367. return ids
  2368. }
  2369. return nil
  2370. }
  2371. // RemovedEdges returns all edge names that were removed in this mutation.
  2372. func (m *AgentBaseMutation) RemovedEdges() []string {
  2373. edges := make([]string, 0, 1)
  2374. if m.removedwx_agent != nil {
  2375. edges = append(edges, agentbase.EdgeWxAgent)
  2376. }
  2377. return edges
  2378. }
  2379. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2380. // the given name in this mutation.
  2381. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2382. switch name {
  2383. case agentbase.EdgeWxAgent:
  2384. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2385. for id := range m.removedwx_agent {
  2386. ids = append(ids, id)
  2387. }
  2388. return ids
  2389. }
  2390. return nil
  2391. }
  2392. // ClearedEdges returns all edge names that were cleared in this mutation.
  2393. func (m *AgentBaseMutation) ClearedEdges() []string {
  2394. edges := make([]string, 0, 1)
  2395. if m.clearedwx_agent {
  2396. edges = append(edges, agentbase.EdgeWxAgent)
  2397. }
  2398. return edges
  2399. }
  2400. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2401. // was cleared in this mutation.
  2402. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2403. switch name {
  2404. case agentbase.EdgeWxAgent:
  2405. return m.clearedwx_agent
  2406. }
  2407. return false
  2408. }
  2409. // ClearEdge clears the value of the edge with the given name. It returns an error
  2410. // if that edge is not defined in the schema.
  2411. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2412. switch name {
  2413. }
  2414. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2415. }
  2416. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2417. // It returns an error if the edge is not defined in the schema.
  2418. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2419. switch name {
  2420. case agentbase.EdgeWxAgent:
  2421. m.ResetWxAgent()
  2422. return nil
  2423. }
  2424. return fmt.Errorf("unknown AgentBase edge %s", name)
  2425. }
  2426. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2427. type AliyunAvatarMutation struct {
  2428. config
  2429. op Op
  2430. typ string
  2431. id *uint64
  2432. created_at *time.Time
  2433. updated_at *time.Time
  2434. deleted_at *time.Time
  2435. user_id *uint64
  2436. adduser_id *int64
  2437. biz_id *string
  2438. access_key_id *string
  2439. access_key_secret *string
  2440. app_id *string
  2441. tenant_id *uint64
  2442. addtenant_id *int64
  2443. response *string
  2444. token *string
  2445. session_id *string
  2446. clearedFields map[string]struct{}
  2447. done bool
  2448. oldValue func(context.Context) (*AliyunAvatar, error)
  2449. predicates []predicate.AliyunAvatar
  2450. }
  2451. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2452. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2453. type aliyunavatarOption func(*AliyunAvatarMutation)
  2454. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2455. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2456. m := &AliyunAvatarMutation{
  2457. config: c,
  2458. op: op,
  2459. typ: TypeAliyunAvatar,
  2460. clearedFields: make(map[string]struct{}),
  2461. }
  2462. for _, opt := range opts {
  2463. opt(m)
  2464. }
  2465. return m
  2466. }
  2467. // withAliyunAvatarID sets the ID field of the mutation.
  2468. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2469. return func(m *AliyunAvatarMutation) {
  2470. var (
  2471. err error
  2472. once sync.Once
  2473. value *AliyunAvatar
  2474. )
  2475. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2476. once.Do(func() {
  2477. if m.done {
  2478. err = errors.New("querying old values post mutation is not allowed")
  2479. } else {
  2480. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2481. }
  2482. })
  2483. return value, err
  2484. }
  2485. m.id = &id
  2486. }
  2487. }
  2488. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2489. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2490. return func(m *AliyunAvatarMutation) {
  2491. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2492. return node, nil
  2493. }
  2494. m.id = &node.ID
  2495. }
  2496. }
  2497. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2498. // executed in a transaction (ent.Tx), a transactional client is returned.
  2499. func (m AliyunAvatarMutation) Client() *Client {
  2500. client := &Client{config: m.config}
  2501. client.init()
  2502. return client
  2503. }
  2504. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2505. // it returns an error otherwise.
  2506. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2507. if _, ok := m.driver.(*txDriver); !ok {
  2508. return nil, errors.New("ent: mutation is not running in a transaction")
  2509. }
  2510. tx := &Tx{config: m.config}
  2511. tx.init()
  2512. return tx, nil
  2513. }
  2514. // SetID sets the value of the id field. Note that this
  2515. // operation is only accepted on creation of AliyunAvatar entities.
  2516. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2517. m.id = &id
  2518. }
  2519. // ID returns the ID value in the mutation. Note that the ID is only available
  2520. // if it was provided to the builder or after it was returned from the database.
  2521. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2522. if m.id == nil {
  2523. return
  2524. }
  2525. return *m.id, true
  2526. }
  2527. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2528. // That means, if the mutation is applied within a transaction with an isolation level such
  2529. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2530. // or updated by the mutation.
  2531. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2532. switch {
  2533. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2534. id, exists := m.ID()
  2535. if exists {
  2536. return []uint64{id}, nil
  2537. }
  2538. fallthrough
  2539. case m.op.Is(OpUpdate | OpDelete):
  2540. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2541. default:
  2542. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2543. }
  2544. }
  2545. // SetCreatedAt sets the "created_at" field.
  2546. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2547. m.created_at = &t
  2548. }
  2549. // CreatedAt returns the value of the "created_at" field in the mutation.
  2550. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2551. v := m.created_at
  2552. if v == nil {
  2553. return
  2554. }
  2555. return *v, true
  2556. }
  2557. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2558. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2560. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2561. if !m.op.Is(OpUpdateOne) {
  2562. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2563. }
  2564. if m.id == nil || m.oldValue == nil {
  2565. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2566. }
  2567. oldValue, err := m.oldValue(ctx)
  2568. if err != nil {
  2569. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2570. }
  2571. return oldValue.CreatedAt, nil
  2572. }
  2573. // ResetCreatedAt resets all changes to the "created_at" field.
  2574. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2575. m.created_at = nil
  2576. }
  2577. // SetUpdatedAt sets the "updated_at" field.
  2578. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2579. m.updated_at = &t
  2580. }
  2581. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2582. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2583. v := m.updated_at
  2584. if v == nil {
  2585. return
  2586. }
  2587. return *v, true
  2588. }
  2589. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2590. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2592. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2593. if !m.op.Is(OpUpdateOne) {
  2594. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2595. }
  2596. if m.id == nil || m.oldValue == nil {
  2597. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2598. }
  2599. oldValue, err := m.oldValue(ctx)
  2600. if err != nil {
  2601. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2602. }
  2603. return oldValue.UpdatedAt, nil
  2604. }
  2605. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2606. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2607. m.updated_at = nil
  2608. }
  2609. // SetDeletedAt sets the "deleted_at" field.
  2610. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2611. m.deleted_at = &t
  2612. }
  2613. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2614. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2615. v := m.deleted_at
  2616. if v == nil {
  2617. return
  2618. }
  2619. return *v, true
  2620. }
  2621. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2622. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2624. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2625. if !m.op.Is(OpUpdateOne) {
  2626. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2627. }
  2628. if m.id == nil || m.oldValue == nil {
  2629. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2630. }
  2631. oldValue, err := m.oldValue(ctx)
  2632. if err != nil {
  2633. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2634. }
  2635. return oldValue.DeletedAt, nil
  2636. }
  2637. // ClearDeletedAt clears the value of the "deleted_at" field.
  2638. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2639. m.deleted_at = nil
  2640. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2641. }
  2642. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2643. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2644. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2645. return ok
  2646. }
  2647. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2648. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2649. m.deleted_at = nil
  2650. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2651. }
  2652. // SetUserID sets the "user_id" field.
  2653. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2654. m.user_id = &u
  2655. m.adduser_id = nil
  2656. }
  2657. // UserID returns the value of the "user_id" field in the mutation.
  2658. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2659. v := m.user_id
  2660. if v == nil {
  2661. return
  2662. }
  2663. return *v, true
  2664. }
  2665. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2666. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2668. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2669. if !m.op.Is(OpUpdateOne) {
  2670. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2671. }
  2672. if m.id == nil || m.oldValue == nil {
  2673. return v, errors.New("OldUserID requires an ID field in the mutation")
  2674. }
  2675. oldValue, err := m.oldValue(ctx)
  2676. if err != nil {
  2677. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2678. }
  2679. return oldValue.UserID, nil
  2680. }
  2681. // AddUserID adds u to the "user_id" field.
  2682. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2683. if m.adduser_id != nil {
  2684. *m.adduser_id += u
  2685. } else {
  2686. m.adduser_id = &u
  2687. }
  2688. }
  2689. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2690. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2691. v := m.adduser_id
  2692. if v == nil {
  2693. return
  2694. }
  2695. return *v, true
  2696. }
  2697. // ResetUserID resets all changes to the "user_id" field.
  2698. func (m *AliyunAvatarMutation) ResetUserID() {
  2699. m.user_id = nil
  2700. m.adduser_id = nil
  2701. }
  2702. // SetBizID sets the "biz_id" field.
  2703. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2704. m.biz_id = &s
  2705. }
  2706. // BizID returns the value of the "biz_id" field in the mutation.
  2707. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2708. v := m.biz_id
  2709. if v == nil {
  2710. return
  2711. }
  2712. return *v, true
  2713. }
  2714. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2715. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2717. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2718. if !m.op.Is(OpUpdateOne) {
  2719. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2720. }
  2721. if m.id == nil || m.oldValue == nil {
  2722. return v, errors.New("OldBizID requires an ID field in the mutation")
  2723. }
  2724. oldValue, err := m.oldValue(ctx)
  2725. if err != nil {
  2726. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2727. }
  2728. return oldValue.BizID, nil
  2729. }
  2730. // ResetBizID resets all changes to the "biz_id" field.
  2731. func (m *AliyunAvatarMutation) ResetBizID() {
  2732. m.biz_id = nil
  2733. }
  2734. // SetAccessKeyID sets the "access_key_id" field.
  2735. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2736. m.access_key_id = &s
  2737. }
  2738. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2739. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2740. v := m.access_key_id
  2741. if v == nil {
  2742. return
  2743. }
  2744. return *v, true
  2745. }
  2746. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2747. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2749. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2750. if !m.op.Is(OpUpdateOne) {
  2751. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2752. }
  2753. if m.id == nil || m.oldValue == nil {
  2754. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2755. }
  2756. oldValue, err := m.oldValue(ctx)
  2757. if err != nil {
  2758. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2759. }
  2760. return oldValue.AccessKeyID, nil
  2761. }
  2762. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2763. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2764. m.access_key_id = nil
  2765. }
  2766. // SetAccessKeySecret sets the "access_key_secret" field.
  2767. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2768. m.access_key_secret = &s
  2769. }
  2770. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2771. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2772. v := m.access_key_secret
  2773. if v == nil {
  2774. return
  2775. }
  2776. return *v, true
  2777. }
  2778. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2779. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2781. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2782. if !m.op.Is(OpUpdateOne) {
  2783. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2784. }
  2785. if m.id == nil || m.oldValue == nil {
  2786. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2787. }
  2788. oldValue, err := m.oldValue(ctx)
  2789. if err != nil {
  2790. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2791. }
  2792. return oldValue.AccessKeySecret, nil
  2793. }
  2794. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2795. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2796. m.access_key_secret = nil
  2797. }
  2798. // SetAppID sets the "app_id" field.
  2799. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2800. m.app_id = &s
  2801. }
  2802. // AppID returns the value of the "app_id" field in the mutation.
  2803. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2804. v := m.app_id
  2805. if v == nil {
  2806. return
  2807. }
  2808. return *v, true
  2809. }
  2810. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2811. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2813. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2814. if !m.op.Is(OpUpdateOne) {
  2815. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2816. }
  2817. if m.id == nil || m.oldValue == nil {
  2818. return v, errors.New("OldAppID requires an ID field in the mutation")
  2819. }
  2820. oldValue, err := m.oldValue(ctx)
  2821. if err != nil {
  2822. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2823. }
  2824. return oldValue.AppID, nil
  2825. }
  2826. // ClearAppID clears the value of the "app_id" field.
  2827. func (m *AliyunAvatarMutation) ClearAppID() {
  2828. m.app_id = nil
  2829. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2830. }
  2831. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2832. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2833. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2834. return ok
  2835. }
  2836. // ResetAppID resets all changes to the "app_id" field.
  2837. func (m *AliyunAvatarMutation) ResetAppID() {
  2838. m.app_id = nil
  2839. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2840. }
  2841. // SetTenantID sets the "tenant_id" field.
  2842. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2843. m.tenant_id = &u
  2844. m.addtenant_id = nil
  2845. }
  2846. // TenantID returns the value of the "tenant_id" field in the mutation.
  2847. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2848. v := m.tenant_id
  2849. if v == nil {
  2850. return
  2851. }
  2852. return *v, true
  2853. }
  2854. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2855. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2857. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2858. if !m.op.Is(OpUpdateOne) {
  2859. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2860. }
  2861. if m.id == nil || m.oldValue == nil {
  2862. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2863. }
  2864. oldValue, err := m.oldValue(ctx)
  2865. if err != nil {
  2866. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2867. }
  2868. return oldValue.TenantID, nil
  2869. }
  2870. // AddTenantID adds u to the "tenant_id" field.
  2871. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2872. if m.addtenant_id != nil {
  2873. *m.addtenant_id += u
  2874. } else {
  2875. m.addtenant_id = &u
  2876. }
  2877. }
  2878. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2879. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2880. v := m.addtenant_id
  2881. if v == nil {
  2882. return
  2883. }
  2884. return *v, true
  2885. }
  2886. // ResetTenantID resets all changes to the "tenant_id" field.
  2887. func (m *AliyunAvatarMutation) ResetTenantID() {
  2888. m.tenant_id = nil
  2889. m.addtenant_id = nil
  2890. }
  2891. // SetResponse sets the "response" field.
  2892. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2893. m.response = &s
  2894. }
  2895. // Response returns the value of the "response" field in the mutation.
  2896. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2897. v := m.response
  2898. if v == nil {
  2899. return
  2900. }
  2901. return *v, true
  2902. }
  2903. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2904. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2906. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2907. if !m.op.Is(OpUpdateOne) {
  2908. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2909. }
  2910. if m.id == nil || m.oldValue == nil {
  2911. return v, errors.New("OldResponse requires an ID field in the mutation")
  2912. }
  2913. oldValue, err := m.oldValue(ctx)
  2914. if err != nil {
  2915. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2916. }
  2917. return oldValue.Response, nil
  2918. }
  2919. // ResetResponse resets all changes to the "response" field.
  2920. func (m *AliyunAvatarMutation) ResetResponse() {
  2921. m.response = nil
  2922. }
  2923. // SetToken sets the "token" field.
  2924. func (m *AliyunAvatarMutation) SetToken(s string) {
  2925. m.token = &s
  2926. }
  2927. // Token returns the value of the "token" field in the mutation.
  2928. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2929. v := m.token
  2930. if v == nil {
  2931. return
  2932. }
  2933. return *v, true
  2934. }
  2935. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2936. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2938. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2939. if !m.op.Is(OpUpdateOne) {
  2940. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2941. }
  2942. if m.id == nil || m.oldValue == nil {
  2943. return v, errors.New("OldToken requires an ID field in the mutation")
  2944. }
  2945. oldValue, err := m.oldValue(ctx)
  2946. if err != nil {
  2947. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2948. }
  2949. return oldValue.Token, nil
  2950. }
  2951. // ResetToken resets all changes to the "token" field.
  2952. func (m *AliyunAvatarMutation) ResetToken() {
  2953. m.token = nil
  2954. }
  2955. // SetSessionID sets the "session_id" field.
  2956. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2957. m.session_id = &s
  2958. }
  2959. // SessionID returns the value of the "session_id" field in the mutation.
  2960. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2961. v := m.session_id
  2962. if v == nil {
  2963. return
  2964. }
  2965. return *v, true
  2966. }
  2967. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2968. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2970. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2971. if !m.op.Is(OpUpdateOne) {
  2972. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2973. }
  2974. if m.id == nil || m.oldValue == nil {
  2975. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2976. }
  2977. oldValue, err := m.oldValue(ctx)
  2978. if err != nil {
  2979. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2980. }
  2981. return oldValue.SessionID, nil
  2982. }
  2983. // ResetSessionID resets all changes to the "session_id" field.
  2984. func (m *AliyunAvatarMutation) ResetSessionID() {
  2985. m.session_id = nil
  2986. }
  2987. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2988. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2989. m.predicates = append(m.predicates, ps...)
  2990. }
  2991. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2992. // users can use type-assertion to append predicates that do not depend on any generated package.
  2993. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2994. p := make([]predicate.AliyunAvatar, len(ps))
  2995. for i := range ps {
  2996. p[i] = ps[i]
  2997. }
  2998. m.Where(p...)
  2999. }
  3000. // Op returns the operation name.
  3001. func (m *AliyunAvatarMutation) Op() Op {
  3002. return m.op
  3003. }
  3004. // SetOp allows setting the mutation operation.
  3005. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3006. m.op = op
  3007. }
  3008. // Type returns the node type of this mutation (AliyunAvatar).
  3009. func (m *AliyunAvatarMutation) Type() string {
  3010. return m.typ
  3011. }
  3012. // Fields returns all fields that were changed during this mutation. Note that in
  3013. // order to get all numeric fields that were incremented/decremented, call
  3014. // AddedFields().
  3015. func (m *AliyunAvatarMutation) Fields() []string {
  3016. fields := make([]string, 0, 12)
  3017. if m.created_at != nil {
  3018. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3019. }
  3020. if m.updated_at != nil {
  3021. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3022. }
  3023. if m.deleted_at != nil {
  3024. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3025. }
  3026. if m.user_id != nil {
  3027. fields = append(fields, aliyunavatar.FieldUserID)
  3028. }
  3029. if m.biz_id != nil {
  3030. fields = append(fields, aliyunavatar.FieldBizID)
  3031. }
  3032. if m.access_key_id != nil {
  3033. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3034. }
  3035. if m.access_key_secret != nil {
  3036. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3037. }
  3038. if m.app_id != nil {
  3039. fields = append(fields, aliyunavatar.FieldAppID)
  3040. }
  3041. if m.tenant_id != nil {
  3042. fields = append(fields, aliyunavatar.FieldTenantID)
  3043. }
  3044. if m.response != nil {
  3045. fields = append(fields, aliyunavatar.FieldResponse)
  3046. }
  3047. if m.token != nil {
  3048. fields = append(fields, aliyunavatar.FieldToken)
  3049. }
  3050. if m.session_id != nil {
  3051. fields = append(fields, aliyunavatar.FieldSessionID)
  3052. }
  3053. return fields
  3054. }
  3055. // Field returns the value of a field with the given name. The second boolean
  3056. // return value indicates that this field was not set, or was not defined in the
  3057. // schema.
  3058. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3059. switch name {
  3060. case aliyunavatar.FieldCreatedAt:
  3061. return m.CreatedAt()
  3062. case aliyunavatar.FieldUpdatedAt:
  3063. return m.UpdatedAt()
  3064. case aliyunavatar.FieldDeletedAt:
  3065. return m.DeletedAt()
  3066. case aliyunavatar.FieldUserID:
  3067. return m.UserID()
  3068. case aliyunavatar.FieldBizID:
  3069. return m.BizID()
  3070. case aliyunavatar.FieldAccessKeyID:
  3071. return m.AccessKeyID()
  3072. case aliyunavatar.FieldAccessKeySecret:
  3073. return m.AccessKeySecret()
  3074. case aliyunavatar.FieldAppID:
  3075. return m.AppID()
  3076. case aliyunavatar.FieldTenantID:
  3077. return m.TenantID()
  3078. case aliyunavatar.FieldResponse:
  3079. return m.Response()
  3080. case aliyunavatar.FieldToken:
  3081. return m.Token()
  3082. case aliyunavatar.FieldSessionID:
  3083. return m.SessionID()
  3084. }
  3085. return nil, false
  3086. }
  3087. // OldField returns the old value of the field from the database. An error is
  3088. // returned if the mutation operation is not UpdateOne, or the query to the
  3089. // database failed.
  3090. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3091. switch name {
  3092. case aliyunavatar.FieldCreatedAt:
  3093. return m.OldCreatedAt(ctx)
  3094. case aliyunavatar.FieldUpdatedAt:
  3095. return m.OldUpdatedAt(ctx)
  3096. case aliyunavatar.FieldDeletedAt:
  3097. return m.OldDeletedAt(ctx)
  3098. case aliyunavatar.FieldUserID:
  3099. return m.OldUserID(ctx)
  3100. case aliyunavatar.FieldBizID:
  3101. return m.OldBizID(ctx)
  3102. case aliyunavatar.FieldAccessKeyID:
  3103. return m.OldAccessKeyID(ctx)
  3104. case aliyunavatar.FieldAccessKeySecret:
  3105. return m.OldAccessKeySecret(ctx)
  3106. case aliyunavatar.FieldAppID:
  3107. return m.OldAppID(ctx)
  3108. case aliyunavatar.FieldTenantID:
  3109. return m.OldTenantID(ctx)
  3110. case aliyunavatar.FieldResponse:
  3111. return m.OldResponse(ctx)
  3112. case aliyunavatar.FieldToken:
  3113. return m.OldToken(ctx)
  3114. case aliyunavatar.FieldSessionID:
  3115. return m.OldSessionID(ctx)
  3116. }
  3117. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3118. }
  3119. // SetField sets the value of a field with the given name. It returns an error if
  3120. // the field is not defined in the schema, or if the type mismatched the field
  3121. // type.
  3122. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3123. switch name {
  3124. case aliyunavatar.FieldCreatedAt:
  3125. v, ok := value.(time.Time)
  3126. if !ok {
  3127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3128. }
  3129. m.SetCreatedAt(v)
  3130. return nil
  3131. case aliyunavatar.FieldUpdatedAt:
  3132. v, ok := value.(time.Time)
  3133. if !ok {
  3134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3135. }
  3136. m.SetUpdatedAt(v)
  3137. return nil
  3138. case aliyunavatar.FieldDeletedAt:
  3139. v, ok := value.(time.Time)
  3140. if !ok {
  3141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3142. }
  3143. m.SetDeletedAt(v)
  3144. return nil
  3145. case aliyunavatar.FieldUserID:
  3146. v, ok := value.(uint64)
  3147. if !ok {
  3148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3149. }
  3150. m.SetUserID(v)
  3151. return nil
  3152. case aliyunavatar.FieldBizID:
  3153. v, ok := value.(string)
  3154. if !ok {
  3155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3156. }
  3157. m.SetBizID(v)
  3158. return nil
  3159. case aliyunavatar.FieldAccessKeyID:
  3160. v, ok := value.(string)
  3161. if !ok {
  3162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3163. }
  3164. m.SetAccessKeyID(v)
  3165. return nil
  3166. case aliyunavatar.FieldAccessKeySecret:
  3167. v, ok := value.(string)
  3168. if !ok {
  3169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3170. }
  3171. m.SetAccessKeySecret(v)
  3172. return nil
  3173. case aliyunavatar.FieldAppID:
  3174. v, ok := value.(string)
  3175. if !ok {
  3176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3177. }
  3178. m.SetAppID(v)
  3179. return nil
  3180. case aliyunavatar.FieldTenantID:
  3181. v, ok := value.(uint64)
  3182. if !ok {
  3183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3184. }
  3185. m.SetTenantID(v)
  3186. return nil
  3187. case aliyunavatar.FieldResponse:
  3188. v, ok := value.(string)
  3189. if !ok {
  3190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3191. }
  3192. m.SetResponse(v)
  3193. return nil
  3194. case aliyunavatar.FieldToken:
  3195. v, ok := value.(string)
  3196. if !ok {
  3197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3198. }
  3199. m.SetToken(v)
  3200. return nil
  3201. case aliyunavatar.FieldSessionID:
  3202. v, ok := value.(string)
  3203. if !ok {
  3204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3205. }
  3206. m.SetSessionID(v)
  3207. return nil
  3208. }
  3209. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3210. }
  3211. // AddedFields returns all numeric fields that were incremented/decremented during
  3212. // this mutation.
  3213. func (m *AliyunAvatarMutation) AddedFields() []string {
  3214. var fields []string
  3215. if m.adduser_id != nil {
  3216. fields = append(fields, aliyunavatar.FieldUserID)
  3217. }
  3218. if m.addtenant_id != nil {
  3219. fields = append(fields, aliyunavatar.FieldTenantID)
  3220. }
  3221. return fields
  3222. }
  3223. // AddedField returns the numeric value that was incremented/decremented on a field
  3224. // with the given name. The second boolean return value indicates that this field
  3225. // was not set, or was not defined in the schema.
  3226. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3227. switch name {
  3228. case aliyunavatar.FieldUserID:
  3229. return m.AddedUserID()
  3230. case aliyunavatar.FieldTenantID:
  3231. return m.AddedTenantID()
  3232. }
  3233. return nil, false
  3234. }
  3235. // AddField adds the value to the field with the given name. It returns an error if
  3236. // the field is not defined in the schema, or if the type mismatched the field
  3237. // type.
  3238. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3239. switch name {
  3240. case aliyunavatar.FieldUserID:
  3241. v, ok := value.(int64)
  3242. if !ok {
  3243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3244. }
  3245. m.AddUserID(v)
  3246. return nil
  3247. case aliyunavatar.FieldTenantID:
  3248. v, ok := value.(int64)
  3249. if !ok {
  3250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3251. }
  3252. m.AddTenantID(v)
  3253. return nil
  3254. }
  3255. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3256. }
  3257. // ClearedFields returns all nullable fields that were cleared during this
  3258. // mutation.
  3259. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3260. var fields []string
  3261. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3262. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3263. }
  3264. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3265. fields = append(fields, aliyunavatar.FieldAppID)
  3266. }
  3267. return fields
  3268. }
  3269. // FieldCleared returns a boolean indicating if a field with the given name was
  3270. // cleared in this mutation.
  3271. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3272. _, ok := m.clearedFields[name]
  3273. return ok
  3274. }
  3275. // ClearField clears the value of the field with the given name. It returns an
  3276. // error if the field is not defined in the schema.
  3277. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3278. switch name {
  3279. case aliyunavatar.FieldDeletedAt:
  3280. m.ClearDeletedAt()
  3281. return nil
  3282. case aliyunavatar.FieldAppID:
  3283. m.ClearAppID()
  3284. return nil
  3285. }
  3286. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3287. }
  3288. // ResetField resets all changes in the mutation for the field with the given name.
  3289. // It returns an error if the field is not defined in the schema.
  3290. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3291. switch name {
  3292. case aliyunavatar.FieldCreatedAt:
  3293. m.ResetCreatedAt()
  3294. return nil
  3295. case aliyunavatar.FieldUpdatedAt:
  3296. m.ResetUpdatedAt()
  3297. return nil
  3298. case aliyunavatar.FieldDeletedAt:
  3299. m.ResetDeletedAt()
  3300. return nil
  3301. case aliyunavatar.FieldUserID:
  3302. m.ResetUserID()
  3303. return nil
  3304. case aliyunavatar.FieldBizID:
  3305. m.ResetBizID()
  3306. return nil
  3307. case aliyunavatar.FieldAccessKeyID:
  3308. m.ResetAccessKeyID()
  3309. return nil
  3310. case aliyunavatar.FieldAccessKeySecret:
  3311. m.ResetAccessKeySecret()
  3312. return nil
  3313. case aliyunavatar.FieldAppID:
  3314. m.ResetAppID()
  3315. return nil
  3316. case aliyunavatar.FieldTenantID:
  3317. m.ResetTenantID()
  3318. return nil
  3319. case aliyunavatar.FieldResponse:
  3320. m.ResetResponse()
  3321. return nil
  3322. case aliyunavatar.FieldToken:
  3323. m.ResetToken()
  3324. return nil
  3325. case aliyunavatar.FieldSessionID:
  3326. m.ResetSessionID()
  3327. return nil
  3328. }
  3329. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3330. }
  3331. // AddedEdges returns all edge names that were set/added in this mutation.
  3332. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3333. edges := make([]string, 0, 0)
  3334. return edges
  3335. }
  3336. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3337. // name in this mutation.
  3338. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3339. return nil
  3340. }
  3341. // RemovedEdges returns all edge names that were removed in this mutation.
  3342. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3343. edges := make([]string, 0, 0)
  3344. return edges
  3345. }
  3346. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3347. // the given name in this mutation.
  3348. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3349. return nil
  3350. }
  3351. // ClearedEdges returns all edge names that were cleared in this mutation.
  3352. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3353. edges := make([]string, 0, 0)
  3354. return edges
  3355. }
  3356. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3357. // was cleared in this mutation.
  3358. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3359. return false
  3360. }
  3361. // ClearEdge clears the value of the edge with the given name. It returns an error
  3362. // if that edge is not defined in the schema.
  3363. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3364. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3365. }
  3366. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3367. // It returns an error if the edge is not defined in the schema.
  3368. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3369. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3370. }
  3371. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3372. type AllocAgentMutation struct {
  3373. config
  3374. op Op
  3375. typ string
  3376. id *uint64
  3377. created_at *time.Time
  3378. updated_at *time.Time
  3379. deleted_at *time.Time
  3380. user_id *string
  3381. organization_id *uint64
  3382. addorganization_id *int64
  3383. agents *[]uint64
  3384. appendagents []uint64
  3385. status *int
  3386. addstatus *int
  3387. clearedFields map[string]struct{}
  3388. done bool
  3389. oldValue func(context.Context) (*AllocAgent, error)
  3390. predicates []predicate.AllocAgent
  3391. }
  3392. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3393. // allocagentOption allows management of the mutation configuration using functional options.
  3394. type allocagentOption func(*AllocAgentMutation)
  3395. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3396. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3397. m := &AllocAgentMutation{
  3398. config: c,
  3399. op: op,
  3400. typ: TypeAllocAgent,
  3401. clearedFields: make(map[string]struct{}),
  3402. }
  3403. for _, opt := range opts {
  3404. opt(m)
  3405. }
  3406. return m
  3407. }
  3408. // withAllocAgentID sets the ID field of the mutation.
  3409. func withAllocAgentID(id uint64) allocagentOption {
  3410. return func(m *AllocAgentMutation) {
  3411. var (
  3412. err error
  3413. once sync.Once
  3414. value *AllocAgent
  3415. )
  3416. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3417. once.Do(func() {
  3418. if m.done {
  3419. err = errors.New("querying old values post mutation is not allowed")
  3420. } else {
  3421. value, err = m.Client().AllocAgent.Get(ctx, id)
  3422. }
  3423. })
  3424. return value, err
  3425. }
  3426. m.id = &id
  3427. }
  3428. }
  3429. // withAllocAgent sets the old AllocAgent of the mutation.
  3430. func withAllocAgent(node *AllocAgent) allocagentOption {
  3431. return func(m *AllocAgentMutation) {
  3432. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3433. return node, nil
  3434. }
  3435. m.id = &node.ID
  3436. }
  3437. }
  3438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3439. // executed in a transaction (ent.Tx), a transactional client is returned.
  3440. func (m AllocAgentMutation) Client() *Client {
  3441. client := &Client{config: m.config}
  3442. client.init()
  3443. return client
  3444. }
  3445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3446. // it returns an error otherwise.
  3447. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3448. if _, ok := m.driver.(*txDriver); !ok {
  3449. return nil, errors.New("ent: mutation is not running in a transaction")
  3450. }
  3451. tx := &Tx{config: m.config}
  3452. tx.init()
  3453. return tx, nil
  3454. }
  3455. // SetID sets the value of the id field. Note that this
  3456. // operation is only accepted on creation of AllocAgent entities.
  3457. func (m *AllocAgentMutation) SetID(id uint64) {
  3458. m.id = &id
  3459. }
  3460. // ID returns the ID value in the mutation. Note that the ID is only available
  3461. // if it was provided to the builder or after it was returned from the database.
  3462. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3463. if m.id == nil {
  3464. return
  3465. }
  3466. return *m.id, true
  3467. }
  3468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3469. // That means, if the mutation is applied within a transaction with an isolation level such
  3470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3471. // or updated by the mutation.
  3472. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3473. switch {
  3474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3475. id, exists := m.ID()
  3476. if exists {
  3477. return []uint64{id}, nil
  3478. }
  3479. fallthrough
  3480. case m.op.Is(OpUpdate | OpDelete):
  3481. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3482. default:
  3483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3484. }
  3485. }
  3486. // SetCreatedAt sets the "created_at" field.
  3487. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3488. m.created_at = &t
  3489. }
  3490. // CreatedAt returns the value of the "created_at" field in the mutation.
  3491. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3492. v := m.created_at
  3493. if v == nil {
  3494. return
  3495. }
  3496. return *v, true
  3497. }
  3498. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3499. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3501. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3502. if !m.op.Is(OpUpdateOne) {
  3503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3504. }
  3505. if m.id == nil || m.oldValue == nil {
  3506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3507. }
  3508. oldValue, err := m.oldValue(ctx)
  3509. if err != nil {
  3510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3511. }
  3512. return oldValue.CreatedAt, nil
  3513. }
  3514. // ResetCreatedAt resets all changes to the "created_at" field.
  3515. func (m *AllocAgentMutation) ResetCreatedAt() {
  3516. m.created_at = nil
  3517. }
  3518. // SetUpdatedAt sets the "updated_at" field.
  3519. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3520. m.updated_at = &t
  3521. }
  3522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3523. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3524. v := m.updated_at
  3525. if v == nil {
  3526. return
  3527. }
  3528. return *v, true
  3529. }
  3530. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3531. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3533. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3534. if !m.op.Is(OpUpdateOne) {
  3535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3536. }
  3537. if m.id == nil || m.oldValue == nil {
  3538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3539. }
  3540. oldValue, err := m.oldValue(ctx)
  3541. if err != nil {
  3542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3543. }
  3544. return oldValue.UpdatedAt, nil
  3545. }
  3546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3547. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3548. m.updated_at = nil
  3549. }
  3550. // SetDeletedAt sets the "deleted_at" field.
  3551. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3552. m.deleted_at = &t
  3553. }
  3554. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3555. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3556. v := m.deleted_at
  3557. if v == nil {
  3558. return
  3559. }
  3560. return *v, true
  3561. }
  3562. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3563. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3565. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3566. if !m.op.Is(OpUpdateOne) {
  3567. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3568. }
  3569. if m.id == nil || m.oldValue == nil {
  3570. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3571. }
  3572. oldValue, err := m.oldValue(ctx)
  3573. if err != nil {
  3574. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3575. }
  3576. return oldValue.DeletedAt, nil
  3577. }
  3578. // ClearDeletedAt clears the value of the "deleted_at" field.
  3579. func (m *AllocAgentMutation) ClearDeletedAt() {
  3580. m.deleted_at = nil
  3581. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3582. }
  3583. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3584. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3585. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3586. return ok
  3587. }
  3588. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3589. func (m *AllocAgentMutation) ResetDeletedAt() {
  3590. m.deleted_at = nil
  3591. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3592. }
  3593. // SetUserID sets the "user_id" field.
  3594. func (m *AllocAgentMutation) SetUserID(s string) {
  3595. m.user_id = &s
  3596. }
  3597. // UserID returns the value of the "user_id" field in the mutation.
  3598. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3599. v := m.user_id
  3600. if v == nil {
  3601. return
  3602. }
  3603. return *v, true
  3604. }
  3605. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3606. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3608. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3609. if !m.op.Is(OpUpdateOne) {
  3610. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3611. }
  3612. if m.id == nil || m.oldValue == nil {
  3613. return v, errors.New("OldUserID requires an ID field in the mutation")
  3614. }
  3615. oldValue, err := m.oldValue(ctx)
  3616. if err != nil {
  3617. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3618. }
  3619. return oldValue.UserID, nil
  3620. }
  3621. // ClearUserID clears the value of the "user_id" field.
  3622. func (m *AllocAgentMutation) ClearUserID() {
  3623. m.user_id = nil
  3624. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3625. }
  3626. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3627. func (m *AllocAgentMutation) UserIDCleared() bool {
  3628. _, ok := m.clearedFields[allocagent.FieldUserID]
  3629. return ok
  3630. }
  3631. // ResetUserID resets all changes to the "user_id" field.
  3632. func (m *AllocAgentMutation) ResetUserID() {
  3633. m.user_id = nil
  3634. delete(m.clearedFields, allocagent.FieldUserID)
  3635. }
  3636. // SetOrganizationID sets the "organization_id" field.
  3637. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3638. m.organization_id = &u
  3639. m.addorganization_id = nil
  3640. }
  3641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3642. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3643. v := m.organization_id
  3644. if v == nil {
  3645. return
  3646. }
  3647. return *v, true
  3648. }
  3649. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3650. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3652. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3653. if !m.op.Is(OpUpdateOne) {
  3654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3655. }
  3656. if m.id == nil || m.oldValue == nil {
  3657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3658. }
  3659. oldValue, err := m.oldValue(ctx)
  3660. if err != nil {
  3661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3662. }
  3663. return oldValue.OrganizationID, nil
  3664. }
  3665. // AddOrganizationID adds u to the "organization_id" field.
  3666. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3667. if m.addorganization_id != nil {
  3668. *m.addorganization_id += u
  3669. } else {
  3670. m.addorganization_id = &u
  3671. }
  3672. }
  3673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3674. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3675. v := m.addorganization_id
  3676. if v == nil {
  3677. return
  3678. }
  3679. return *v, true
  3680. }
  3681. // ClearOrganizationID clears the value of the "organization_id" field.
  3682. func (m *AllocAgentMutation) ClearOrganizationID() {
  3683. m.organization_id = nil
  3684. m.addorganization_id = nil
  3685. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3686. }
  3687. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3688. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3689. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3690. return ok
  3691. }
  3692. // ResetOrganizationID resets all changes to the "organization_id" field.
  3693. func (m *AllocAgentMutation) ResetOrganizationID() {
  3694. m.organization_id = nil
  3695. m.addorganization_id = nil
  3696. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3697. }
  3698. // SetAgents sets the "agents" field.
  3699. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3700. m.agents = &u
  3701. m.appendagents = nil
  3702. }
  3703. // Agents returns the value of the "agents" field in the mutation.
  3704. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3705. v := m.agents
  3706. if v == nil {
  3707. return
  3708. }
  3709. return *v, true
  3710. }
  3711. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3712. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3714. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3715. if !m.op.Is(OpUpdateOne) {
  3716. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3717. }
  3718. if m.id == nil || m.oldValue == nil {
  3719. return v, errors.New("OldAgents requires an ID field in the mutation")
  3720. }
  3721. oldValue, err := m.oldValue(ctx)
  3722. if err != nil {
  3723. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3724. }
  3725. return oldValue.Agents, nil
  3726. }
  3727. // AppendAgents adds u to the "agents" field.
  3728. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3729. m.appendagents = append(m.appendagents, u...)
  3730. }
  3731. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3732. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3733. if len(m.appendagents) == 0 {
  3734. return nil, false
  3735. }
  3736. return m.appendagents, true
  3737. }
  3738. // ResetAgents resets all changes to the "agents" field.
  3739. func (m *AllocAgentMutation) ResetAgents() {
  3740. m.agents = nil
  3741. m.appendagents = nil
  3742. }
  3743. // SetStatus sets the "status" field.
  3744. func (m *AllocAgentMutation) SetStatus(i int) {
  3745. m.status = &i
  3746. m.addstatus = nil
  3747. }
  3748. // Status returns the value of the "status" field in the mutation.
  3749. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3750. v := m.status
  3751. if v == nil {
  3752. return
  3753. }
  3754. return *v, true
  3755. }
  3756. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3757. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3759. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3760. if !m.op.Is(OpUpdateOne) {
  3761. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3762. }
  3763. if m.id == nil || m.oldValue == nil {
  3764. return v, errors.New("OldStatus requires an ID field in the mutation")
  3765. }
  3766. oldValue, err := m.oldValue(ctx)
  3767. if err != nil {
  3768. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3769. }
  3770. return oldValue.Status, nil
  3771. }
  3772. // AddStatus adds i to the "status" field.
  3773. func (m *AllocAgentMutation) AddStatus(i int) {
  3774. if m.addstatus != nil {
  3775. *m.addstatus += i
  3776. } else {
  3777. m.addstatus = &i
  3778. }
  3779. }
  3780. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3781. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3782. v := m.addstatus
  3783. if v == nil {
  3784. return
  3785. }
  3786. return *v, true
  3787. }
  3788. // ClearStatus clears the value of the "status" field.
  3789. func (m *AllocAgentMutation) ClearStatus() {
  3790. m.status = nil
  3791. m.addstatus = nil
  3792. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3793. }
  3794. // StatusCleared returns if the "status" field was cleared in this mutation.
  3795. func (m *AllocAgentMutation) StatusCleared() bool {
  3796. _, ok := m.clearedFields[allocagent.FieldStatus]
  3797. return ok
  3798. }
  3799. // ResetStatus resets all changes to the "status" field.
  3800. func (m *AllocAgentMutation) ResetStatus() {
  3801. m.status = nil
  3802. m.addstatus = nil
  3803. delete(m.clearedFields, allocagent.FieldStatus)
  3804. }
  3805. // Where appends a list predicates to the AllocAgentMutation builder.
  3806. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3807. m.predicates = append(m.predicates, ps...)
  3808. }
  3809. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3810. // users can use type-assertion to append predicates that do not depend on any generated package.
  3811. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3812. p := make([]predicate.AllocAgent, len(ps))
  3813. for i := range ps {
  3814. p[i] = ps[i]
  3815. }
  3816. m.Where(p...)
  3817. }
  3818. // Op returns the operation name.
  3819. func (m *AllocAgentMutation) Op() Op {
  3820. return m.op
  3821. }
  3822. // SetOp allows setting the mutation operation.
  3823. func (m *AllocAgentMutation) SetOp(op Op) {
  3824. m.op = op
  3825. }
  3826. // Type returns the node type of this mutation (AllocAgent).
  3827. func (m *AllocAgentMutation) Type() string {
  3828. return m.typ
  3829. }
  3830. // Fields returns all fields that were changed during this mutation. Note that in
  3831. // order to get all numeric fields that were incremented/decremented, call
  3832. // AddedFields().
  3833. func (m *AllocAgentMutation) Fields() []string {
  3834. fields := make([]string, 0, 7)
  3835. if m.created_at != nil {
  3836. fields = append(fields, allocagent.FieldCreatedAt)
  3837. }
  3838. if m.updated_at != nil {
  3839. fields = append(fields, allocagent.FieldUpdatedAt)
  3840. }
  3841. if m.deleted_at != nil {
  3842. fields = append(fields, allocagent.FieldDeletedAt)
  3843. }
  3844. if m.user_id != nil {
  3845. fields = append(fields, allocagent.FieldUserID)
  3846. }
  3847. if m.organization_id != nil {
  3848. fields = append(fields, allocagent.FieldOrganizationID)
  3849. }
  3850. if m.agents != nil {
  3851. fields = append(fields, allocagent.FieldAgents)
  3852. }
  3853. if m.status != nil {
  3854. fields = append(fields, allocagent.FieldStatus)
  3855. }
  3856. return fields
  3857. }
  3858. // Field returns the value of a field with the given name. The second boolean
  3859. // return value indicates that this field was not set, or was not defined in the
  3860. // schema.
  3861. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3862. switch name {
  3863. case allocagent.FieldCreatedAt:
  3864. return m.CreatedAt()
  3865. case allocagent.FieldUpdatedAt:
  3866. return m.UpdatedAt()
  3867. case allocagent.FieldDeletedAt:
  3868. return m.DeletedAt()
  3869. case allocagent.FieldUserID:
  3870. return m.UserID()
  3871. case allocagent.FieldOrganizationID:
  3872. return m.OrganizationID()
  3873. case allocagent.FieldAgents:
  3874. return m.Agents()
  3875. case allocagent.FieldStatus:
  3876. return m.Status()
  3877. }
  3878. return nil, false
  3879. }
  3880. // OldField returns the old value of the field from the database. An error is
  3881. // returned if the mutation operation is not UpdateOne, or the query to the
  3882. // database failed.
  3883. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3884. switch name {
  3885. case allocagent.FieldCreatedAt:
  3886. return m.OldCreatedAt(ctx)
  3887. case allocagent.FieldUpdatedAt:
  3888. return m.OldUpdatedAt(ctx)
  3889. case allocagent.FieldDeletedAt:
  3890. return m.OldDeletedAt(ctx)
  3891. case allocagent.FieldUserID:
  3892. return m.OldUserID(ctx)
  3893. case allocagent.FieldOrganizationID:
  3894. return m.OldOrganizationID(ctx)
  3895. case allocagent.FieldAgents:
  3896. return m.OldAgents(ctx)
  3897. case allocagent.FieldStatus:
  3898. return m.OldStatus(ctx)
  3899. }
  3900. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3901. }
  3902. // SetField sets the value of a field with the given name. It returns an error if
  3903. // the field is not defined in the schema, or if the type mismatched the field
  3904. // type.
  3905. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3906. switch name {
  3907. case allocagent.FieldCreatedAt:
  3908. v, ok := value.(time.Time)
  3909. if !ok {
  3910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3911. }
  3912. m.SetCreatedAt(v)
  3913. return nil
  3914. case allocagent.FieldUpdatedAt:
  3915. v, ok := value.(time.Time)
  3916. if !ok {
  3917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3918. }
  3919. m.SetUpdatedAt(v)
  3920. return nil
  3921. case allocagent.FieldDeletedAt:
  3922. v, ok := value.(time.Time)
  3923. if !ok {
  3924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3925. }
  3926. m.SetDeletedAt(v)
  3927. return nil
  3928. case allocagent.FieldUserID:
  3929. v, ok := value.(string)
  3930. if !ok {
  3931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3932. }
  3933. m.SetUserID(v)
  3934. return nil
  3935. case allocagent.FieldOrganizationID:
  3936. v, ok := value.(uint64)
  3937. if !ok {
  3938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3939. }
  3940. m.SetOrganizationID(v)
  3941. return nil
  3942. case allocagent.FieldAgents:
  3943. v, ok := value.([]uint64)
  3944. if !ok {
  3945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3946. }
  3947. m.SetAgents(v)
  3948. return nil
  3949. case allocagent.FieldStatus:
  3950. v, ok := value.(int)
  3951. if !ok {
  3952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3953. }
  3954. m.SetStatus(v)
  3955. return nil
  3956. }
  3957. return fmt.Errorf("unknown AllocAgent field %s", name)
  3958. }
  3959. // AddedFields returns all numeric fields that were incremented/decremented during
  3960. // this mutation.
  3961. func (m *AllocAgentMutation) AddedFields() []string {
  3962. var fields []string
  3963. if m.addorganization_id != nil {
  3964. fields = append(fields, allocagent.FieldOrganizationID)
  3965. }
  3966. if m.addstatus != nil {
  3967. fields = append(fields, allocagent.FieldStatus)
  3968. }
  3969. return fields
  3970. }
  3971. // AddedField returns the numeric value that was incremented/decremented on a field
  3972. // with the given name. The second boolean return value indicates that this field
  3973. // was not set, or was not defined in the schema.
  3974. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3975. switch name {
  3976. case allocagent.FieldOrganizationID:
  3977. return m.AddedOrganizationID()
  3978. case allocagent.FieldStatus:
  3979. return m.AddedStatus()
  3980. }
  3981. return nil, false
  3982. }
  3983. // AddField adds the value to the field with the given name. It returns an error if
  3984. // the field is not defined in the schema, or if the type mismatched the field
  3985. // type.
  3986. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3987. switch name {
  3988. case allocagent.FieldOrganizationID:
  3989. v, ok := value.(int64)
  3990. if !ok {
  3991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3992. }
  3993. m.AddOrganizationID(v)
  3994. return nil
  3995. case allocagent.FieldStatus:
  3996. v, ok := value.(int)
  3997. if !ok {
  3998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3999. }
  4000. m.AddStatus(v)
  4001. return nil
  4002. }
  4003. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4004. }
  4005. // ClearedFields returns all nullable fields that were cleared during this
  4006. // mutation.
  4007. func (m *AllocAgentMutation) ClearedFields() []string {
  4008. var fields []string
  4009. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4010. fields = append(fields, allocagent.FieldDeletedAt)
  4011. }
  4012. if m.FieldCleared(allocagent.FieldUserID) {
  4013. fields = append(fields, allocagent.FieldUserID)
  4014. }
  4015. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4016. fields = append(fields, allocagent.FieldOrganizationID)
  4017. }
  4018. if m.FieldCleared(allocagent.FieldStatus) {
  4019. fields = append(fields, allocagent.FieldStatus)
  4020. }
  4021. return fields
  4022. }
  4023. // FieldCleared returns a boolean indicating if a field with the given name was
  4024. // cleared in this mutation.
  4025. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4026. _, ok := m.clearedFields[name]
  4027. return ok
  4028. }
  4029. // ClearField clears the value of the field with the given name. It returns an
  4030. // error if the field is not defined in the schema.
  4031. func (m *AllocAgentMutation) ClearField(name string) error {
  4032. switch name {
  4033. case allocagent.FieldDeletedAt:
  4034. m.ClearDeletedAt()
  4035. return nil
  4036. case allocagent.FieldUserID:
  4037. m.ClearUserID()
  4038. return nil
  4039. case allocagent.FieldOrganizationID:
  4040. m.ClearOrganizationID()
  4041. return nil
  4042. case allocagent.FieldStatus:
  4043. m.ClearStatus()
  4044. return nil
  4045. }
  4046. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4047. }
  4048. // ResetField resets all changes in the mutation for the field with the given name.
  4049. // It returns an error if the field is not defined in the schema.
  4050. func (m *AllocAgentMutation) ResetField(name string) error {
  4051. switch name {
  4052. case allocagent.FieldCreatedAt:
  4053. m.ResetCreatedAt()
  4054. return nil
  4055. case allocagent.FieldUpdatedAt:
  4056. m.ResetUpdatedAt()
  4057. return nil
  4058. case allocagent.FieldDeletedAt:
  4059. m.ResetDeletedAt()
  4060. return nil
  4061. case allocagent.FieldUserID:
  4062. m.ResetUserID()
  4063. return nil
  4064. case allocagent.FieldOrganizationID:
  4065. m.ResetOrganizationID()
  4066. return nil
  4067. case allocagent.FieldAgents:
  4068. m.ResetAgents()
  4069. return nil
  4070. case allocagent.FieldStatus:
  4071. m.ResetStatus()
  4072. return nil
  4073. }
  4074. return fmt.Errorf("unknown AllocAgent field %s", name)
  4075. }
  4076. // AddedEdges returns all edge names that were set/added in this mutation.
  4077. func (m *AllocAgentMutation) AddedEdges() []string {
  4078. edges := make([]string, 0, 0)
  4079. return edges
  4080. }
  4081. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4082. // name in this mutation.
  4083. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4084. return nil
  4085. }
  4086. // RemovedEdges returns all edge names that were removed in this mutation.
  4087. func (m *AllocAgentMutation) RemovedEdges() []string {
  4088. edges := make([]string, 0, 0)
  4089. return edges
  4090. }
  4091. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4092. // the given name in this mutation.
  4093. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4094. return nil
  4095. }
  4096. // ClearedEdges returns all edge names that were cleared in this mutation.
  4097. func (m *AllocAgentMutation) ClearedEdges() []string {
  4098. edges := make([]string, 0, 0)
  4099. return edges
  4100. }
  4101. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4102. // was cleared in this mutation.
  4103. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4104. return false
  4105. }
  4106. // ClearEdge clears the value of the edge with the given name. It returns an error
  4107. // if that edge is not defined in the schema.
  4108. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4109. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4110. }
  4111. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4112. // It returns an error if the edge is not defined in the schema.
  4113. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4114. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4115. }
  4116. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4117. type ApiKeyMutation struct {
  4118. config
  4119. op Op
  4120. typ string
  4121. id *uint64
  4122. created_at *time.Time
  4123. updated_at *time.Time
  4124. deleted_at *time.Time
  4125. title *string
  4126. key *string
  4127. organization_id *uint64
  4128. addorganization_id *int64
  4129. custom_agent_base *string
  4130. custom_agent_key *string
  4131. openai_base *string
  4132. openai_key *string
  4133. clearedFields map[string]struct{}
  4134. agent *uint64
  4135. clearedagent bool
  4136. done bool
  4137. oldValue func(context.Context) (*ApiKey, error)
  4138. predicates []predicate.ApiKey
  4139. }
  4140. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4141. // apikeyOption allows management of the mutation configuration using functional options.
  4142. type apikeyOption func(*ApiKeyMutation)
  4143. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4144. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4145. m := &ApiKeyMutation{
  4146. config: c,
  4147. op: op,
  4148. typ: TypeApiKey,
  4149. clearedFields: make(map[string]struct{}),
  4150. }
  4151. for _, opt := range opts {
  4152. opt(m)
  4153. }
  4154. return m
  4155. }
  4156. // withApiKeyID sets the ID field of the mutation.
  4157. func withApiKeyID(id uint64) apikeyOption {
  4158. return func(m *ApiKeyMutation) {
  4159. var (
  4160. err error
  4161. once sync.Once
  4162. value *ApiKey
  4163. )
  4164. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4165. once.Do(func() {
  4166. if m.done {
  4167. err = errors.New("querying old values post mutation is not allowed")
  4168. } else {
  4169. value, err = m.Client().ApiKey.Get(ctx, id)
  4170. }
  4171. })
  4172. return value, err
  4173. }
  4174. m.id = &id
  4175. }
  4176. }
  4177. // withApiKey sets the old ApiKey of the mutation.
  4178. func withApiKey(node *ApiKey) apikeyOption {
  4179. return func(m *ApiKeyMutation) {
  4180. m.oldValue = func(context.Context) (*ApiKey, error) {
  4181. return node, nil
  4182. }
  4183. m.id = &node.ID
  4184. }
  4185. }
  4186. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4187. // executed in a transaction (ent.Tx), a transactional client is returned.
  4188. func (m ApiKeyMutation) Client() *Client {
  4189. client := &Client{config: m.config}
  4190. client.init()
  4191. return client
  4192. }
  4193. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4194. // it returns an error otherwise.
  4195. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4196. if _, ok := m.driver.(*txDriver); !ok {
  4197. return nil, errors.New("ent: mutation is not running in a transaction")
  4198. }
  4199. tx := &Tx{config: m.config}
  4200. tx.init()
  4201. return tx, nil
  4202. }
  4203. // SetID sets the value of the id field. Note that this
  4204. // operation is only accepted on creation of ApiKey entities.
  4205. func (m *ApiKeyMutation) SetID(id uint64) {
  4206. m.id = &id
  4207. }
  4208. // ID returns the ID value in the mutation. Note that the ID is only available
  4209. // if it was provided to the builder or after it was returned from the database.
  4210. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4211. if m.id == nil {
  4212. return
  4213. }
  4214. return *m.id, true
  4215. }
  4216. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4217. // That means, if the mutation is applied within a transaction with an isolation level such
  4218. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4219. // or updated by the mutation.
  4220. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4221. switch {
  4222. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4223. id, exists := m.ID()
  4224. if exists {
  4225. return []uint64{id}, nil
  4226. }
  4227. fallthrough
  4228. case m.op.Is(OpUpdate | OpDelete):
  4229. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4230. default:
  4231. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4232. }
  4233. }
  4234. // SetCreatedAt sets the "created_at" field.
  4235. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4236. m.created_at = &t
  4237. }
  4238. // CreatedAt returns the value of the "created_at" field in the mutation.
  4239. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4240. v := m.created_at
  4241. if v == nil {
  4242. return
  4243. }
  4244. return *v, true
  4245. }
  4246. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4247. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4249. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4250. if !m.op.Is(OpUpdateOne) {
  4251. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4252. }
  4253. if m.id == nil || m.oldValue == nil {
  4254. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4255. }
  4256. oldValue, err := m.oldValue(ctx)
  4257. if err != nil {
  4258. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4259. }
  4260. return oldValue.CreatedAt, nil
  4261. }
  4262. // ResetCreatedAt resets all changes to the "created_at" field.
  4263. func (m *ApiKeyMutation) ResetCreatedAt() {
  4264. m.created_at = nil
  4265. }
  4266. // SetUpdatedAt sets the "updated_at" field.
  4267. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4268. m.updated_at = &t
  4269. }
  4270. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4271. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4272. v := m.updated_at
  4273. if v == nil {
  4274. return
  4275. }
  4276. return *v, true
  4277. }
  4278. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4279. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4281. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4282. if !m.op.Is(OpUpdateOne) {
  4283. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4284. }
  4285. if m.id == nil || m.oldValue == nil {
  4286. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4287. }
  4288. oldValue, err := m.oldValue(ctx)
  4289. if err != nil {
  4290. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4291. }
  4292. return oldValue.UpdatedAt, nil
  4293. }
  4294. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4295. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4296. m.updated_at = nil
  4297. }
  4298. // SetDeletedAt sets the "deleted_at" field.
  4299. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4300. m.deleted_at = &t
  4301. }
  4302. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4303. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4304. v := m.deleted_at
  4305. if v == nil {
  4306. return
  4307. }
  4308. return *v, true
  4309. }
  4310. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4311. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4313. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4314. if !m.op.Is(OpUpdateOne) {
  4315. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4316. }
  4317. if m.id == nil || m.oldValue == nil {
  4318. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4319. }
  4320. oldValue, err := m.oldValue(ctx)
  4321. if err != nil {
  4322. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4323. }
  4324. return oldValue.DeletedAt, nil
  4325. }
  4326. // ClearDeletedAt clears the value of the "deleted_at" field.
  4327. func (m *ApiKeyMutation) ClearDeletedAt() {
  4328. m.deleted_at = nil
  4329. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4330. }
  4331. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4332. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4333. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4334. return ok
  4335. }
  4336. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4337. func (m *ApiKeyMutation) ResetDeletedAt() {
  4338. m.deleted_at = nil
  4339. delete(m.clearedFields, apikey.FieldDeletedAt)
  4340. }
  4341. // SetTitle sets the "title" field.
  4342. func (m *ApiKeyMutation) SetTitle(s string) {
  4343. m.title = &s
  4344. }
  4345. // Title returns the value of the "title" field in the mutation.
  4346. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4347. v := m.title
  4348. if v == nil {
  4349. return
  4350. }
  4351. return *v, true
  4352. }
  4353. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4354. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4356. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4357. if !m.op.Is(OpUpdateOne) {
  4358. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4359. }
  4360. if m.id == nil || m.oldValue == nil {
  4361. return v, errors.New("OldTitle requires an ID field in the mutation")
  4362. }
  4363. oldValue, err := m.oldValue(ctx)
  4364. if err != nil {
  4365. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4366. }
  4367. return oldValue.Title, nil
  4368. }
  4369. // ClearTitle clears the value of the "title" field.
  4370. func (m *ApiKeyMutation) ClearTitle() {
  4371. m.title = nil
  4372. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4373. }
  4374. // TitleCleared returns if the "title" field was cleared in this mutation.
  4375. func (m *ApiKeyMutation) TitleCleared() bool {
  4376. _, ok := m.clearedFields[apikey.FieldTitle]
  4377. return ok
  4378. }
  4379. // ResetTitle resets all changes to the "title" field.
  4380. func (m *ApiKeyMutation) ResetTitle() {
  4381. m.title = nil
  4382. delete(m.clearedFields, apikey.FieldTitle)
  4383. }
  4384. // SetKey sets the "key" field.
  4385. func (m *ApiKeyMutation) SetKey(s string) {
  4386. m.key = &s
  4387. }
  4388. // Key returns the value of the "key" field in the mutation.
  4389. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4390. v := m.key
  4391. if v == nil {
  4392. return
  4393. }
  4394. return *v, true
  4395. }
  4396. // OldKey returns the old "key" field's value of the ApiKey entity.
  4397. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4399. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4400. if !m.op.Is(OpUpdateOne) {
  4401. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4402. }
  4403. if m.id == nil || m.oldValue == nil {
  4404. return v, errors.New("OldKey requires an ID field in the mutation")
  4405. }
  4406. oldValue, err := m.oldValue(ctx)
  4407. if err != nil {
  4408. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4409. }
  4410. return oldValue.Key, nil
  4411. }
  4412. // ClearKey clears the value of the "key" field.
  4413. func (m *ApiKeyMutation) ClearKey() {
  4414. m.key = nil
  4415. m.clearedFields[apikey.FieldKey] = struct{}{}
  4416. }
  4417. // KeyCleared returns if the "key" field was cleared in this mutation.
  4418. func (m *ApiKeyMutation) KeyCleared() bool {
  4419. _, ok := m.clearedFields[apikey.FieldKey]
  4420. return ok
  4421. }
  4422. // ResetKey resets all changes to the "key" field.
  4423. func (m *ApiKeyMutation) ResetKey() {
  4424. m.key = nil
  4425. delete(m.clearedFields, apikey.FieldKey)
  4426. }
  4427. // SetOrganizationID sets the "organization_id" field.
  4428. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4429. m.organization_id = &u
  4430. m.addorganization_id = nil
  4431. }
  4432. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4433. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4434. v := m.organization_id
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4441. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4453. }
  4454. return oldValue.OrganizationID, nil
  4455. }
  4456. // AddOrganizationID adds u to the "organization_id" field.
  4457. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4458. if m.addorganization_id != nil {
  4459. *m.addorganization_id += u
  4460. } else {
  4461. m.addorganization_id = &u
  4462. }
  4463. }
  4464. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4465. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4466. v := m.addorganization_id
  4467. if v == nil {
  4468. return
  4469. }
  4470. return *v, true
  4471. }
  4472. // ResetOrganizationID resets all changes to the "organization_id" field.
  4473. func (m *ApiKeyMutation) ResetOrganizationID() {
  4474. m.organization_id = nil
  4475. m.addorganization_id = nil
  4476. }
  4477. // SetAgentID sets the "agent_id" field.
  4478. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4479. m.agent = &u
  4480. }
  4481. // AgentID returns the value of the "agent_id" field in the mutation.
  4482. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4483. v := m.agent
  4484. if v == nil {
  4485. return
  4486. }
  4487. return *v, true
  4488. }
  4489. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4490. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4492. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4493. if !m.op.Is(OpUpdateOne) {
  4494. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4495. }
  4496. if m.id == nil || m.oldValue == nil {
  4497. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4498. }
  4499. oldValue, err := m.oldValue(ctx)
  4500. if err != nil {
  4501. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4502. }
  4503. return oldValue.AgentID, nil
  4504. }
  4505. // ResetAgentID resets all changes to the "agent_id" field.
  4506. func (m *ApiKeyMutation) ResetAgentID() {
  4507. m.agent = nil
  4508. }
  4509. // SetCustomAgentBase sets the "custom_agent_base" field.
  4510. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4511. m.custom_agent_base = &s
  4512. }
  4513. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4514. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4515. v := m.custom_agent_base
  4516. if v == nil {
  4517. return
  4518. }
  4519. return *v, true
  4520. }
  4521. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4522. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4524. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4525. if !m.op.Is(OpUpdateOne) {
  4526. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4527. }
  4528. if m.id == nil || m.oldValue == nil {
  4529. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4530. }
  4531. oldValue, err := m.oldValue(ctx)
  4532. if err != nil {
  4533. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4534. }
  4535. return oldValue.CustomAgentBase, nil
  4536. }
  4537. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4538. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4539. m.custom_agent_base = nil
  4540. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4541. }
  4542. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4543. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4544. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4545. return ok
  4546. }
  4547. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4548. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4549. m.custom_agent_base = nil
  4550. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4551. }
  4552. // SetCustomAgentKey sets the "custom_agent_key" field.
  4553. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4554. m.custom_agent_key = &s
  4555. }
  4556. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4557. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4558. v := m.custom_agent_key
  4559. if v == nil {
  4560. return
  4561. }
  4562. return *v, true
  4563. }
  4564. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4565. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4567. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4568. if !m.op.Is(OpUpdateOne) {
  4569. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4570. }
  4571. if m.id == nil || m.oldValue == nil {
  4572. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4573. }
  4574. oldValue, err := m.oldValue(ctx)
  4575. if err != nil {
  4576. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4577. }
  4578. return oldValue.CustomAgentKey, nil
  4579. }
  4580. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4581. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4582. m.custom_agent_key = nil
  4583. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4584. }
  4585. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4586. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4587. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4588. return ok
  4589. }
  4590. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4591. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4592. m.custom_agent_key = nil
  4593. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4594. }
  4595. // SetOpenaiBase sets the "openai_base" field.
  4596. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4597. m.openai_base = &s
  4598. }
  4599. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4600. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4601. v := m.openai_base
  4602. if v == nil {
  4603. return
  4604. }
  4605. return *v, true
  4606. }
  4607. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4608. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4610. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4611. if !m.op.Is(OpUpdateOne) {
  4612. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4613. }
  4614. if m.id == nil || m.oldValue == nil {
  4615. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4616. }
  4617. oldValue, err := m.oldValue(ctx)
  4618. if err != nil {
  4619. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4620. }
  4621. return oldValue.OpenaiBase, nil
  4622. }
  4623. // ClearOpenaiBase clears the value of the "openai_base" field.
  4624. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4625. m.openai_base = nil
  4626. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4627. }
  4628. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4629. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4630. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4631. return ok
  4632. }
  4633. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4634. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4635. m.openai_base = nil
  4636. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4637. }
  4638. // SetOpenaiKey sets the "openai_key" field.
  4639. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4640. m.openai_key = &s
  4641. }
  4642. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4643. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4644. v := m.openai_key
  4645. if v == nil {
  4646. return
  4647. }
  4648. return *v, true
  4649. }
  4650. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4651. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4653. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4654. if !m.op.Is(OpUpdateOne) {
  4655. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4656. }
  4657. if m.id == nil || m.oldValue == nil {
  4658. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4659. }
  4660. oldValue, err := m.oldValue(ctx)
  4661. if err != nil {
  4662. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4663. }
  4664. return oldValue.OpenaiKey, nil
  4665. }
  4666. // ClearOpenaiKey clears the value of the "openai_key" field.
  4667. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4668. m.openai_key = nil
  4669. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4670. }
  4671. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4672. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4673. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4674. return ok
  4675. }
  4676. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4677. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4678. m.openai_key = nil
  4679. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4680. }
  4681. // ClearAgent clears the "agent" edge to the Agent entity.
  4682. func (m *ApiKeyMutation) ClearAgent() {
  4683. m.clearedagent = true
  4684. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4685. }
  4686. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4687. func (m *ApiKeyMutation) AgentCleared() bool {
  4688. return m.clearedagent
  4689. }
  4690. // AgentIDs returns the "agent" edge IDs in the mutation.
  4691. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4692. // AgentID instead. It exists only for internal usage by the builders.
  4693. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4694. if id := m.agent; id != nil {
  4695. ids = append(ids, *id)
  4696. }
  4697. return
  4698. }
  4699. // ResetAgent resets all changes to the "agent" edge.
  4700. func (m *ApiKeyMutation) ResetAgent() {
  4701. m.agent = nil
  4702. m.clearedagent = false
  4703. }
  4704. // Where appends a list predicates to the ApiKeyMutation builder.
  4705. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4706. m.predicates = append(m.predicates, ps...)
  4707. }
  4708. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4709. // users can use type-assertion to append predicates that do not depend on any generated package.
  4710. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4711. p := make([]predicate.ApiKey, len(ps))
  4712. for i := range ps {
  4713. p[i] = ps[i]
  4714. }
  4715. m.Where(p...)
  4716. }
  4717. // Op returns the operation name.
  4718. func (m *ApiKeyMutation) Op() Op {
  4719. return m.op
  4720. }
  4721. // SetOp allows setting the mutation operation.
  4722. func (m *ApiKeyMutation) SetOp(op Op) {
  4723. m.op = op
  4724. }
  4725. // Type returns the node type of this mutation (ApiKey).
  4726. func (m *ApiKeyMutation) Type() string {
  4727. return m.typ
  4728. }
  4729. // Fields returns all fields that were changed during this mutation. Note that in
  4730. // order to get all numeric fields that were incremented/decremented, call
  4731. // AddedFields().
  4732. func (m *ApiKeyMutation) Fields() []string {
  4733. fields := make([]string, 0, 11)
  4734. if m.created_at != nil {
  4735. fields = append(fields, apikey.FieldCreatedAt)
  4736. }
  4737. if m.updated_at != nil {
  4738. fields = append(fields, apikey.FieldUpdatedAt)
  4739. }
  4740. if m.deleted_at != nil {
  4741. fields = append(fields, apikey.FieldDeletedAt)
  4742. }
  4743. if m.title != nil {
  4744. fields = append(fields, apikey.FieldTitle)
  4745. }
  4746. if m.key != nil {
  4747. fields = append(fields, apikey.FieldKey)
  4748. }
  4749. if m.organization_id != nil {
  4750. fields = append(fields, apikey.FieldOrganizationID)
  4751. }
  4752. if m.agent != nil {
  4753. fields = append(fields, apikey.FieldAgentID)
  4754. }
  4755. if m.custom_agent_base != nil {
  4756. fields = append(fields, apikey.FieldCustomAgentBase)
  4757. }
  4758. if m.custom_agent_key != nil {
  4759. fields = append(fields, apikey.FieldCustomAgentKey)
  4760. }
  4761. if m.openai_base != nil {
  4762. fields = append(fields, apikey.FieldOpenaiBase)
  4763. }
  4764. if m.openai_key != nil {
  4765. fields = append(fields, apikey.FieldOpenaiKey)
  4766. }
  4767. return fields
  4768. }
  4769. // Field returns the value of a field with the given name. The second boolean
  4770. // return value indicates that this field was not set, or was not defined in the
  4771. // schema.
  4772. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4773. switch name {
  4774. case apikey.FieldCreatedAt:
  4775. return m.CreatedAt()
  4776. case apikey.FieldUpdatedAt:
  4777. return m.UpdatedAt()
  4778. case apikey.FieldDeletedAt:
  4779. return m.DeletedAt()
  4780. case apikey.FieldTitle:
  4781. return m.Title()
  4782. case apikey.FieldKey:
  4783. return m.Key()
  4784. case apikey.FieldOrganizationID:
  4785. return m.OrganizationID()
  4786. case apikey.FieldAgentID:
  4787. return m.AgentID()
  4788. case apikey.FieldCustomAgentBase:
  4789. return m.CustomAgentBase()
  4790. case apikey.FieldCustomAgentKey:
  4791. return m.CustomAgentKey()
  4792. case apikey.FieldOpenaiBase:
  4793. return m.OpenaiBase()
  4794. case apikey.FieldOpenaiKey:
  4795. return m.OpenaiKey()
  4796. }
  4797. return nil, false
  4798. }
  4799. // OldField returns the old value of the field from the database. An error is
  4800. // returned if the mutation operation is not UpdateOne, or the query to the
  4801. // database failed.
  4802. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4803. switch name {
  4804. case apikey.FieldCreatedAt:
  4805. return m.OldCreatedAt(ctx)
  4806. case apikey.FieldUpdatedAt:
  4807. return m.OldUpdatedAt(ctx)
  4808. case apikey.FieldDeletedAt:
  4809. return m.OldDeletedAt(ctx)
  4810. case apikey.FieldTitle:
  4811. return m.OldTitle(ctx)
  4812. case apikey.FieldKey:
  4813. return m.OldKey(ctx)
  4814. case apikey.FieldOrganizationID:
  4815. return m.OldOrganizationID(ctx)
  4816. case apikey.FieldAgentID:
  4817. return m.OldAgentID(ctx)
  4818. case apikey.FieldCustomAgentBase:
  4819. return m.OldCustomAgentBase(ctx)
  4820. case apikey.FieldCustomAgentKey:
  4821. return m.OldCustomAgentKey(ctx)
  4822. case apikey.FieldOpenaiBase:
  4823. return m.OldOpenaiBase(ctx)
  4824. case apikey.FieldOpenaiKey:
  4825. return m.OldOpenaiKey(ctx)
  4826. }
  4827. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4828. }
  4829. // SetField sets the value of a field with the given name. It returns an error if
  4830. // the field is not defined in the schema, or if the type mismatched the field
  4831. // type.
  4832. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4833. switch name {
  4834. case apikey.FieldCreatedAt:
  4835. v, ok := value.(time.Time)
  4836. if !ok {
  4837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4838. }
  4839. m.SetCreatedAt(v)
  4840. return nil
  4841. case apikey.FieldUpdatedAt:
  4842. v, ok := value.(time.Time)
  4843. if !ok {
  4844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4845. }
  4846. m.SetUpdatedAt(v)
  4847. return nil
  4848. case apikey.FieldDeletedAt:
  4849. v, ok := value.(time.Time)
  4850. if !ok {
  4851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4852. }
  4853. m.SetDeletedAt(v)
  4854. return nil
  4855. case apikey.FieldTitle:
  4856. v, ok := value.(string)
  4857. if !ok {
  4858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4859. }
  4860. m.SetTitle(v)
  4861. return nil
  4862. case apikey.FieldKey:
  4863. v, ok := value.(string)
  4864. if !ok {
  4865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4866. }
  4867. m.SetKey(v)
  4868. return nil
  4869. case apikey.FieldOrganizationID:
  4870. v, ok := value.(uint64)
  4871. if !ok {
  4872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4873. }
  4874. m.SetOrganizationID(v)
  4875. return nil
  4876. case apikey.FieldAgentID:
  4877. v, ok := value.(uint64)
  4878. if !ok {
  4879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4880. }
  4881. m.SetAgentID(v)
  4882. return nil
  4883. case apikey.FieldCustomAgentBase:
  4884. v, ok := value.(string)
  4885. if !ok {
  4886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4887. }
  4888. m.SetCustomAgentBase(v)
  4889. return nil
  4890. case apikey.FieldCustomAgentKey:
  4891. v, ok := value.(string)
  4892. if !ok {
  4893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4894. }
  4895. m.SetCustomAgentKey(v)
  4896. return nil
  4897. case apikey.FieldOpenaiBase:
  4898. v, ok := value.(string)
  4899. if !ok {
  4900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4901. }
  4902. m.SetOpenaiBase(v)
  4903. return nil
  4904. case apikey.FieldOpenaiKey:
  4905. v, ok := value.(string)
  4906. if !ok {
  4907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4908. }
  4909. m.SetOpenaiKey(v)
  4910. return nil
  4911. }
  4912. return fmt.Errorf("unknown ApiKey field %s", name)
  4913. }
  4914. // AddedFields returns all numeric fields that were incremented/decremented during
  4915. // this mutation.
  4916. func (m *ApiKeyMutation) AddedFields() []string {
  4917. var fields []string
  4918. if m.addorganization_id != nil {
  4919. fields = append(fields, apikey.FieldOrganizationID)
  4920. }
  4921. return fields
  4922. }
  4923. // AddedField returns the numeric value that was incremented/decremented on a field
  4924. // with the given name. The second boolean return value indicates that this field
  4925. // was not set, or was not defined in the schema.
  4926. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4927. switch name {
  4928. case apikey.FieldOrganizationID:
  4929. return m.AddedOrganizationID()
  4930. }
  4931. return nil, false
  4932. }
  4933. // AddField adds the value to the field with the given name. It returns an error if
  4934. // the field is not defined in the schema, or if the type mismatched the field
  4935. // type.
  4936. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4937. switch name {
  4938. case apikey.FieldOrganizationID:
  4939. v, ok := value.(int64)
  4940. if !ok {
  4941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4942. }
  4943. m.AddOrganizationID(v)
  4944. return nil
  4945. }
  4946. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4947. }
  4948. // ClearedFields returns all nullable fields that were cleared during this
  4949. // mutation.
  4950. func (m *ApiKeyMutation) ClearedFields() []string {
  4951. var fields []string
  4952. if m.FieldCleared(apikey.FieldDeletedAt) {
  4953. fields = append(fields, apikey.FieldDeletedAt)
  4954. }
  4955. if m.FieldCleared(apikey.FieldTitle) {
  4956. fields = append(fields, apikey.FieldTitle)
  4957. }
  4958. if m.FieldCleared(apikey.FieldKey) {
  4959. fields = append(fields, apikey.FieldKey)
  4960. }
  4961. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4962. fields = append(fields, apikey.FieldCustomAgentBase)
  4963. }
  4964. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4965. fields = append(fields, apikey.FieldCustomAgentKey)
  4966. }
  4967. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4968. fields = append(fields, apikey.FieldOpenaiBase)
  4969. }
  4970. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4971. fields = append(fields, apikey.FieldOpenaiKey)
  4972. }
  4973. return fields
  4974. }
  4975. // FieldCleared returns a boolean indicating if a field with the given name was
  4976. // cleared in this mutation.
  4977. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4978. _, ok := m.clearedFields[name]
  4979. return ok
  4980. }
  4981. // ClearField clears the value of the field with the given name. It returns an
  4982. // error if the field is not defined in the schema.
  4983. func (m *ApiKeyMutation) ClearField(name string) error {
  4984. switch name {
  4985. case apikey.FieldDeletedAt:
  4986. m.ClearDeletedAt()
  4987. return nil
  4988. case apikey.FieldTitle:
  4989. m.ClearTitle()
  4990. return nil
  4991. case apikey.FieldKey:
  4992. m.ClearKey()
  4993. return nil
  4994. case apikey.FieldCustomAgentBase:
  4995. m.ClearCustomAgentBase()
  4996. return nil
  4997. case apikey.FieldCustomAgentKey:
  4998. m.ClearCustomAgentKey()
  4999. return nil
  5000. case apikey.FieldOpenaiBase:
  5001. m.ClearOpenaiBase()
  5002. return nil
  5003. case apikey.FieldOpenaiKey:
  5004. m.ClearOpenaiKey()
  5005. return nil
  5006. }
  5007. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5008. }
  5009. // ResetField resets all changes in the mutation for the field with the given name.
  5010. // It returns an error if the field is not defined in the schema.
  5011. func (m *ApiKeyMutation) ResetField(name string) error {
  5012. switch name {
  5013. case apikey.FieldCreatedAt:
  5014. m.ResetCreatedAt()
  5015. return nil
  5016. case apikey.FieldUpdatedAt:
  5017. m.ResetUpdatedAt()
  5018. return nil
  5019. case apikey.FieldDeletedAt:
  5020. m.ResetDeletedAt()
  5021. return nil
  5022. case apikey.FieldTitle:
  5023. m.ResetTitle()
  5024. return nil
  5025. case apikey.FieldKey:
  5026. m.ResetKey()
  5027. return nil
  5028. case apikey.FieldOrganizationID:
  5029. m.ResetOrganizationID()
  5030. return nil
  5031. case apikey.FieldAgentID:
  5032. m.ResetAgentID()
  5033. return nil
  5034. case apikey.FieldCustomAgentBase:
  5035. m.ResetCustomAgentBase()
  5036. return nil
  5037. case apikey.FieldCustomAgentKey:
  5038. m.ResetCustomAgentKey()
  5039. return nil
  5040. case apikey.FieldOpenaiBase:
  5041. m.ResetOpenaiBase()
  5042. return nil
  5043. case apikey.FieldOpenaiKey:
  5044. m.ResetOpenaiKey()
  5045. return nil
  5046. }
  5047. return fmt.Errorf("unknown ApiKey field %s", name)
  5048. }
  5049. // AddedEdges returns all edge names that were set/added in this mutation.
  5050. func (m *ApiKeyMutation) AddedEdges() []string {
  5051. edges := make([]string, 0, 1)
  5052. if m.agent != nil {
  5053. edges = append(edges, apikey.EdgeAgent)
  5054. }
  5055. return edges
  5056. }
  5057. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5058. // name in this mutation.
  5059. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5060. switch name {
  5061. case apikey.EdgeAgent:
  5062. if id := m.agent; id != nil {
  5063. return []ent.Value{*id}
  5064. }
  5065. }
  5066. return nil
  5067. }
  5068. // RemovedEdges returns all edge names that were removed in this mutation.
  5069. func (m *ApiKeyMutation) RemovedEdges() []string {
  5070. edges := make([]string, 0, 1)
  5071. return edges
  5072. }
  5073. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5074. // the given name in this mutation.
  5075. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5076. return nil
  5077. }
  5078. // ClearedEdges returns all edge names that were cleared in this mutation.
  5079. func (m *ApiKeyMutation) ClearedEdges() []string {
  5080. edges := make([]string, 0, 1)
  5081. if m.clearedagent {
  5082. edges = append(edges, apikey.EdgeAgent)
  5083. }
  5084. return edges
  5085. }
  5086. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5087. // was cleared in this mutation.
  5088. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5089. switch name {
  5090. case apikey.EdgeAgent:
  5091. return m.clearedagent
  5092. }
  5093. return false
  5094. }
  5095. // ClearEdge clears the value of the edge with the given name. It returns an error
  5096. // if that edge is not defined in the schema.
  5097. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5098. switch name {
  5099. case apikey.EdgeAgent:
  5100. m.ClearAgent()
  5101. return nil
  5102. }
  5103. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5104. }
  5105. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5106. // It returns an error if the edge is not defined in the schema.
  5107. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5108. switch name {
  5109. case apikey.EdgeAgent:
  5110. m.ResetAgent()
  5111. return nil
  5112. }
  5113. return fmt.Errorf("unknown ApiKey edge %s", name)
  5114. }
  5115. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5116. type BatchMsgMutation struct {
  5117. config
  5118. op Op
  5119. typ string
  5120. id *uint64
  5121. created_at *time.Time
  5122. updated_at *time.Time
  5123. deleted_at *time.Time
  5124. status *uint8
  5125. addstatus *int8
  5126. batch_no *string
  5127. task_name *string
  5128. fromwxid *string
  5129. msg *string
  5130. tag *string
  5131. tagids *string
  5132. total *int32
  5133. addtotal *int32
  5134. success *int32
  5135. addsuccess *int32
  5136. fail *int32
  5137. addfail *int32
  5138. start_time *time.Time
  5139. stop_time *time.Time
  5140. send_time *time.Time
  5141. _type *int32
  5142. add_type *int32
  5143. organization_id *uint64
  5144. addorganization_id *int64
  5145. ctype *uint64
  5146. addctype *int64
  5147. cc *string
  5148. phone *string
  5149. template_name *string
  5150. template_code *string
  5151. lang *string
  5152. clearedFields map[string]struct{}
  5153. done bool
  5154. oldValue func(context.Context) (*BatchMsg, error)
  5155. predicates []predicate.BatchMsg
  5156. }
  5157. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5158. // batchmsgOption allows management of the mutation configuration using functional options.
  5159. type batchmsgOption func(*BatchMsgMutation)
  5160. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5161. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5162. m := &BatchMsgMutation{
  5163. config: c,
  5164. op: op,
  5165. typ: TypeBatchMsg,
  5166. clearedFields: make(map[string]struct{}),
  5167. }
  5168. for _, opt := range opts {
  5169. opt(m)
  5170. }
  5171. return m
  5172. }
  5173. // withBatchMsgID sets the ID field of the mutation.
  5174. func withBatchMsgID(id uint64) batchmsgOption {
  5175. return func(m *BatchMsgMutation) {
  5176. var (
  5177. err error
  5178. once sync.Once
  5179. value *BatchMsg
  5180. )
  5181. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5182. once.Do(func() {
  5183. if m.done {
  5184. err = errors.New("querying old values post mutation is not allowed")
  5185. } else {
  5186. value, err = m.Client().BatchMsg.Get(ctx, id)
  5187. }
  5188. })
  5189. return value, err
  5190. }
  5191. m.id = &id
  5192. }
  5193. }
  5194. // withBatchMsg sets the old BatchMsg of the mutation.
  5195. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5196. return func(m *BatchMsgMutation) {
  5197. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5198. return node, nil
  5199. }
  5200. m.id = &node.ID
  5201. }
  5202. }
  5203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5204. // executed in a transaction (ent.Tx), a transactional client is returned.
  5205. func (m BatchMsgMutation) Client() *Client {
  5206. client := &Client{config: m.config}
  5207. client.init()
  5208. return client
  5209. }
  5210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5211. // it returns an error otherwise.
  5212. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5213. if _, ok := m.driver.(*txDriver); !ok {
  5214. return nil, errors.New("ent: mutation is not running in a transaction")
  5215. }
  5216. tx := &Tx{config: m.config}
  5217. tx.init()
  5218. return tx, nil
  5219. }
  5220. // SetID sets the value of the id field. Note that this
  5221. // operation is only accepted on creation of BatchMsg entities.
  5222. func (m *BatchMsgMutation) SetID(id uint64) {
  5223. m.id = &id
  5224. }
  5225. // ID returns the ID value in the mutation. Note that the ID is only available
  5226. // if it was provided to the builder or after it was returned from the database.
  5227. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5228. if m.id == nil {
  5229. return
  5230. }
  5231. return *m.id, true
  5232. }
  5233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5234. // That means, if the mutation is applied within a transaction with an isolation level such
  5235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5236. // or updated by the mutation.
  5237. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5238. switch {
  5239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5240. id, exists := m.ID()
  5241. if exists {
  5242. return []uint64{id}, nil
  5243. }
  5244. fallthrough
  5245. case m.op.Is(OpUpdate | OpDelete):
  5246. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5247. default:
  5248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5249. }
  5250. }
  5251. // SetCreatedAt sets the "created_at" field.
  5252. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5253. m.created_at = &t
  5254. }
  5255. // CreatedAt returns the value of the "created_at" field in the mutation.
  5256. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5257. v := m.created_at
  5258. if v == nil {
  5259. return
  5260. }
  5261. return *v, true
  5262. }
  5263. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5264. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5266. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5267. if !m.op.Is(OpUpdateOne) {
  5268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5269. }
  5270. if m.id == nil || m.oldValue == nil {
  5271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5272. }
  5273. oldValue, err := m.oldValue(ctx)
  5274. if err != nil {
  5275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5276. }
  5277. return oldValue.CreatedAt, nil
  5278. }
  5279. // ResetCreatedAt resets all changes to the "created_at" field.
  5280. func (m *BatchMsgMutation) ResetCreatedAt() {
  5281. m.created_at = nil
  5282. }
  5283. // SetUpdatedAt sets the "updated_at" field.
  5284. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5285. m.updated_at = &t
  5286. }
  5287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5288. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5289. v := m.updated_at
  5290. if v == nil {
  5291. return
  5292. }
  5293. return *v, true
  5294. }
  5295. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5296. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5298. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5299. if !m.op.Is(OpUpdateOne) {
  5300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5301. }
  5302. if m.id == nil || m.oldValue == nil {
  5303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5304. }
  5305. oldValue, err := m.oldValue(ctx)
  5306. if err != nil {
  5307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5308. }
  5309. return oldValue.UpdatedAt, nil
  5310. }
  5311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5312. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5313. m.updated_at = nil
  5314. }
  5315. // SetDeletedAt sets the "deleted_at" field.
  5316. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5317. m.deleted_at = &t
  5318. }
  5319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5320. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5321. v := m.deleted_at
  5322. if v == nil {
  5323. return
  5324. }
  5325. return *v, true
  5326. }
  5327. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5328. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5330. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5331. if !m.op.Is(OpUpdateOne) {
  5332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5333. }
  5334. if m.id == nil || m.oldValue == nil {
  5335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5336. }
  5337. oldValue, err := m.oldValue(ctx)
  5338. if err != nil {
  5339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5340. }
  5341. return oldValue.DeletedAt, nil
  5342. }
  5343. // ClearDeletedAt clears the value of the "deleted_at" field.
  5344. func (m *BatchMsgMutation) ClearDeletedAt() {
  5345. m.deleted_at = nil
  5346. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5347. }
  5348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5349. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5350. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5351. return ok
  5352. }
  5353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5354. func (m *BatchMsgMutation) ResetDeletedAt() {
  5355. m.deleted_at = nil
  5356. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5357. }
  5358. // SetStatus sets the "status" field.
  5359. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5360. m.status = &u
  5361. m.addstatus = nil
  5362. }
  5363. // Status returns the value of the "status" field in the mutation.
  5364. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5365. v := m.status
  5366. if v == nil {
  5367. return
  5368. }
  5369. return *v, true
  5370. }
  5371. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5372. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5374. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5375. if !m.op.Is(OpUpdateOne) {
  5376. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5377. }
  5378. if m.id == nil || m.oldValue == nil {
  5379. return v, errors.New("OldStatus requires an ID field in the mutation")
  5380. }
  5381. oldValue, err := m.oldValue(ctx)
  5382. if err != nil {
  5383. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5384. }
  5385. return oldValue.Status, nil
  5386. }
  5387. // AddStatus adds u to the "status" field.
  5388. func (m *BatchMsgMutation) AddStatus(u int8) {
  5389. if m.addstatus != nil {
  5390. *m.addstatus += u
  5391. } else {
  5392. m.addstatus = &u
  5393. }
  5394. }
  5395. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5396. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5397. v := m.addstatus
  5398. if v == nil {
  5399. return
  5400. }
  5401. return *v, true
  5402. }
  5403. // ClearStatus clears the value of the "status" field.
  5404. func (m *BatchMsgMutation) ClearStatus() {
  5405. m.status = nil
  5406. m.addstatus = nil
  5407. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5408. }
  5409. // StatusCleared returns if the "status" field was cleared in this mutation.
  5410. func (m *BatchMsgMutation) StatusCleared() bool {
  5411. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5412. return ok
  5413. }
  5414. // ResetStatus resets all changes to the "status" field.
  5415. func (m *BatchMsgMutation) ResetStatus() {
  5416. m.status = nil
  5417. m.addstatus = nil
  5418. delete(m.clearedFields, batchmsg.FieldStatus)
  5419. }
  5420. // SetBatchNo sets the "batch_no" field.
  5421. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5422. m.batch_no = &s
  5423. }
  5424. // BatchNo returns the value of the "batch_no" field in the mutation.
  5425. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5426. v := m.batch_no
  5427. if v == nil {
  5428. return
  5429. }
  5430. return *v, true
  5431. }
  5432. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5433. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5435. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5436. if !m.op.Is(OpUpdateOne) {
  5437. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5438. }
  5439. if m.id == nil || m.oldValue == nil {
  5440. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5441. }
  5442. oldValue, err := m.oldValue(ctx)
  5443. if err != nil {
  5444. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5445. }
  5446. return oldValue.BatchNo, nil
  5447. }
  5448. // ClearBatchNo clears the value of the "batch_no" field.
  5449. func (m *BatchMsgMutation) ClearBatchNo() {
  5450. m.batch_no = nil
  5451. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5452. }
  5453. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5454. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5455. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5456. return ok
  5457. }
  5458. // ResetBatchNo resets all changes to the "batch_no" field.
  5459. func (m *BatchMsgMutation) ResetBatchNo() {
  5460. m.batch_no = nil
  5461. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5462. }
  5463. // SetTaskName sets the "task_name" field.
  5464. func (m *BatchMsgMutation) SetTaskName(s string) {
  5465. m.task_name = &s
  5466. }
  5467. // TaskName returns the value of the "task_name" field in the mutation.
  5468. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5469. v := m.task_name
  5470. if v == nil {
  5471. return
  5472. }
  5473. return *v, true
  5474. }
  5475. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5476. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5478. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5479. if !m.op.Is(OpUpdateOne) {
  5480. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5481. }
  5482. if m.id == nil || m.oldValue == nil {
  5483. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5484. }
  5485. oldValue, err := m.oldValue(ctx)
  5486. if err != nil {
  5487. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5488. }
  5489. return oldValue.TaskName, nil
  5490. }
  5491. // ClearTaskName clears the value of the "task_name" field.
  5492. func (m *BatchMsgMutation) ClearTaskName() {
  5493. m.task_name = nil
  5494. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5495. }
  5496. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5497. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5498. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5499. return ok
  5500. }
  5501. // ResetTaskName resets all changes to the "task_name" field.
  5502. func (m *BatchMsgMutation) ResetTaskName() {
  5503. m.task_name = nil
  5504. delete(m.clearedFields, batchmsg.FieldTaskName)
  5505. }
  5506. // SetFromwxid sets the "fromwxid" field.
  5507. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5508. m.fromwxid = &s
  5509. }
  5510. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5511. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5512. v := m.fromwxid
  5513. if v == nil {
  5514. return
  5515. }
  5516. return *v, true
  5517. }
  5518. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5519. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5521. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5522. if !m.op.Is(OpUpdateOne) {
  5523. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5524. }
  5525. if m.id == nil || m.oldValue == nil {
  5526. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5527. }
  5528. oldValue, err := m.oldValue(ctx)
  5529. if err != nil {
  5530. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5531. }
  5532. return oldValue.Fromwxid, nil
  5533. }
  5534. // ClearFromwxid clears the value of the "fromwxid" field.
  5535. func (m *BatchMsgMutation) ClearFromwxid() {
  5536. m.fromwxid = nil
  5537. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5538. }
  5539. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5540. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5541. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5542. return ok
  5543. }
  5544. // ResetFromwxid resets all changes to the "fromwxid" field.
  5545. func (m *BatchMsgMutation) ResetFromwxid() {
  5546. m.fromwxid = nil
  5547. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5548. }
  5549. // SetMsg sets the "msg" field.
  5550. func (m *BatchMsgMutation) SetMsg(s string) {
  5551. m.msg = &s
  5552. }
  5553. // Msg returns the value of the "msg" field in the mutation.
  5554. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5555. v := m.msg
  5556. if v == nil {
  5557. return
  5558. }
  5559. return *v, true
  5560. }
  5561. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5562. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5564. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5565. if !m.op.Is(OpUpdateOne) {
  5566. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5567. }
  5568. if m.id == nil || m.oldValue == nil {
  5569. return v, errors.New("OldMsg requires an ID field in the mutation")
  5570. }
  5571. oldValue, err := m.oldValue(ctx)
  5572. if err != nil {
  5573. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5574. }
  5575. return oldValue.Msg, nil
  5576. }
  5577. // ClearMsg clears the value of the "msg" field.
  5578. func (m *BatchMsgMutation) ClearMsg() {
  5579. m.msg = nil
  5580. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5581. }
  5582. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5583. func (m *BatchMsgMutation) MsgCleared() bool {
  5584. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5585. return ok
  5586. }
  5587. // ResetMsg resets all changes to the "msg" field.
  5588. func (m *BatchMsgMutation) ResetMsg() {
  5589. m.msg = nil
  5590. delete(m.clearedFields, batchmsg.FieldMsg)
  5591. }
  5592. // SetTag sets the "tag" field.
  5593. func (m *BatchMsgMutation) SetTag(s string) {
  5594. m.tag = &s
  5595. }
  5596. // Tag returns the value of the "tag" field in the mutation.
  5597. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5598. v := m.tag
  5599. if v == nil {
  5600. return
  5601. }
  5602. return *v, true
  5603. }
  5604. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5605. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5607. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5608. if !m.op.Is(OpUpdateOne) {
  5609. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5610. }
  5611. if m.id == nil || m.oldValue == nil {
  5612. return v, errors.New("OldTag requires an ID field in the mutation")
  5613. }
  5614. oldValue, err := m.oldValue(ctx)
  5615. if err != nil {
  5616. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5617. }
  5618. return oldValue.Tag, nil
  5619. }
  5620. // ClearTag clears the value of the "tag" field.
  5621. func (m *BatchMsgMutation) ClearTag() {
  5622. m.tag = nil
  5623. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5624. }
  5625. // TagCleared returns if the "tag" field was cleared in this mutation.
  5626. func (m *BatchMsgMutation) TagCleared() bool {
  5627. _, ok := m.clearedFields[batchmsg.FieldTag]
  5628. return ok
  5629. }
  5630. // ResetTag resets all changes to the "tag" field.
  5631. func (m *BatchMsgMutation) ResetTag() {
  5632. m.tag = nil
  5633. delete(m.clearedFields, batchmsg.FieldTag)
  5634. }
  5635. // SetTagids sets the "tagids" field.
  5636. func (m *BatchMsgMutation) SetTagids(s string) {
  5637. m.tagids = &s
  5638. }
  5639. // Tagids returns the value of the "tagids" field in the mutation.
  5640. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5641. v := m.tagids
  5642. if v == nil {
  5643. return
  5644. }
  5645. return *v, true
  5646. }
  5647. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5650. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5651. if !m.op.Is(OpUpdateOne) {
  5652. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5653. }
  5654. if m.id == nil || m.oldValue == nil {
  5655. return v, errors.New("OldTagids requires an ID field in the mutation")
  5656. }
  5657. oldValue, err := m.oldValue(ctx)
  5658. if err != nil {
  5659. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5660. }
  5661. return oldValue.Tagids, nil
  5662. }
  5663. // ClearTagids clears the value of the "tagids" field.
  5664. func (m *BatchMsgMutation) ClearTagids() {
  5665. m.tagids = nil
  5666. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5667. }
  5668. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5669. func (m *BatchMsgMutation) TagidsCleared() bool {
  5670. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5671. return ok
  5672. }
  5673. // ResetTagids resets all changes to the "tagids" field.
  5674. func (m *BatchMsgMutation) ResetTagids() {
  5675. m.tagids = nil
  5676. delete(m.clearedFields, batchmsg.FieldTagids)
  5677. }
  5678. // SetTotal sets the "total" field.
  5679. func (m *BatchMsgMutation) SetTotal(i int32) {
  5680. m.total = &i
  5681. m.addtotal = nil
  5682. }
  5683. // Total returns the value of the "total" field in the mutation.
  5684. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5685. v := m.total
  5686. if v == nil {
  5687. return
  5688. }
  5689. return *v, true
  5690. }
  5691. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5692. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5694. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5695. if !m.op.Is(OpUpdateOne) {
  5696. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5697. }
  5698. if m.id == nil || m.oldValue == nil {
  5699. return v, errors.New("OldTotal requires an ID field in the mutation")
  5700. }
  5701. oldValue, err := m.oldValue(ctx)
  5702. if err != nil {
  5703. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5704. }
  5705. return oldValue.Total, nil
  5706. }
  5707. // AddTotal adds i to the "total" field.
  5708. func (m *BatchMsgMutation) AddTotal(i int32) {
  5709. if m.addtotal != nil {
  5710. *m.addtotal += i
  5711. } else {
  5712. m.addtotal = &i
  5713. }
  5714. }
  5715. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5716. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5717. v := m.addtotal
  5718. if v == nil {
  5719. return
  5720. }
  5721. return *v, true
  5722. }
  5723. // ClearTotal clears the value of the "total" field.
  5724. func (m *BatchMsgMutation) ClearTotal() {
  5725. m.total = nil
  5726. m.addtotal = nil
  5727. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5728. }
  5729. // TotalCleared returns if the "total" field was cleared in this mutation.
  5730. func (m *BatchMsgMutation) TotalCleared() bool {
  5731. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5732. return ok
  5733. }
  5734. // ResetTotal resets all changes to the "total" field.
  5735. func (m *BatchMsgMutation) ResetTotal() {
  5736. m.total = nil
  5737. m.addtotal = nil
  5738. delete(m.clearedFields, batchmsg.FieldTotal)
  5739. }
  5740. // SetSuccess sets the "success" field.
  5741. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5742. m.success = &i
  5743. m.addsuccess = nil
  5744. }
  5745. // Success returns the value of the "success" field in the mutation.
  5746. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5747. v := m.success
  5748. if v == nil {
  5749. return
  5750. }
  5751. return *v, true
  5752. }
  5753. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5754. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5756. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5757. if !m.op.Is(OpUpdateOne) {
  5758. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5759. }
  5760. if m.id == nil || m.oldValue == nil {
  5761. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5762. }
  5763. oldValue, err := m.oldValue(ctx)
  5764. if err != nil {
  5765. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5766. }
  5767. return oldValue.Success, nil
  5768. }
  5769. // AddSuccess adds i to the "success" field.
  5770. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5771. if m.addsuccess != nil {
  5772. *m.addsuccess += i
  5773. } else {
  5774. m.addsuccess = &i
  5775. }
  5776. }
  5777. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5778. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5779. v := m.addsuccess
  5780. if v == nil {
  5781. return
  5782. }
  5783. return *v, true
  5784. }
  5785. // ClearSuccess clears the value of the "success" field.
  5786. func (m *BatchMsgMutation) ClearSuccess() {
  5787. m.success = nil
  5788. m.addsuccess = nil
  5789. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5790. }
  5791. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5792. func (m *BatchMsgMutation) SuccessCleared() bool {
  5793. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5794. return ok
  5795. }
  5796. // ResetSuccess resets all changes to the "success" field.
  5797. func (m *BatchMsgMutation) ResetSuccess() {
  5798. m.success = nil
  5799. m.addsuccess = nil
  5800. delete(m.clearedFields, batchmsg.FieldSuccess)
  5801. }
  5802. // SetFail sets the "fail" field.
  5803. func (m *BatchMsgMutation) SetFail(i int32) {
  5804. m.fail = &i
  5805. m.addfail = nil
  5806. }
  5807. // Fail returns the value of the "fail" field in the mutation.
  5808. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5809. v := m.fail
  5810. if v == nil {
  5811. return
  5812. }
  5813. return *v, true
  5814. }
  5815. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5816. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5818. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5819. if !m.op.Is(OpUpdateOne) {
  5820. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5821. }
  5822. if m.id == nil || m.oldValue == nil {
  5823. return v, errors.New("OldFail requires an ID field in the mutation")
  5824. }
  5825. oldValue, err := m.oldValue(ctx)
  5826. if err != nil {
  5827. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5828. }
  5829. return oldValue.Fail, nil
  5830. }
  5831. // AddFail adds i to the "fail" field.
  5832. func (m *BatchMsgMutation) AddFail(i int32) {
  5833. if m.addfail != nil {
  5834. *m.addfail += i
  5835. } else {
  5836. m.addfail = &i
  5837. }
  5838. }
  5839. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5840. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5841. v := m.addfail
  5842. if v == nil {
  5843. return
  5844. }
  5845. return *v, true
  5846. }
  5847. // ClearFail clears the value of the "fail" field.
  5848. func (m *BatchMsgMutation) ClearFail() {
  5849. m.fail = nil
  5850. m.addfail = nil
  5851. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5852. }
  5853. // FailCleared returns if the "fail" field was cleared in this mutation.
  5854. func (m *BatchMsgMutation) FailCleared() bool {
  5855. _, ok := m.clearedFields[batchmsg.FieldFail]
  5856. return ok
  5857. }
  5858. // ResetFail resets all changes to the "fail" field.
  5859. func (m *BatchMsgMutation) ResetFail() {
  5860. m.fail = nil
  5861. m.addfail = nil
  5862. delete(m.clearedFields, batchmsg.FieldFail)
  5863. }
  5864. // SetStartTime sets the "start_time" field.
  5865. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5866. m.start_time = &t
  5867. }
  5868. // StartTime returns the value of the "start_time" field in the mutation.
  5869. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5870. v := m.start_time
  5871. if v == nil {
  5872. return
  5873. }
  5874. return *v, true
  5875. }
  5876. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5877. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5879. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5880. if !m.op.Is(OpUpdateOne) {
  5881. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5882. }
  5883. if m.id == nil || m.oldValue == nil {
  5884. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5885. }
  5886. oldValue, err := m.oldValue(ctx)
  5887. if err != nil {
  5888. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5889. }
  5890. return oldValue.StartTime, nil
  5891. }
  5892. // ClearStartTime clears the value of the "start_time" field.
  5893. func (m *BatchMsgMutation) ClearStartTime() {
  5894. m.start_time = nil
  5895. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5896. }
  5897. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5898. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5899. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5900. return ok
  5901. }
  5902. // ResetStartTime resets all changes to the "start_time" field.
  5903. func (m *BatchMsgMutation) ResetStartTime() {
  5904. m.start_time = nil
  5905. delete(m.clearedFields, batchmsg.FieldStartTime)
  5906. }
  5907. // SetStopTime sets the "stop_time" field.
  5908. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5909. m.stop_time = &t
  5910. }
  5911. // StopTime returns the value of the "stop_time" field in the mutation.
  5912. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5913. v := m.stop_time
  5914. if v == nil {
  5915. return
  5916. }
  5917. return *v, true
  5918. }
  5919. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5920. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5922. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5923. if !m.op.Is(OpUpdateOne) {
  5924. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5925. }
  5926. if m.id == nil || m.oldValue == nil {
  5927. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5928. }
  5929. oldValue, err := m.oldValue(ctx)
  5930. if err != nil {
  5931. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5932. }
  5933. return oldValue.StopTime, nil
  5934. }
  5935. // ClearStopTime clears the value of the "stop_time" field.
  5936. func (m *BatchMsgMutation) ClearStopTime() {
  5937. m.stop_time = nil
  5938. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5939. }
  5940. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5941. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5942. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5943. return ok
  5944. }
  5945. // ResetStopTime resets all changes to the "stop_time" field.
  5946. func (m *BatchMsgMutation) ResetStopTime() {
  5947. m.stop_time = nil
  5948. delete(m.clearedFields, batchmsg.FieldStopTime)
  5949. }
  5950. // SetSendTime sets the "send_time" field.
  5951. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5952. m.send_time = &t
  5953. }
  5954. // SendTime returns the value of the "send_time" field in the mutation.
  5955. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5956. v := m.send_time
  5957. if v == nil {
  5958. return
  5959. }
  5960. return *v, true
  5961. }
  5962. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5963. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5965. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5966. if !m.op.Is(OpUpdateOne) {
  5967. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5968. }
  5969. if m.id == nil || m.oldValue == nil {
  5970. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5971. }
  5972. oldValue, err := m.oldValue(ctx)
  5973. if err != nil {
  5974. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5975. }
  5976. return oldValue.SendTime, nil
  5977. }
  5978. // ClearSendTime clears the value of the "send_time" field.
  5979. func (m *BatchMsgMutation) ClearSendTime() {
  5980. m.send_time = nil
  5981. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5982. }
  5983. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5984. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5985. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5986. return ok
  5987. }
  5988. // ResetSendTime resets all changes to the "send_time" field.
  5989. func (m *BatchMsgMutation) ResetSendTime() {
  5990. m.send_time = nil
  5991. delete(m.clearedFields, batchmsg.FieldSendTime)
  5992. }
  5993. // SetType sets the "type" field.
  5994. func (m *BatchMsgMutation) SetType(i int32) {
  5995. m._type = &i
  5996. m.add_type = nil
  5997. }
  5998. // GetType returns the value of the "type" field in the mutation.
  5999. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6000. v := m._type
  6001. if v == nil {
  6002. return
  6003. }
  6004. return *v, true
  6005. }
  6006. // OldType returns the old "type" field's value of the BatchMsg entity.
  6007. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6009. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6010. if !m.op.Is(OpUpdateOne) {
  6011. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6012. }
  6013. if m.id == nil || m.oldValue == nil {
  6014. return v, errors.New("OldType requires an ID field in the mutation")
  6015. }
  6016. oldValue, err := m.oldValue(ctx)
  6017. if err != nil {
  6018. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6019. }
  6020. return oldValue.Type, nil
  6021. }
  6022. // AddType adds i to the "type" field.
  6023. func (m *BatchMsgMutation) AddType(i int32) {
  6024. if m.add_type != nil {
  6025. *m.add_type += i
  6026. } else {
  6027. m.add_type = &i
  6028. }
  6029. }
  6030. // AddedType returns the value that was added to the "type" field in this mutation.
  6031. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6032. v := m.add_type
  6033. if v == nil {
  6034. return
  6035. }
  6036. return *v, true
  6037. }
  6038. // ClearType clears the value of the "type" field.
  6039. func (m *BatchMsgMutation) ClearType() {
  6040. m._type = nil
  6041. m.add_type = nil
  6042. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6043. }
  6044. // TypeCleared returns if the "type" field was cleared in this mutation.
  6045. func (m *BatchMsgMutation) TypeCleared() bool {
  6046. _, ok := m.clearedFields[batchmsg.FieldType]
  6047. return ok
  6048. }
  6049. // ResetType resets all changes to the "type" field.
  6050. func (m *BatchMsgMutation) ResetType() {
  6051. m._type = nil
  6052. m.add_type = nil
  6053. delete(m.clearedFields, batchmsg.FieldType)
  6054. }
  6055. // SetOrganizationID sets the "organization_id" field.
  6056. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6057. m.organization_id = &u
  6058. m.addorganization_id = nil
  6059. }
  6060. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6061. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6062. v := m.organization_id
  6063. if v == nil {
  6064. return
  6065. }
  6066. return *v, true
  6067. }
  6068. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6069. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6071. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6072. if !m.op.Is(OpUpdateOne) {
  6073. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6074. }
  6075. if m.id == nil || m.oldValue == nil {
  6076. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6077. }
  6078. oldValue, err := m.oldValue(ctx)
  6079. if err != nil {
  6080. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6081. }
  6082. return oldValue.OrganizationID, nil
  6083. }
  6084. // AddOrganizationID adds u to the "organization_id" field.
  6085. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6086. if m.addorganization_id != nil {
  6087. *m.addorganization_id += u
  6088. } else {
  6089. m.addorganization_id = &u
  6090. }
  6091. }
  6092. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6093. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6094. v := m.addorganization_id
  6095. if v == nil {
  6096. return
  6097. }
  6098. return *v, true
  6099. }
  6100. // ResetOrganizationID resets all changes to the "organization_id" field.
  6101. func (m *BatchMsgMutation) ResetOrganizationID() {
  6102. m.organization_id = nil
  6103. m.addorganization_id = nil
  6104. }
  6105. // SetCtype sets the "ctype" field.
  6106. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6107. m.ctype = &u
  6108. m.addctype = nil
  6109. }
  6110. // Ctype returns the value of the "ctype" field in the mutation.
  6111. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6112. v := m.ctype
  6113. if v == nil {
  6114. return
  6115. }
  6116. return *v, true
  6117. }
  6118. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6119. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6121. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6122. if !m.op.Is(OpUpdateOne) {
  6123. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6124. }
  6125. if m.id == nil || m.oldValue == nil {
  6126. return v, errors.New("OldCtype requires an ID field in the mutation")
  6127. }
  6128. oldValue, err := m.oldValue(ctx)
  6129. if err != nil {
  6130. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6131. }
  6132. return oldValue.Ctype, nil
  6133. }
  6134. // AddCtype adds u to the "ctype" field.
  6135. func (m *BatchMsgMutation) AddCtype(u int64) {
  6136. if m.addctype != nil {
  6137. *m.addctype += u
  6138. } else {
  6139. m.addctype = &u
  6140. }
  6141. }
  6142. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6143. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6144. v := m.addctype
  6145. if v == nil {
  6146. return
  6147. }
  6148. return *v, true
  6149. }
  6150. // ResetCtype resets all changes to the "ctype" field.
  6151. func (m *BatchMsgMutation) ResetCtype() {
  6152. m.ctype = nil
  6153. m.addctype = nil
  6154. }
  6155. // SetCc sets the "cc" field.
  6156. func (m *BatchMsgMutation) SetCc(s string) {
  6157. m.cc = &s
  6158. }
  6159. // Cc returns the value of the "cc" field in the mutation.
  6160. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6161. v := m.cc
  6162. if v == nil {
  6163. return
  6164. }
  6165. return *v, true
  6166. }
  6167. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6168. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6170. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6171. if !m.op.Is(OpUpdateOne) {
  6172. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6173. }
  6174. if m.id == nil || m.oldValue == nil {
  6175. return v, errors.New("OldCc requires an ID field in the mutation")
  6176. }
  6177. oldValue, err := m.oldValue(ctx)
  6178. if err != nil {
  6179. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6180. }
  6181. return oldValue.Cc, nil
  6182. }
  6183. // ClearCc clears the value of the "cc" field.
  6184. func (m *BatchMsgMutation) ClearCc() {
  6185. m.cc = nil
  6186. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6187. }
  6188. // CcCleared returns if the "cc" field was cleared in this mutation.
  6189. func (m *BatchMsgMutation) CcCleared() bool {
  6190. _, ok := m.clearedFields[batchmsg.FieldCc]
  6191. return ok
  6192. }
  6193. // ResetCc resets all changes to the "cc" field.
  6194. func (m *BatchMsgMutation) ResetCc() {
  6195. m.cc = nil
  6196. delete(m.clearedFields, batchmsg.FieldCc)
  6197. }
  6198. // SetPhone sets the "phone" field.
  6199. func (m *BatchMsgMutation) SetPhone(s string) {
  6200. m.phone = &s
  6201. }
  6202. // Phone returns the value of the "phone" field in the mutation.
  6203. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6204. v := m.phone
  6205. if v == nil {
  6206. return
  6207. }
  6208. return *v, true
  6209. }
  6210. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6211. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6213. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6214. if !m.op.Is(OpUpdateOne) {
  6215. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6216. }
  6217. if m.id == nil || m.oldValue == nil {
  6218. return v, errors.New("OldPhone requires an ID field in the mutation")
  6219. }
  6220. oldValue, err := m.oldValue(ctx)
  6221. if err != nil {
  6222. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6223. }
  6224. return oldValue.Phone, nil
  6225. }
  6226. // ClearPhone clears the value of the "phone" field.
  6227. func (m *BatchMsgMutation) ClearPhone() {
  6228. m.phone = nil
  6229. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6230. }
  6231. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6232. func (m *BatchMsgMutation) PhoneCleared() bool {
  6233. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6234. return ok
  6235. }
  6236. // ResetPhone resets all changes to the "phone" field.
  6237. func (m *BatchMsgMutation) ResetPhone() {
  6238. m.phone = nil
  6239. delete(m.clearedFields, batchmsg.FieldPhone)
  6240. }
  6241. // SetTemplateName sets the "template_name" field.
  6242. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6243. m.template_name = &s
  6244. }
  6245. // TemplateName returns the value of the "template_name" field in the mutation.
  6246. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6247. v := m.template_name
  6248. if v == nil {
  6249. return
  6250. }
  6251. return *v, true
  6252. }
  6253. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6254. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6256. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6257. if !m.op.Is(OpUpdateOne) {
  6258. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6259. }
  6260. if m.id == nil || m.oldValue == nil {
  6261. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6262. }
  6263. oldValue, err := m.oldValue(ctx)
  6264. if err != nil {
  6265. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6266. }
  6267. return oldValue.TemplateName, nil
  6268. }
  6269. // ClearTemplateName clears the value of the "template_name" field.
  6270. func (m *BatchMsgMutation) ClearTemplateName() {
  6271. m.template_name = nil
  6272. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6273. }
  6274. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6275. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6276. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6277. return ok
  6278. }
  6279. // ResetTemplateName resets all changes to the "template_name" field.
  6280. func (m *BatchMsgMutation) ResetTemplateName() {
  6281. m.template_name = nil
  6282. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6283. }
  6284. // SetTemplateCode sets the "template_code" field.
  6285. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6286. m.template_code = &s
  6287. }
  6288. // TemplateCode returns the value of the "template_code" field in the mutation.
  6289. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6290. v := m.template_code
  6291. if v == nil {
  6292. return
  6293. }
  6294. return *v, true
  6295. }
  6296. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6297. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6299. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6300. if !m.op.Is(OpUpdateOne) {
  6301. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6302. }
  6303. if m.id == nil || m.oldValue == nil {
  6304. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6305. }
  6306. oldValue, err := m.oldValue(ctx)
  6307. if err != nil {
  6308. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6309. }
  6310. return oldValue.TemplateCode, nil
  6311. }
  6312. // ClearTemplateCode clears the value of the "template_code" field.
  6313. func (m *BatchMsgMutation) ClearTemplateCode() {
  6314. m.template_code = nil
  6315. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6316. }
  6317. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6318. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6319. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6320. return ok
  6321. }
  6322. // ResetTemplateCode resets all changes to the "template_code" field.
  6323. func (m *BatchMsgMutation) ResetTemplateCode() {
  6324. m.template_code = nil
  6325. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6326. }
  6327. // SetLang sets the "lang" field.
  6328. func (m *BatchMsgMutation) SetLang(s string) {
  6329. m.lang = &s
  6330. }
  6331. // Lang returns the value of the "lang" field in the mutation.
  6332. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6333. v := m.lang
  6334. if v == nil {
  6335. return
  6336. }
  6337. return *v, true
  6338. }
  6339. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6340. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6342. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6343. if !m.op.Is(OpUpdateOne) {
  6344. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6345. }
  6346. if m.id == nil || m.oldValue == nil {
  6347. return v, errors.New("OldLang requires an ID field in the mutation")
  6348. }
  6349. oldValue, err := m.oldValue(ctx)
  6350. if err != nil {
  6351. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6352. }
  6353. return oldValue.Lang, nil
  6354. }
  6355. // ClearLang clears the value of the "lang" field.
  6356. func (m *BatchMsgMutation) ClearLang() {
  6357. m.lang = nil
  6358. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6359. }
  6360. // LangCleared returns if the "lang" field was cleared in this mutation.
  6361. func (m *BatchMsgMutation) LangCleared() bool {
  6362. _, ok := m.clearedFields[batchmsg.FieldLang]
  6363. return ok
  6364. }
  6365. // ResetLang resets all changes to the "lang" field.
  6366. func (m *BatchMsgMutation) ResetLang() {
  6367. m.lang = nil
  6368. delete(m.clearedFields, batchmsg.FieldLang)
  6369. }
  6370. // Where appends a list predicates to the BatchMsgMutation builder.
  6371. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6372. m.predicates = append(m.predicates, ps...)
  6373. }
  6374. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6375. // users can use type-assertion to append predicates that do not depend on any generated package.
  6376. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6377. p := make([]predicate.BatchMsg, len(ps))
  6378. for i := range ps {
  6379. p[i] = ps[i]
  6380. }
  6381. m.Where(p...)
  6382. }
  6383. // Op returns the operation name.
  6384. func (m *BatchMsgMutation) Op() Op {
  6385. return m.op
  6386. }
  6387. // SetOp allows setting the mutation operation.
  6388. func (m *BatchMsgMutation) SetOp(op Op) {
  6389. m.op = op
  6390. }
  6391. // Type returns the node type of this mutation (BatchMsg).
  6392. func (m *BatchMsgMutation) Type() string {
  6393. return m.typ
  6394. }
  6395. // Fields returns all fields that were changed during this mutation. Note that in
  6396. // order to get all numeric fields that were incremented/decremented, call
  6397. // AddedFields().
  6398. func (m *BatchMsgMutation) Fields() []string {
  6399. fields := make([]string, 0, 24)
  6400. if m.created_at != nil {
  6401. fields = append(fields, batchmsg.FieldCreatedAt)
  6402. }
  6403. if m.updated_at != nil {
  6404. fields = append(fields, batchmsg.FieldUpdatedAt)
  6405. }
  6406. if m.deleted_at != nil {
  6407. fields = append(fields, batchmsg.FieldDeletedAt)
  6408. }
  6409. if m.status != nil {
  6410. fields = append(fields, batchmsg.FieldStatus)
  6411. }
  6412. if m.batch_no != nil {
  6413. fields = append(fields, batchmsg.FieldBatchNo)
  6414. }
  6415. if m.task_name != nil {
  6416. fields = append(fields, batchmsg.FieldTaskName)
  6417. }
  6418. if m.fromwxid != nil {
  6419. fields = append(fields, batchmsg.FieldFromwxid)
  6420. }
  6421. if m.msg != nil {
  6422. fields = append(fields, batchmsg.FieldMsg)
  6423. }
  6424. if m.tag != nil {
  6425. fields = append(fields, batchmsg.FieldTag)
  6426. }
  6427. if m.tagids != nil {
  6428. fields = append(fields, batchmsg.FieldTagids)
  6429. }
  6430. if m.total != nil {
  6431. fields = append(fields, batchmsg.FieldTotal)
  6432. }
  6433. if m.success != nil {
  6434. fields = append(fields, batchmsg.FieldSuccess)
  6435. }
  6436. if m.fail != nil {
  6437. fields = append(fields, batchmsg.FieldFail)
  6438. }
  6439. if m.start_time != nil {
  6440. fields = append(fields, batchmsg.FieldStartTime)
  6441. }
  6442. if m.stop_time != nil {
  6443. fields = append(fields, batchmsg.FieldStopTime)
  6444. }
  6445. if m.send_time != nil {
  6446. fields = append(fields, batchmsg.FieldSendTime)
  6447. }
  6448. if m._type != nil {
  6449. fields = append(fields, batchmsg.FieldType)
  6450. }
  6451. if m.organization_id != nil {
  6452. fields = append(fields, batchmsg.FieldOrganizationID)
  6453. }
  6454. if m.ctype != nil {
  6455. fields = append(fields, batchmsg.FieldCtype)
  6456. }
  6457. if m.cc != nil {
  6458. fields = append(fields, batchmsg.FieldCc)
  6459. }
  6460. if m.phone != nil {
  6461. fields = append(fields, batchmsg.FieldPhone)
  6462. }
  6463. if m.template_name != nil {
  6464. fields = append(fields, batchmsg.FieldTemplateName)
  6465. }
  6466. if m.template_code != nil {
  6467. fields = append(fields, batchmsg.FieldTemplateCode)
  6468. }
  6469. if m.lang != nil {
  6470. fields = append(fields, batchmsg.FieldLang)
  6471. }
  6472. return fields
  6473. }
  6474. // Field returns the value of a field with the given name. The second boolean
  6475. // return value indicates that this field was not set, or was not defined in the
  6476. // schema.
  6477. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6478. switch name {
  6479. case batchmsg.FieldCreatedAt:
  6480. return m.CreatedAt()
  6481. case batchmsg.FieldUpdatedAt:
  6482. return m.UpdatedAt()
  6483. case batchmsg.FieldDeletedAt:
  6484. return m.DeletedAt()
  6485. case batchmsg.FieldStatus:
  6486. return m.Status()
  6487. case batchmsg.FieldBatchNo:
  6488. return m.BatchNo()
  6489. case batchmsg.FieldTaskName:
  6490. return m.TaskName()
  6491. case batchmsg.FieldFromwxid:
  6492. return m.Fromwxid()
  6493. case batchmsg.FieldMsg:
  6494. return m.Msg()
  6495. case batchmsg.FieldTag:
  6496. return m.Tag()
  6497. case batchmsg.FieldTagids:
  6498. return m.Tagids()
  6499. case batchmsg.FieldTotal:
  6500. return m.Total()
  6501. case batchmsg.FieldSuccess:
  6502. return m.Success()
  6503. case batchmsg.FieldFail:
  6504. return m.Fail()
  6505. case batchmsg.FieldStartTime:
  6506. return m.StartTime()
  6507. case batchmsg.FieldStopTime:
  6508. return m.StopTime()
  6509. case batchmsg.FieldSendTime:
  6510. return m.SendTime()
  6511. case batchmsg.FieldType:
  6512. return m.GetType()
  6513. case batchmsg.FieldOrganizationID:
  6514. return m.OrganizationID()
  6515. case batchmsg.FieldCtype:
  6516. return m.Ctype()
  6517. case batchmsg.FieldCc:
  6518. return m.Cc()
  6519. case batchmsg.FieldPhone:
  6520. return m.Phone()
  6521. case batchmsg.FieldTemplateName:
  6522. return m.TemplateName()
  6523. case batchmsg.FieldTemplateCode:
  6524. return m.TemplateCode()
  6525. case batchmsg.FieldLang:
  6526. return m.Lang()
  6527. }
  6528. return nil, false
  6529. }
  6530. // OldField returns the old value of the field from the database. An error is
  6531. // returned if the mutation operation is not UpdateOne, or the query to the
  6532. // database failed.
  6533. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6534. switch name {
  6535. case batchmsg.FieldCreatedAt:
  6536. return m.OldCreatedAt(ctx)
  6537. case batchmsg.FieldUpdatedAt:
  6538. return m.OldUpdatedAt(ctx)
  6539. case batchmsg.FieldDeletedAt:
  6540. return m.OldDeletedAt(ctx)
  6541. case batchmsg.FieldStatus:
  6542. return m.OldStatus(ctx)
  6543. case batchmsg.FieldBatchNo:
  6544. return m.OldBatchNo(ctx)
  6545. case batchmsg.FieldTaskName:
  6546. return m.OldTaskName(ctx)
  6547. case batchmsg.FieldFromwxid:
  6548. return m.OldFromwxid(ctx)
  6549. case batchmsg.FieldMsg:
  6550. return m.OldMsg(ctx)
  6551. case batchmsg.FieldTag:
  6552. return m.OldTag(ctx)
  6553. case batchmsg.FieldTagids:
  6554. return m.OldTagids(ctx)
  6555. case batchmsg.FieldTotal:
  6556. return m.OldTotal(ctx)
  6557. case batchmsg.FieldSuccess:
  6558. return m.OldSuccess(ctx)
  6559. case batchmsg.FieldFail:
  6560. return m.OldFail(ctx)
  6561. case batchmsg.FieldStartTime:
  6562. return m.OldStartTime(ctx)
  6563. case batchmsg.FieldStopTime:
  6564. return m.OldStopTime(ctx)
  6565. case batchmsg.FieldSendTime:
  6566. return m.OldSendTime(ctx)
  6567. case batchmsg.FieldType:
  6568. return m.OldType(ctx)
  6569. case batchmsg.FieldOrganizationID:
  6570. return m.OldOrganizationID(ctx)
  6571. case batchmsg.FieldCtype:
  6572. return m.OldCtype(ctx)
  6573. case batchmsg.FieldCc:
  6574. return m.OldCc(ctx)
  6575. case batchmsg.FieldPhone:
  6576. return m.OldPhone(ctx)
  6577. case batchmsg.FieldTemplateName:
  6578. return m.OldTemplateName(ctx)
  6579. case batchmsg.FieldTemplateCode:
  6580. return m.OldTemplateCode(ctx)
  6581. case batchmsg.FieldLang:
  6582. return m.OldLang(ctx)
  6583. }
  6584. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6585. }
  6586. // SetField sets the value of a field with the given name. It returns an error if
  6587. // the field is not defined in the schema, or if the type mismatched the field
  6588. // type.
  6589. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6590. switch name {
  6591. case batchmsg.FieldCreatedAt:
  6592. v, ok := value.(time.Time)
  6593. if !ok {
  6594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6595. }
  6596. m.SetCreatedAt(v)
  6597. return nil
  6598. case batchmsg.FieldUpdatedAt:
  6599. v, ok := value.(time.Time)
  6600. if !ok {
  6601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6602. }
  6603. m.SetUpdatedAt(v)
  6604. return nil
  6605. case batchmsg.FieldDeletedAt:
  6606. v, ok := value.(time.Time)
  6607. if !ok {
  6608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6609. }
  6610. m.SetDeletedAt(v)
  6611. return nil
  6612. case batchmsg.FieldStatus:
  6613. v, ok := value.(uint8)
  6614. if !ok {
  6615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6616. }
  6617. m.SetStatus(v)
  6618. return nil
  6619. case batchmsg.FieldBatchNo:
  6620. v, ok := value.(string)
  6621. if !ok {
  6622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6623. }
  6624. m.SetBatchNo(v)
  6625. return nil
  6626. case batchmsg.FieldTaskName:
  6627. v, ok := value.(string)
  6628. if !ok {
  6629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6630. }
  6631. m.SetTaskName(v)
  6632. return nil
  6633. case batchmsg.FieldFromwxid:
  6634. v, ok := value.(string)
  6635. if !ok {
  6636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6637. }
  6638. m.SetFromwxid(v)
  6639. return nil
  6640. case batchmsg.FieldMsg:
  6641. v, ok := value.(string)
  6642. if !ok {
  6643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6644. }
  6645. m.SetMsg(v)
  6646. return nil
  6647. case batchmsg.FieldTag:
  6648. v, ok := value.(string)
  6649. if !ok {
  6650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6651. }
  6652. m.SetTag(v)
  6653. return nil
  6654. case batchmsg.FieldTagids:
  6655. v, ok := value.(string)
  6656. if !ok {
  6657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6658. }
  6659. m.SetTagids(v)
  6660. return nil
  6661. case batchmsg.FieldTotal:
  6662. v, ok := value.(int32)
  6663. if !ok {
  6664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6665. }
  6666. m.SetTotal(v)
  6667. return nil
  6668. case batchmsg.FieldSuccess:
  6669. v, ok := value.(int32)
  6670. if !ok {
  6671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6672. }
  6673. m.SetSuccess(v)
  6674. return nil
  6675. case batchmsg.FieldFail:
  6676. v, ok := value.(int32)
  6677. if !ok {
  6678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6679. }
  6680. m.SetFail(v)
  6681. return nil
  6682. case batchmsg.FieldStartTime:
  6683. v, ok := value.(time.Time)
  6684. if !ok {
  6685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6686. }
  6687. m.SetStartTime(v)
  6688. return nil
  6689. case batchmsg.FieldStopTime:
  6690. v, ok := value.(time.Time)
  6691. if !ok {
  6692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6693. }
  6694. m.SetStopTime(v)
  6695. return nil
  6696. case batchmsg.FieldSendTime:
  6697. v, ok := value.(time.Time)
  6698. if !ok {
  6699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6700. }
  6701. m.SetSendTime(v)
  6702. return nil
  6703. case batchmsg.FieldType:
  6704. v, ok := value.(int32)
  6705. if !ok {
  6706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6707. }
  6708. m.SetType(v)
  6709. return nil
  6710. case batchmsg.FieldOrganizationID:
  6711. v, ok := value.(uint64)
  6712. if !ok {
  6713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6714. }
  6715. m.SetOrganizationID(v)
  6716. return nil
  6717. case batchmsg.FieldCtype:
  6718. v, ok := value.(uint64)
  6719. if !ok {
  6720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6721. }
  6722. m.SetCtype(v)
  6723. return nil
  6724. case batchmsg.FieldCc:
  6725. v, ok := value.(string)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.SetCc(v)
  6730. return nil
  6731. case batchmsg.FieldPhone:
  6732. v, ok := value.(string)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.SetPhone(v)
  6737. return nil
  6738. case batchmsg.FieldTemplateName:
  6739. v, ok := value.(string)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.SetTemplateName(v)
  6744. return nil
  6745. case batchmsg.FieldTemplateCode:
  6746. v, ok := value.(string)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.SetTemplateCode(v)
  6751. return nil
  6752. case batchmsg.FieldLang:
  6753. v, ok := value.(string)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.SetLang(v)
  6758. return nil
  6759. }
  6760. return fmt.Errorf("unknown BatchMsg field %s", name)
  6761. }
  6762. // AddedFields returns all numeric fields that were incremented/decremented during
  6763. // this mutation.
  6764. func (m *BatchMsgMutation) AddedFields() []string {
  6765. var fields []string
  6766. if m.addstatus != nil {
  6767. fields = append(fields, batchmsg.FieldStatus)
  6768. }
  6769. if m.addtotal != nil {
  6770. fields = append(fields, batchmsg.FieldTotal)
  6771. }
  6772. if m.addsuccess != nil {
  6773. fields = append(fields, batchmsg.FieldSuccess)
  6774. }
  6775. if m.addfail != nil {
  6776. fields = append(fields, batchmsg.FieldFail)
  6777. }
  6778. if m.add_type != nil {
  6779. fields = append(fields, batchmsg.FieldType)
  6780. }
  6781. if m.addorganization_id != nil {
  6782. fields = append(fields, batchmsg.FieldOrganizationID)
  6783. }
  6784. if m.addctype != nil {
  6785. fields = append(fields, batchmsg.FieldCtype)
  6786. }
  6787. return fields
  6788. }
  6789. // AddedField returns the numeric value that was incremented/decremented on a field
  6790. // with the given name. The second boolean return value indicates that this field
  6791. // was not set, or was not defined in the schema.
  6792. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6793. switch name {
  6794. case batchmsg.FieldStatus:
  6795. return m.AddedStatus()
  6796. case batchmsg.FieldTotal:
  6797. return m.AddedTotal()
  6798. case batchmsg.FieldSuccess:
  6799. return m.AddedSuccess()
  6800. case batchmsg.FieldFail:
  6801. return m.AddedFail()
  6802. case batchmsg.FieldType:
  6803. return m.AddedType()
  6804. case batchmsg.FieldOrganizationID:
  6805. return m.AddedOrganizationID()
  6806. case batchmsg.FieldCtype:
  6807. return m.AddedCtype()
  6808. }
  6809. return nil, false
  6810. }
  6811. // AddField adds the value to the field with the given name. It returns an error if
  6812. // the field is not defined in the schema, or if the type mismatched the field
  6813. // type.
  6814. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6815. switch name {
  6816. case batchmsg.FieldStatus:
  6817. v, ok := value.(int8)
  6818. if !ok {
  6819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6820. }
  6821. m.AddStatus(v)
  6822. return nil
  6823. case batchmsg.FieldTotal:
  6824. v, ok := value.(int32)
  6825. if !ok {
  6826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6827. }
  6828. m.AddTotal(v)
  6829. return nil
  6830. case batchmsg.FieldSuccess:
  6831. v, ok := value.(int32)
  6832. if !ok {
  6833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6834. }
  6835. m.AddSuccess(v)
  6836. return nil
  6837. case batchmsg.FieldFail:
  6838. v, ok := value.(int32)
  6839. if !ok {
  6840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6841. }
  6842. m.AddFail(v)
  6843. return nil
  6844. case batchmsg.FieldType:
  6845. v, ok := value.(int32)
  6846. if !ok {
  6847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6848. }
  6849. m.AddType(v)
  6850. return nil
  6851. case batchmsg.FieldOrganizationID:
  6852. v, ok := value.(int64)
  6853. if !ok {
  6854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6855. }
  6856. m.AddOrganizationID(v)
  6857. return nil
  6858. case batchmsg.FieldCtype:
  6859. v, ok := value.(int64)
  6860. if !ok {
  6861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6862. }
  6863. m.AddCtype(v)
  6864. return nil
  6865. }
  6866. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6867. }
  6868. // ClearedFields returns all nullable fields that were cleared during this
  6869. // mutation.
  6870. func (m *BatchMsgMutation) ClearedFields() []string {
  6871. var fields []string
  6872. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6873. fields = append(fields, batchmsg.FieldDeletedAt)
  6874. }
  6875. if m.FieldCleared(batchmsg.FieldStatus) {
  6876. fields = append(fields, batchmsg.FieldStatus)
  6877. }
  6878. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6879. fields = append(fields, batchmsg.FieldBatchNo)
  6880. }
  6881. if m.FieldCleared(batchmsg.FieldTaskName) {
  6882. fields = append(fields, batchmsg.FieldTaskName)
  6883. }
  6884. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6885. fields = append(fields, batchmsg.FieldFromwxid)
  6886. }
  6887. if m.FieldCleared(batchmsg.FieldMsg) {
  6888. fields = append(fields, batchmsg.FieldMsg)
  6889. }
  6890. if m.FieldCleared(batchmsg.FieldTag) {
  6891. fields = append(fields, batchmsg.FieldTag)
  6892. }
  6893. if m.FieldCleared(batchmsg.FieldTagids) {
  6894. fields = append(fields, batchmsg.FieldTagids)
  6895. }
  6896. if m.FieldCleared(batchmsg.FieldTotal) {
  6897. fields = append(fields, batchmsg.FieldTotal)
  6898. }
  6899. if m.FieldCleared(batchmsg.FieldSuccess) {
  6900. fields = append(fields, batchmsg.FieldSuccess)
  6901. }
  6902. if m.FieldCleared(batchmsg.FieldFail) {
  6903. fields = append(fields, batchmsg.FieldFail)
  6904. }
  6905. if m.FieldCleared(batchmsg.FieldStartTime) {
  6906. fields = append(fields, batchmsg.FieldStartTime)
  6907. }
  6908. if m.FieldCleared(batchmsg.FieldStopTime) {
  6909. fields = append(fields, batchmsg.FieldStopTime)
  6910. }
  6911. if m.FieldCleared(batchmsg.FieldSendTime) {
  6912. fields = append(fields, batchmsg.FieldSendTime)
  6913. }
  6914. if m.FieldCleared(batchmsg.FieldType) {
  6915. fields = append(fields, batchmsg.FieldType)
  6916. }
  6917. if m.FieldCleared(batchmsg.FieldCc) {
  6918. fields = append(fields, batchmsg.FieldCc)
  6919. }
  6920. if m.FieldCleared(batchmsg.FieldPhone) {
  6921. fields = append(fields, batchmsg.FieldPhone)
  6922. }
  6923. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6924. fields = append(fields, batchmsg.FieldTemplateName)
  6925. }
  6926. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6927. fields = append(fields, batchmsg.FieldTemplateCode)
  6928. }
  6929. if m.FieldCleared(batchmsg.FieldLang) {
  6930. fields = append(fields, batchmsg.FieldLang)
  6931. }
  6932. return fields
  6933. }
  6934. // FieldCleared returns a boolean indicating if a field with the given name was
  6935. // cleared in this mutation.
  6936. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6937. _, ok := m.clearedFields[name]
  6938. return ok
  6939. }
  6940. // ClearField clears the value of the field with the given name. It returns an
  6941. // error if the field is not defined in the schema.
  6942. func (m *BatchMsgMutation) ClearField(name string) error {
  6943. switch name {
  6944. case batchmsg.FieldDeletedAt:
  6945. m.ClearDeletedAt()
  6946. return nil
  6947. case batchmsg.FieldStatus:
  6948. m.ClearStatus()
  6949. return nil
  6950. case batchmsg.FieldBatchNo:
  6951. m.ClearBatchNo()
  6952. return nil
  6953. case batchmsg.FieldTaskName:
  6954. m.ClearTaskName()
  6955. return nil
  6956. case batchmsg.FieldFromwxid:
  6957. m.ClearFromwxid()
  6958. return nil
  6959. case batchmsg.FieldMsg:
  6960. m.ClearMsg()
  6961. return nil
  6962. case batchmsg.FieldTag:
  6963. m.ClearTag()
  6964. return nil
  6965. case batchmsg.FieldTagids:
  6966. m.ClearTagids()
  6967. return nil
  6968. case batchmsg.FieldTotal:
  6969. m.ClearTotal()
  6970. return nil
  6971. case batchmsg.FieldSuccess:
  6972. m.ClearSuccess()
  6973. return nil
  6974. case batchmsg.FieldFail:
  6975. m.ClearFail()
  6976. return nil
  6977. case batchmsg.FieldStartTime:
  6978. m.ClearStartTime()
  6979. return nil
  6980. case batchmsg.FieldStopTime:
  6981. m.ClearStopTime()
  6982. return nil
  6983. case batchmsg.FieldSendTime:
  6984. m.ClearSendTime()
  6985. return nil
  6986. case batchmsg.FieldType:
  6987. m.ClearType()
  6988. return nil
  6989. case batchmsg.FieldCc:
  6990. m.ClearCc()
  6991. return nil
  6992. case batchmsg.FieldPhone:
  6993. m.ClearPhone()
  6994. return nil
  6995. case batchmsg.FieldTemplateName:
  6996. m.ClearTemplateName()
  6997. return nil
  6998. case batchmsg.FieldTemplateCode:
  6999. m.ClearTemplateCode()
  7000. return nil
  7001. case batchmsg.FieldLang:
  7002. m.ClearLang()
  7003. return nil
  7004. }
  7005. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7006. }
  7007. // ResetField resets all changes in the mutation for the field with the given name.
  7008. // It returns an error if the field is not defined in the schema.
  7009. func (m *BatchMsgMutation) ResetField(name string) error {
  7010. switch name {
  7011. case batchmsg.FieldCreatedAt:
  7012. m.ResetCreatedAt()
  7013. return nil
  7014. case batchmsg.FieldUpdatedAt:
  7015. m.ResetUpdatedAt()
  7016. return nil
  7017. case batchmsg.FieldDeletedAt:
  7018. m.ResetDeletedAt()
  7019. return nil
  7020. case batchmsg.FieldStatus:
  7021. m.ResetStatus()
  7022. return nil
  7023. case batchmsg.FieldBatchNo:
  7024. m.ResetBatchNo()
  7025. return nil
  7026. case batchmsg.FieldTaskName:
  7027. m.ResetTaskName()
  7028. return nil
  7029. case batchmsg.FieldFromwxid:
  7030. m.ResetFromwxid()
  7031. return nil
  7032. case batchmsg.FieldMsg:
  7033. m.ResetMsg()
  7034. return nil
  7035. case batchmsg.FieldTag:
  7036. m.ResetTag()
  7037. return nil
  7038. case batchmsg.FieldTagids:
  7039. m.ResetTagids()
  7040. return nil
  7041. case batchmsg.FieldTotal:
  7042. m.ResetTotal()
  7043. return nil
  7044. case batchmsg.FieldSuccess:
  7045. m.ResetSuccess()
  7046. return nil
  7047. case batchmsg.FieldFail:
  7048. m.ResetFail()
  7049. return nil
  7050. case batchmsg.FieldStartTime:
  7051. m.ResetStartTime()
  7052. return nil
  7053. case batchmsg.FieldStopTime:
  7054. m.ResetStopTime()
  7055. return nil
  7056. case batchmsg.FieldSendTime:
  7057. m.ResetSendTime()
  7058. return nil
  7059. case batchmsg.FieldType:
  7060. m.ResetType()
  7061. return nil
  7062. case batchmsg.FieldOrganizationID:
  7063. m.ResetOrganizationID()
  7064. return nil
  7065. case batchmsg.FieldCtype:
  7066. m.ResetCtype()
  7067. return nil
  7068. case batchmsg.FieldCc:
  7069. m.ResetCc()
  7070. return nil
  7071. case batchmsg.FieldPhone:
  7072. m.ResetPhone()
  7073. return nil
  7074. case batchmsg.FieldTemplateName:
  7075. m.ResetTemplateName()
  7076. return nil
  7077. case batchmsg.FieldTemplateCode:
  7078. m.ResetTemplateCode()
  7079. return nil
  7080. case batchmsg.FieldLang:
  7081. m.ResetLang()
  7082. return nil
  7083. }
  7084. return fmt.Errorf("unknown BatchMsg field %s", name)
  7085. }
  7086. // AddedEdges returns all edge names that were set/added in this mutation.
  7087. func (m *BatchMsgMutation) AddedEdges() []string {
  7088. edges := make([]string, 0, 0)
  7089. return edges
  7090. }
  7091. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7092. // name in this mutation.
  7093. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7094. return nil
  7095. }
  7096. // RemovedEdges returns all edge names that were removed in this mutation.
  7097. func (m *BatchMsgMutation) RemovedEdges() []string {
  7098. edges := make([]string, 0, 0)
  7099. return edges
  7100. }
  7101. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7102. // the given name in this mutation.
  7103. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7104. return nil
  7105. }
  7106. // ClearedEdges returns all edge names that were cleared in this mutation.
  7107. func (m *BatchMsgMutation) ClearedEdges() []string {
  7108. edges := make([]string, 0, 0)
  7109. return edges
  7110. }
  7111. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7112. // was cleared in this mutation.
  7113. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7114. return false
  7115. }
  7116. // ClearEdge clears the value of the edge with the given name. It returns an error
  7117. // if that edge is not defined in the schema.
  7118. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7119. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7120. }
  7121. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7122. // It returns an error if the edge is not defined in the schema.
  7123. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7124. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7125. }
  7126. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7127. type CategoryMutation struct {
  7128. config
  7129. op Op
  7130. typ string
  7131. id *uint64
  7132. created_at *time.Time
  7133. updated_at *time.Time
  7134. deleted_at *time.Time
  7135. name *string
  7136. organization_id *uint64
  7137. addorganization_id *int64
  7138. clearedFields map[string]struct{}
  7139. done bool
  7140. oldValue func(context.Context) (*Category, error)
  7141. predicates []predicate.Category
  7142. }
  7143. var _ ent.Mutation = (*CategoryMutation)(nil)
  7144. // categoryOption allows management of the mutation configuration using functional options.
  7145. type categoryOption func(*CategoryMutation)
  7146. // newCategoryMutation creates new mutation for the Category entity.
  7147. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7148. m := &CategoryMutation{
  7149. config: c,
  7150. op: op,
  7151. typ: TypeCategory,
  7152. clearedFields: make(map[string]struct{}),
  7153. }
  7154. for _, opt := range opts {
  7155. opt(m)
  7156. }
  7157. return m
  7158. }
  7159. // withCategoryID sets the ID field of the mutation.
  7160. func withCategoryID(id uint64) categoryOption {
  7161. return func(m *CategoryMutation) {
  7162. var (
  7163. err error
  7164. once sync.Once
  7165. value *Category
  7166. )
  7167. m.oldValue = func(ctx context.Context) (*Category, error) {
  7168. once.Do(func() {
  7169. if m.done {
  7170. err = errors.New("querying old values post mutation is not allowed")
  7171. } else {
  7172. value, err = m.Client().Category.Get(ctx, id)
  7173. }
  7174. })
  7175. return value, err
  7176. }
  7177. m.id = &id
  7178. }
  7179. }
  7180. // withCategory sets the old Category of the mutation.
  7181. func withCategory(node *Category) categoryOption {
  7182. return func(m *CategoryMutation) {
  7183. m.oldValue = func(context.Context) (*Category, error) {
  7184. return node, nil
  7185. }
  7186. m.id = &node.ID
  7187. }
  7188. }
  7189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7190. // executed in a transaction (ent.Tx), a transactional client is returned.
  7191. func (m CategoryMutation) Client() *Client {
  7192. client := &Client{config: m.config}
  7193. client.init()
  7194. return client
  7195. }
  7196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7197. // it returns an error otherwise.
  7198. func (m CategoryMutation) Tx() (*Tx, error) {
  7199. if _, ok := m.driver.(*txDriver); !ok {
  7200. return nil, errors.New("ent: mutation is not running in a transaction")
  7201. }
  7202. tx := &Tx{config: m.config}
  7203. tx.init()
  7204. return tx, nil
  7205. }
  7206. // SetID sets the value of the id field. Note that this
  7207. // operation is only accepted on creation of Category entities.
  7208. func (m *CategoryMutation) SetID(id uint64) {
  7209. m.id = &id
  7210. }
  7211. // ID returns the ID value in the mutation. Note that the ID is only available
  7212. // if it was provided to the builder or after it was returned from the database.
  7213. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7214. if m.id == nil {
  7215. return
  7216. }
  7217. return *m.id, true
  7218. }
  7219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7220. // That means, if the mutation is applied within a transaction with an isolation level such
  7221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7222. // or updated by the mutation.
  7223. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7224. switch {
  7225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7226. id, exists := m.ID()
  7227. if exists {
  7228. return []uint64{id}, nil
  7229. }
  7230. fallthrough
  7231. case m.op.Is(OpUpdate | OpDelete):
  7232. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7233. default:
  7234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7235. }
  7236. }
  7237. // SetCreatedAt sets the "created_at" field.
  7238. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7239. m.created_at = &t
  7240. }
  7241. // CreatedAt returns the value of the "created_at" field in the mutation.
  7242. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7243. v := m.created_at
  7244. if v == nil {
  7245. return
  7246. }
  7247. return *v, true
  7248. }
  7249. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7250. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7252. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7253. if !m.op.Is(OpUpdateOne) {
  7254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7255. }
  7256. if m.id == nil || m.oldValue == nil {
  7257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7258. }
  7259. oldValue, err := m.oldValue(ctx)
  7260. if err != nil {
  7261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7262. }
  7263. return oldValue.CreatedAt, nil
  7264. }
  7265. // ResetCreatedAt resets all changes to the "created_at" field.
  7266. func (m *CategoryMutation) ResetCreatedAt() {
  7267. m.created_at = nil
  7268. }
  7269. // SetUpdatedAt sets the "updated_at" field.
  7270. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7271. m.updated_at = &t
  7272. }
  7273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7274. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7275. v := m.updated_at
  7276. if v == nil {
  7277. return
  7278. }
  7279. return *v, true
  7280. }
  7281. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7282. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7284. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7285. if !m.op.Is(OpUpdateOne) {
  7286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7287. }
  7288. if m.id == nil || m.oldValue == nil {
  7289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7290. }
  7291. oldValue, err := m.oldValue(ctx)
  7292. if err != nil {
  7293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7294. }
  7295. return oldValue.UpdatedAt, nil
  7296. }
  7297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7298. func (m *CategoryMutation) ResetUpdatedAt() {
  7299. m.updated_at = nil
  7300. }
  7301. // SetDeletedAt sets the "deleted_at" field.
  7302. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7303. m.deleted_at = &t
  7304. }
  7305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7306. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7307. v := m.deleted_at
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7314. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7326. }
  7327. return oldValue.DeletedAt, nil
  7328. }
  7329. // ClearDeletedAt clears the value of the "deleted_at" field.
  7330. func (m *CategoryMutation) ClearDeletedAt() {
  7331. m.deleted_at = nil
  7332. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7333. }
  7334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7335. func (m *CategoryMutation) DeletedAtCleared() bool {
  7336. _, ok := m.clearedFields[category.FieldDeletedAt]
  7337. return ok
  7338. }
  7339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7340. func (m *CategoryMutation) ResetDeletedAt() {
  7341. m.deleted_at = nil
  7342. delete(m.clearedFields, category.FieldDeletedAt)
  7343. }
  7344. // SetName sets the "name" field.
  7345. func (m *CategoryMutation) SetName(s string) {
  7346. m.name = &s
  7347. }
  7348. // Name returns the value of the "name" field in the mutation.
  7349. func (m *CategoryMutation) Name() (r string, exists bool) {
  7350. v := m.name
  7351. if v == nil {
  7352. return
  7353. }
  7354. return *v, true
  7355. }
  7356. // OldName returns the old "name" field's value of the Category entity.
  7357. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7359. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7360. if !m.op.Is(OpUpdateOne) {
  7361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7362. }
  7363. if m.id == nil || m.oldValue == nil {
  7364. return v, errors.New("OldName requires an ID field in the mutation")
  7365. }
  7366. oldValue, err := m.oldValue(ctx)
  7367. if err != nil {
  7368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7369. }
  7370. return oldValue.Name, nil
  7371. }
  7372. // ResetName resets all changes to the "name" field.
  7373. func (m *CategoryMutation) ResetName() {
  7374. m.name = nil
  7375. }
  7376. // SetOrganizationID sets the "organization_id" field.
  7377. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7378. m.organization_id = &u
  7379. m.addorganization_id = nil
  7380. }
  7381. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7382. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7383. v := m.organization_id
  7384. if v == nil {
  7385. return
  7386. }
  7387. return *v, true
  7388. }
  7389. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7390. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7392. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7393. if !m.op.Is(OpUpdateOne) {
  7394. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7395. }
  7396. if m.id == nil || m.oldValue == nil {
  7397. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7398. }
  7399. oldValue, err := m.oldValue(ctx)
  7400. if err != nil {
  7401. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7402. }
  7403. return oldValue.OrganizationID, nil
  7404. }
  7405. // AddOrganizationID adds u to the "organization_id" field.
  7406. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7407. if m.addorganization_id != nil {
  7408. *m.addorganization_id += u
  7409. } else {
  7410. m.addorganization_id = &u
  7411. }
  7412. }
  7413. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7414. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7415. v := m.addorganization_id
  7416. if v == nil {
  7417. return
  7418. }
  7419. return *v, true
  7420. }
  7421. // ResetOrganizationID resets all changes to the "organization_id" field.
  7422. func (m *CategoryMutation) ResetOrganizationID() {
  7423. m.organization_id = nil
  7424. m.addorganization_id = nil
  7425. }
  7426. // Where appends a list predicates to the CategoryMutation builder.
  7427. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7428. m.predicates = append(m.predicates, ps...)
  7429. }
  7430. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7431. // users can use type-assertion to append predicates that do not depend on any generated package.
  7432. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7433. p := make([]predicate.Category, len(ps))
  7434. for i := range ps {
  7435. p[i] = ps[i]
  7436. }
  7437. m.Where(p...)
  7438. }
  7439. // Op returns the operation name.
  7440. func (m *CategoryMutation) Op() Op {
  7441. return m.op
  7442. }
  7443. // SetOp allows setting the mutation operation.
  7444. func (m *CategoryMutation) SetOp(op Op) {
  7445. m.op = op
  7446. }
  7447. // Type returns the node type of this mutation (Category).
  7448. func (m *CategoryMutation) Type() string {
  7449. return m.typ
  7450. }
  7451. // Fields returns all fields that were changed during this mutation. Note that in
  7452. // order to get all numeric fields that were incremented/decremented, call
  7453. // AddedFields().
  7454. func (m *CategoryMutation) Fields() []string {
  7455. fields := make([]string, 0, 5)
  7456. if m.created_at != nil {
  7457. fields = append(fields, category.FieldCreatedAt)
  7458. }
  7459. if m.updated_at != nil {
  7460. fields = append(fields, category.FieldUpdatedAt)
  7461. }
  7462. if m.deleted_at != nil {
  7463. fields = append(fields, category.FieldDeletedAt)
  7464. }
  7465. if m.name != nil {
  7466. fields = append(fields, category.FieldName)
  7467. }
  7468. if m.organization_id != nil {
  7469. fields = append(fields, category.FieldOrganizationID)
  7470. }
  7471. return fields
  7472. }
  7473. // Field returns the value of a field with the given name. The second boolean
  7474. // return value indicates that this field was not set, or was not defined in the
  7475. // schema.
  7476. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7477. switch name {
  7478. case category.FieldCreatedAt:
  7479. return m.CreatedAt()
  7480. case category.FieldUpdatedAt:
  7481. return m.UpdatedAt()
  7482. case category.FieldDeletedAt:
  7483. return m.DeletedAt()
  7484. case category.FieldName:
  7485. return m.Name()
  7486. case category.FieldOrganizationID:
  7487. return m.OrganizationID()
  7488. }
  7489. return nil, false
  7490. }
  7491. // OldField returns the old value of the field from the database. An error is
  7492. // returned if the mutation operation is not UpdateOne, or the query to the
  7493. // database failed.
  7494. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7495. switch name {
  7496. case category.FieldCreatedAt:
  7497. return m.OldCreatedAt(ctx)
  7498. case category.FieldUpdatedAt:
  7499. return m.OldUpdatedAt(ctx)
  7500. case category.FieldDeletedAt:
  7501. return m.OldDeletedAt(ctx)
  7502. case category.FieldName:
  7503. return m.OldName(ctx)
  7504. case category.FieldOrganizationID:
  7505. return m.OldOrganizationID(ctx)
  7506. }
  7507. return nil, fmt.Errorf("unknown Category field %s", name)
  7508. }
  7509. // SetField sets the value of a field with the given name. It returns an error if
  7510. // the field is not defined in the schema, or if the type mismatched the field
  7511. // type.
  7512. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7513. switch name {
  7514. case category.FieldCreatedAt:
  7515. v, ok := value.(time.Time)
  7516. if !ok {
  7517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7518. }
  7519. m.SetCreatedAt(v)
  7520. return nil
  7521. case category.FieldUpdatedAt:
  7522. v, ok := value.(time.Time)
  7523. if !ok {
  7524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7525. }
  7526. m.SetUpdatedAt(v)
  7527. return nil
  7528. case category.FieldDeletedAt:
  7529. v, ok := value.(time.Time)
  7530. if !ok {
  7531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7532. }
  7533. m.SetDeletedAt(v)
  7534. return nil
  7535. case category.FieldName:
  7536. v, ok := value.(string)
  7537. if !ok {
  7538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7539. }
  7540. m.SetName(v)
  7541. return nil
  7542. case category.FieldOrganizationID:
  7543. v, ok := value.(uint64)
  7544. if !ok {
  7545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7546. }
  7547. m.SetOrganizationID(v)
  7548. return nil
  7549. }
  7550. return fmt.Errorf("unknown Category field %s", name)
  7551. }
  7552. // AddedFields returns all numeric fields that were incremented/decremented during
  7553. // this mutation.
  7554. func (m *CategoryMutation) AddedFields() []string {
  7555. var fields []string
  7556. if m.addorganization_id != nil {
  7557. fields = append(fields, category.FieldOrganizationID)
  7558. }
  7559. return fields
  7560. }
  7561. // AddedField returns the numeric value that was incremented/decremented on a field
  7562. // with the given name. The second boolean return value indicates that this field
  7563. // was not set, or was not defined in the schema.
  7564. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7565. switch name {
  7566. case category.FieldOrganizationID:
  7567. return m.AddedOrganizationID()
  7568. }
  7569. return nil, false
  7570. }
  7571. // AddField adds the value to the field with the given name. It returns an error if
  7572. // the field is not defined in the schema, or if the type mismatched the field
  7573. // type.
  7574. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7575. switch name {
  7576. case category.FieldOrganizationID:
  7577. v, ok := value.(int64)
  7578. if !ok {
  7579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7580. }
  7581. m.AddOrganizationID(v)
  7582. return nil
  7583. }
  7584. return fmt.Errorf("unknown Category numeric field %s", name)
  7585. }
  7586. // ClearedFields returns all nullable fields that were cleared during this
  7587. // mutation.
  7588. func (m *CategoryMutation) ClearedFields() []string {
  7589. var fields []string
  7590. if m.FieldCleared(category.FieldDeletedAt) {
  7591. fields = append(fields, category.FieldDeletedAt)
  7592. }
  7593. return fields
  7594. }
  7595. // FieldCleared returns a boolean indicating if a field with the given name was
  7596. // cleared in this mutation.
  7597. func (m *CategoryMutation) FieldCleared(name string) bool {
  7598. _, ok := m.clearedFields[name]
  7599. return ok
  7600. }
  7601. // ClearField clears the value of the field with the given name. It returns an
  7602. // error if the field is not defined in the schema.
  7603. func (m *CategoryMutation) ClearField(name string) error {
  7604. switch name {
  7605. case category.FieldDeletedAt:
  7606. m.ClearDeletedAt()
  7607. return nil
  7608. }
  7609. return fmt.Errorf("unknown Category nullable field %s", name)
  7610. }
  7611. // ResetField resets all changes in the mutation for the field with the given name.
  7612. // It returns an error if the field is not defined in the schema.
  7613. func (m *CategoryMutation) ResetField(name string) error {
  7614. switch name {
  7615. case category.FieldCreatedAt:
  7616. m.ResetCreatedAt()
  7617. return nil
  7618. case category.FieldUpdatedAt:
  7619. m.ResetUpdatedAt()
  7620. return nil
  7621. case category.FieldDeletedAt:
  7622. m.ResetDeletedAt()
  7623. return nil
  7624. case category.FieldName:
  7625. m.ResetName()
  7626. return nil
  7627. case category.FieldOrganizationID:
  7628. m.ResetOrganizationID()
  7629. return nil
  7630. }
  7631. return fmt.Errorf("unknown Category field %s", name)
  7632. }
  7633. // AddedEdges returns all edge names that were set/added in this mutation.
  7634. func (m *CategoryMutation) AddedEdges() []string {
  7635. edges := make([]string, 0, 0)
  7636. return edges
  7637. }
  7638. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7639. // name in this mutation.
  7640. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7641. return nil
  7642. }
  7643. // RemovedEdges returns all edge names that were removed in this mutation.
  7644. func (m *CategoryMutation) RemovedEdges() []string {
  7645. edges := make([]string, 0, 0)
  7646. return edges
  7647. }
  7648. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7649. // the given name in this mutation.
  7650. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7651. return nil
  7652. }
  7653. // ClearedEdges returns all edge names that were cleared in this mutation.
  7654. func (m *CategoryMutation) ClearedEdges() []string {
  7655. edges := make([]string, 0, 0)
  7656. return edges
  7657. }
  7658. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7659. // was cleared in this mutation.
  7660. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7661. return false
  7662. }
  7663. // ClearEdge clears the value of the edge with the given name. It returns an error
  7664. // if that edge is not defined in the schema.
  7665. func (m *CategoryMutation) ClearEdge(name string) error {
  7666. return fmt.Errorf("unknown Category unique edge %s", name)
  7667. }
  7668. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7669. // It returns an error if the edge is not defined in the schema.
  7670. func (m *CategoryMutation) ResetEdge(name string) error {
  7671. return fmt.Errorf("unknown Category edge %s", name)
  7672. }
  7673. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7674. type ChatRecordsMutation struct {
  7675. config
  7676. op Op
  7677. typ string
  7678. id *uint64
  7679. created_at *time.Time
  7680. updated_at *time.Time
  7681. deleted_at *time.Time
  7682. content *string
  7683. content_type *uint8
  7684. addcontent_type *int8
  7685. session_id *uint64
  7686. addsession_id *int64
  7687. user_id *uint64
  7688. adduser_id *int64
  7689. bot_id *uint64
  7690. addbot_id *int64
  7691. bot_type *uint8
  7692. addbot_type *int8
  7693. clearedFields map[string]struct{}
  7694. done bool
  7695. oldValue func(context.Context) (*ChatRecords, error)
  7696. predicates []predicate.ChatRecords
  7697. }
  7698. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7699. // chatrecordsOption allows management of the mutation configuration using functional options.
  7700. type chatrecordsOption func(*ChatRecordsMutation)
  7701. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7702. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7703. m := &ChatRecordsMutation{
  7704. config: c,
  7705. op: op,
  7706. typ: TypeChatRecords,
  7707. clearedFields: make(map[string]struct{}),
  7708. }
  7709. for _, opt := range opts {
  7710. opt(m)
  7711. }
  7712. return m
  7713. }
  7714. // withChatRecordsID sets the ID field of the mutation.
  7715. func withChatRecordsID(id uint64) chatrecordsOption {
  7716. return func(m *ChatRecordsMutation) {
  7717. var (
  7718. err error
  7719. once sync.Once
  7720. value *ChatRecords
  7721. )
  7722. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7723. once.Do(func() {
  7724. if m.done {
  7725. err = errors.New("querying old values post mutation is not allowed")
  7726. } else {
  7727. value, err = m.Client().ChatRecords.Get(ctx, id)
  7728. }
  7729. })
  7730. return value, err
  7731. }
  7732. m.id = &id
  7733. }
  7734. }
  7735. // withChatRecords sets the old ChatRecords of the mutation.
  7736. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7737. return func(m *ChatRecordsMutation) {
  7738. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7739. return node, nil
  7740. }
  7741. m.id = &node.ID
  7742. }
  7743. }
  7744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7745. // executed in a transaction (ent.Tx), a transactional client is returned.
  7746. func (m ChatRecordsMutation) Client() *Client {
  7747. client := &Client{config: m.config}
  7748. client.init()
  7749. return client
  7750. }
  7751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7752. // it returns an error otherwise.
  7753. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7754. if _, ok := m.driver.(*txDriver); !ok {
  7755. return nil, errors.New("ent: mutation is not running in a transaction")
  7756. }
  7757. tx := &Tx{config: m.config}
  7758. tx.init()
  7759. return tx, nil
  7760. }
  7761. // SetID sets the value of the id field. Note that this
  7762. // operation is only accepted on creation of ChatRecords entities.
  7763. func (m *ChatRecordsMutation) SetID(id uint64) {
  7764. m.id = &id
  7765. }
  7766. // ID returns the ID value in the mutation. Note that the ID is only available
  7767. // if it was provided to the builder or after it was returned from the database.
  7768. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7769. if m.id == nil {
  7770. return
  7771. }
  7772. return *m.id, true
  7773. }
  7774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7775. // That means, if the mutation is applied within a transaction with an isolation level such
  7776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7777. // or updated by the mutation.
  7778. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7779. switch {
  7780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7781. id, exists := m.ID()
  7782. if exists {
  7783. return []uint64{id}, nil
  7784. }
  7785. fallthrough
  7786. case m.op.Is(OpUpdate | OpDelete):
  7787. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7788. default:
  7789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7790. }
  7791. }
  7792. // SetCreatedAt sets the "created_at" field.
  7793. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7794. m.created_at = &t
  7795. }
  7796. // CreatedAt returns the value of the "created_at" field in the mutation.
  7797. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7798. v := m.created_at
  7799. if v == nil {
  7800. return
  7801. }
  7802. return *v, true
  7803. }
  7804. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7805. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7807. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7808. if !m.op.Is(OpUpdateOne) {
  7809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7810. }
  7811. if m.id == nil || m.oldValue == nil {
  7812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7813. }
  7814. oldValue, err := m.oldValue(ctx)
  7815. if err != nil {
  7816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7817. }
  7818. return oldValue.CreatedAt, nil
  7819. }
  7820. // ResetCreatedAt resets all changes to the "created_at" field.
  7821. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7822. m.created_at = nil
  7823. }
  7824. // SetUpdatedAt sets the "updated_at" field.
  7825. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7826. m.updated_at = &t
  7827. }
  7828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7829. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7830. v := m.updated_at
  7831. if v == nil {
  7832. return
  7833. }
  7834. return *v, true
  7835. }
  7836. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7837. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7839. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7840. if !m.op.Is(OpUpdateOne) {
  7841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7842. }
  7843. if m.id == nil || m.oldValue == nil {
  7844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7845. }
  7846. oldValue, err := m.oldValue(ctx)
  7847. if err != nil {
  7848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7849. }
  7850. return oldValue.UpdatedAt, nil
  7851. }
  7852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7853. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7854. m.updated_at = nil
  7855. }
  7856. // SetDeletedAt sets the "deleted_at" field.
  7857. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7858. m.deleted_at = &t
  7859. }
  7860. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7861. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7862. v := m.deleted_at
  7863. if v == nil {
  7864. return
  7865. }
  7866. return *v, true
  7867. }
  7868. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7869. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7871. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7872. if !m.op.Is(OpUpdateOne) {
  7873. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7874. }
  7875. if m.id == nil || m.oldValue == nil {
  7876. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7877. }
  7878. oldValue, err := m.oldValue(ctx)
  7879. if err != nil {
  7880. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7881. }
  7882. return oldValue.DeletedAt, nil
  7883. }
  7884. // ClearDeletedAt clears the value of the "deleted_at" field.
  7885. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7886. m.deleted_at = nil
  7887. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7888. }
  7889. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7890. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7891. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7892. return ok
  7893. }
  7894. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7895. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7896. m.deleted_at = nil
  7897. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7898. }
  7899. // SetContent sets the "content" field.
  7900. func (m *ChatRecordsMutation) SetContent(s string) {
  7901. m.content = &s
  7902. }
  7903. // Content returns the value of the "content" field in the mutation.
  7904. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7905. v := m.content
  7906. if v == nil {
  7907. return
  7908. }
  7909. return *v, true
  7910. }
  7911. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7912. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7914. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7915. if !m.op.Is(OpUpdateOne) {
  7916. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7917. }
  7918. if m.id == nil || m.oldValue == nil {
  7919. return v, errors.New("OldContent requires an ID field in the mutation")
  7920. }
  7921. oldValue, err := m.oldValue(ctx)
  7922. if err != nil {
  7923. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7924. }
  7925. return oldValue.Content, nil
  7926. }
  7927. // ResetContent resets all changes to the "content" field.
  7928. func (m *ChatRecordsMutation) ResetContent() {
  7929. m.content = nil
  7930. }
  7931. // SetContentType sets the "content_type" field.
  7932. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7933. m.content_type = &u
  7934. m.addcontent_type = nil
  7935. }
  7936. // ContentType returns the value of the "content_type" field in the mutation.
  7937. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7938. v := m.content_type
  7939. if v == nil {
  7940. return
  7941. }
  7942. return *v, true
  7943. }
  7944. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7945. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7947. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7948. if !m.op.Is(OpUpdateOne) {
  7949. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7950. }
  7951. if m.id == nil || m.oldValue == nil {
  7952. return v, errors.New("OldContentType requires an ID field in the mutation")
  7953. }
  7954. oldValue, err := m.oldValue(ctx)
  7955. if err != nil {
  7956. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7957. }
  7958. return oldValue.ContentType, nil
  7959. }
  7960. // AddContentType adds u to the "content_type" field.
  7961. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7962. if m.addcontent_type != nil {
  7963. *m.addcontent_type += u
  7964. } else {
  7965. m.addcontent_type = &u
  7966. }
  7967. }
  7968. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7969. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7970. v := m.addcontent_type
  7971. if v == nil {
  7972. return
  7973. }
  7974. return *v, true
  7975. }
  7976. // ResetContentType resets all changes to the "content_type" field.
  7977. func (m *ChatRecordsMutation) ResetContentType() {
  7978. m.content_type = nil
  7979. m.addcontent_type = nil
  7980. }
  7981. // SetSessionID sets the "session_id" field.
  7982. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7983. m.session_id = &u
  7984. m.addsession_id = nil
  7985. }
  7986. // SessionID returns the value of the "session_id" field in the mutation.
  7987. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7988. v := m.session_id
  7989. if v == nil {
  7990. return
  7991. }
  7992. return *v, true
  7993. }
  7994. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7995. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7997. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7998. if !m.op.Is(OpUpdateOne) {
  7999. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8000. }
  8001. if m.id == nil || m.oldValue == nil {
  8002. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8003. }
  8004. oldValue, err := m.oldValue(ctx)
  8005. if err != nil {
  8006. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8007. }
  8008. return oldValue.SessionID, nil
  8009. }
  8010. // AddSessionID adds u to the "session_id" field.
  8011. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8012. if m.addsession_id != nil {
  8013. *m.addsession_id += u
  8014. } else {
  8015. m.addsession_id = &u
  8016. }
  8017. }
  8018. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8019. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8020. v := m.addsession_id
  8021. if v == nil {
  8022. return
  8023. }
  8024. return *v, true
  8025. }
  8026. // ResetSessionID resets all changes to the "session_id" field.
  8027. func (m *ChatRecordsMutation) ResetSessionID() {
  8028. m.session_id = nil
  8029. m.addsession_id = nil
  8030. }
  8031. // SetUserID sets the "user_id" field.
  8032. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8033. m.user_id = &u
  8034. m.adduser_id = nil
  8035. }
  8036. // UserID returns the value of the "user_id" field in the mutation.
  8037. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8038. v := m.user_id
  8039. if v == nil {
  8040. return
  8041. }
  8042. return *v, true
  8043. }
  8044. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8045. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8047. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8048. if !m.op.Is(OpUpdateOne) {
  8049. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8050. }
  8051. if m.id == nil || m.oldValue == nil {
  8052. return v, errors.New("OldUserID requires an ID field in the mutation")
  8053. }
  8054. oldValue, err := m.oldValue(ctx)
  8055. if err != nil {
  8056. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8057. }
  8058. return oldValue.UserID, nil
  8059. }
  8060. // AddUserID adds u to the "user_id" field.
  8061. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8062. if m.adduser_id != nil {
  8063. *m.adduser_id += u
  8064. } else {
  8065. m.adduser_id = &u
  8066. }
  8067. }
  8068. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8069. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8070. v := m.adduser_id
  8071. if v == nil {
  8072. return
  8073. }
  8074. return *v, true
  8075. }
  8076. // ResetUserID resets all changes to the "user_id" field.
  8077. func (m *ChatRecordsMutation) ResetUserID() {
  8078. m.user_id = nil
  8079. m.adduser_id = nil
  8080. }
  8081. // SetBotID sets the "bot_id" field.
  8082. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8083. m.bot_id = &u
  8084. m.addbot_id = nil
  8085. }
  8086. // BotID returns the value of the "bot_id" field in the mutation.
  8087. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8088. v := m.bot_id
  8089. if v == nil {
  8090. return
  8091. }
  8092. return *v, true
  8093. }
  8094. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8095. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8097. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8098. if !m.op.Is(OpUpdateOne) {
  8099. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8100. }
  8101. if m.id == nil || m.oldValue == nil {
  8102. return v, errors.New("OldBotID requires an ID field in the mutation")
  8103. }
  8104. oldValue, err := m.oldValue(ctx)
  8105. if err != nil {
  8106. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8107. }
  8108. return oldValue.BotID, nil
  8109. }
  8110. // AddBotID adds u to the "bot_id" field.
  8111. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8112. if m.addbot_id != nil {
  8113. *m.addbot_id += u
  8114. } else {
  8115. m.addbot_id = &u
  8116. }
  8117. }
  8118. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8119. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8120. v := m.addbot_id
  8121. if v == nil {
  8122. return
  8123. }
  8124. return *v, true
  8125. }
  8126. // ResetBotID resets all changes to the "bot_id" field.
  8127. func (m *ChatRecordsMutation) ResetBotID() {
  8128. m.bot_id = nil
  8129. m.addbot_id = nil
  8130. }
  8131. // SetBotType sets the "bot_type" field.
  8132. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8133. m.bot_type = &u
  8134. m.addbot_type = nil
  8135. }
  8136. // BotType returns the value of the "bot_type" field in the mutation.
  8137. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8138. v := m.bot_type
  8139. if v == nil {
  8140. return
  8141. }
  8142. return *v, true
  8143. }
  8144. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8145. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8147. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8148. if !m.op.Is(OpUpdateOne) {
  8149. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8150. }
  8151. if m.id == nil || m.oldValue == nil {
  8152. return v, errors.New("OldBotType requires an ID field in the mutation")
  8153. }
  8154. oldValue, err := m.oldValue(ctx)
  8155. if err != nil {
  8156. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8157. }
  8158. return oldValue.BotType, nil
  8159. }
  8160. // AddBotType adds u to the "bot_type" field.
  8161. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8162. if m.addbot_type != nil {
  8163. *m.addbot_type += u
  8164. } else {
  8165. m.addbot_type = &u
  8166. }
  8167. }
  8168. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8169. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8170. v := m.addbot_type
  8171. if v == nil {
  8172. return
  8173. }
  8174. return *v, true
  8175. }
  8176. // ResetBotType resets all changes to the "bot_type" field.
  8177. func (m *ChatRecordsMutation) ResetBotType() {
  8178. m.bot_type = nil
  8179. m.addbot_type = nil
  8180. }
  8181. // Where appends a list predicates to the ChatRecordsMutation builder.
  8182. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8183. m.predicates = append(m.predicates, ps...)
  8184. }
  8185. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8186. // users can use type-assertion to append predicates that do not depend on any generated package.
  8187. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8188. p := make([]predicate.ChatRecords, len(ps))
  8189. for i := range ps {
  8190. p[i] = ps[i]
  8191. }
  8192. m.Where(p...)
  8193. }
  8194. // Op returns the operation name.
  8195. func (m *ChatRecordsMutation) Op() Op {
  8196. return m.op
  8197. }
  8198. // SetOp allows setting the mutation operation.
  8199. func (m *ChatRecordsMutation) SetOp(op Op) {
  8200. m.op = op
  8201. }
  8202. // Type returns the node type of this mutation (ChatRecords).
  8203. func (m *ChatRecordsMutation) Type() string {
  8204. return m.typ
  8205. }
  8206. // Fields returns all fields that were changed during this mutation. Note that in
  8207. // order to get all numeric fields that were incremented/decremented, call
  8208. // AddedFields().
  8209. func (m *ChatRecordsMutation) Fields() []string {
  8210. fields := make([]string, 0, 9)
  8211. if m.created_at != nil {
  8212. fields = append(fields, chatrecords.FieldCreatedAt)
  8213. }
  8214. if m.updated_at != nil {
  8215. fields = append(fields, chatrecords.FieldUpdatedAt)
  8216. }
  8217. if m.deleted_at != nil {
  8218. fields = append(fields, chatrecords.FieldDeletedAt)
  8219. }
  8220. if m.content != nil {
  8221. fields = append(fields, chatrecords.FieldContent)
  8222. }
  8223. if m.content_type != nil {
  8224. fields = append(fields, chatrecords.FieldContentType)
  8225. }
  8226. if m.session_id != nil {
  8227. fields = append(fields, chatrecords.FieldSessionID)
  8228. }
  8229. if m.user_id != nil {
  8230. fields = append(fields, chatrecords.FieldUserID)
  8231. }
  8232. if m.bot_id != nil {
  8233. fields = append(fields, chatrecords.FieldBotID)
  8234. }
  8235. if m.bot_type != nil {
  8236. fields = append(fields, chatrecords.FieldBotType)
  8237. }
  8238. return fields
  8239. }
  8240. // Field returns the value of a field with the given name. The second boolean
  8241. // return value indicates that this field was not set, or was not defined in the
  8242. // schema.
  8243. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8244. switch name {
  8245. case chatrecords.FieldCreatedAt:
  8246. return m.CreatedAt()
  8247. case chatrecords.FieldUpdatedAt:
  8248. return m.UpdatedAt()
  8249. case chatrecords.FieldDeletedAt:
  8250. return m.DeletedAt()
  8251. case chatrecords.FieldContent:
  8252. return m.Content()
  8253. case chatrecords.FieldContentType:
  8254. return m.ContentType()
  8255. case chatrecords.FieldSessionID:
  8256. return m.SessionID()
  8257. case chatrecords.FieldUserID:
  8258. return m.UserID()
  8259. case chatrecords.FieldBotID:
  8260. return m.BotID()
  8261. case chatrecords.FieldBotType:
  8262. return m.BotType()
  8263. }
  8264. return nil, false
  8265. }
  8266. // OldField returns the old value of the field from the database. An error is
  8267. // returned if the mutation operation is not UpdateOne, or the query to the
  8268. // database failed.
  8269. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8270. switch name {
  8271. case chatrecords.FieldCreatedAt:
  8272. return m.OldCreatedAt(ctx)
  8273. case chatrecords.FieldUpdatedAt:
  8274. return m.OldUpdatedAt(ctx)
  8275. case chatrecords.FieldDeletedAt:
  8276. return m.OldDeletedAt(ctx)
  8277. case chatrecords.FieldContent:
  8278. return m.OldContent(ctx)
  8279. case chatrecords.FieldContentType:
  8280. return m.OldContentType(ctx)
  8281. case chatrecords.FieldSessionID:
  8282. return m.OldSessionID(ctx)
  8283. case chatrecords.FieldUserID:
  8284. return m.OldUserID(ctx)
  8285. case chatrecords.FieldBotID:
  8286. return m.OldBotID(ctx)
  8287. case chatrecords.FieldBotType:
  8288. return m.OldBotType(ctx)
  8289. }
  8290. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8291. }
  8292. // SetField sets the value of a field with the given name. It returns an error if
  8293. // the field is not defined in the schema, or if the type mismatched the field
  8294. // type.
  8295. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8296. switch name {
  8297. case chatrecords.FieldCreatedAt:
  8298. v, ok := value.(time.Time)
  8299. if !ok {
  8300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8301. }
  8302. m.SetCreatedAt(v)
  8303. return nil
  8304. case chatrecords.FieldUpdatedAt:
  8305. v, ok := value.(time.Time)
  8306. if !ok {
  8307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8308. }
  8309. m.SetUpdatedAt(v)
  8310. return nil
  8311. case chatrecords.FieldDeletedAt:
  8312. v, ok := value.(time.Time)
  8313. if !ok {
  8314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8315. }
  8316. m.SetDeletedAt(v)
  8317. return nil
  8318. case chatrecords.FieldContent:
  8319. v, ok := value.(string)
  8320. if !ok {
  8321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8322. }
  8323. m.SetContent(v)
  8324. return nil
  8325. case chatrecords.FieldContentType:
  8326. v, ok := value.(uint8)
  8327. if !ok {
  8328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8329. }
  8330. m.SetContentType(v)
  8331. return nil
  8332. case chatrecords.FieldSessionID:
  8333. v, ok := value.(uint64)
  8334. if !ok {
  8335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8336. }
  8337. m.SetSessionID(v)
  8338. return nil
  8339. case chatrecords.FieldUserID:
  8340. v, ok := value.(uint64)
  8341. if !ok {
  8342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8343. }
  8344. m.SetUserID(v)
  8345. return nil
  8346. case chatrecords.FieldBotID:
  8347. v, ok := value.(uint64)
  8348. if !ok {
  8349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8350. }
  8351. m.SetBotID(v)
  8352. return nil
  8353. case chatrecords.FieldBotType:
  8354. v, ok := value.(uint8)
  8355. if !ok {
  8356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8357. }
  8358. m.SetBotType(v)
  8359. return nil
  8360. }
  8361. return fmt.Errorf("unknown ChatRecords field %s", name)
  8362. }
  8363. // AddedFields returns all numeric fields that were incremented/decremented during
  8364. // this mutation.
  8365. func (m *ChatRecordsMutation) AddedFields() []string {
  8366. var fields []string
  8367. if m.addcontent_type != nil {
  8368. fields = append(fields, chatrecords.FieldContentType)
  8369. }
  8370. if m.addsession_id != nil {
  8371. fields = append(fields, chatrecords.FieldSessionID)
  8372. }
  8373. if m.adduser_id != nil {
  8374. fields = append(fields, chatrecords.FieldUserID)
  8375. }
  8376. if m.addbot_id != nil {
  8377. fields = append(fields, chatrecords.FieldBotID)
  8378. }
  8379. if m.addbot_type != nil {
  8380. fields = append(fields, chatrecords.FieldBotType)
  8381. }
  8382. return fields
  8383. }
  8384. // AddedField returns the numeric value that was incremented/decremented on a field
  8385. // with the given name. The second boolean return value indicates that this field
  8386. // was not set, or was not defined in the schema.
  8387. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8388. switch name {
  8389. case chatrecords.FieldContentType:
  8390. return m.AddedContentType()
  8391. case chatrecords.FieldSessionID:
  8392. return m.AddedSessionID()
  8393. case chatrecords.FieldUserID:
  8394. return m.AddedUserID()
  8395. case chatrecords.FieldBotID:
  8396. return m.AddedBotID()
  8397. case chatrecords.FieldBotType:
  8398. return m.AddedBotType()
  8399. }
  8400. return nil, false
  8401. }
  8402. // AddField adds the value to the field with the given name. It returns an error if
  8403. // the field is not defined in the schema, or if the type mismatched the field
  8404. // type.
  8405. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8406. switch name {
  8407. case chatrecords.FieldContentType:
  8408. v, ok := value.(int8)
  8409. if !ok {
  8410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8411. }
  8412. m.AddContentType(v)
  8413. return nil
  8414. case chatrecords.FieldSessionID:
  8415. v, ok := value.(int64)
  8416. if !ok {
  8417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8418. }
  8419. m.AddSessionID(v)
  8420. return nil
  8421. case chatrecords.FieldUserID:
  8422. v, ok := value.(int64)
  8423. if !ok {
  8424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8425. }
  8426. m.AddUserID(v)
  8427. return nil
  8428. case chatrecords.FieldBotID:
  8429. v, ok := value.(int64)
  8430. if !ok {
  8431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8432. }
  8433. m.AddBotID(v)
  8434. return nil
  8435. case chatrecords.FieldBotType:
  8436. v, ok := value.(int8)
  8437. if !ok {
  8438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8439. }
  8440. m.AddBotType(v)
  8441. return nil
  8442. }
  8443. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8444. }
  8445. // ClearedFields returns all nullable fields that were cleared during this
  8446. // mutation.
  8447. func (m *ChatRecordsMutation) ClearedFields() []string {
  8448. var fields []string
  8449. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8450. fields = append(fields, chatrecords.FieldDeletedAt)
  8451. }
  8452. return fields
  8453. }
  8454. // FieldCleared returns a boolean indicating if a field with the given name was
  8455. // cleared in this mutation.
  8456. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8457. _, ok := m.clearedFields[name]
  8458. return ok
  8459. }
  8460. // ClearField clears the value of the field with the given name. It returns an
  8461. // error if the field is not defined in the schema.
  8462. func (m *ChatRecordsMutation) ClearField(name string) error {
  8463. switch name {
  8464. case chatrecords.FieldDeletedAt:
  8465. m.ClearDeletedAt()
  8466. return nil
  8467. }
  8468. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8469. }
  8470. // ResetField resets all changes in the mutation for the field with the given name.
  8471. // It returns an error if the field is not defined in the schema.
  8472. func (m *ChatRecordsMutation) ResetField(name string) error {
  8473. switch name {
  8474. case chatrecords.FieldCreatedAt:
  8475. m.ResetCreatedAt()
  8476. return nil
  8477. case chatrecords.FieldUpdatedAt:
  8478. m.ResetUpdatedAt()
  8479. return nil
  8480. case chatrecords.FieldDeletedAt:
  8481. m.ResetDeletedAt()
  8482. return nil
  8483. case chatrecords.FieldContent:
  8484. m.ResetContent()
  8485. return nil
  8486. case chatrecords.FieldContentType:
  8487. m.ResetContentType()
  8488. return nil
  8489. case chatrecords.FieldSessionID:
  8490. m.ResetSessionID()
  8491. return nil
  8492. case chatrecords.FieldUserID:
  8493. m.ResetUserID()
  8494. return nil
  8495. case chatrecords.FieldBotID:
  8496. m.ResetBotID()
  8497. return nil
  8498. case chatrecords.FieldBotType:
  8499. m.ResetBotType()
  8500. return nil
  8501. }
  8502. return fmt.Errorf("unknown ChatRecords field %s", name)
  8503. }
  8504. // AddedEdges returns all edge names that were set/added in this mutation.
  8505. func (m *ChatRecordsMutation) AddedEdges() []string {
  8506. edges := make([]string, 0, 0)
  8507. return edges
  8508. }
  8509. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8510. // name in this mutation.
  8511. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8512. return nil
  8513. }
  8514. // RemovedEdges returns all edge names that were removed in this mutation.
  8515. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8516. edges := make([]string, 0, 0)
  8517. return edges
  8518. }
  8519. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8520. // the given name in this mutation.
  8521. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8522. return nil
  8523. }
  8524. // ClearedEdges returns all edge names that were cleared in this mutation.
  8525. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8526. edges := make([]string, 0, 0)
  8527. return edges
  8528. }
  8529. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8530. // was cleared in this mutation.
  8531. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8532. return false
  8533. }
  8534. // ClearEdge clears the value of the edge with the given name. It returns an error
  8535. // if that edge is not defined in the schema.
  8536. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8537. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8538. }
  8539. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8540. // It returns an error if the edge is not defined in the schema.
  8541. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8542. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8543. }
  8544. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8545. type ChatSessionMutation struct {
  8546. config
  8547. op Op
  8548. typ string
  8549. id *uint64
  8550. created_at *time.Time
  8551. updated_at *time.Time
  8552. deleted_at *time.Time
  8553. name *string
  8554. user_id *uint64
  8555. adduser_id *int64
  8556. bot_id *uint64
  8557. addbot_id *int64
  8558. bot_type *uint8
  8559. addbot_type *int8
  8560. clearedFields map[string]struct{}
  8561. done bool
  8562. oldValue func(context.Context) (*ChatSession, error)
  8563. predicates []predicate.ChatSession
  8564. }
  8565. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8566. // chatsessionOption allows management of the mutation configuration using functional options.
  8567. type chatsessionOption func(*ChatSessionMutation)
  8568. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8569. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8570. m := &ChatSessionMutation{
  8571. config: c,
  8572. op: op,
  8573. typ: TypeChatSession,
  8574. clearedFields: make(map[string]struct{}),
  8575. }
  8576. for _, opt := range opts {
  8577. opt(m)
  8578. }
  8579. return m
  8580. }
  8581. // withChatSessionID sets the ID field of the mutation.
  8582. func withChatSessionID(id uint64) chatsessionOption {
  8583. return func(m *ChatSessionMutation) {
  8584. var (
  8585. err error
  8586. once sync.Once
  8587. value *ChatSession
  8588. )
  8589. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8590. once.Do(func() {
  8591. if m.done {
  8592. err = errors.New("querying old values post mutation is not allowed")
  8593. } else {
  8594. value, err = m.Client().ChatSession.Get(ctx, id)
  8595. }
  8596. })
  8597. return value, err
  8598. }
  8599. m.id = &id
  8600. }
  8601. }
  8602. // withChatSession sets the old ChatSession of the mutation.
  8603. func withChatSession(node *ChatSession) chatsessionOption {
  8604. return func(m *ChatSessionMutation) {
  8605. m.oldValue = func(context.Context) (*ChatSession, error) {
  8606. return node, nil
  8607. }
  8608. m.id = &node.ID
  8609. }
  8610. }
  8611. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8612. // executed in a transaction (ent.Tx), a transactional client is returned.
  8613. func (m ChatSessionMutation) Client() *Client {
  8614. client := &Client{config: m.config}
  8615. client.init()
  8616. return client
  8617. }
  8618. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8619. // it returns an error otherwise.
  8620. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8621. if _, ok := m.driver.(*txDriver); !ok {
  8622. return nil, errors.New("ent: mutation is not running in a transaction")
  8623. }
  8624. tx := &Tx{config: m.config}
  8625. tx.init()
  8626. return tx, nil
  8627. }
  8628. // SetID sets the value of the id field. Note that this
  8629. // operation is only accepted on creation of ChatSession entities.
  8630. func (m *ChatSessionMutation) SetID(id uint64) {
  8631. m.id = &id
  8632. }
  8633. // ID returns the ID value in the mutation. Note that the ID is only available
  8634. // if it was provided to the builder or after it was returned from the database.
  8635. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8636. if m.id == nil {
  8637. return
  8638. }
  8639. return *m.id, true
  8640. }
  8641. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8642. // That means, if the mutation is applied within a transaction with an isolation level such
  8643. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8644. // or updated by the mutation.
  8645. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8646. switch {
  8647. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8648. id, exists := m.ID()
  8649. if exists {
  8650. return []uint64{id}, nil
  8651. }
  8652. fallthrough
  8653. case m.op.Is(OpUpdate | OpDelete):
  8654. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8655. default:
  8656. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8657. }
  8658. }
  8659. // SetCreatedAt sets the "created_at" field.
  8660. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8661. m.created_at = &t
  8662. }
  8663. // CreatedAt returns the value of the "created_at" field in the mutation.
  8664. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8665. v := m.created_at
  8666. if v == nil {
  8667. return
  8668. }
  8669. return *v, true
  8670. }
  8671. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8672. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8674. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8675. if !m.op.Is(OpUpdateOne) {
  8676. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8677. }
  8678. if m.id == nil || m.oldValue == nil {
  8679. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8680. }
  8681. oldValue, err := m.oldValue(ctx)
  8682. if err != nil {
  8683. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8684. }
  8685. return oldValue.CreatedAt, nil
  8686. }
  8687. // ResetCreatedAt resets all changes to the "created_at" field.
  8688. func (m *ChatSessionMutation) ResetCreatedAt() {
  8689. m.created_at = nil
  8690. }
  8691. // SetUpdatedAt sets the "updated_at" field.
  8692. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8693. m.updated_at = &t
  8694. }
  8695. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8696. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8697. v := m.updated_at
  8698. if v == nil {
  8699. return
  8700. }
  8701. return *v, true
  8702. }
  8703. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8704. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8706. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8707. if !m.op.Is(OpUpdateOne) {
  8708. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8709. }
  8710. if m.id == nil || m.oldValue == nil {
  8711. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8712. }
  8713. oldValue, err := m.oldValue(ctx)
  8714. if err != nil {
  8715. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8716. }
  8717. return oldValue.UpdatedAt, nil
  8718. }
  8719. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8720. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8721. m.updated_at = nil
  8722. }
  8723. // SetDeletedAt sets the "deleted_at" field.
  8724. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8725. m.deleted_at = &t
  8726. }
  8727. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8728. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8729. v := m.deleted_at
  8730. if v == nil {
  8731. return
  8732. }
  8733. return *v, true
  8734. }
  8735. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8736. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8738. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8739. if !m.op.Is(OpUpdateOne) {
  8740. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8741. }
  8742. if m.id == nil || m.oldValue == nil {
  8743. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8744. }
  8745. oldValue, err := m.oldValue(ctx)
  8746. if err != nil {
  8747. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8748. }
  8749. return oldValue.DeletedAt, nil
  8750. }
  8751. // ClearDeletedAt clears the value of the "deleted_at" field.
  8752. func (m *ChatSessionMutation) ClearDeletedAt() {
  8753. m.deleted_at = nil
  8754. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8755. }
  8756. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8757. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8758. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8759. return ok
  8760. }
  8761. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8762. func (m *ChatSessionMutation) ResetDeletedAt() {
  8763. m.deleted_at = nil
  8764. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8765. }
  8766. // SetName sets the "name" field.
  8767. func (m *ChatSessionMutation) SetName(s string) {
  8768. m.name = &s
  8769. }
  8770. // Name returns the value of the "name" field in the mutation.
  8771. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8772. v := m.name
  8773. if v == nil {
  8774. return
  8775. }
  8776. return *v, true
  8777. }
  8778. // OldName returns the old "name" field's value of the ChatSession entity.
  8779. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8781. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8782. if !m.op.Is(OpUpdateOne) {
  8783. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8784. }
  8785. if m.id == nil || m.oldValue == nil {
  8786. return v, errors.New("OldName requires an ID field in the mutation")
  8787. }
  8788. oldValue, err := m.oldValue(ctx)
  8789. if err != nil {
  8790. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8791. }
  8792. return oldValue.Name, nil
  8793. }
  8794. // ResetName resets all changes to the "name" field.
  8795. func (m *ChatSessionMutation) ResetName() {
  8796. m.name = nil
  8797. }
  8798. // SetUserID sets the "user_id" field.
  8799. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8800. m.user_id = &u
  8801. m.adduser_id = nil
  8802. }
  8803. // UserID returns the value of the "user_id" field in the mutation.
  8804. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8805. v := m.user_id
  8806. if v == nil {
  8807. return
  8808. }
  8809. return *v, true
  8810. }
  8811. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8812. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8814. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8815. if !m.op.Is(OpUpdateOne) {
  8816. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8817. }
  8818. if m.id == nil || m.oldValue == nil {
  8819. return v, errors.New("OldUserID requires an ID field in the mutation")
  8820. }
  8821. oldValue, err := m.oldValue(ctx)
  8822. if err != nil {
  8823. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8824. }
  8825. return oldValue.UserID, nil
  8826. }
  8827. // AddUserID adds u to the "user_id" field.
  8828. func (m *ChatSessionMutation) AddUserID(u int64) {
  8829. if m.adduser_id != nil {
  8830. *m.adduser_id += u
  8831. } else {
  8832. m.adduser_id = &u
  8833. }
  8834. }
  8835. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8836. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8837. v := m.adduser_id
  8838. if v == nil {
  8839. return
  8840. }
  8841. return *v, true
  8842. }
  8843. // ResetUserID resets all changes to the "user_id" field.
  8844. func (m *ChatSessionMutation) ResetUserID() {
  8845. m.user_id = nil
  8846. m.adduser_id = nil
  8847. }
  8848. // SetBotID sets the "bot_id" field.
  8849. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8850. m.bot_id = &u
  8851. m.addbot_id = nil
  8852. }
  8853. // BotID returns the value of the "bot_id" field in the mutation.
  8854. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8855. v := m.bot_id
  8856. if v == nil {
  8857. return
  8858. }
  8859. return *v, true
  8860. }
  8861. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8862. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8864. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8865. if !m.op.Is(OpUpdateOne) {
  8866. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8867. }
  8868. if m.id == nil || m.oldValue == nil {
  8869. return v, errors.New("OldBotID requires an ID field in the mutation")
  8870. }
  8871. oldValue, err := m.oldValue(ctx)
  8872. if err != nil {
  8873. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8874. }
  8875. return oldValue.BotID, nil
  8876. }
  8877. // AddBotID adds u to the "bot_id" field.
  8878. func (m *ChatSessionMutation) AddBotID(u int64) {
  8879. if m.addbot_id != nil {
  8880. *m.addbot_id += u
  8881. } else {
  8882. m.addbot_id = &u
  8883. }
  8884. }
  8885. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8886. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8887. v := m.addbot_id
  8888. if v == nil {
  8889. return
  8890. }
  8891. return *v, true
  8892. }
  8893. // ResetBotID resets all changes to the "bot_id" field.
  8894. func (m *ChatSessionMutation) ResetBotID() {
  8895. m.bot_id = nil
  8896. m.addbot_id = nil
  8897. }
  8898. // SetBotType sets the "bot_type" field.
  8899. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8900. m.bot_type = &u
  8901. m.addbot_type = nil
  8902. }
  8903. // BotType returns the value of the "bot_type" field in the mutation.
  8904. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8905. v := m.bot_type
  8906. if v == nil {
  8907. return
  8908. }
  8909. return *v, true
  8910. }
  8911. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8912. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8914. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8915. if !m.op.Is(OpUpdateOne) {
  8916. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8917. }
  8918. if m.id == nil || m.oldValue == nil {
  8919. return v, errors.New("OldBotType requires an ID field in the mutation")
  8920. }
  8921. oldValue, err := m.oldValue(ctx)
  8922. if err != nil {
  8923. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8924. }
  8925. return oldValue.BotType, nil
  8926. }
  8927. // AddBotType adds u to the "bot_type" field.
  8928. func (m *ChatSessionMutation) AddBotType(u int8) {
  8929. if m.addbot_type != nil {
  8930. *m.addbot_type += u
  8931. } else {
  8932. m.addbot_type = &u
  8933. }
  8934. }
  8935. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8936. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8937. v := m.addbot_type
  8938. if v == nil {
  8939. return
  8940. }
  8941. return *v, true
  8942. }
  8943. // ResetBotType resets all changes to the "bot_type" field.
  8944. func (m *ChatSessionMutation) ResetBotType() {
  8945. m.bot_type = nil
  8946. m.addbot_type = nil
  8947. }
  8948. // Where appends a list predicates to the ChatSessionMutation builder.
  8949. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8950. m.predicates = append(m.predicates, ps...)
  8951. }
  8952. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8953. // users can use type-assertion to append predicates that do not depend on any generated package.
  8954. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8955. p := make([]predicate.ChatSession, len(ps))
  8956. for i := range ps {
  8957. p[i] = ps[i]
  8958. }
  8959. m.Where(p...)
  8960. }
  8961. // Op returns the operation name.
  8962. func (m *ChatSessionMutation) Op() Op {
  8963. return m.op
  8964. }
  8965. // SetOp allows setting the mutation operation.
  8966. func (m *ChatSessionMutation) SetOp(op Op) {
  8967. m.op = op
  8968. }
  8969. // Type returns the node type of this mutation (ChatSession).
  8970. func (m *ChatSessionMutation) Type() string {
  8971. return m.typ
  8972. }
  8973. // Fields returns all fields that were changed during this mutation. Note that in
  8974. // order to get all numeric fields that were incremented/decremented, call
  8975. // AddedFields().
  8976. func (m *ChatSessionMutation) Fields() []string {
  8977. fields := make([]string, 0, 7)
  8978. if m.created_at != nil {
  8979. fields = append(fields, chatsession.FieldCreatedAt)
  8980. }
  8981. if m.updated_at != nil {
  8982. fields = append(fields, chatsession.FieldUpdatedAt)
  8983. }
  8984. if m.deleted_at != nil {
  8985. fields = append(fields, chatsession.FieldDeletedAt)
  8986. }
  8987. if m.name != nil {
  8988. fields = append(fields, chatsession.FieldName)
  8989. }
  8990. if m.user_id != nil {
  8991. fields = append(fields, chatsession.FieldUserID)
  8992. }
  8993. if m.bot_id != nil {
  8994. fields = append(fields, chatsession.FieldBotID)
  8995. }
  8996. if m.bot_type != nil {
  8997. fields = append(fields, chatsession.FieldBotType)
  8998. }
  8999. return fields
  9000. }
  9001. // Field returns the value of a field with the given name. The second boolean
  9002. // return value indicates that this field was not set, or was not defined in the
  9003. // schema.
  9004. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9005. switch name {
  9006. case chatsession.FieldCreatedAt:
  9007. return m.CreatedAt()
  9008. case chatsession.FieldUpdatedAt:
  9009. return m.UpdatedAt()
  9010. case chatsession.FieldDeletedAt:
  9011. return m.DeletedAt()
  9012. case chatsession.FieldName:
  9013. return m.Name()
  9014. case chatsession.FieldUserID:
  9015. return m.UserID()
  9016. case chatsession.FieldBotID:
  9017. return m.BotID()
  9018. case chatsession.FieldBotType:
  9019. return m.BotType()
  9020. }
  9021. return nil, false
  9022. }
  9023. // OldField returns the old value of the field from the database. An error is
  9024. // returned if the mutation operation is not UpdateOne, or the query to the
  9025. // database failed.
  9026. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9027. switch name {
  9028. case chatsession.FieldCreatedAt:
  9029. return m.OldCreatedAt(ctx)
  9030. case chatsession.FieldUpdatedAt:
  9031. return m.OldUpdatedAt(ctx)
  9032. case chatsession.FieldDeletedAt:
  9033. return m.OldDeletedAt(ctx)
  9034. case chatsession.FieldName:
  9035. return m.OldName(ctx)
  9036. case chatsession.FieldUserID:
  9037. return m.OldUserID(ctx)
  9038. case chatsession.FieldBotID:
  9039. return m.OldBotID(ctx)
  9040. case chatsession.FieldBotType:
  9041. return m.OldBotType(ctx)
  9042. }
  9043. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9044. }
  9045. // SetField sets the value of a field with the given name. It returns an error if
  9046. // the field is not defined in the schema, or if the type mismatched the field
  9047. // type.
  9048. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9049. switch name {
  9050. case chatsession.FieldCreatedAt:
  9051. v, ok := value.(time.Time)
  9052. if !ok {
  9053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9054. }
  9055. m.SetCreatedAt(v)
  9056. return nil
  9057. case chatsession.FieldUpdatedAt:
  9058. v, ok := value.(time.Time)
  9059. if !ok {
  9060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9061. }
  9062. m.SetUpdatedAt(v)
  9063. return nil
  9064. case chatsession.FieldDeletedAt:
  9065. v, ok := value.(time.Time)
  9066. if !ok {
  9067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9068. }
  9069. m.SetDeletedAt(v)
  9070. return nil
  9071. case chatsession.FieldName:
  9072. v, ok := value.(string)
  9073. if !ok {
  9074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9075. }
  9076. m.SetName(v)
  9077. return nil
  9078. case chatsession.FieldUserID:
  9079. v, ok := value.(uint64)
  9080. if !ok {
  9081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9082. }
  9083. m.SetUserID(v)
  9084. return nil
  9085. case chatsession.FieldBotID:
  9086. v, ok := value.(uint64)
  9087. if !ok {
  9088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9089. }
  9090. m.SetBotID(v)
  9091. return nil
  9092. case chatsession.FieldBotType:
  9093. v, ok := value.(uint8)
  9094. if !ok {
  9095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9096. }
  9097. m.SetBotType(v)
  9098. return nil
  9099. }
  9100. return fmt.Errorf("unknown ChatSession field %s", name)
  9101. }
  9102. // AddedFields returns all numeric fields that were incremented/decremented during
  9103. // this mutation.
  9104. func (m *ChatSessionMutation) AddedFields() []string {
  9105. var fields []string
  9106. if m.adduser_id != nil {
  9107. fields = append(fields, chatsession.FieldUserID)
  9108. }
  9109. if m.addbot_id != nil {
  9110. fields = append(fields, chatsession.FieldBotID)
  9111. }
  9112. if m.addbot_type != nil {
  9113. fields = append(fields, chatsession.FieldBotType)
  9114. }
  9115. return fields
  9116. }
  9117. // AddedField returns the numeric value that was incremented/decremented on a field
  9118. // with the given name. The second boolean return value indicates that this field
  9119. // was not set, or was not defined in the schema.
  9120. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9121. switch name {
  9122. case chatsession.FieldUserID:
  9123. return m.AddedUserID()
  9124. case chatsession.FieldBotID:
  9125. return m.AddedBotID()
  9126. case chatsession.FieldBotType:
  9127. return m.AddedBotType()
  9128. }
  9129. return nil, false
  9130. }
  9131. // AddField adds the value to the field with the given name. It returns an error if
  9132. // the field is not defined in the schema, or if the type mismatched the field
  9133. // type.
  9134. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9135. switch name {
  9136. case chatsession.FieldUserID:
  9137. v, ok := value.(int64)
  9138. if !ok {
  9139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9140. }
  9141. m.AddUserID(v)
  9142. return nil
  9143. case chatsession.FieldBotID:
  9144. v, ok := value.(int64)
  9145. if !ok {
  9146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9147. }
  9148. m.AddBotID(v)
  9149. return nil
  9150. case chatsession.FieldBotType:
  9151. v, ok := value.(int8)
  9152. if !ok {
  9153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9154. }
  9155. m.AddBotType(v)
  9156. return nil
  9157. }
  9158. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9159. }
  9160. // ClearedFields returns all nullable fields that were cleared during this
  9161. // mutation.
  9162. func (m *ChatSessionMutation) ClearedFields() []string {
  9163. var fields []string
  9164. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9165. fields = append(fields, chatsession.FieldDeletedAt)
  9166. }
  9167. return fields
  9168. }
  9169. // FieldCleared returns a boolean indicating if a field with the given name was
  9170. // cleared in this mutation.
  9171. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9172. _, ok := m.clearedFields[name]
  9173. return ok
  9174. }
  9175. // ClearField clears the value of the field with the given name. It returns an
  9176. // error if the field is not defined in the schema.
  9177. func (m *ChatSessionMutation) ClearField(name string) error {
  9178. switch name {
  9179. case chatsession.FieldDeletedAt:
  9180. m.ClearDeletedAt()
  9181. return nil
  9182. }
  9183. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9184. }
  9185. // ResetField resets all changes in the mutation for the field with the given name.
  9186. // It returns an error if the field is not defined in the schema.
  9187. func (m *ChatSessionMutation) ResetField(name string) error {
  9188. switch name {
  9189. case chatsession.FieldCreatedAt:
  9190. m.ResetCreatedAt()
  9191. return nil
  9192. case chatsession.FieldUpdatedAt:
  9193. m.ResetUpdatedAt()
  9194. return nil
  9195. case chatsession.FieldDeletedAt:
  9196. m.ResetDeletedAt()
  9197. return nil
  9198. case chatsession.FieldName:
  9199. m.ResetName()
  9200. return nil
  9201. case chatsession.FieldUserID:
  9202. m.ResetUserID()
  9203. return nil
  9204. case chatsession.FieldBotID:
  9205. m.ResetBotID()
  9206. return nil
  9207. case chatsession.FieldBotType:
  9208. m.ResetBotType()
  9209. return nil
  9210. }
  9211. return fmt.Errorf("unknown ChatSession field %s", name)
  9212. }
  9213. // AddedEdges returns all edge names that were set/added in this mutation.
  9214. func (m *ChatSessionMutation) AddedEdges() []string {
  9215. edges := make([]string, 0, 0)
  9216. return edges
  9217. }
  9218. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9219. // name in this mutation.
  9220. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9221. return nil
  9222. }
  9223. // RemovedEdges returns all edge names that were removed in this mutation.
  9224. func (m *ChatSessionMutation) RemovedEdges() []string {
  9225. edges := make([]string, 0, 0)
  9226. return edges
  9227. }
  9228. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9229. // the given name in this mutation.
  9230. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9231. return nil
  9232. }
  9233. // ClearedEdges returns all edge names that were cleared in this mutation.
  9234. func (m *ChatSessionMutation) ClearedEdges() []string {
  9235. edges := make([]string, 0, 0)
  9236. return edges
  9237. }
  9238. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9239. // was cleared in this mutation.
  9240. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9241. return false
  9242. }
  9243. // ClearEdge clears the value of the edge with the given name. It returns an error
  9244. // if that edge is not defined in the schema.
  9245. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9246. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9247. }
  9248. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9249. // It returns an error if the edge is not defined in the schema.
  9250. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9251. return fmt.Errorf("unknown ChatSession edge %s", name)
  9252. }
  9253. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9254. type ContactMutation struct {
  9255. config
  9256. op Op
  9257. typ string
  9258. id *uint64
  9259. created_at *time.Time
  9260. updated_at *time.Time
  9261. status *uint8
  9262. addstatus *int8
  9263. deleted_at *time.Time
  9264. wx_wxid *string
  9265. _type *int
  9266. add_type *int
  9267. wxid *string
  9268. account *string
  9269. nickname *string
  9270. markname *string
  9271. headimg *string
  9272. sex *int
  9273. addsex *int
  9274. starrole *string
  9275. dontseeit *int
  9276. adddontseeit *int
  9277. dontseeme *int
  9278. adddontseeme *int
  9279. lag *string
  9280. gid *string
  9281. gname *string
  9282. v3 *string
  9283. organization_id *uint64
  9284. addorganization_id *int64
  9285. ctype *uint64
  9286. addctype *int64
  9287. cage *int
  9288. addcage *int
  9289. cname *string
  9290. carea *string
  9291. cbirthday *string
  9292. cbirtharea *string
  9293. cidcard_no *string
  9294. ctitle *string
  9295. cc *string
  9296. phone *string
  9297. clearedFields map[string]struct{}
  9298. contact_relationships map[uint64]struct{}
  9299. removedcontact_relationships map[uint64]struct{}
  9300. clearedcontact_relationships bool
  9301. contact_messages map[uint64]struct{}
  9302. removedcontact_messages map[uint64]struct{}
  9303. clearedcontact_messages bool
  9304. done bool
  9305. oldValue func(context.Context) (*Contact, error)
  9306. predicates []predicate.Contact
  9307. }
  9308. var _ ent.Mutation = (*ContactMutation)(nil)
  9309. // contactOption allows management of the mutation configuration using functional options.
  9310. type contactOption func(*ContactMutation)
  9311. // newContactMutation creates new mutation for the Contact entity.
  9312. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9313. m := &ContactMutation{
  9314. config: c,
  9315. op: op,
  9316. typ: TypeContact,
  9317. clearedFields: make(map[string]struct{}),
  9318. }
  9319. for _, opt := range opts {
  9320. opt(m)
  9321. }
  9322. return m
  9323. }
  9324. // withContactID sets the ID field of the mutation.
  9325. func withContactID(id uint64) contactOption {
  9326. return func(m *ContactMutation) {
  9327. var (
  9328. err error
  9329. once sync.Once
  9330. value *Contact
  9331. )
  9332. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9333. once.Do(func() {
  9334. if m.done {
  9335. err = errors.New("querying old values post mutation is not allowed")
  9336. } else {
  9337. value, err = m.Client().Contact.Get(ctx, id)
  9338. }
  9339. })
  9340. return value, err
  9341. }
  9342. m.id = &id
  9343. }
  9344. }
  9345. // withContact sets the old Contact of the mutation.
  9346. func withContact(node *Contact) contactOption {
  9347. return func(m *ContactMutation) {
  9348. m.oldValue = func(context.Context) (*Contact, error) {
  9349. return node, nil
  9350. }
  9351. m.id = &node.ID
  9352. }
  9353. }
  9354. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9355. // executed in a transaction (ent.Tx), a transactional client is returned.
  9356. func (m ContactMutation) Client() *Client {
  9357. client := &Client{config: m.config}
  9358. client.init()
  9359. return client
  9360. }
  9361. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9362. // it returns an error otherwise.
  9363. func (m ContactMutation) Tx() (*Tx, error) {
  9364. if _, ok := m.driver.(*txDriver); !ok {
  9365. return nil, errors.New("ent: mutation is not running in a transaction")
  9366. }
  9367. tx := &Tx{config: m.config}
  9368. tx.init()
  9369. return tx, nil
  9370. }
  9371. // SetID sets the value of the id field. Note that this
  9372. // operation is only accepted on creation of Contact entities.
  9373. func (m *ContactMutation) SetID(id uint64) {
  9374. m.id = &id
  9375. }
  9376. // ID returns the ID value in the mutation. Note that the ID is only available
  9377. // if it was provided to the builder or after it was returned from the database.
  9378. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9379. if m.id == nil {
  9380. return
  9381. }
  9382. return *m.id, true
  9383. }
  9384. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9385. // That means, if the mutation is applied within a transaction with an isolation level such
  9386. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9387. // or updated by the mutation.
  9388. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9389. switch {
  9390. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9391. id, exists := m.ID()
  9392. if exists {
  9393. return []uint64{id}, nil
  9394. }
  9395. fallthrough
  9396. case m.op.Is(OpUpdate | OpDelete):
  9397. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9398. default:
  9399. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9400. }
  9401. }
  9402. // SetCreatedAt sets the "created_at" field.
  9403. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9404. m.created_at = &t
  9405. }
  9406. // CreatedAt returns the value of the "created_at" field in the mutation.
  9407. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9408. v := m.created_at
  9409. if v == nil {
  9410. return
  9411. }
  9412. return *v, true
  9413. }
  9414. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9415. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9417. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9418. if !m.op.Is(OpUpdateOne) {
  9419. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9420. }
  9421. if m.id == nil || m.oldValue == nil {
  9422. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9423. }
  9424. oldValue, err := m.oldValue(ctx)
  9425. if err != nil {
  9426. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9427. }
  9428. return oldValue.CreatedAt, nil
  9429. }
  9430. // ResetCreatedAt resets all changes to the "created_at" field.
  9431. func (m *ContactMutation) ResetCreatedAt() {
  9432. m.created_at = nil
  9433. }
  9434. // SetUpdatedAt sets the "updated_at" field.
  9435. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9436. m.updated_at = &t
  9437. }
  9438. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9439. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9440. v := m.updated_at
  9441. if v == nil {
  9442. return
  9443. }
  9444. return *v, true
  9445. }
  9446. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9447. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9449. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9450. if !m.op.Is(OpUpdateOne) {
  9451. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9452. }
  9453. if m.id == nil || m.oldValue == nil {
  9454. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9455. }
  9456. oldValue, err := m.oldValue(ctx)
  9457. if err != nil {
  9458. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9459. }
  9460. return oldValue.UpdatedAt, nil
  9461. }
  9462. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9463. func (m *ContactMutation) ResetUpdatedAt() {
  9464. m.updated_at = nil
  9465. }
  9466. // SetStatus sets the "status" field.
  9467. func (m *ContactMutation) SetStatus(u uint8) {
  9468. m.status = &u
  9469. m.addstatus = nil
  9470. }
  9471. // Status returns the value of the "status" field in the mutation.
  9472. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9473. v := m.status
  9474. if v == nil {
  9475. return
  9476. }
  9477. return *v, true
  9478. }
  9479. // OldStatus returns the old "status" field's value of the Contact entity.
  9480. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9482. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9483. if !m.op.Is(OpUpdateOne) {
  9484. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9485. }
  9486. if m.id == nil || m.oldValue == nil {
  9487. return v, errors.New("OldStatus requires an ID field in the mutation")
  9488. }
  9489. oldValue, err := m.oldValue(ctx)
  9490. if err != nil {
  9491. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9492. }
  9493. return oldValue.Status, nil
  9494. }
  9495. // AddStatus adds u to the "status" field.
  9496. func (m *ContactMutation) AddStatus(u int8) {
  9497. if m.addstatus != nil {
  9498. *m.addstatus += u
  9499. } else {
  9500. m.addstatus = &u
  9501. }
  9502. }
  9503. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9504. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9505. v := m.addstatus
  9506. if v == nil {
  9507. return
  9508. }
  9509. return *v, true
  9510. }
  9511. // ClearStatus clears the value of the "status" field.
  9512. func (m *ContactMutation) ClearStatus() {
  9513. m.status = nil
  9514. m.addstatus = nil
  9515. m.clearedFields[contact.FieldStatus] = struct{}{}
  9516. }
  9517. // StatusCleared returns if the "status" field was cleared in this mutation.
  9518. func (m *ContactMutation) StatusCleared() bool {
  9519. _, ok := m.clearedFields[contact.FieldStatus]
  9520. return ok
  9521. }
  9522. // ResetStatus resets all changes to the "status" field.
  9523. func (m *ContactMutation) ResetStatus() {
  9524. m.status = nil
  9525. m.addstatus = nil
  9526. delete(m.clearedFields, contact.FieldStatus)
  9527. }
  9528. // SetDeletedAt sets the "deleted_at" field.
  9529. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9530. m.deleted_at = &t
  9531. }
  9532. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9533. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9534. v := m.deleted_at
  9535. if v == nil {
  9536. return
  9537. }
  9538. return *v, true
  9539. }
  9540. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9541. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9543. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9544. if !m.op.Is(OpUpdateOne) {
  9545. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9546. }
  9547. if m.id == nil || m.oldValue == nil {
  9548. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9549. }
  9550. oldValue, err := m.oldValue(ctx)
  9551. if err != nil {
  9552. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9553. }
  9554. return oldValue.DeletedAt, nil
  9555. }
  9556. // ClearDeletedAt clears the value of the "deleted_at" field.
  9557. func (m *ContactMutation) ClearDeletedAt() {
  9558. m.deleted_at = nil
  9559. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9560. }
  9561. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9562. func (m *ContactMutation) DeletedAtCleared() bool {
  9563. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9564. return ok
  9565. }
  9566. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9567. func (m *ContactMutation) ResetDeletedAt() {
  9568. m.deleted_at = nil
  9569. delete(m.clearedFields, contact.FieldDeletedAt)
  9570. }
  9571. // SetWxWxid sets the "wx_wxid" field.
  9572. func (m *ContactMutation) SetWxWxid(s string) {
  9573. m.wx_wxid = &s
  9574. }
  9575. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9576. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9577. v := m.wx_wxid
  9578. if v == nil {
  9579. return
  9580. }
  9581. return *v, true
  9582. }
  9583. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9584. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9586. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9587. if !m.op.Is(OpUpdateOne) {
  9588. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9589. }
  9590. if m.id == nil || m.oldValue == nil {
  9591. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9592. }
  9593. oldValue, err := m.oldValue(ctx)
  9594. if err != nil {
  9595. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9596. }
  9597. return oldValue.WxWxid, nil
  9598. }
  9599. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9600. func (m *ContactMutation) ResetWxWxid() {
  9601. m.wx_wxid = nil
  9602. }
  9603. // SetType sets the "type" field.
  9604. func (m *ContactMutation) SetType(i int) {
  9605. m._type = &i
  9606. m.add_type = nil
  9607. }
  9608. // GetType returns the value of the "type" field in the mutation.
  9609. func (m *ContactMutation) GetType() (r int, exists bool) {
  9610. v := m._type
  9611. if v == nil {
  9612. return
  9613. }
  9614. return *v, true
  9615. }
  9616. // OldType returns the old "type" field's value of the Contact entity.
  9617. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9619. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9620. if !m.op.Is(OpUpdateOne) {
  9621. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9622. }
  9623. if m.id == nil || m.oldValue == nil {
  9624. return v, errors.New("OldType requires an ID field in the mutation")
  9625. }
  9626. oldValue, err := m.oldValue(ctx)
  9627. if err != nil {
  9628. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9629. }
  9630. return oldValue.Type, nil
  9631. }
  9632. // AddType adds i to the "type" field.
  9633. func (m *ContactMutation) AddType(i int) {
  9634. if m.add_type != nil {
  9635. *m.add_type += i
  9636. } else {
  9637. m.add_type = &i
  9638. }
  9639. }
  9640. // AddedType returns the value that was added to the "type" field in this mutation.
  9641. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9642. v := m.add_type
  9643. if v == nil {
  9644. return
  9645. }
  9646. return *v, true
  9647. }
  9648. // ClearType clears the value of the "type" field.
  9649. func (m *ContactMutation) ClearType() {
  9650. m._type = nil
  9651. m.add_type = nil
  9652. m.clearedFields[contact.FieldType] = struct{}{}
  9653. }
  9654. // TypeCleared returns if the "type" field was cleared in this mutation.
  9655. func (m *ContactMutation) TypeCleared() bool {
  9656. _, ok := m.clearedFields[contact.FieldType]
  9657. return ok
  9658. }
  9659. // ResetType resets all changes to the "type" field.
  9660. func (m *ContactMutation) ResetType() {
  9661. m._type = nil
  9662. m.add_type = nil
  9663. delete(m.clearedFields, contact.FieldType)
  9664. }
  9665. // SetWxid sets the "wxid" field.
  9666. func (m *ContactMutation) SetWxid(s string) {
  9667. m.wxid = &s
  9668. }
  9669. // Wxid returns the value of the "wxid" field in the mutation.
  9670. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9671. v := m.wxid
  9672. if v == nil {
  9673. return
  9674. }
  9675. return *v, true
  9676. }
  9677. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9678. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9680. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9681. if !m.op.Is(OpUpdateOne) {
  9682. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9683. }
  9684. if m.id == nil || m.oldValue == nil {
  9685. return v, errors.New("OldWxid requires an ID field in the mutation")
  9686. }
  9687. oldValue, err := m.oldValue(ctx)
  9688. if err != nil {
  9689. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9690. }
  9691. return oldValue.Wxid, nil
  9692. }
  9693. // ResetWxid resets all changes to the "wxid" field.
  9694. func (m *ContactMutation) ResetWxid() {
  9695. m.wxid = nil
  9696. }
  9697. // SetAccount sets the "account" field.
  9698. func (m *ContactMutation) SetAccount(s string) {
  9699. m.account = &s
  9700. }
  9701. // Account returns the value of the "account" field in the mutation.
  9702. func (m *ContactMutation) Account() (r string, exists bool) {
  9703. v := m.account
  9704. if v == nil {
  9705. return
  9706. }
  9707. return *v, true
  9708. }
  9709. // OldAccount returns the old "account" field's value of the Contact entity.
  9710. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9712. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9713. if !m.op.Is(OpUpdateOne) {
  9714. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9715. }
  9716. if m.id == nil || m.oldValue == nil {
  9717. return v, errors.New("OldAccount requires an ID field in the mutation")
  9718. }
  9719. oldValue, err := m.oldValue(ctx)
  9720. if err != nil {
  9721. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9722. }
  9723. return oldValue.Account, nil
  9724. }
  9725. // ResetAccount resets all changes to the "account" field.
  9726. func (m *ContactMutation) ResetAccount() {
  9727. m.account = nil
  9728. }
  9729. // SetNickname sets the "nickname" field.
  9730. func (m *ContactMutation) SetNickname(s string) {
  9731. m.nickname = &s
  9732. }
  9733. // Nickname returns the value of the "nickname" field in the mutation.
  9734. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9735. v := m.nickname
  9736. if v == nil {
  9737. return
  9738. }
  9739. return *v, true
  9740. }
  9741. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9742. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9744. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9745. if !m.op.Is(OpUpdateOne) {
  9746. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9747. }
  9748. if m.id == nil || m.oldValue == nil {
  9749. return v, errors.New("OldNickname requires an ID field in the mutation")
  9750. }
  9751. oldValue, err := m.oldValue(ctx)
  9752. if err != nil {
  9753. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9754. }
  9755. return oldValue.Nickname, nil
  9756. }
  9757. // ResetNickname resets all changes to the "nickname" field.
  9758. func (m *ContactMutation) ResetNickname() {
  9759. m.nickname = nil
  9760. }
  9761. // SetMarkname sets the "markname" field.
  9762. func (m *ContactMutation) SetMarkname(s string) {
  9763. m.markname = &s
  9764. }
  9765. // Markname returns the value of the "markname" field in the mutation.
  9766. func (m *ContactMutation) Markname() (r string, exists bool) {
  9767. v := m.markname
  9768. if v == nil {
  9769. return
  9770. }
  9771. return *v, true
  9772. }
  9773. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9774. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9776. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9777. if !m.op.Is(OpUpdateOne) {
  9778. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9779. }
  9780. if m.id == nil || m.oldValue == nil {
  9781. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9782. }
  9783. oldValue, err := m.oldValue(ctx)
  9784. if err != nil {
  9785. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9786. }
  9787. return oldValue.Markname, nil
  9788. }
  9789. // ResetMarkname resets all changes to the "markname" field.
  9790. func (m *ContactMutation) ResetMarkname() {
  9791. m.markname = nil
  9792. }
  9793. // SetHeadimg sets the "headimg" field.
  9794. func (m *ContactMutation) SetHeadimg(s string) {
  9795. m.headimg = &s
  9796. }
  9797. // Headimg returns the value of the "headimg" field in the mutation.
  9798. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9799. v := m.headimg
  9800. if v == nil {
  9801. return
  9802. }
  9803. return *v, true
  9804. }
  9805. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9806. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9808. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9809. if !m.op.Is(OpUpdateOne) {
  9810. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9811. }
  9812. if m.id == nil || m.oldValue == nil {
  9813. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9814. }
  9815. oldValue, err := m.oldValue(ctx)
  9816. if err != nil {
  9817. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9818. }
  9819. return oldValue.Headimg, nil
  9820. }
  9821. // ResetHeadimg resets all changes to the "headimg" field.
  9822. func (m *ContactMutation) ResetHeadimg() {
  9823. m.headimg = nil
  9824. }
  9825. // SetSex sets the "sex" field.
  9826. func (m *ContactMutation) SetSex(i int) {
  9827. m.sex = &i
  9828. m.addsex = nil
  9829. }
  9830. // Sex returns the value of the "sex" field in the mutation.
  9831. func (m *ContactMutation) Sex() (r int, exists bool) {
  9832. v := m.sex
  9833. if v == nil {
  9834. return
  9835. }
  9836. return *v, true
  9837. }
  9838. // OldSex returns the old "sex" field's value of the Contact entity.
  9839. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9841. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9842. if !m.op.Is(OpUpdateOne) {
  9843. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9844. }
  9845. if m.id == nil || m.oldValue == nil {
  9846. return v, errors.New("OldSex requires an ID field in the mutation")
  9847. }
  9848. oldValue, err := m.oldValue(ctx)
  9849. if err != nil {
  9850. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9851. }
  9852. return oldValue.Sex, nil
  9853. }
  9854. // AddSex adds i to the "sex" field.
  9855. func (m *ContactMutation) AddSex(i int) {
  9856. if m.addsex != nil {
  9857. *m.addsex += i
  9858. } else {
  9859. m.addsex = &i
  9860. }
  9861. }
  9862. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9863. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9864. v := m.addsex
  9865. if v == nil {
  9866. return
  9867. }
  9868. return *v, true
  9869. }
  9870. // ResetSex resets all changes to the "sex" field.
  9871. func (m *ContactMutation) ResetSex() {
  9872. m.sex = nil
  9873. m.addsex = nil
  9874. }
  9875. // SetStarrole sets the "starrole" field.
  9876. func (m *ContactMutation) SetStarrole(s string) {
  9877. m.starrole = &s
  9878. }
  9879. // Starrole returns the value of the "starrole" field in the mutation.
  9880. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9881. v := m.starrole
  9882. if v == nil {
  9883. return
  9884. }
  9885. return *v, true
  9886. }
  9887. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9888. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9890. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9891. if !m.op.Is(OpUpdateOne) {
  9892. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9893. }
  9894. if m.id == nil || m.oldValue == nil {
  9895. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9896. }
  9897. oldValue, err := m.oldValue(ctx)
  9898. if err != nil {
  9899. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9900. }
  9901. return oldValue.Starrole, nil
  9902. }
  9903. // ResetStarrole resets all changes to the "starrole" field.
  9904. func (m *ContactMutation) ResetStarrole() {
  9905. m.starrole = nil
  9906. }
  9907. // SetDontseeit sets the "dontseeit" field.
  9908. func (m *ContactMutation) SetDontseeit(i int) {
  9909. m.dontseeit = &i
  9910. m.adddontseeit = nil
  9911. }
  9912. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9913. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9914. v := m.dontseeit
  9915. if v == nil {
  9916. return
  9917. }
  9918. return *v, true
  9919. }
  9920. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9921. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9923. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9924. if !m.op.Is(OpUpdateOne) {
  9925. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9926. }
  9927. if m.id == nil || m.oldValue == nil {
  9928. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9929. }
  9930. oldValue, err := m.oldValue(ctx)
  9931. if err != nil {
  9932. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9933. }
  9934. return oldValue.Dontseeit, nil
  9935. }
  9936. // AddDontseeit adds i to the "dontseeit" field.
  9937. func (m *ContactMutation) AddDontseeit(i int) {
  9938. if m.adddontseeit != nil {
  9939. *m.adddontseeit += i
  9940. } else {
  9941. m.adddontseeit = &i
  9942. }
  9943. }
  9944. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9945. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9946. v := m.adddontseeit
  9947. if v == nil {
  9948. return
  9949. }
  9950. return *v, true
  9951. }
  9952. // ResetDontseeit resets all changes to the "dontseeit" field.
  9953. func (m *ContactMutation) ResetDontseeit() {
  9954. m.dontseeit = nil
  9955. m.adddontseeit = nil
  9956. }
  9957. // SetDontseeme sets the "dontseeme" field.
  9958. func (m *ContactMutation) SetDontseeme(i int) {
  9959. m.dontseeme = &i
  9960. m.adddontseeme = nil
  9961. }
  9962. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9963. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9964. v := m.dontseeme
  9965. if v == nil {
  9966. return
  9967. }
  9968. return *v, true
  9969. }
  9970. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9971. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9973. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9974. if !m.op.Is(OpUpdateOne) {
  9975. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9976. }
  9977. if m.id == nil || m.oldValue == nil {
  9978. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  9979. }
  9980. oldValue, err := m.oldValue(ctx)
  9981. if err != nil {
  9982. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  9983. }
  9984. return oldValue.Dontseeme, nil
  9985. }
  9986. // AddDontseeme adds i to the "dontseeme" field.
  9987. func (m *ContactMutation) AddDontseeme(i int) {
  9988. if m.adddontseeme != nil {
  9989. *m.adddontseeme += i
  9990. } else {
  9991. m.adddontseeme = &i
  9992. }
  9993. }
  9994. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  9995. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  9996. v := m.adddontseeme
  9997. if v == nil {
  9998. return
  9999. }
  10000. return *v, true
  10001. }
  10002. // ResetDontseeme resets all changes to the "dontseeme" field.
  10003. func (m *ContactMutation) ResetDontseeme() {
  10004. m.dontseeme = nil
  10005. m.adddontseeme = nil
  10006. }
  10007. // SetLag sets the "lag" field.
  10008. func (m *ContactMutation) SetLag(s string) {
  10009. m.lag = &s
  10010. }
  10011. // Lag returns the value of the "lag" field in the mutation.
  10012. func (m *ContactMutation) Lag() (r string, exists bool) {
  10013. v := m.lag
  10014. if v == nil {
  10015. return
  10016. }
  10017. return *v, true
  10018. }
  10019. // OldLag returns the old "lag" field's value of the Contact entity.
  10020. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10022. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10023. if !m.op.Is(OpUpdateOne) {
  10024. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10025. }
  10026. if m.id == nil || m.oldValue == nil {
  10027. return v, errors.New("OldLag requires an ID field in the mutation")
  10028. }
  10029. oldValue, err := m.oldValue(ctx)
  10030. if err != nil {
  10031. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10032. }
  10033. return oldValue.Lag, nil
  10034. }
  10035. // ResetLag resets all changes to the "lag" field.
  10036. func (m *ContactMutation) ResetLag() {
  10037. m.lag = nil
  10038. }
  10039. // SetGid sets the "gid" field.
  10040. func (m *ContactMutation) SetGid(s string) {
  10041. m.gid = &s
  10042. }
  10043. // Gid returns the value of the "gid" field in the mutation.
  10044. func (m *ContactMutation) Gid() (r string, exists bool) {
  10045. v := m.gid
  10046. if v == nil {
  10047. return
  10048. }
  10049. return *v, true
  10050. }
  10051. // OldGid returns the old "gid" field's value of the Contact entity.
  10052. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10054. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10055. if !m.op.Is(OpUpdateOne) {
  10056. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10057. }
  10058. if m.id == nil || m.oldValue == nil {
  10059. return v, errors.New("OldGid requires an ID field in the mutation")
  10060. }
  10061. oldValue, err := m.oldValue(ctx)
  10062. if err != nil {
  10063. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10064. }
  10065. return oldValue.Gid, nil
  10066. }
  10067. // ResetGid resets all changes to the "gid" field.
  10068. func (m *ContactMutation) ResetGid() {
  10069. m.gid = nil
  10070. }
  10071. // SetGname sets the "gname" field.
  10072. func (m *ContactMutation) SetGname(s string) {
  10073. m.gname = &s
  10074. }
  10075. // Gname returns the value of the "gname" field in the mutation.
  10076. func (m *ContactMutation) Gname() (r string, exists bool) {
  10077. v := m.gname
  10078. if v == nil {
  10079. return
  10080. }
  10081. return *v, true
  10082. }
  10083. // OldGname returns the old "gname" field's value of the Contact entity.
  10084. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10086. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10087. if !m.op.Is(OpUpdateOne) {
  10088. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10089. }
  10090. if m.id == nil || m.oldValue == nil {
  10091. return v, errors.New("OldGname requires an ID field in the mutation")
  10092. }
  10093. oldValue, err := m.oldValue(ctx)
  10094. if err != nil {
  10095. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10096. }
  10097. return oldValue.Gname, nil
  10098. }
  10099. // ResetGname resets all changes to the "gname" field.
  10100. func (m *ContactMutation) ResetGname() {
  10101. m.gname = nil
  10102. }
  10103. // SetV3 sets the "v3" field.
  10104. func (m *ContactMutation) SetV3(s string) {
  10105. m.v3 = &s
  10106. }
  10107. // V3 returns the value of the "v3" field in the mutation.
  10108. func (m *ContactMutation) V3() (r string, exists bool) {
  10109. v := m.v3
  10110. if v == nil {
  10111. return
  10112. }
  10113. return *v, true
  10114. }
  10115. // OldV3 returns the old "v3" field's value of the Contact entity.
  10116. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10118. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10119. if !m.op.Is(OpUpdateOne) {
  10120. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10121. }
  10122. if m.id == nil || m.oldValue == nil {
  10123. return v, errors.New("OldV3 requires an ID field in the mutation")
  10124. }
  10125. oldValue, err := m.oldValue(ctx)
  10126. if err != nil {
  10127. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10128. }
  10129. return oldValue.V3, nil
  10130. }
  10131. // ResetV3 resets all changes to the "v3" field.
  10132. func (m *ContactMutation) ResetV3() {
  10133. m.v3 = nil
  10134. }
  10135. // SetOrganizationID sets the "organization_id" field.
  10136. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10137. m.organization_id = &u
  10138. m.addorganization_id = nil
  10139. }
  10140. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10141. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10142. v := m.organization_id
  10143. if v == nil {
  10144. return
  10145. }
  10146. return *v, true
  10147. }
  10148. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10149. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10151. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10152. if !m.op.Is(OpUpdateOne) {
  10153. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10154. }
  10155. if m.id == nil || m.oldValue == nil {
  10156. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10157. }
  10158. oldValue, err := m.oldValue(ctx)
  10159. if err != nil {
  10160. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10161. }
  10162. return oldValue.OrganizationID, nil
  10163. }
  10164. // AddOrganizationID adds u to the "organization_id" field.
  10165. func (m *ContactMutation) AddOrganizationID(u int64) {
  10166. if m.addorganization_id != nil {
  10167. *m.addorganization_id += u
  10168. } else {
  10169. m.addorganization_id = &u
  10170. }
  10171. }
  10172. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10173. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10174. v := m.addorganization_id
  10175. if v == nil {
  10176. return
  10177. }
  10178. return *v, true
  10179. }
  10180. // ClearOrganizationID clears the value of the "organization_id" field.
  10181. func (m *ContactMutation) ClearOrganizationID() {
  10182. m.organization_id = nil
  10183. m.addorganization_id = nil
  10184. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10185. }
  10186. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10187. func (m *ContactMutation) OrganizationIDCleared() bool {
  10188. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10189. return ok
  10190. }
  10191. // ResetOrganizationID resets all changes to the "organization_id" field.
  10192. func (m *ContactMutation) ResetOrganizationID() {
  10193. m.organization_id = nil
  10194. m.addorganization_id = nil
  10195. delete(m.clearedFields, contact.FieldOrganizationID)
  10196. }
  10197. // SetCtype sets the "ctype" field.
  10198. func (m *ContactMutation) SetCtype(u uint64) {
  10199. m.ctype = &u
  10200. m.addctype = nil
  10201. }
  10202. // Ctype returns the value of the "ctype" field in the mutation.
  10203. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10204. v := m.ctype
  10205. if v == nil {
  10206. return
  10207. }
  10208. return *v, true
  10209. }
  10210. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10211. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10213. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10214. if !m.op.Is(OpUpdateOne) {
  10215. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10216. }
  10217. if m.id == nil || m.oldValue == nil {
  10218. return v, errors.New("OldCtype requires an ID field in the mutation")
  10219. }
  10220. oldValue, err := m.oldValue(ctx)
  10221. if err != nil {
  10222. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10223. }
  10224. return oldValue.Ctype, nil
  10225. }
  10226. // AddCtype adds u to the "ctype" field.
  10227. func (m *ContactMutation) AddCtype(u int64) {
  10228. if m.addctype != nil {
  10229. *m.addctype += u
  10230. } else {
  10231. m.addctype = &u
  10232. }
  10233. }
  10234. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10235. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10236. v := m.addctype
  10237. if v == nil {
  10238. return
  10239. }
  10240. return *v, true
  10241. }
  10242. // ResetCtype resets all changes to the "ctype" field.
  10243. func (m *ContactMutation) ResetCtype() {
  10244. m.ctype = nil
  10245. m.addctype = nil
  10246. }
  10247. // SetCage sets the "cage" field.
  10248. func (m *ContactMutation) SetCage(i int) {
  10249. m.cage = &i
  10250. m.addcage = nil
  10251. }
  10252. // Cage returns the value of the "cage" field in the mutation.
  10253. func (m *ContactMutation) Cage() (r int, exists bool) {
  10254. v := m.cage
  10255. if v == nil {
  10256. return
  10257. }
  10258. return *v, true
  10259. }
  10260. // OldCage returns the old "cage" field's value of the Contact entity.
  10261. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10263. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10264. if !m.op.Is(OpUpdateOne) {
  10265. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10266. }
  10267. if m.id == nil || m.oldValue == nil {
  10268. return v, errors.New("OldCage requires an ID field in the mutation")
  10269. }
  10270. oldValue, err := m.oldValue(ctx)
  10271. if err != nil {
  10272. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10273. }
  10274. return oldValue.Cage, nil
  10275. }
  10276. // AddCage adds i to the "cage" field.
  10277. func (m *ContactMutation) AddCage(i int) {
  10278. if m.addcage != nil {
  10279. *m.addcage += i
  10280. } else {
  10281. m.addcage = &i
  10282. }
  10283. }
  10284. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10285. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10286. v := m.addcage
  10287. if v == nil {
  10288. return
  10289. }
  10290. return *v, true
  10291. }
  10292. // ResetCage resets all changes to the "cage" field.
  10293. func (m *ContactMutation) ResetCage() {
  10294. m.cage = nil
  10295. m.addcage = nil
  10296. }
  10297. // SetCname sets the "cname" field.
  10298. func (m *ContactMutation) SetCname(s string) {
  10299. m.cname = &s
  10300. }
  10301. // Cname returns the value of the "cname" field in the mutation.
  10302. func (m *ContactMutation) Cname() (r string, exists bool) {
  10303. v := m.cname
  10304. if v == nil {
  10305. return
  10306. }
  10307. return *v, true
  10308. }
  10309. // OldCname returns the old "cname" field's value of the Contact entity.
  10310. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10312. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10313. if !m.op.Is(OpUpdateOne) {
  10314. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10315. }
  10316. if m.id == nil || m.oldValue == nil {
  10317. return v, errors.New("OldCname requires an ID field in the mutation")
  10318. }
  10319. oldValue, err := m.oldValue(ctx)
  10320. if err != nil {
  10321. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10322. }
  10323. return oldValue.Cname, nil
  10324. }
  10325. // ResetCname resets all changes to the "cname" field.
  10326. func (m *ContactMutation) ResetCname() {
  10327. m.cname = nil
  10328. }
  10329. // SetCarea sets the "carea" field.
  10330. func (m *ContactMutation) SetCarea(s string) {
  10331. m.carea = &s
  10332. }
  10333. // Carea returns the value of the "carea" field in the mutation.
  10334. func (m *ContactMutation) Carea() (r string, exists bool) {
  10335. v := m.carea
  10336. if v == nil {
  10337. return
  10338. }
  10339. return *v, true
  10340. }
  10341. // OldCarea returns the old "carea" field's value of the Contact entity.
  10342. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10344. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10345. if !m.op.Is(OpUpdateOne) {
  10346. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10347. }
  10348. if m.id == nil || m.oldValue == nil {
  10349. return v, errors.New("OldCarea requires an ID field in the mutation")
  10350. }
  10351. oldValue, err := m.oldValue(ctx)
  10352. if err != nil {
  10353. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10354. }
  10355. return oldValue.Carea, nil
  10356. }
  10357. // ResetCarea resets all changes to the "carea" field.
  10358. func (m *ContactMutation) ResetCarea() {
  10359. m.carea = nil
  10360. }
  10361. // SetCbirthday sets the "cbirthday" field.
  10362. func (m *ContactMutation) SetCbirthday(s string) {
  10363. m.cbirthday = &s
  10364. }
  10365. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10366. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10367. v := m.cbirthday
  10368. if v == nil {
  10369. return
  10370. }
  10371. return *v, true
  10372. }
  10373. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10374. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10376. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10377. if !m.op.Is(OpUpdateOne) {
  10378. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10379. }
  10380. if m.id == nil || m.oldValue == nil {
  10381. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10382. }
  10383. oldValue, err := m.oldValue(ctx)
  10384. if err != nil {
  10385. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10386. }
  10387. return oldValue.Cbirthday, nil
  10388. }
  10389. // ResetCbirthday resets all changes to the "cbirthday" field.
  10390. func (m *ContactMutation) ResetCbirthday() {
  10391. m.cbirthday = nil
  10392. }
  10393. // SetCbirtharea sets the "cbirtharea" field.
  10394. func (m *ContactMutation) SetCbirtharea(s string) {
  10395. m.cbirtharea = &s
  10396. }
  10397. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10398. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10399. v := m.cbirtharea
  10400. if v == nil {
  10401. return
  10402. }
  10403. return *v, true
  10404. }
  10405. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10406. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10408. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10409. if !m.op.Is(OpUpdateOne) {
  10410. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10411. }
  10412. if m.id == nil || m.oldValue == nil {
  10413. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10414. }
  10415. oldValue, err := m.oldValue(ctx)
  10416. if err != nil {
  10417. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10418. }
  10419. return oldValue.Cbirtharea, nil
  10420. }
  10421. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10422. func (m *ContactMutation) ResetCbirtharea() {
  10423. m.cbirtharea = nil
  10424. }
  10425. // SetCidcardNo sets the "cidcard_no" field.
  10426. func (m *ContactMutation) SetCidcardNo(s string) {
  10427. m.cidcard_no = &s
  10428. }
  10429. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10430. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10431. v := m.cidcard_no
  10432. if v == nil {
  10433. return
  10434. }
  10435. return *v, true
  10436. }
  10437. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10438. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10440. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10441. if !m.op.Is(OpUpdateOne) {
  10442. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10443. }
  10444. if m.id == nil || m.oldValue == nil {
  10445. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10446. }
  10447. oldValue, err := m.oldValue(ctx)
  10448. if err != nil {
  10449. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10450. }
  10451. return oldValue.CidcardNo, nil
  10452. }
  10453. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10454. func (m *ContactMutation) ResetCidcardNo() {
  10455. m.cidcard_no = nil
  10456. }
  10457. // SetCtitle sets the "ctitle" field.
  10458. func (m *ContactMutation) SetCtitle(s string) {
  10459. m.ctitle = &s
  10460. }
  10461. // Ctitle returns the value of the "ctitle" field in the mutation.
  10462. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10463. v := m.ctitle
  10464. if v == nil {
  10465. return
  10466. }
  10467. return *v, true
  10468. }
  10469. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10470. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10472. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10473. if !m.op.Is(OpUpdateOne) {
  10474. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10475. }
  10476. if m.id == nil || m.oldValue == nil {
  10477. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10478. }
  10479. oldValue, err := m.oldValue(ctx)
  10480. if err != nil {
  10481. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10482. }
  10483. return oldValue.Ctitle, nil
  10484. }
  10485. // ResetCtitle resets all changes to the "ctitle" field.
  10486. func (m *ContactMutation) ResetCtitle() {
  10487. m.ctitle = nil
  10488. }
  10489. // SetCc sets the "cc" field.
  10490. func (m *ContactMutation) SetCc(s string) {
  10491. m.cc = &s
  10492. }
  10493. // Cc returns the value of the "cc" field in the mutation.
  10494. func (m *ContactMutation) Cc() (r string, exists bool) {
  10495. v := m.cc
  10496. if v == nil {
  10497. return
  10498. }
  10499. return *v, true
  10500. }
  10501. // OldCc returns the old "cc" field's value of the Contact entity.
  10502. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10504. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10505. if !m.op.Is(OpUpdateOne) {
  10506. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10507. }
  10508. if m.id == nil || m.oldValue == nil {
  10509. return v, errors.New("OldCc requires an ID field in the mutation")
  10510. }
  10511. oldValue, err := m.oldValue(ctx)
  10512. if err != nil {
  10513. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10514. }
  10515. return oldValue.Cc, nil
  10516. }
  10517. // ResetCc resets all changes to the "cc" field.
  10518. func (m *ContactMutation) ResetCc() {
  10519. m.cc = nil
  10520. }
  10521. // SetPhone sets the "phone" field.
  10522. func (m *ContactMutation) SetPhone(s string) {
  10523. m.phone = &s
  10524. }
  10525. // Phone returns the value of the "phone" field in the mutation.
  10526. func (m *ContactMutation) Phone() (r string, exists bool) {
  10527. v := m.phone
  10528. if v == nil {
  10529. return
  10530. }
  10531. return *v, true
  10532. }
  10533. // OldPhone returns the old "phone" field's value of the Contact entity.
  10534. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10536. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10537. if !m.op.Is(OpUpdateOne) {
  10538. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10539. }
  10540. if m.id == nil || m.oldValue == nil {
  10541. return v, errors.New("OldPhone requires an ID field in the mutation")
  10542. }
  10543. oldValue, err := m.oldValue(ctx)
  10544. if err != nil {
  10545. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10546. }
  10547. return oldValue.Phone, nil
  10548. }
  10549. // ResetPhone resets all changes to the "phone" field.
  10550. func (m *ContactMutation) ResetPhone() {
  10551. m.phone = nil
  10552. }
  10553. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10554. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10555. if m.contact_relationships == nil {
  10556. m.contact_relationships = make(map[uint64]struct{})
  10557. }
  10558. for i := range ids {
  10559. m.contact_relationships[ids[i]] = struct{}{}
  10560. }
  10561. }
  10562. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10563. func (m *ContactMutation) ClearContactRelationships() {
  10564. m.clearedcontact_relationships = true
  10565. }
  10566. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10567. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10568. return m.clearedcontact_relationships
  10569. }
  10570. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10571. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10572. if m.removedcontact_relationships == nil {
  10573. m.removedcontact_relationships = make(map[uint64]struct{})
  10574. }
  10575. for i := range ids {
  10576. delete(m.contact_relationships, ids[i])
  10577. m.removedcontact_relationships[ids[i]] = struct{}{}
  10578. }
  10579. }
  10580. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10581. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10582. for id := range m.removedcontact_relationships {
  10583. ids = append(ids, id)
  10584. }
  10585. return
  10586. }
  10587. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10588. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10589. for id := range m.contact_relationships {
  10590. ids = append(ids, id)
  10591. }
  10592. return
  10593. }
  10594. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10595. func (m *ContactMutation) ResetContactRelationships() {
  10596. m.contact_relationships = nil
  10597. m.clearedcontact_relationships = false
  10598. m.removedcontact_relationships = nil
  10599. }
  10600. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10601. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10602. if m.contact_messages == nil {
  10603. m.contact_messages = make(map[uint64]struct{})
  10604. }
  10605. for i := range ids {
  10606. m.contact_messages[ids[i]] = struct{}{}
  10607. }
  10608. }
  10609. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10610. func (m *ContactMutation) ClearContactMessages() {
  10611. m.clearedcontact_messages = true
  10612. }
  10613. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10614. func (m *ContactMutation) ContactMessagesCleared() bool {
  10615. return m.clearedcontact_messages
  10616. }
  10617. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10618. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10619. if m.removedcontact_messages == nil {
  10620. m.removedcontact_messages = make(map[uint64]struct{})
  10621. }
  10622. for i := range ids {
  10623. delete(m.contact_messages, ids[i])
  10624. m.removedcontact_messages[ids[i]] = struct{}{}
  10625. }
  10626. }
  10627. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10628. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10629. for id := range m.removedcontact_messages {
  10630. ids = append(ids, id)
  10631. }
  10632. return
  10633. }
  10634. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10635. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10636. for id := range m.contact_messages {
  10637. ids = append(ids, id)
  10638. }
  10639. return
  10640. }
  10641. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10642. func (m *ContactMutation) ResetContactMessages() {
  10643. m.contact_messages = nil
  10644. m.clearedcontact_messages = false
  10645. m.removedcontact_messages = nil
  10646. }
  10647. // Where appends a list predicates to the ContactMutation builder.
  10648. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10649. m.predicates = append(m.predicates, ps...)
  10650. }
  10651. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10652. // users can use type-assertion to append predicates that do not depend on any generated package.
  10653. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10654. p := make([]predicate.Contact, len(ps))
  10655. for i := range ps {
  10656. p[i] = ps[i]
  10657. }
  10658. m.Where(p...)
  10659. }
  10660. // Op returns the operation name.
  10661. func (m *ContactMutation) Op() Op {
  10662. return m.op
  10663. }
  10664. // SetOp allows setting the mutation operation.
  10665. func (m *ContactMutation) SetOp(op Op) {
  10666. m.op = op
  10667. }
  10668. // Type returns the node type of this mutation (Contact).
  10669. func (m *ContactMutation) Type() string {
  10670. return m.typ
  10671. }
  10672. // Fields returns all fields that were changed during this mutation. Note that in
  10673. // order to get all numeric fields that were incremented/decremented, call
  10674. // AddedFields().
  10675. func (m *ContactMutation) Fields() []string {
  10676. fields := make([]string, 0, 30)
  10677. if m.created_at != nil {
  10678. fields = append(fields, contact.FieldCreatedAt)
  10679. }
  10680. if m.updated_at != nil {
  10681. fields = append(fields, contact.FieldUpdatedAt)
  10682. }
  10683. if m.status != nil {
  10684. fields = append(fields, contact.FieldStatus)
  10685. }
  10686. if m.deleted_at != nil {
  10687. fields = append(fields, contact.FieldDeletedAt)
  10688. }
  10689. if m.wx_wxid != nil {
  10690. fields = append(fields, contact.FieldWxWxid)
  10691. }
  10692. if m._type != nil {
  10693. fields = append(fields, contact.FieldType)
  10694. }
  10695. if m.wxid != nil {
  10696. fields = append(fields, contact.FieldWxid)
  10697. }
  10698. if m.account != nil {
  10699. fields = append(fields, contact.FieldAccount)
  10700. }
  10701. if m.nickname != nil {
  10702. fields = append(fields, contact.FieldNickname)
  10703. }
  10704. if m.markname != nil {
  10705. fields = append(fields, contact.FieldMarkname)
  10706. }
  10707. if m.headimg != nil {
  10708. fields = append(fields, contact.FieldHeadimg)
  10709. }
  10710. if m.sex != nil {
  10711. fields = append(fields, contact.FieldSex)
  10712. }
  10713. if m.starrole != nil {
  10714. fields = append(fields, contact.FieldStarrole)
  10715. }
  10716. if m.dontseeit != nil {
  10717. fields = append(fields, contact.FieldDontseeit)
  10718. }
  10719. if m.dontseeme != nil {
  10720. fields = append(fields, contact.FieldDontseeme)
  10721. }
  10722. if m.lag != nil {
  10723. fields = append(fields, contact.FieldLag)
  10724. }
  10725. if m.gid != nil {
  10726. fields = append(fields, contact.FieldGid)
  10727. }
  10728. if m.gname != nil {
  10729. fields = append(fields, contact.FieldGname)
  10730. }
  10731. if m.v3 != nil {
  10732. fields = append(fields, contact.FieldV3)
  10733. }
  10734. if m.organization_id != nil {
  10735. fields = append(fields, contact.FieldOrganizationID)
  10736. }
  10737. if m.ctype != nil {
  10738. fields = append(fields, contact.FieldCtype)
  10739. }
  10740. if m.cage != nil {
  10741. fields = append(fields, contact.FieldCage)
  10742. }
  10743. if m.cname != nil {
  10744. fields = append(fields, contact.FieldCname)
  10745. }
  10746. if m.carea != nil {
  10747. fields = append(fields, contact.FieldCarea)
  10748. }
  10749. if m.cbirthday != nil {
  10750. fields = append(fields, contact.FieldCbirthday)
  10751. }
  10752. if m.cbirtharea != nil {
  10753. fields = append(fields, contact.FieldCbirtharea)
  10754. }
  10755. if m.cidcard_no != nil {
  10756. fields = append(fields, contact.FieldCidcardNo)
  10757. }
  10758. if m.ctitle != nil {
  10759. fields = append(fields, contact.FieldCtitle)
  10760. }
  10761. if m.cc != nil {
  10762. fields = append(fields, contact.FieldCc)
  10763. }
  10764. if m.phone != nil {
  10765. fields = append(fields, contact.FieldPhone)
  10766. }
  10767. return fields
  10768. }
  10769. // Field returns the value of a field with the given name. The second boolean
  10770. // return value indicates that this field was not set, or was not defined in the
  10771. // schema.
  10772. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10773. switch name {
  10774. case contact.FieldCreatedAt:
  10775. return m.CreatedAt()
  10776. case contact.FieldUpdatedAt:
  10777. return m.UpdatedAt()
  10778. case contact.FieldStatus:
  10779. return m.Status()
  10780. case contact.FieldDeletedAt:
  10781. return m.DeletedAt()
  10782. case contact.FieldWxWxid:
  10783. return m.WxWxid()
  10784. case contact.FieldType:
  10785. return m.GetType()
  10786. case contact.FieldWxid:
  10787. return m.Wxid()
  10788. case contact.FieldAccount:
  10789. return m.Account()
  10790. case contact.FieldNickname:
  10791. return m.Nickname()
  10792. case contact.FieldMarkname:
  10793. return m.Markname()
  10794. case contact.FieldHeadimg:
  10795. return m.Headimg()
  10796. case contact.FieldSex:
  10797. return m.Sex()
  10798. case contact.FieldStarrole:
  10799. return m.Starrole()
  10800. case contact.FieldDontseeit:
  10801. return m.Dontseeit()
  10802. case contact.FieldDontseeme:
  10803. return m.Dontseeme()
  10804. case contact.FieldLag:
  10805. return m.Lag()
  10806. case contact.FieldGid:
  10807. return m.Gid()
  10808. case contact.FieldGname:
  10809. return m.Gname()
  10810. case contact.FieldV3:
  10811. return m.V3()
  10812. case contact.FieldOrganizationID:
  10813. return m.OrganizationID()
  10814. case contact.FieldCtype:
  10815. return m.Ctype()
  10816. case contact.FieldCage:
  10817. return m.Cage()
  10818. case contact.FieldCname:
  10819. return m.Cname()
  10820. case contact.FieldCarea:
  10821. return m.Carea()
  10822. case contact.FieldCbirthday:
  10823. return m.Cbirthday()
  10824. case contact.FieldCbirtharea:
  10825. return m.Cbirtharea()
  10826. case contact.FieldCidcardNo:
  10827. return m.CidcardNo()
  10828. case contact.FieldCtitle:
  10829. return m.Ctitle()
  10830. case contact.FieldCc:
  10831. return m.Cc()
  10832. case contact.FieldPhone:
  10833. return m.Phone()
  10834. }
  10835. return nil, false
  10836. }
  10837. // OldField returns the old value of the field from the database. An error is
  10838. // returned if the mutation operation is not UpdateOne, or the query to the
  10839. // database failed.
  10840. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10841. switch name {
  10842. case contact.FieldCreatedAt:
  10843. return m.OldCreatedAt(ctx)
  10844. case contact.FieldUpdatedAt:
  10845. return m.OldUpdatedAt(ctx)
  10846. case contact.FieldStatus:
  10847. return m.OldStatus(ctx)
  10848. case contact.FieldDeletedAt:
  10849. return m.OldDeletedAt(ctx)
  10850. case contact.FieldWxWxid:
  10851. return m.OldWxWxid(ctx)
  10852. case contact.FieldType:
  10853. return m.OldType(ctx)
  10854. case contact.FieldWxid:
  10855. return m.OldWxid(ctx)
  10856. case contact.FieldAccount:
  10857. return m.OldAccount(ctx)
  10858. case contact.FieldNickname:
  10859. return m.OldNickname(ctx)
  10860. case contact.FieldMarkname:
  10861. return m.OldMarkname(ctx)
  10862. case contact.FieldHeadimg:
  10863. return m.OldHeadimg(ctx)
  10864. case contact.FieldSex:
  10865. return m.OldSex(ctx)
  10866. case contact.FieldStarrole:
  10867. return m.OldStarrole(ctx)
  10868. case contact.FieldDontseeit:
  10869. return m.OldDontseeit(ctx)
  10870. case contact.FieldDontseeme:
  10871. return m.OldDontseeme(ctx)
  10872. case contact.FieldLag:
  10873. return m.OldLag(ctx)
  10874. case contact.FieldGid:
  10875. return m.OldGid(ctx)
  10876. case contact.FieldGname:
  10877. return m.OldGname(ctx)
  10878. case contact.FieldV3:
  10879. return m.OldV3(ctx)
  10880. case contact.FieldOrganizationID:
  10881. return m.OldOrganizationID(ctx)
  10882. case contact.FieldCtype:
  10883. return m.OldCtype(ctx)
  10884. case contact.FieldCage:
  10885. return m.OldCage(ctx)
  10886. case contact.FieldCname:
  10887. return m.OldCname(ctx)
  10888. case contact.FieldCarea:
  10889. return m.OldCarea(ctx)
  10890. case contact.FieldCbirthday:
  10891. return m.OldCbirthday(ctx)
  10892. case contact.FieldCbirtharea:
  10893. return m.OldCbirtharea(ctx)
  10894. case contact.FieldCidcardNo:
  10895. return m.OldCidcardNo(ctx)
  10896. case contact.FieldCtitle:
  10897. return m.OldCtitle(ctx)
  10898. case contact.FieldCc:
  10899. return m.OldCc(ctx)
  10900. case contact.FieldPhone:
  10901. return m.OldPhone(ctx)
  10902. }
  10903. return nil, fmt.Errorf("unknown Contact field %s", name)
  10904. }
  10905. // SetField sets the value of a field with the given name. It returns an error if
  10906. // the field is not defined in the schema, or if the type mismatched the field
  10907. // type.
  10908. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10909. switch name {
  10910. case contact.FieldCreatedAt:
  10911. v, ok := value.(time.Time)
  10912. if !ok {
  10913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10914. }
  10915. m.SetCreatedAt(v)
  10916. return nil
  10917. case contact.FieldUpdatedAt:
  10918. v, ok := value.(time.Time)
  10919. if !ok {
  10920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10921. }
  10922. m.SetUpdatedAt(v)
  10923. return nil
  10924. case contact.FieldStatus:
  10925. v, ok := value.(uint8)
  10926. if !ok {
  10927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10928. }
  10929. m.SetStatus(v)
  10930. return nil
  10931. case contact.FieldDeletedAt:
  10932. v, ok := value.(time.Time)
  10933. if !ok {
  10934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10935. }
  10936. m.SetDeletedAt(v)
  10937. return nil
  10938. case contact.FieldWxWxid:
  10939. v, ok := value.(string)
  10940. if !ok {
  10941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10942. }
  10943. m.SetWxWxid(v)
  10944. return nil
  10945. case contact.FieldType:
  10946. v, ok := value.(int)
  10947. if !ok {
  10948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10949. }
  10950. m.SetType(v)
  10951. return nil
  10952. case contact.FieldWxid:
  10953. v, ok := value.(string)
  10954. if !ok {
  10955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10956. }
  10957. m.SetWxid(v)
  10958. return nil
  10959. case contact.FieldAccount:
  10960. v, ok := value.(string)
  10961. if !ok {
  10962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10963. }
  10964. m.SetAccount(v)
  10965. return nil
  10966. case contact.FieldNickname:
  10967. v, ok := value.(string)
  10968. if !ok {
  10969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10970. }
  10971. m.SetNickname(v)
  10972. return nil
  10973. case contact.FieldMarkname:
  10974. v, ok := value.(string)
  10975. if !ok {
  10976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10977. }
  10978. m.SetMarkname(v)
  10979. return nil
  10980. case contact.FieldHeadimg:
  10981. v, ok := value.(string)
  10982. if !ok {
  10983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10984. }
  10985. m.SetHeadimg(v)
  10986. return nil
  10987. case contact.FieldSex:
  10988. v, ok := value.(int)
  10989. if !ok {
  10990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10991. }
  10992. m.SetSex(v)
  10993. return nil
  10994. case contact.FieldStarrole:
  10995. v, ok := value.(string)
  10996. if !ok {
  10997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10998. }
  10999. m.SetStarrole(v)
  11000. return nil
  11001. case contact.FieldDontseeit:
  11002. v, ok := value.(int)
  11003. if !ok {
  11004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11005. }
  11006. m.SetDontseeit(v)
  11007. return nil
  11008. case contact.FieldDontseeme:
  11009. v, ok := value.(int)
  11010. if !ok {
  11011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11012. }
  11013. m.SetDontseeme(v)
  11014. return nil
  11015. case contact.FieldLag:
  11016. v, ok := value.(string)
  11017. if !ok {
  11018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11019. }
  11020. m.SetLag(v)
  11021. return nil
  11022. case contact.FieldGid:
  11023. v, ok := value.(string)
  11024. if !ok {
  11025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11026. }
  11027. m.SetGid(v)
  11028. return nil
  11029. case contact.FieldGname:
  11030. v, ok := value.(string)
  11031. if !ok {
  11032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11033. }
  11034. m.SetGname(v)
  11035. return nil
  11036. case contact.FieldV3:
  11037. v, ok := value.(string)
  11038. if !ok {
  11039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11040. }
  11041. m.SetV3(v)
  11042. return nil
  11043. case contact.FieldOrganizationID:
  11044. v, ok := value.(uint64)
  11045. if !ok {
  11046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11047. }
  11048. m.SetOrganizationID(v)
  11049. return nil
  11050. case contact.FieldCtype:
  11051. v, ok := value.(uint64)
  11052. if !ok {
  11053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11054. }
  11055. m.SetCtype(v)
  11056. return nil
  11057. case contact.FieldCage:
  11058. v, ok := value.(int)
  11059. if !ok {
  11060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11061. }
  11062. m.SetCage(v)
  11063. return nil
  11064. case contact.FieldCname:
  11065. v, ok := value.(string)
  11066. if !ok {
  11067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11068. }
  11069. m.SetCname(v)
  11070. return nil
  11071. case contact.FieldCarea:
  11072. v, ok := value.(string)
  11073. if !ok {
  11074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11075. }
  11076. m.SetCarea(v)
  11077. return nil
  11078. case contact.FieldCbirthday:
  11079. v, ok := value.(string)
  11080. if !ok {
  11081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11082. }
  11083. m.SetCbirthday(v)
  11084. return nil
  11085. case contact.FieldCbirtharea:
  11086. v, ok := value.(string)
  11087. if !ok {
  11088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11089. }
  11090. m.SetCbirtharea(v)
  11091. return nil
  11092. case contact.FieldCidcardNo:
  11093. v, ok := value.(string)
  11094. if !ok {
  11095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11096. }
  11097. m.SetCidcardNo(v)
  11098. return nil
  11099. case contact.FieldCtitle:
  11100. v, ok := value.(string)
  11101. if !ok {
  11102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11103. }
  11104. m.SetCtitle(v)
  11105. return nil
  11106. case contact.FieldCc:
  11107. v, ok := value.(string)
  11108. if !ok {
  11109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11110. }
  11111. m.SetCc(v)
  11112. return nil
  11113. case contact.FieldPhone:
  11114. v, ok := value.(string)
  11115. if !ok {
  11116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11117. }
  11118. m.SetPhone(v)
  11119. return nil
  11120. }
  11121. return fmt.Errorf("unknown Contact field %s", name)
  11122. }
  11123. // AddedFields returns all numeric fields that were incremented/decremented during
  11124. // this mutation.
  11125. func (m *ContactMutation) AddedFields() []string {
  11126. var fields []string
  11127. if m.addstatus != nil {
  11128. fields = append(fields, contact.FieldStatus)
  11129. }
  11130. if m.add_type != nil {
  11131. fields = append(fields, contact.FieldType)
  11132. }
  11133. if m.addsex != nil {
  11134. fields = append(fields, contact.FieldSex)
  11135. }
  11136. if m.adddontseeit != nil {
  11137. fields = append(fields, contact.FieldDontseeit)
  11138. }
  11139. if m.adddontseeme != nil {
  11140. fields = append(fields, contact.FieldDontseeme)
  11141. }
  11142. if m.addorganization_id != nil {
  11143. fields = append(fields, contact.FieldOrganizationID)
  11144. }
  11145. if m.addctype != nil {
  11146. fields = append(fields, contact.FieldCtype)
  11147. }
  11148. if m.addcage != nil {
  11149. fields = append(fields, contact.FieldCage)
  11150. }
  11151. return fields
  11152. }
  11153. // AddedField returns the numeric value that was incremented/decremented on a field
  11154. // with the given name. The second boolean return value indicates that this field
  11155. // was not set, or was not defined in the schema.
  11156. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11157. switch name {
  11158. case contact.FieldStatus:
  11159. return m.AddedStatus()
  11160. case contact.FieldType:
  11161. return m.AddedType()
  11162. case contact.FieldSex:
  11163. return m.AddedSex()
  11164. case contact.FieldDontseeit:
  11165. return m.AddedDontseeit()
  11166. case contact.FieldDontseeme:
  11167. return m.AddedDontseeme()
  11168. case contact.FieldOrganizationID:
  11169. return m.AddedOrganizationID()
  11170. case contact.FieldCtype:
  11171. return m.AddedCtype()
  11172. case contact.FieldCage:
  11173. return m.AddedCage()
  11174. }
  11175. return nil, false
  11176. }
  11177. // AddField adds the value to the field with the given name. It returns an error if
  11178. // the field is not defined in the schema, or if the type mismatched the field
  11179. // type.
  11180. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11181. switch name {
  11182. case contact.FieldStatus:
  11183. v, ok := value.(int8)
  11184. if !ok {
  11185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11186. }
  11187. m.AddStatus(v)
  11188. return nil
  11189. case contact.FieldType:
  11190. v, ok := value.(int)
  11191. if !ok {
  11192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11193. }
  11194. m.AddType(v)
  11195. return nil
  11196. case contact.FieldSex:
  11197. v, ok := value.(int)
  11198. if !ok {
  11199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11200. }
  11201. m.AddSex(v)
  11202. return nil
  11203. case contact.FieldDontseeit:
  11204. v, ok := value.(int)
  11205. if !ok {
  11206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11207. }
  11208. m.AddDontseeit(v)
  11209. return nil
  11210. case contact.FieldDontseeme:
  11211. v, ok := value.(int)
  11212. if !ok {
  11213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11214. }
  11215. m.AddDontseeme(v)
  11216. return nil
  11217. case contact.FieldOrganizationID:
  11218. v, ok := value.(int64)
  11219. if !ok {
  11220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11221. }
  11222. m.AddOrganizationID(v)
  11223. return nil
  11224. case contact.FieldCtype:
  11225. v, ok := value.(int64)
  11226. if !ok {
  11227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11228. }
  11229. m.AddCtype(v)
  11230. return nil
  11231. case contact.FieldCage:
  11232. v, ok := value.(int)
  11233. if !ok {
  11234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11235. }
  11236. m.AddCage(v)
  11237. return nil
  11238. }
  11239. return fmt.Errorf("unknown Contact numeric field %s", name)
  11240. }
  11241. // ClearedFields returns all nullable fields that were cleared during this
  11242. // mutation.
  11243. func (m *ContactMutation) ClearedFields() []string {
  11244. var fields []string
  11245. if m.FieldCleared(contact.FieldStatus) {
  11246. fields = append(fields, contact.FieldStatus)
  11247. }
  11248. if m.FieldCleared(contact.FieldDeletedAt) {
  11249. fields = append(fields, contact.FieldDeletedAt)
  11250. }
  11251. if m.FieldCleared(contact.FieldType) {
  11252. fields = append(fields, contact.FieldType)
  11253. }
  11254. if m.FieldCleared(contact.FieldOrganizationID) {
  11255. fields = append(fields, contact.FieldOrganizationID)
  11256. }
  11257. return fields
  11258. }
  11259. // FieldCleared returns a boolean indicating if a field with the given name was
  11260. // cleared in this mutation.
  11261. func (m *ContactMutation) FieldCleared(name string) bool {
  11262. _, ok := m.clearedFields[name]
  11263. return ok
  11264. }
  11265. // ClearField clears the value of the field with the given name. It returns an
  11266. // error if the field is not defined in the schema.
  11267. func (m *ContactMutation) ClearField(name string) error {
  11268. switch name {
  11269. case contact.FieldStatus:
  11270. m.ClearStatus()
  11271. return nil
  11272. case contact.FieldDeletedAt:
  11273. m.ClearDeletedAt()
  11274. return nil
  11275. case contact.FieldType:
  11276. m.ClearType()
  11277. return nil
  11278. case contact.FieldOrganizationID:
  11279. m.ClearOrganizationID()
  11280. return nil
  11281. }
  11282. return fmt.Errorf("unknown Contact nullable field %s", name)
  11283. }
  11284. // ResetField resets all changes in the mutation for the field with the given name.
  11285. // It returns an error if the field is not defined in the schema.
  11286. func (m *ContactMutation) ResetField(name string) error {
  11287. switch name {
  11288. case contact.FieldCreatedAt:
  11289. m.ResetCreatedAt()
  11290. return nil
  11291. case contact.FieldUpdatedAt:
  11292. m.ResetUpdatedAt()
  11293. return nil
  11294. case contact.FieldStatus:
  11295. m.ResetStatus()
  11296. return nil
  11297. case contact.FieldDeletedAt:
  11298. m.ResetDeletedAt()
  11299. return nil
  11300. case contact.FieldWxWxid:
  11301. m.ResetWxWxid()
  11302. return nil
  11303. case contact.FieldType:
  11304. m.ResetType()
  11305. return nil
  11306. case contact.FieldWxid:
  11307. m.ResetWxid()
  11308. return nil
  11309. case contact.FieldAccount:
  11310. m.ResetAccount()
  11311. return nil
  11312. case contact.FieldNickname:
  11313. m.ResetNickname()
  11314. return nil
  11315. case contact.FieldMarkname:
  11316. m.ResetMarkname()
  11317. return nil
  11318. case contact.FieldHeadimg:
  11319. m.ResetHeadimg()
  11320. return nil
  11321. case contact.FieldSex:
  11322. m.ResetSex()
  11323. return nil
  11324. case contact.FieldStarrole:
  11325. m.ResetStarrole()
  11326. return nil
  11327. case contact.FieldDontseeit:
  11328. m.ResetDontseeit()
  11329. return nil
  11330. case contact.FieldDontseeme:
  11331. m.ResetDontseeme()
  11332. return nil
  11333. case contact.FieldLag:
  11334. m.ResetLag()
  11335. return nil
  11336. case contact.FieldGid:
  11337. m.ResetGid()
  11338. return nil
  11339. case contact.FieldGname:
  11340. m.ResetGname()
  11341. return nil
  11342. case contact.FieldV3:
  11343. m.ResetV3()
  11344. return nil
  11345. case contact.FieldOrganizationID:
  11346. m.ResetOrganizationID()
  11347. return nil
  11348. case contact.FieldCtype:
  11349. m.ResetCtype()
  11350. return nil
  11351. case contact.FieldCage:
  11352. m.ResetCage()
  11353. return nil
  11354. case contact.FieldCname:
  11355. m.ResetCname()
  11356. return nil
  11357. case contact.FieldCarea:
  11358. m.ResetCarea()
  11359. return nil
  11360. case contact.FieldCbirthday:
  11361. m.ResetCbirthday()
  11362. return nil
  11363. case contact.FieldCbirtharea:
  11364. m.ResetCbirtharea()
  11365. return nil
  11366. case contact.FieldCidcardNo:
  11367. m.ResetCidcardNo()
  11368. return nil
  11369. case contact.FieldCtitle:
  11370. m.ResetCtitle()
  11371. return nil
  11372. case contact.FieldCc:
  11373. m.ResetCc()
  11374. return nil
  11375. case contact.FieldPhone:
  11376. m.ResetPhone()
  11377. return nil
  11378. }
  11379. return fmt.Errorf("unknown Contact field %s", name)
  11380. }
  11381. // AddedEdges returns all edge names that were set/added in this mutation.
  11382. func (m *ContactMutation) AddedEdges() []string {
  11383. edges := make([]string, 0, 2)
  11384. if m.contact_relationships != nil {
  11385. edges = append(edges, contact.EdgeContactRelationships)
  11386. }
  11387. if m.contact_messages != nil {
  11388. edges = append(edges, contact.EdgeContactMessages)
  11389. }
  11390. return edges
  11391. }
  11392. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11393. // name in this mutation.
  11394. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11395. switch name {
  11396. case contact.EdgeContactRelationships:
  11397. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11398. for id := range m.contact_relationships {
  11399. ids = append(ids, id)
  11400. }
  11401. return ids
  11402. case contact.EdgeContactMessages:
  11403. ids := make([]ent.Value, 0, len(m.contact_messages))
  11404. for id := range m.contact_messages {
  11405. ids = append(ids, id)
  11406. }
  11407. return ids
  11408. }
  11409. return nil
  11410. }
  11411. // RemovedEdges returns all edge names that were removed in this mutation.
  11412. func (m *ContactMutation) RemovedEdges() []string {
  11413. edges := make([]string, 0, 2)
  11414. if m.removedcontact_relationships != nil {
  11415. edges = append(edges, contact.EdgeContactRelationships)
  11416. }
  11417. if m.removedcontact_messages != nil {
  11418. edges = append(edges, contact.EdgeContactMessages)
  11419. }
  11420. return edges
  11421. }
  11422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11423. // the given name in this mutation.
  11424. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11425. switch name {
  11426. case contact.EdgeContactRelationships:
  11427. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11428. for id := range m.removedcontact_relationships {
  11429. ids = append(ids, id)
  11430. }
  11431. return ids
  11432. case contact.EdgeContactMessages:
  11433. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11434. for id := range m.removedcontact_messages {
  11435. ids = append(ids, id)
  11436. }
  11437. return ids
  11438. }
  11439. return nil
  11440. }
  11441. // ClearedEdges returns all edge names that were cleared in this mutation.
  11442. func (m *ContactMutation) ClearedEdges() []string {
  11443. edges := make([]string, 0, 2)
  11444. if m.clearedcontact_relationships {
  11445. edges = append(edges, contact.EdgeContactRelationships)
  11446. }
  11447. if m.clearedcontact_messages {
  11448. edges = append(edges, contact.EdgeContactMessages)
  11449. }
  11450. return edges
  11451. }
  11452. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11453. // was cleared in this mutation.
  11454. func (m *ContactMutation) EdgeCleared(name string) bool {
  11455. switch name {
  11456. case contact.EdgeContactRelationships:
  11457. return m.clearedcontact_relationships
  11458. case contact.EdgeContactMessages:
  11459. return m.clearedcontact_messages
  11460. }
  11461. return false
  11462. }
  11463. // ClearEdge clears the value of the edge with the given name. It returns an error
  11464. // if that edge is not defined in the schema.
  11465. func (m *ContactMutation) ClearEdge(name string) error {
  11466. switch name {
  11467. }
  11468. return fmt.Errorf("unknown Contact unique edge %s", name)
  11469. }
  11470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11471. // It returns an error if the edge is not defined in the schema.
  11472. func (m *ContactMutation) ResetEdge(name string) error {
  11473. switch name {
  11474. case contact.EdgeContactRelationships:
  11475. m.ResetContactRelationships()
  11476. return nil
  11477. case contact.EdgeContactMessages:
  11478. m.ResetContactMessages()
  11479. return nil
  11480. }
  11481. return fmt.Errorf("unknown Contact edge %s", name)
  11482. }
  11483. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11484. type CreditBalanceMutation struct {
  11485. config
  11486. op Op
  11487. typ string
  11488. id *uint64
  11489. created_at *time.Time
  11490. updated_at *time.Time
  11491. deleted_at *time.Time
  11492. user_id *string
  11493. balance *float32
  11494. addbalance *float32
  11495. status *int
  11496. addstatus *int
  11497. organization_id *uint64
  11498. addorganization_id *int64
  11499. clearedFields map[string]struct{}
  11500. done bool
  11501. oldValue func(context.Context) (*CreditBalance, error)
  11502. predicates []predicate.CreditBalance
  11503. }
  11504. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11505. // creditbalanceOption allows management of the mutation configuration using functional options.
  11506. type creditbalanceOption func(*CreditBalanceMutation)
  11507. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11508. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11509. m := &CreditBalanceMutation{
  11510. config: c,
  11511. op: op,
  11512. typ: TypeCreditBalance,
  11513. clearedFields: make(map[string]struct{}),
  11514. }
  11515. for _, opt := range opts {
  11516. opt(m)
  11517. }
  11518. return m
  11519. }
  11520. // withCreditBalanceID sets the ID field of the mutation.
  11521. func withCreditBalanceID(id uint64) creditbalanceOption {
  11522. return func(m *CreditBalanceMutation) {
  11523. var (
  11524. err error
  11525. once sync.Once
  11526. value *CreditBalance
  11527. )
  11528. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11529. once.Do(func() {
  11530. if m.done {
  11531. err = errors.New("querying old values post mutation is not allowed")
  11532. } else {
  11533. value, err = m.Client().CreditBalance.Get(ctx, id)
  11534. }
  11535. })
  11536. return value, err
  11537. }
  11538. m.id = &id
  11539. }
  11540. }
  11541. // withCreditBalance sets the old CreditBalance of the mutation.
  11542. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11543. return func(m *CreditBalanceMutation) {
  11544. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11545. return node, nil
  11546. }
  11547. m.id = &node.ID
  11548. }
  11549. }
  11550. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11551. // executed in a transaction (ent.Tx), a transactional client is returned.
  11552. func (m CreditBalanceMutation) Client() *Client {
  11553. client := &Client{config: m.config}
  11554. client.init()
  11555. return client
  11556. }
  11557. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11558. // it returns an error otherwise.
  11559. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11560. if _, ok := m.driver.(*txDriver); !ok {
  11561. return nil, errors.New("ent: mutation is not running in a transaction")
  11562. }
  11563. tx := &Tx{config: m.config}
  11564. tx.init()
  11565. return tx, nil
  11566. }
  11567. // SetID sets the value of the id field. Note that this
  11568. // operation is only accepted on creation of CreditBalance entities.
  11569. func (m *CreditBalanceMutation) SetID(id uint64) {
  11570. m.id = &id
  11571. }
  11572. // ID returns the ID value in the mutation. Note that the ID is only available
  11573. // if it was provided to the builder or after it was returned from the database.
  11574. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11575. if m.id == nil {
  11576. return
  11577. }
  11578. return *m.id, true
  11579. }
  11580. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11581. // That means, if the mutation is applied within a transaction with an isolation level such
  11582. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11583. // or updated by the mutation.
  11584. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11585. switch {
  11586. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11587. id, exists := m.ID()
  11588. if exists {
  11589. return []uint64{id}, nil
  11590. }
  11591. fallthrough
  11592. case m.op.Is(OpUpdate | OpDelete):
  11593. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11594. default:
  11595. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11596. }
  11597. }
  11598. // SetCreatedAt sets the "created_at" field.
  11599. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11600. m.created_at = &t
  11601. }
  11602. // CreatedAt returns the value of the "created_at" field in the mutation.
  11603. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11604. v := m.created_at
  11605. if v == nil {
  11606. return
  11607. }
  11608. return *v, true
  11609. }
  11610. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11611. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11613. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11614. if !m.op.Is(OpUpdateOne) {
  11615. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11616. }
  11617. if m.id == nil || m.oldValue == nil {
  11618. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11619. }
  11620. oldValue, err := m.oldValue(ctx)
  11621. if err != nil {
  11622. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11623. }
  11624. return oldValue.CreatedAt, nil
  11625. }
  11626. // ResetCreatedAt resets all changes to the "created_at" field.
  11627. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11628. m.created_at = nil
  11629. }
  11630. // SetUpdatedAt sets the "updated_at" field.
  11631. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11632. m.updated_at = &t
  11633. }
  11634. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11635. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11636. v := m.updated_at
  11637. if v == nil {
  11638. return
  11639. }
  11640. return *v, true
  11641. }
  11642. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11643. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11645. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11646. if !m.op.Is(OpUpdateOne) {
  11647. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11648. }
  11649. if m.id == nil || m.oldValue == nil {
  11650. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11651. }
  11652. oldValue, err := m.oldValue(ctx)
  11653. if err != nil {
  11654. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11655. }
  11656. return oldValue.UpdatedAt, nil
  11657. }
  11658. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11659. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11660. m.updated_at = nil
  11661. }
  11662. // SetDeletedAt sets the "deleted_at" field.
  11663. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11664. m.deleted_at = &t
  11665. }
  11666. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11667. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11668. v := m.deleted_at
  11669. if v == nil {
  11670. return
  11671. }
  11672. return *v, true
  11673. }
  11674. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11675. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11677. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11678. if !m.op.Is(OpUpdateOne) {
  11679. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11680. }
  11681. if m.id == nil || m.oldValue == nil {
  11682. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11683. }
  11684. oldValue, err := m.oldValue(ctx)
  11685. if err != nil {
  11686. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11687. }
  11688. return oldValue.DeletedAt, nil
  11689. }
  11690. // ClearDeletedAt clears the value of the "deleted_at" field.
  11691. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11692. m.deleted_at = nil
  11693. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11694. }
  11695. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11696. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11697. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11698. return ok
  11699. }
  11700. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11701. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11702. m.deleted_at = nil
  11703. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11704. }
  11705. // SetUserID sets the "user_id" field.
  11706. func (m *CreditBalanceMutation) SetUserID(s string) {
  11707. m.user_id = &s
  11708. }
  11709. // UserID returns the value of the "user_id" field in the mutation.
  11710. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11711. v := m.user_id
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11718. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11720. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldUserID requires an ID field in the mutation")
  11726. }
  11727. oldValue, err := m.oldValue(ctx)
  11728. if err != nil {
  11729. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11730. }
  11731. return oldValue.UserID, nil
  11732. }
  11733. // ClearUserID clears the value of the "user_id" field.
  11734. func (m *CreditBalanceMutation) ClearUserID() {
  11735. m.user_id = nil
  11736. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11737. }
  11738. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11739. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11740. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11741. return ok
  11742. }
  11743. // ResetUserID resets all changes to the "user_id" field.
  11744. func (m *CreditBalanceMutation) ResetUserID() {
  11745. m.user_id = nil
  11746. delete(m.clearedFields, creditbalance.FieldUserID)
  11747. }
  11748. // SetBalance sets the "balance" field.
  11749. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11750. m.balance = &f
  11751. m.addbalance = nil
  11752. }
  11753. // Balance returns the value of the "balance" field in the mutation.
  11754. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11755. v := m.balance
  11756. if v == nil {
  11757. return
  11758. }
  11759. return *v, true
  11760. }
  11761. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11762. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11764. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  11765. if !m.op.Is(OpUpdateOne) {
  11766. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  11767. }
  11768. if m.id == nil || m.oldValue == nil {
  11769. return v, errors.New("OldBalance requires an ID field in the mutation")
  11770. }
  11771. oldValue, err := m.oldValue(ctx)
  11772. if err != nil {
  11773. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  11774. }
  11775. return oldValue.Balance, nil
  11776. }
  11777. // AddBalance adds f to the "balance" field.
  11778. func (m *CreditBalanceMutation) AddBalance(f float32) {
  11779. if m.addbalance != nil {
  11780. *m.addbalance += f
  11781. } else {
  11782. m.addbalance = &f
  11783. }
  11784. }
  11785. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  11786. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  11787. v := m.addbalance
  11788. if v == nil {
  11789. return
  11790. }
  11791. return *v, true
  11792. }
  11793. // ResetBalance resets all changes to the "balance" field.
  11794. func (m *CreditBalanceMutation) ResetBalance() {
  11795. m.balance = nil
  11796. m.addbalance = nil
  11797. }
  11798. // SetStatus sets the "status" field.
  11799. func (m *CreditBalanceMutation) SetStatus(i int) {
  11800. m.status = &i
  11801. m.addstatus = nil
  11802. }
  11803. // Status returns the value of the "status" field in the mutation.
  11804. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  11805. v := m.status
  11806. if v == nil {
  11807. return
  11808. }
  11809. return *v, true
  11810. }
  11811. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  11812. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11814. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  11815. if !m.op.Is(OpUpdateOne) {
  11816. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11817. }
  11818. if m.id == nil || m.oldValue == nil {
  11819. return v, errors.New("OldStatus requires an ID field in the mutation")
  11820. }
  11821. oldValue, err := m.oldValue(ctx)
  11822. if err != nil {
  11823. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11824. }
  11825. return oldValue.Status, nil
  11826. }
  11827. // AddStatus adds i to the "status" field.
  11828. func (m *CreditBalanceMutation) AddStatus(i int) {
  11829. if m.addstatus != nil {
  11830. *m.addstatus += i
  11831. } else {
  11832. m.addstatus = &i
  11833. }
  11834. }
  11835. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11836. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  11837. v := m.addstatus
  11838. if v == nil {
  11839. return
  11840. }
  11841. return *v, true
  11842. }
  11843. // ClearStatus clears the value of the "status" field.
  11844. func (m *CreditBalanceMutation) ClearStatus() {
  11845. m.status = nil
  11846. m.addstatus = nil
  11847. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  11848. }
  11849. // StatusCleared returns if the "status" field was cleared in this mutation.
  11850. func (m *CreditBalanceMutation) StatusCleared() bool {
  11851. _, ok := m.clearedFields[creditbalance.FieldStatus]
  11852. return ok
  11853. }
  11854. // ResetStatus resets all changes to the "status" field.
  11855. func (m *CreditBalanceMutation) ResetStatus() {
  11856. m.status = nil
  11857. m.addstatus = nil
  11858. delete(m.clearedFields, creditbalance.FieldStatus)
  11859. }
  11860. // SetOrganizationID sets the "organization_id" field.
  11861. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  11862. m.organization_id = &u
  11863. m.addorganization_id = nil
  11864. }
  11865. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11866. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  11867. v := m.organization_id
  11868. if v == nil {
  11869. return
  11870. }
  11871. return *v, true
  11872. }
  11873. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  11874. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11876. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11877. if !m.op.Is(OpUpdateOne) {
  11878. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11879. }
  11880. if m.id == nil || m.oldValue == nil {
  11881. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11882. }
  11883. oldValue, err := m.oldValue(ctx)
  11884. if err != nil {
  11885. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11886. }
  11887. return oldValue.OrganizationID, nil
  11888. }
  11889. // AddOrganizationID adds u to the "organization_id" field.
  11890. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  11891. if m.addorganization_id != nil {
  11892. *m.addorganization_id += u
  11893. } else {
  11894. m.addorganization_id = &u
  11895. }
  11896. }
  11897. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11898. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  11899. v := m.addorganization_id
  11900. if v == nil {
  11901. return
  11902. }
  11903. return *v, true
  11904. }
  11905. // ClearOrganizationID clears the value of the "organization_id" field.
  11906. func (m *CreditBalanceMutation) ClearOrganizationID() {
  11907. m.organization_id = nil
  11908. m.addorganization_id = nil
  11909. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  11910. }
  11911. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11912. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  11913. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  11914. return ok
  11915. }
  11916. // ResetOrganizationID resets all changes to the "organization_id" field.
  11917. func (m *CreditBalanceMutation) ResetOrganizationID() {
  11918. m.organization_id = nil
  11919. m.addorganization_id = nil
  11920. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  11921. }
  11922. // Where appends a list predicates to the CreditBalanceMutation builder.
  11923. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  11924. m.predicates = append(m.predicates, ps...)
  11925. }
  11926. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  11927. // users can use type-assertion to append predicates that do not depend on any generated package.
  11928. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  11929. p := make([]predicate.CreditBalance, len(ps))
  11930. for i := range ps {
  11931. p[i] = ps[i]
  11932. }
  11933. m.Where(p...)
  11934. }
  11935. // Op returns the operation name.
  11936. func (m *CreditBalanceMutation) Op() Op {
  11937. return m.op
  11938. }
  11939. // SetOp allows setting the mutation operation.
  11940. func (m *CreditBalanceMutation) SetOp(op Op) {
  11941. m.op = op
  11942. }
  11943. // Type returns the node type of this mutation (CreditBalance).
  11944. func (m *CreditBalanceMutation) Type() string {
  11945. return m.typ
  11946. }
  11947. // Fields returns all fields that were changed during this mutation. Note that in
  11948. // order to get all numeric fields that were incremented/decremented, call
  11949. // AddedFields().
  11950. func (m *CreditBalanceMutation) Fields() []string {
  11951. fields := make([]string, 0, 7)
  11952. if m.created_at != nil {
  11953. fields = append(fields, creditbalance.FieldCreatedAt)
  11954. }
  11955. if m.updated_at != nil {
  11956. fields = append(fields, creditbalance.FieldUpdatedAt)
  11957. }
  11958. if m.deleted_at != nil {
  11959. fields = append(fields, creditbalance.FieldDeletedAt)
  11960. }
  11961. if m.user_id != nil {
  11962. fields = append(fields, creditbalance.FieldUserID)
  11963. }
  11964. if m.balance != nil {
  11965. fields = append(fields, creditbalance.FieldBalance)
  11966. }
  11967. if m.status != nil {
  11968. fields = append(fields, creditbalance.FieldStatus)
  11969. }
  11970. if m.organization_id != nil {
  11971. fields = append(fields, creditbalance.FieldOrganizationID)
  11972. }
  11973. return fields
  11974. }
  11975. // Field returns the value of a field with the given name. The second boolean
  11976. // return value indicates that this field was not set, or was not defined in the
  11977. // schema.
  11978. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  11979. switch name {
  11980. case creditbalance.FieldCreatedAt:
  11981. return m.CreatedAt()
  11982. case creditbalance.FieldUpdatedAt:
  11983. return m.UpdatedAt()
  11984. case creditbalance.FieldDeletedAt:
  11985. return m.DeletedAt()
  11986. case creditbalance.FieldUserID:
  11987. return m.UserID()
  11988. case creditbalance.FieldBalance:
  11989. return m.Balance()
  11990. case creditbalance.FieldStatus:
  11991. return m.Status()
  11992. case creditbalance.FieldOrganizationID:
  11993. return m.OrganizationID()
  11994. }
  11995. return nil, false
  11996. }
  11997. // OldField returns the old value of the field from the database. An error is
  11998. // returned if the mutation operation is not UpdateOne, or the query to the
  11999. // database failed.
  12000. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12001. switch name {
  12002. case creditbalance.FieldCreatedAt:
  12003. return m.OldCreatedAt(ctx)
  12004. case creditbalance.FieldUpdatedAt:
  12005. return m.OldUpdatedAt(ctx)
  12006. case creditbalance.FieldDeletedAt:
  12007. return m.OldDeletedAt(ctx)
  12008. case creditbalance.FieldUserID:
  12009. return m.OldUserID(ctx)
  12010. case creditbalance.FieldBalance:
  12011. return m.OldBalance(ctx)
  12012. case creditbalance.FieldStatus:
  12013. return m.OldStatus(ctx)
  12014. case creditbalance.FieldOrganizationID:
  12015. return m.OldOrganizationID(ctx)
  12016. }
  12017. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  12018. }
  12019. // SetField sets the value of a field with the given name. It returns an error if
  12020. // the field is not defined in the schema, or if the type mismatched the field
  12021. // type.
  12022. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  12023. switch name {
  12024. case creditbalance.FieldCreatedAt:
  12025. v, ok := value.(time.Time)
  12026. if !ok {
  12027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12028. }
  12029. m.SetCreatedAt(v)
  12030. return nil
  12031. case creditbalance.FieldUpdatedAt:
  12032. v, ok := value.(time.Time)
  12033. if !ok {
  12034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12035. }
  12036. m.SetUpdatedAt(v)
  12037. return nil
  12038. case creditbalance.FieldDeletedAt:
  12039. v, ok := value.(time.Time)
  12040. if !ok {
  12041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12042. }
  12043. m.SetDeletedAt(v)
  12044. return nil
  12045. case creditbalance.FieldUserID:
  12046. v, ok := value.(string)
  12047. if !ok {
  12048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12049. }
  12050. m.SetUserID(v)
  12051. return nil
  12052. case creditbalance.FieldBalance:
  12053. v, ok := value.(float32)
  12054. if !ok {
  12055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12056. }
  12057. m.SetBalance(v)
  12058. return nil
  12059. case creditbalance.FieldStatus:
  12060. v, ok := value.(int)
  12061. if !ok {
  12062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12063. }
  12064. m.SetStatus(v)
  12065. return nil
  12066. case creditbalance.FieldOrganizationID:
  12067. v, ok := value.(uint64)
  12068. if !ok {
  12069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12070. }
  12071. m.SetOrganizationID(v)
  12072. return nil
  12073. }
  12074. return fmt.Errorf("unknown CreditBalance field %s", name)
  12075. }
  12076. // AddedFields returns all numeric fields that were incremented/decremented during
  12077. // this mutation.
  12078. func (m *CreditBalanceMutation) AddedFields() []string {
  12079. var fields []string
  12080. if m.addbalance != nil {
  12081. fields = append(fields, creditbalance.FieldBalance)
  12082. }
  12083. if m.addstatus != nil {
  12084. fields = append(fields, creditbalance.FieldStatus)
  12085. }
  12086. if m.addorganization_id != nil {
  12087. fields = append(fields, creditbalance.FieldOrganizationID)
  12088. }
  12089. return fields
  12090. }
  12091. // AddedField returns the numeric value that was incremented/decremented on a field
  12092. // with the given name. The second boolean return value indicates that this field
  12093. // was not set, or was not defined in the schema.
  12094. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12095. switch name {
  12096. case creditbalance.FieldBalance:
  12097. return m.AddedBalance()
  12098. case creditbalance.FieldStatus:
  12099. return m.AddedStatus()
  12100. case creditbalance.FieldOrganizationID:
  12101. return m.AddedOrganizationID()
  12102. }
  12103. return nil, false
  12104. }
  12105. // AddField adds the value to the field with the given name. It returns an error if
  12106. // the field is not defined in the schema, or if the type mismatched the field
  12107. // type.
  12108. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12109. switch name {
  12110. case creditbalance.FieldBalance:
  12111. v, ok := value.(float32)
  12112. if !ok {
  12113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12114. }
  12115. m.AddBalance(v)
  12116. return nil
  12117. case creditbalance.FieldStatus:
  12118. v, ok := value.(int)
  12119. if !ok {
  12120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12121. }
  12122. m.AddStatus(v)
  12123. return nil
  12124. case creditbalance.FieldOrganizationID:
  12125. v, ok := value.(int64)
  12126. if !ok {
  12127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12128. }
  12129. m.AddOrganizationID(v)
  12130. return nil
  12131. }
  12132. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12133. }
  12134. // ClearedFields returns all nullable fields that were cleared during this
  12135. // mutation.
  12136. func (m *CreditBalanceMutation) ClearedFields() []string {
  12137. var fields []string
  12138. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12139. fields = append(fields, creditbalance.FieldDeletedAt)
  12140. }
  12141. if m.FieldCleared(creditbalance.FieldUserID) {
  12142. fields = append(fields, creditbalance.FieldUserID)
  12143. }
  12144. if m.FieldCleared(creditbalance.FieldStatus) {
  12145. fields = append(fields, creditbalance.FieldStatus)
  12146. }
  12147. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12148. fields = append(fields, creditbalance.FieldOrganizationID)
  12149. }
  12150. return fields
  12151. }
  12152. // FieldCleared returns a boolean indicating if a field with the given name was
  12153. // cleared in this mutation.
  12154. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12155. _, ok := m.clearedFields[name]
  12156. return ok
  12157. }
  12158. // ClearField clears the value of the field with the given name. It returns an
  12159. // error if the field is not defined in the schema.
  12160. func (m *CreditBalanceMutation) ClearField(name string) error {
  12161. switch name {
  12162. case creditbalance.FieldDeletedAt:
  12163. m.ClearDeletedAt()
  12164. return nil
  12165. case creditbalance.FieldUserID:
  12166. m.ClearUserID()
  12167. return nil
  12168. case creditbalance.FieldStatus:
  12169. m.ClearStatus()
  12170. return nil
  12171. case creditbalance.FieldOrganizationID:
  12172. m.ClearOrganizationID()
  12173. return nil
  12174. }
  12175. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12176. }
  12177. // ResetField resets all changes in the mutation for the field with the given name.
  12178. // It returns an error if the field is not defined in the schema.
  12179. func (m *CreditBalanceMutation) ResetField(name string) error {
  12180. switch name {
  12181. case creditbalance.FieldCreatedAt:
  12182. m.ResetCreatedAt()
  12183. return nil
  12184. case creditbalance.FieldUpdatedAt:
  12185. m.ResetUpdatedAt()
  12186. return nil
  12187. case creditbalance.FieldDeletedAt:
  12188. m.ResetDeletedAt()
  12189. return nil
  12190. case creditbalance.FieldUserID:
  12191. m.ResetUserID()
  12192. return nil
  12193. case creditbalance.FieldBalance:
  12194. m.ResetBalance()
  12195. return nil
  12196. case creditbalance.FieldStatus:
  12197. m.ResetStatus()
  12198. return nil
  12199. case creditbalance.FieldOrganizationID:
  12200. m.ResetOrganizationID()
  12201. return nil
  12202. }
  12203. return fmt.Errorf("unknown CreditBalance field %s", name)
  12204. }
  12205. // AddedEdges returns all edge names that were set/added in this mutation.
  12206. func (m *CreditBalanceMutation) AddedEdges() []string {
  12207. edges := make([]string, 0, 0)
  12208. return edges
  12209. }
  12210. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12211. // name in this mutation.
  12212. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12213. return nil
  12214. }
  12215. // RemovedEdges returns all edge names that were removed in this mutation.
  12216. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12217. edges := make([]string, 0, 0)
  12218. return edges
  12219. }
  12220. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12221. // the given name in this mutation.
  12222. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12223. return nil
  12224. }
  12225. // ClearedEdges returns all edge names that were cleared in this mutation.
  12226. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12227. edges := make([]string, 0, 0)
  12228. return edges
  12229. }
  12230. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12231. // was cleared in this mutation.
  12232. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12233. return false
  12234. }
  12235. // ClearEdge clears the value of the edge with the given name. It returns an error
  12236. // if that edge is not defined in the schema.
  12237. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12238. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12239. }
  12240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12241. // It returns an error if the edge is not defined in the schema.
  12242. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12243. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12244. }
  12245. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12246. type CreditUsageMutation struct {
  12247. config
  12248. op Op
  12249. typ string
  12250. id *uint64
  12251. created_at *time.Time
  12252. updated_at *time.Time
  12253. deleted_at *time.Time
  12254. user_id *string
  12255. number *float32
  12256. addnumber *float32
  12257. status *int
  12258. addstatus *int
  12259. ntype *int
  12260. addntype *int
  12261. table *string
  12262. organization_id *uint64
  12263. addorganization_id *int64
  12264. nid *uint64
  12265. addnid *int64
  12266. reason *string
  12267. operator *string
  12268. clearedFields map[string]struct{}
  12269. done bool
  12270. oldValue func(context.Context) (*CreditUsage, error)
  12271. predicates []predicate.CreditUsage
  12272. }
  12273. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12274. // creditusageOption allows management of the mutation configuration using functional options.
  12275. type creditusageOption func(*CreditUsageMutation)
  12276. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12277. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12278. m := &CreditUsageMutation{
  12279. config: c,
  12280. op: op,
  12281. typ: TypeCreditUsage,
  12282. clearedFields: make(map[string]struct{}),
  12283. }
  12284. for _, opt := range opts {
  12285. opt(m)
  12286. }
  12287. return m
  12288. }
  12289. // withCreditUsageID sets the ID field of the mutation.
  12290. func withCreditUsageID(id uint64) creditusageOption {
  12291. return func(m *CreditUsageMutation) {
  12292. var (
  12293. err error
  12294. once sync.Once
  12295. value *CreditUsage
  12296. )
  12297. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12298. once.Do(func() {
  12299. if m.done {
  12300. err = errors.New("querying old values post mutation is not allowed")
  12301. } else {
  12302. value, err = m.Client().CreditUsage.Get(ctx, id)
  12303. }
  12304. })
  12305. return value, err
  12306. }
  12307. m.id = &id
  12308. }
  12309. }
  12310. // withCreditUsage sets the old CreditUsage of the mutation.
  12311. func withCreditUsage(node *CreditUsage) creditusageOption {
  12312. return func(m *CreditUsageMutation) {
  12313. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12314. return node, nil
  12315. }
  12316. m.id = &node.ID
  12317. }
  12318. }
  12319. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12320. // executed in a transaction (ent.Tx), a transactional client is returned.
  12321. func (m CreditUsageMutation) Client() *Client {
  12322. client := &Client{config: m.config}
  12323. client.init()
  12324. return client
  12325. }
  12326. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12327. // it returns an error otherwise.
  12328. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12329. if _, ok := m.driver.(*txDriver); !ok {
  12330. return nil, errors.New("ent: mutation is not running in a transaction")
  12331. }
  12332. tx := &Tx{config: m.config}
  12333. tx.init()
  12334. return tx, nil
  12335. }
  12336. // SetID sets the value of the id field. Note that this
  12337. // operation is only accepted on creation of CreditUsage entities.
  12338. func (m *CreditUsageMutation) SetID(id uint64) {
  12339. m.id = &id
  12340. }
  12341. // ID returns the ID value in the mutation. Note that the ID is only available
  12342. // if it was provided to the builder or after it was returned from the database.
  12343. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12344. if m.id == nil {
  12345. return
  12346. }
  12347. return *m.id, true
  12348. }
  12349. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12350. // That means, if the mutation is applied within a transaction with an isolation level such
  12351. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12352. // or updated by the mutation.
  12353. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12354. switch {
  12355. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12356. id, exists := m.ID()
  12357. if exists {
  12358. return []uint64{id}, nil
  12359. }
  12360. fallthrough
  12361. case m.op.Is(OpUpdate | OpDelete):
  12362. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12363. default:
  12364. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12365. }
  12366. }
  12367. // SetCreatedAt sets the "created_at" field.
  12368. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12369. m.created_at = &t
  12370. }
  12371. // CreatedAt returns the value of the "created_at" field in the mutation.
  12372. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12373. v := m.created_at
  12374. if v == nil {
  12375. return
  12376. }
  12377. return *v, true
  12378. }
  12379. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12380. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12382. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12383. if !m.op.Is(OpUpdateOne) {
  12384. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12385. }
  12386. if m.id == nil || m.oldValue == nil {
  12387. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12388. }
  12389. oldValue, err := m.oldValue(ctx)
  12390. if err != nil {
  12391. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12392. }
  12393. return oldValue.CreatedAt, nil
  12394. }
  12395. // ResetCreatedAt resets all changes to the "created_at" field.
  12396. func (m *CreditUsageMutation) ResetCreatedAt() {
  12397. m.created_at = nil
  12398. }
  12399. // SetUpdatedAt sets the "updated_at" field.
  12400. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12401. m.updated_at = &t
  12402. }
  12403. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12404. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12405. v := m.updated_at
  12406. if v == nil {
  12407. return
  12408. }
  12409. return *v, true
  12410. }
  12411. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12412. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12414. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12415. if !m.op.Is(OpUpdateOne) {
  12416. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12417. }
  12418. if m.id == nil || m.oldValue == nil {
  12419. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12420. }
  12421. oldValue, err := m.oldValue(ctx)
  12422. if err != nil {
  12423. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12424. }
  12425. return oldValue.UpdatedAt, nil
  12426. }
  12427. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12428. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12429. m.updated_at = nil
  12430. }
  12431. // SetDeletedAt sets the "deleted_at" field.
  12432. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12433. m.deleted_at = &t
  12434. }
  12435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12436. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12437. v := m.deleted_at
  12438. if v == nil {
  12439. return
  12440. }
  12441. return *v, true
  12442. }
  12443. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12444. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12446. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12447. if !m.op.Is(OpUpdateOne) {
  12448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12449. }
  12450. if m.id == nil || m.oldValue == nil {
  12451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12452. }
  12453. oldValue, err := m.oldValue(ctx)
  12454. if err != nil {
  12455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12456. }
  12457. return oldValue.DeletedAt, nil
  12458. }
  12459. // ClearDeletedAt clears the value of the "deleted_at" field.
  12460. func (m *CreditUsageMutation) ClearDeletedAt() {
  12461. m.deleted_at = nil
  12462. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12463. }
  12464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12465. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12466. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12467. return ok
  12468. }
  12469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12470. func (m *CreditUsageMutation) ResetDeletedAt() {
  12471. m.deleted_at = nil
  12472. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12473. }
  12474. // SetUserID sets the "user_id" field.
  12475. func (m *CreditUsageMutation) SetUserID(s string) {
  12476. m.user_id = &s
  12477. }
  12478. // UserID returns the value of the "user_id" field in the mutation.
  12479. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12480. v := m.user_id
  12481. if v == nil {
  12482. return
  12483. }
  12484. return *v, true
  12485. }
  12486. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12487. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12489. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12490. if !m.op.Is(OpUpdateOne) {
  12491. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12492. }
  12493. if m.id == nil || m.oldValue == nil {
  12494. return v, errors.New("OldUserID requires an ID field in the mutation")
  12495. }
  12496. oldValue, err := m.oldValue(ctx)
  12497. if err != nil {
  12498. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12499. }
  12500. return oldValue.UserID, nil
  12501. }
  12502. // ClearUserID clears the value of the "user_id" field.
  12503. func (m *CreditUsageMutation) ClearUserID() {
  12504. m.user_id = nil
  12505. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12506. }
  12507. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12508. func (m *CreditUsageMutation) UserIDCleared() bool {
  12509. _, ok := m.clearedFields[creditusage.FieldUserID]
  12510. return ok
  12511. }
  12512. // ResetUserID resets all changes to the "user_id" field.
  12513. func (m *CreditUsageMutation) ResetUserID() {
  12514. m.user_id = nil
  12515. delete(m.clearedFields, creditusage.FieldUserID)
  12516. }
  12517. // SetNumber sets the "number" field.
  12518. func (m *CreditUsageMutation) SetNumber(f float32) {
  12519. m.number = &f
  12520. m.addnumber = nil
  12521. }
  12522. // Number returns the value of the "number" field in the mutation.
  12523. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12524. v := m.number
  12525. if v == nil {
  12526. return
  12527. }
  12528. return *v, true
  12529. }
  12530. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12531. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12533. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12534. if !m.op.Is(OpUpdateOne) {
  12535. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12536. }
  12537. if m.id == nil || m.oldValue == nil {
  12538. return v, errors.New("OldNumber requires an ID field in the mutation")
  12539. }
  12540. oldValue, err := m.oldValue(ctx)
  12541. if err != nil {
  12542. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12543. }
  12544. return oldValue.Number, nil
  12545. }
  12546. // AddNumber adds f to the "number" field.
  12547. func (m *CreditUsageMutation) AddNumber(f float32) {
  12548. if m.addnumber != nil {
  12549. *m.addnumber += f
  12550. } else {
  12551. m.addnumber = &f
  12552. }
  12553. }
  12554. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12555. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12556. v := m.addnumber
  12557. if v == nil {
  12558. return
  12559. }
  12560. return *v, true
  12561. }
  12562. // ResetNumber resets all changes to the "number" field.
  12563. func (m *CreditUsageMutation) ResetNumber() {
  12564. m.number = nil
  12565. m.addnumber = nil
  12566. }
  12567. // SetStatus sets the "status" field.
  12568. func (m *CreditUsageMutation) SetStatus(i int) {
  12569. m.status = &i
  12570. m.addstatus = nil
  12571. }
  12572. // Status returns the value of the "status" field in the mutation.
  12573. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12574. v := m.status
  12575. if v == nil {
  12576. return
  12577. }
  12578. return *v, true
  12579. }
  12580. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12581. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12583. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12584. if !m.op.Is(OpUpdateOne) {
  12585. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12586. }
  12587. if m.id == nil || m.oldValue == nil {
  12588. return v, errors.New("OldStatus requires an ID field in the mutation")
  12589. }
  12590. oldValue, err := m.oldValue(ctx)
  12591. if err != nil {
  12592. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12593. }
  12594. return oldValue.Status, nil
  12595. }
  12596. // AddStatus adds i to the "status" field.
  12597. func (m *CreditUsageMutation) AddStatus(i int) {
  12598. if m.addstatus != nil {
  12599. *m.addstatus += i
  12600. } else {
  12601. m.addstatus = &i
  12602. }
  12603. }
  12604. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12605. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12606. v := m.addstatus
  12607. if v == nil {
  12608. return
  12609. }
  12610. return *v, true
  12611. }
  12612. // ClearStatus clears the value of the "status" field.
  12613. func (m *CreditUsageMutation) ClearStatus() {
  12614. m.status = nil
  12615. m.addstatus = nil
  12616. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12617. }
  12618. // StatusCleared returns if the "status" field was cleared in this mutation.
  12619. func (m *CreditUsageMutation) StatusCleared() bool {
  12620. _, ok := m.clearedFields[creditusage.FieldStatus]
  12621. return ok
  12622. }
  12623. // ResetStatus resets all changes to the "status" field.
  12624. func (m *CreditUsageMutation) ResetStatus() {
  12625. m.status = nil
  12626. m.addstatus = nil
  12627. delete(m.clearedFields, creditusage.FieldStatus)
  12628. }
  12629. // SetNtype sets the "ntype" field.
  12630. func (m *CreditUsageMutation) SetNtype(i int) {
  12631. m.ntype = &i
  12632. m.addntype = nil
  12633. }
  12634. // Ntype returns the value of the "ntype" field in the mutation.
  12635. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12636. v := m.ntype
  12637. if v == nil {
  12638. return
  12639. }
  12640. return *v, true
  12641. }
  12642. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  12643. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12645. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  12646. if !m.op.Is(OpUpdateOne) {
  12647. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12648. }
  12649. if m.id == nil || m.oldValue == nil {
  12650. return v, errors.New("OldNtype requires an ID field in the mutation")
  12651. }
  12652. oldValue, err := m.oldValue(ctx)
  12653. if err != nil {
  12654. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  12655. }
  12656. return oldValue.Ntype, nil
  12657. }
  12658. // AddNtype adds i to the "ntype" field.
  12659. func (m *CreditUsageMutation) AddNtype(i int) {
  12660. if m.addntype != nil {
  12661. *m.addntype += i
  12662. } else {
  12663. m.addntype = &i
  12664. }
  12665. }
  12666. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12667. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12668. v := m.addntype
  12669. if v == nil {
  12670. return
  12671. }
  12672. return *v, true
  12673. }
  12674. // ResetNtype resets all changes to the "ntype" field.
  12675. func (m *CreditUsageMutation) ResetNtype() {
  12676. m.ntype = nil
  12677. m.addntype = nil
  12678. }
  12679. // SetTable sets the "table" field.
  12680. func (m *CreditUsageMutation) SetTable(s string) {
  12681. m.table = &s
  12682. }
  12683. // Table returns the value of the "table" field in the mutation.
  12684. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12685. v := m.table
  12686. if v == nil {
  12687. return
  12688. }
  12689. return *v, true
  12690. }
  12691. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12692. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12694. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12695. if !m.op.Is(OpUpdateOne) {
  12696. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12697. }
  12698. if m.id == nil || m.oldValue == nil {
  12699. return v, errors.New("OldTable requires an ID field in the mutation")
  12700. }
  12701. oldValue, err := m.oldValue(ctx)
  12702. if err != nil {
  12703. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12704. }
  12705. return oldValue.Table, nil
  12706. }
  12707. // ResetTable resets all changes to the "table" field.
  12708. func (m *CreditUsageMutation) ResetTable() {
  12709. m.table = nil
  12710. }
  12711. // SetOrganizationID sets the "organization_id" field.
  12712. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12713. m.organization_id = &u
  12714. m.addorganization_id = nil
  12715. }
  12716. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12717. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12718. v := m.organization_id
  12719. if v == nil {
  12720. return
  12721. }
  12722. return *v, true
  12723. }
  12724. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12725. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12727. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12728. if !m.op.Is(OpUpdateOne) {
  12729. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12730. }
  12731. if m.id == nil || m.oldValue == nil {
  12732. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12733. }
  12734. oldValue, err := m.oldValue(ctx)
  12735. if err != nil {
  12736. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12737. }
  12738. return oldValue.OrganizationID, nil
  12739. }
  12740. // AddOrganizationID adds u to the "organization_id" field.
  12741. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12742. if m.addorganization_id != nil {
  12743. *m.addorganization_id += u
  12744. } else {
  12745. m.addorganization_id = &u
  12746. }
  12747. }
  12748. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12749. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12750. v := m.addorganization_id
  12751. if v == nil {
  12752. return
  12753. }
  12754. return *v, true
  12755. }
  12756. // ClearOrganizationID clears the value of the "organization_id" field.
  12757. func (m *CreditUsageMutation) ClearOrganizationID() {
  12758. m.organization_id = nil
  12759. m.addorganization_id = nil
  12760. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12761. }
  12762. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12763. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  12764. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  12765. return ok
  12766. }
  12767. // ResetOrganizationID resets all changes to the "organization_id" field.
  12768. func (m *CreditUsageMutation) ResetOrganizationID() {
  12769. m.organization_id = nil
  12770. m.addorganization_id = nil
  12771. delete(m.clearedFields, creditusage.FieldOrganizationID)
  12772. }
  12773. // SetNid sets the "nid" field.
  12774. func (m *CreditUsageMutation) SetNid(u uint64) {
  12775. m.nid = &u
  12776. m.addnid = nil
  12777. }
  12778. // Nid returns the value of the "nid" field in the mutation.
  12779. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  12780. v := m.nid
  12781. if v == nil {
  12782. return
  12783. }
  12784. return *v, true
  12785. }
  12786. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  12787. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12789. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  12790. if !m.op.Is(OpUpdateOne) {
  12791. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  12792. }
  12793. if m.id == nil || m.oldValue == nil {
  12794. return v, errors.New("OldNid requires an ID field in the mutation")
  12795. }
  12796. oldValue, err := m.oldValue(ctx)
  12797. if err != nil {
  12798. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  12799. }
  12800. return oldValue.Nid, nil
  12801. }
  12802. // AddNid adds u to the "nid" field.
  12803. func (m *CreditUsageMutation) AddNid(u int64) {
  12804. if m.addnid != nil {
  12805. *m.addnid += u
  12806. } else {
  12807. m.addnid = &u
  12808. }
  12809. }
  12810. // AddedNid returns the value that was added to the "nid" field in this mutation.
  12811. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  12812. v := m.addnid
  12813. if v == nil {
  12814. return
  12815. }
  12816. return *v, true
  12817. }
  12818. // ResetNid resets all changes to the "nid" field.
  12819. func (m *CreditUsageMutation) ResetNid() {
  12820. m.nid = nil
  12821. m.addnid = nil
  12822. }
  12823. // SetReason sets the "reason" field.
  12824. func (m *CreditUsageMutation) SetReason(s string) {
  12825. m.reason = &s
  12826. }
  12827. // Reason returns the value of the "reason" field in the mutation.
  12828. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  12829. v := m.reason
  12830. if v == nil {
  12831. return
  12832. }
  12833. return *v, true
  12834. }
  12835. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  12836. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12838. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  12839. if !m.op.Is(OpUpdateOne) {
  12840. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  12841. }
  12842. if m.id == nil || m.oldValue == nil {
  12843. return v, errors.New("OldReason requires an ID field in the mutation")
  12844. }
  12845. oldValue, err := m.oldValue(ctx)
  12846. if err != nil {
  12847. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  12848. }
  12849. return oldValue.Reason, nil
  12850. }
  12851. // ResetReason resets all changes to the "reason" field.
  12852. func (m *CreditUsageMutation) ResetReason() {
  12853. m.reason = nil
  12854. }
  12855. // SetOperator sets the "operator" field.
  12856. func (m *CreditUsageMutation) SetOperator(s string) {
  12857. m.operator = &s
  12858. }
  12859. // Operator returns the value of the "operator" field in the mutation.
  12860. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  12861. v := m.operator
  12862. if v == nil {
  12863. return
  12864. }
  12865. return *v, true
  12866. }
  12867. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  12868. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12870. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  12871. if !m.op.Is(OpUpdateOne) {
  12872. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  12873. }
  12874. if m.id == nil || m.oldValue == nil {
  12875. return v, errors.New("OldOperator requires an ID field in the mutation")
  12876. }
  12877. oldValue, err := m.oldValue(ctx)
  12878. if err != nil {
  12879. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  12880. }
  12881. return oldValue.Operator, nil
  12882. }
  12883. // ResetOperator resets all changes to the "operator" field.
  12884. func (m *CreditUsageMutation) ResetOperator() {
  12885. m.operator = nil
  12886. }
  12887. // Where appends a list predicates to the CreditUsageMutation builder.
  12888. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  12889. m.predicates = append(m.predicates, ps...)
  12890. }
  12891. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  12892. // users can use type-assertion to append predicates that do not depend on any generated package.
  12893. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  12894. p := make([]predicate.CreditUsage, len(ps))
  12895. for i := range ps {
  12896. p[i] = ps[i]
  12897. }
  12898. m.Where(p...)
  12899. }
  12900. // Op returns the operation name.
  12901. func (m *CreditUsageMutation) Op() Op {
  12902. return m.op
  12903. }
  12904. // SetOp allows setting the mutation operation.
  12905. func (m *CreditUsageMutation) SetOp(op Op) {
  12906. m.op = op
  12907. }
  12908. // Type returns the node type of this mutation (CreditUsage).
  12909. func (m *CreditUsageMutation) Type() string {
  12910. return m.typ
  12911. }
  12912. // Fields returns all fields that were changed during this mutation. Note that in
  12913. // order to get all numeric fields that were incremented/decremented, call
  12914. // AddedFields().
  12915. func (m *CreditUsageMutation) Fields() []string {
  12916. fields := make([]string, 0, 12)
  12917. if m.created_at != nil {
  12918. fields = append(fields, creditusage.FieldCreatedAt)
  12919. }
  12920. if m.updated_at != nil {
  12921. fields = append(fields, creditusage.FieldUpdatedAt)
  12922. }
  12923. if m.deleted_at != nil {
  12924. fields = append(fields, creditusage.FieldDeletedAt)
  12925. }
  12926. if m.user_id != nil {
  12927. fields = append(fields, creditusage.FieldUserID)
  12928. }
  12929. if m.number != nil {
  12930. fields = append(fields, creditusage.FieldNumber)
  12931. }
  12932. if m.status != nil {
  12933. fields = append(fields, creditusage.FieldStatus)
  12934. }
  12935. if m.ntype != nil {
  12936. fields = append(fields, creditusage.FieldNtype)
  12937. }
  12938. if m.table != nil {
  12939. fields = append(fields, creditusage.FieldTable)
  12940. }
  12941. if m.organization_id != nil {
  12942. fields = append(fields, creditusage.FieldOrganizationID)
  12943. }
  12944. if m.nid != nil {
  12945. fields = append(fields, creditusage.FieldNid)
  12946. }
  12947. if m.reason != nil {
  12948. fields = append(fields, creditusage.FieldReason)
  12949. }
  12950. if m.operator != nil {
  12951. fields = append(fields, creditusage.FieldOperator)
  12952. }
  12953. return fields
  12954. }
  12955. // Field returns the value of a field with the given name. The second boolean
  12956. // return value indicates that this field was not set, or was not defined in the
  12957. // schema.
  12958. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  12959. switch name {
  12960. case creditusage.FieldCreatedAt:
  12961. return m.CreatedAt()
  12962. case creditusage.FieldUpdatedAt:
  12963. return m.UpdatedAt()
  12964. case creditusage.FieldDeletedAt:
  12965. return m.DeletedAt()
  12966. case creditusage.FieldUserID:
  12967. return m.UserID()
  12968. case creditusage.FieldNumber:
  12969. return m.Number()
  12970. case creditusage.FieldStatus:
  12971. return m.Status()
  12972. case creditusage.FieldNtype:
  12973. return m.Ntype()
  12974. case creditusage.FieldTable:
  12975. return m.Table()
  12976. case creditusage.FieldOrganizationID:
  12977. return m.OrganizationID()
  12978. case creditusage.FieldNid:
  12979. return m.Nid()
  12980. case creditusage.FieldReason:
  12981. return m.Reason()
  12982. case creditusage.FieldOperator:
  12983. return m.Operator()
  12984. }
  12985. return nil, false
  12986. }
  12987. // OldField returns the old value of the field from the database. An error is
  12988. // returned if the mutation operation is not UpdateOne, or the query to the
  12989. // database failed.
  12990. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12991. switch name {
  12992. case creditusage.FieldCreatedAt:
  12993. return m.OldCreatedAt(ctx)
  12994. case creditusage.FieldUpdatedAt:
  12995. return m.OldUpdatedAt(ctx)
  12996. case creditusage.FieldDeletedAt:
  12997. return m.OldDeletedAt(ctx)
  12998. case creditusage.FieldUserID:
  12999. return m.OldUserID(ctx)
  13000. case creditusage.FieldNumber:
  13001. return m.OldNumber(ctx)
  13002. case creditusage.FieldStatus:
  13003. return m.OldStatus(ctx)
  13004. case creditusage.FieldNtype:
  13005. return m.OldNtype(ctx)
  13006. case creditusage.FieldTable:
  13007. return m.OldTable(ctx)
  13008. case creditusage.FieldOrganizationID:
  13009. return m.OldOrganizationID(ctx)
  13010. case creditusage.FieldNid:
  13011. return m.OldNid(ctx)
  13012. case creditusage.FieldReason:
  13013. return m.OldReason(ctx)
  13014. case creditusage.FieldOperator:
  13015. return m.OldOperator(ctx)
  13016. }
  13017. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  13018. }
  13019. // SetField sets the value of a field with the given name. It returns an error if
  13020. // the field is not defined in the schema, or if the type mismatched the field
  13021. // type.
  13022. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  13023. switch name {
  13024. case creditusage.FieldCreatedAt:
  13025. v, ok := value.(time.Time)
  13026. if !ok {
  13027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13028. }
  13029. m.SetCreatedAt(v)
  13030. return nil
  13031. case creditusage.FieldUpdatedAt:
  13032. v, ok := value.(time.Time)
  13033. if !ok {
  13034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13035. }
  13036. m.SetUpdatedAt(v)
  13037. return nil
  13038. case creditusage.FieldDeletedAt:
  13039. v, ok := value.(time.Time)
  13040. if !ok {
  13041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13042. }
  13043. m.SetDeletedAt(v)
  13044. return nil
  13045. case creditusage.FieldUserID:
  13046. v, ok := value.(string)
  13047. if !ok {
  13048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13049. }
  13050. m.SetUserID(v)
  13051. return nil
  13052. case creditusage.FieldNumber:
  13053. v, ok := value.(float32)
  13054. if !ok {
  13055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13056. }
  13057. m.SetNumber(v)
  13058. return nil
  13059. case creditusage.FieldStatus:
  13060. v, ok := value.(int)
  13061. if !ok {
  13062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13063. }
  13064. m.SetStatus(v)
  13065. return nil
  13066. case creditusage.FieldNtype:
  13067. v, ok := value.(int)
  13068. if !ok {
  13069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13070. }
  13071. m.SetNtype(v)
  13072. return nil
  13073. case creditusage.FieldTable:
  13074. v, ok := value.(string)
  13075. if !ok {
  13076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13077. }
  13078. m.SetTable(v)
  13079. return nil
  13080. case creditusage.FieldOrganizationID:
  13081. v, ok := value.(uint64)
  13082. if !ok {
  13083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13084. }
  13085. m.SetOrganizationID(v)
  13086. return nil
  13087. case creditusage.FieldNid:
  13088. v, ok := value.(uint64)
  13089. if !ok {
  13090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13091. }
  13092. m.SetNid(v)
  13093. return nil
  13094. case creditusage.FieldReason:
  13095. v, ok := value.(string)
  13096. if !ok {
  13097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13098. }
  13099. m.SetReason(v)
  13100. return nil
  13101. case creditusage.FieldOperator:
  13102. v, ok := value.(string)
  13103. if !ok {
  13104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13105. }
  13106. m.SetOperator(v)
  13107. return nil
  13108. }
  13109. return fmt.Errorf("unknown CreditUsage field %s", name)
  13110. }
  13111. // AddedFields returns all numeric fields that were incremented/decremented during
  13112. // this mutation.
  13113. func (m *CreditUsageMutation) AddedFields() []string {
  13114. var fields []string
  13115. if m.addnumber != nil {
  13116. fields = append(fields, creditusage.FieldNumber)
  13117. }
  13118. if m.addstatus != nil {
  13119. fields = append(fields, creditusage.FieldStatus)
  13120. }
  13121. if m.addntype != nil {
  13122. fields = append(fields, creditusage.FieldNtype)
  13123. }
  13124. if m.addorganization_id != nil {
  13125. fields = append(fields, creditusage.FieldOrganizationID)
  13126. }
  13127. if m.addnid != nil {
  13128. fields = append(fields, creditusage.FieldNid)
  13129. }
  13130. return fields
  13131. }
  13132. // AddedField returns the numeric value that was incremented/decremented on a field
  13133. // with the given name. The second boolean return value indicates that this field
  13134. // was not set, or was not defined in the schema.
  13135. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13136. switch name {
  13137. case creditusage.FieldNumber:
  13138. return m.AddedNumber()
  13139. case creditusage.FieldStatus:
  13140. return m.AddedStatus()
  13141. case creditusage.FieldNtype:
  13142. return m.AddedNtype()
  13143. case creditusage.FieldOrganizationID:
  13144. return m.AddedOrganizationID()
  13145. case creditusage.FieldNid:
  13146. return m.AddedNid()
  13147. }
  13148. return nil, false
  13149. }
  13150. // AddField adds the value to the field with the given name. It returns an error if
  13151. // the field is not defined in the schema, or if the type mismatched the field
  13152. // type.
  13153. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13154. switch name {
  13155. case creditusage.FieldNumber:
  13156. v, ok := value.(float32)
  13157. if !ok {
  13158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13159. }
  13160. m.AddNumber(v)
  13161. return nil
  13162. case creditusage.FieldStatus:
  13163. v, ok := value.(int)
  13164. if !ok {
  13165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13166. }
  13167. m.AddStatus(v)
  13168. return nil
  13169. case creditusage.FieldNtype:
  13170. v, ok := value.(int)
  13171. if !ok {
  13172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13173. }
  13174. m.AddNtype(v)
  13175. return nil
  13176. case creditusage.FieldOrganizationID:
  13177. v, ok := value.(int64)
  13178. if !ok {
  13179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13180. }
  13181. m.AddOrganizationID(v)
  13182. return nil
  13183. case creditusage.FieldNid:
  13184. v, ok := value.(int64)
  13185. if !ok {
  13186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13187. }
  13188. m.AddNid(v)
  13189. return nil
  13190. }
  13191. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13192. }
  13193. // ClearedFields returns all nullable fields that were cleared during this
  13194. // mutation.
  13195. func (m *CreditUsageMutation) ClearedFields() []string {
  13196. var fields []string
  13197. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13198. fields = append(fields, creditusage.FieldDeletedAt)
  13199. }
  13200. if m.FieldCleared(creditusage.FieldUserID) {
  13201. fields = append(fields, creditusage.FieldUserID)
  13202. }
  13203. if m.FieldCleared(creditusage.FieldStatus) {
  13204. fields = append(fields, creditusage.FieldStatus)
  13205. }
  13206. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13207. fields = append(fields, creditusage.FieldOrganizationID)
  13208. }
  13209. return fields
  13210. }
  13211. // FieldCleared returns a boolean indicating if a field with the given name was
  13212. // cleared in this mutation.
  13213. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13214. _, ok := m.clearedFields[name]
  13215. return ok
  13216. }
  13217. // ClearField clears the value of the field with the given name. It returns an
  13218. // error if the field is not defined in the schema.
  13219. func (m *CreditUsageMutation) ClearField(name string) error {
  13220. switch name {
  13221. case creditusage.FieldDeletedAt:
  13222. m.ClearDeletedAt()
  13223. return nil
  13224. case creditusage.FieldUserID:
  13225. m.ClearUserID()
  13226. return nil
  13227. case creditusage.FieldStatus:
  13228. m.ClearStatus()
  13229. return nil
  13230. case creditusage.FieldOrganizationID:
  13231. m.ClearOrganizationID()
  13232. return nil
  13233. }
  13234. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13235. }
  13236. // ResetField resets all changes in the mutation for the field with the given name.
  13237. // It returns an error if the field is not defined in the schema.
  13238. func (m *CreditUsageMutation) ResetField(name string) error {
  13239. switch name {
  13240. case creditusage.FieldCreatedAt:
  13241. m.ResetCreatedAt()
  13242. return nil
  13243. case creditusage.FieldUpdatedAt:
  13244. m.ResetUpdatedAt()
  13245. return nil
  13246. case creditusage.FieldDeletedAt:
  13247. m.ResetDeletedAt()
  13248. return nil
  13249. case creditusage.FieldUserID:
  13250. m.ResetUserID()
  13251. return nil
  13252. case creditusage.FieldNumber:
  13253. m.ResetNumber()
  13254. return nil
  13255. case creditusage.FieldStatus:
  13256. m.ResetStatus()
  13257. return nil
  13258. case creditusage.FieldNtype:
  13259. m.ResetNtype()
  13260. return nil
  13261. case creditusage.FieldTable:
  13262. m.ResetTable()
  13263. return nil
  13264. case creditusage.FieldOrganizationID:
  13265. m.ResetOrganizationID()
  13266. return nil
  13267. case creditusage.FieldNid:
  13268. m.ResetNid()
  13269. return nil
  13270. case creditusage.FieldReason:
  13271. m.ResetReason()
  13272. return nil
  13273. case creditusage.FieldOperator:
  13274. m.ResetOperator()
  13275. return nil
  13276. }
  13277. return fmt.Errorf("unknown CreditUsage field %s", name)
  13278. }
  13279. // AddedEdges returns all edge names that were set/added in this mutation.
  13280. func (m *CreditUsageMutation) AddedEdges() []string {
  13281. edges := make([]string, 0, 0)
  13282. return edges
  13283. }
  13284. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13285. // name in this mutation.
  13286. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13287. return nil
  13288. }
  13289. // RemovedEdges returns all edge names that were removed in this mutation.
  13290. func (m *CreditUsageMutation) RemovedEdges() []string {
  13291. edges := make([]string, 0, 0)
  13292. return edges
  13293. }
  13294. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13295. // the given name in this mutation.
  13296. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13297. return nil
  13298. }
  13299. // ClearedEdges returns all edge names that were cleared in this mutation.
  13300. func (m *CreditUsageMutation) ClearedEdges() []string {
  13301. edges := make([]string, 0, 0)
  13302. return edges
  13303. }
  13304. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13305. // was cleared in this mutation.
  13306. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13307. return false
  13308. }
  13309. // ClearEdge clears the value of the edge with the given name. It returns an error
  13310. // if that edge is not defined in the schema.
  13311. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13312. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13313. }
  13314. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13315. // It returns an error if the edge is not defined in the schema.
  13316. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13317. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13318. }
  13319. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13320. type EmployeeMutation struct {
  13321. config
  13322. op Op
  13323. typ string
  13324. id *uint64
  13325. created_at *time.Time
  13326. updated_at *time.Time
  13327. deleted_at *time.Time
  13328. title *string
  13329. avatar *string
  13330. tags *string
  13331. hire_count *int
  13332. addhire_count *int
  13333. service_count *int
  13334. addservice_count *int
  13335. achievement_count *int
  13336. addachievement_count *int
  13337. intro *string
  13338. estimate *string
  13339. skill *string
  13340. ability_type *string
  13341. scene *string
  13342. switch_in *string
  13343. video_url *string
  13344. organization_id *uint64
  13345. addorganization_id *int64
  13346. category_id *uint64
  13347. addcategory_id *int64
  13348. api_base *string
  13349. api_key *string
  13350. ai_info *string
  13351. is_vip *int
  13352. addis_vip *int
  13353. chat_url *string
  13354. clearedFields map[string]struct{}
  13355. em_work_experiences map[uint64]struct{}
  13356. removedem_work_experiences map[uint64]struct{}
  13357. clearedem_work_experiences bool
  13358. em_tutorial map[uint64]struct{}
  13359. removedem_tutorial map[uint64]struct{}
  13360. clearedem_tutorial bool
  13361. done bool
  13362. oldValue func(context.Context) (*Employee, error)
  13363. predicates []predicate.Employee
  13364. }
  13365. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13366. // employeeOption allows management of the mutation configuration using functional options.
  13367. type employeeOption func(*EmployeeMutation)
  13368. // newEmployeeMutation creates new mutation for the Employee entity.
  13369. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13370. m := &EmployeeMutation{
  13371. config: c,
  13372. op: op,
  13373. typ: TypeEmployee,
  13374. clearedFields: make(map[string]struct{}),
  13375. }
  13376. for _, opt := range opts {
  13377. opt(m)
  13378. }
  13379. return m
  13380. }
  13381. // withEmployeeID sets the ID field of the mutation.
  13382. func withEmployeeID(id uint64) employeeOption {
  13383. return func(m *EmployeeMutation) {
  13384. var (
  13385. err error
  13386. once sync.Once
  13387. value *Employee
  13388. )
  13389. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13390. once.Do(func() {
  13391. if m.done {
  13392. err = errors.New("querying old values post mutation is not allowed")
  13393. } else {
  13394. value, err = m.Client().Employee.Get(ctx, id)
  13395. }
  13396. })
  13397. return value, err
  13398. }
  13399. m.id = &id
  13400. }
  13401. }
  13402. // withEmployee sets the old Employee of the mutation.
  13403. func withEmployee(node *Employee) employeeOption {
  13404. return func(m *EmployeeMutation) {
  13405. m.oldValue = func(context.Context) (*Employee, error) {
  13406. return node, nil
  13407. }
  13408. m.id = &node.ID
  13409. }
  13410. }
  13411. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13412. // executed in a transaction (ent.Tx), a transactional client is returned.
  13413. func (m EmployeeMutation) Client() *Client {
  13414. client := &Client{config: m.config}
  13415. client.init()
  13416. return client
  13417. }
  13418. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13419. // it returns an error otherwise.
  13420. func (m EmployeeMutation) Tx() (*Tx, error) {
  13421. if _, ok := m.driver.(*txDriver); !ok {
  13422. return nil, errors.New("ent: mutation is not running in a transaction")
  13423. }
  13424. tx := &Tx{config: m.config}
  13425. tx.init()
  13426. return tx, nil
  13427. }
  13428. // SetID sets the value of the id field. Note that this
  13429. // operation is only accepted on creation of Employee entities.
  13430. func (m *EmployeeMutation) SetID(id uint64) {
  13431. m.id = &id
  13432. }
  13433. // ID returns the ID value in the mutation. Note that the ID is only available
  13434. // if it was provided to the builder or after it was returned from the database.
  13435. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13436. if m.id == nil {
  13437. return
  13438. }
  13439. return *m.id, true
  13440. }
  13441. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13442. // That means, if the mutation is applied within a transaction with an isolation level such
  13443. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13444. // or updated by the mutation.
  13445. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13446. switch {
  13447. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13448. id, exists := m.ID()
  13449. if exists {
  13450. return []uint64{id}, nil
  13451. }
  13452. fallthrough
  13453. case m.op.Is(OpUpdate | OpDelete):
  13454. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13455. default:
  13456. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13457. }
  13458. }
  13459. // SetCreatedAt sets the "created_at" field.
  13460. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13461. m.created_at = &t
  13462. }
  13463. // CreatedAt returns the value of the "created_at" field in the mutation.
  13464. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13465. v := m.created_at
  13466. if v == nil {
  13467. return
  13468. }
  13469. return *v, true
  13470. }
  13471. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13472. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13474. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13475. if !m.op.Is(OpUpdateOne) {
  13476. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13477. }
  13478. if m.id == nil || m.oldValue == nil {
  13479. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13480. }
  13481. oldValue, err := m.oldValue(ctx)
  13482. if err != nil {
  13483. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13484. }
  13485. return oldValue.CreatedAt, nil
  13486. }
  13487. // ResetCreatedAt resets all changes to the "created_at" field.
  13488. func (m *EmployeeMutation) ResetCreatedAt() {
  13489. m.created_at = nil
  13490. }
  13491. // SetUpdatedAt sets the "updated_at" field.
  13492. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13493. m.updated_at = &t
  13494. }
  13495. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13496. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13497. v := m.updated_at
  13498. if v == nil {
  13499. return
  13500. }
  13501. return *v, true
  13502. }
  13503. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13504. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13506. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13507. if !m.op.Is(OpUpdateOne) {
  13508. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13509. }
  13510. if m.id == nil || m.oldValue == nil {
  13511. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13512. }
  13513. oldValue, err := m.oldValue(ctx)
  13514. if err != nil {
  13515. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13516. }
  13517. return oldValue.UpdatedAt, nil
  13518. }
  13519. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13520. func (m *EmployeeMutation) ResetUpdatedAt() {
  13521. m.updated_at = nil
  13522. }
  13523. // SetDeletedAt sets the "deleted_at" field.
  13524. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13525. m.deleted_at = &t
  13526. }
  13527. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13528. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13529. v := m.deleted_at
  13530. if v == nil {
  13531. return
  13532. }
  13533. return *v, true
  13534. }
  13535. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13536. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13538. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13539. if !m.op.Is(OpUpdateOne) {
  13540. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13541. }
  13542. if m.id == nil || m.oldValue == nil {
  13543. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13544. }
  13545. oldValue, err := m.oldValue(ctx)
  13546. if err != nil {
  13547. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13548. }
  13549. return oldValue.DeletedAt, nil
  13550. }
  13551. // ClearDeletedAt clears the value of the "deleted_at" field.
  13552. func (m *EmployeeMutation) ClearDeletedAt() {
  13553. m.deleted_at = nil
  13554. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13555. }
  13556. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13557. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13558. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13559. return ok
  13560. }
  13561. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13562. func (m *EmployeeMutation) ResetDeletedAt() {
  13563. m.deleted_at = nil
  13564. delete(m.clearedFields, employee.FieldDeletedAt)
  13565. }
  13566. // SetTitle sets the "title" field.
  13567. func (m *EmployeeMutation) SetTitle(s string) {
  13568. m.title = &s
  13569. }
  13570. // Title returns the value of the "title" field in the mutation.
  13571. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13572. v := m.title
  13573. if v == nil {
  13574. return
  13575. }
  13576. return *v, true
  13577. }
  13578. // OldTitle returns the old "title" field's value of the Employee entity.
  13579. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13581. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13582. if !m.op.Is(OpUpdateOne) {
  13583. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13584. }
  13585. if m.id == nil || m.oldValue == nil {
  13586. return v, errors.New("OldTitle requires an ID field in the mutation")
  13587. }
  13588. oldValue, err := m.oldValue(ctx)
  13589. if err != nil {
  13590. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13591. }
  13592. return oldValue.Title, nil
  13593. }
  13594. // ResetTitle resets all changes to the "title" field.
  13595. func (m *EmployeeMutation) ResetTitle() {
  13596. m.title = nil
  13597. }
  13598. // SetAvatar sets the "avatar" field.
  13599. func (m *EmployeeMutation) SetAvatar(s string) {
  13600. m.avatar = &s
  13601. }
  13602. // Avatar returns the value of the "avatar" field in the mutation.
  13603. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13604. v := m.avatar
  13605. if v == nil {
  13606. return
  13607. }
  13608. return *v, true
  13609. }
  13610. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13611. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13613. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13614. if !m.op.Is(OpUpdateOne) {
  13615. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13616. }
  13617. if m.id == nil || m.oldValue == nil {
  13618. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13619. }
  13620. oldValue, err := m.oldValue(ctx)
  13621. if err != nil {
  13622. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13623. }
  13624. return oldValue.Avatar, nil
  13625. }
  13626. // ResetAvatar resets all changes to the "avatar" field.
  13627. func (m *EmployeeMutation) ResetAvatar() {
  13628. m.avatar = nil
  13629. }
  13630. // SetTags sets the "tags" field.
  13631. func (m *EmployeeMutation) SetTags(s string) {
  13632. m.tags = &s
  13633. }
  13634. // Tags returns the value of the "tags" field in the mutation.
  13635. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  13636. v := m.tags
  13637. if v == nil {
  13638. return
  13639. }
  13640. return *v, true
  13641. }
  13642. // OldTags returns the old "tags" field's value of the Employee entity.
  13643. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13645. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  13646. if !m.op.Is(OpUpdateOne) {
  13647. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  13648. }
  13649. if m.id == nil || m.oldValue == nil {
  13650. return v, errors.New("OldTags requires an ID field in the mutation")
  13651. }
  13652. oldValue, err := m.oldValue(ctx)
  13653. if err != nil {
  13654. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  13655. }
  13656. return oldValue.Tags, nil
  13657. }
  13658. // ResetTags resets all changes to the "tags" field.
  13659. func (m *EmployeeMutation) ResetTags() {
  13660. m.tags = nil
  13661. }
  13662. // SetHireCount sets the "hire_count" field.
  13663. func (m *EmployeeMutation) SetHireCount(i int) {
  13664. m.hire_count = &i
  13665. m.addhire_count = nil
  13666. }
  13667. // HireCount returns the value of the "hire_count" field in the mutation.
  13668. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  13669. v := m.hire_count
  13670. if v == nil {
  13671. return
  13672. }
  13673. return *v, true
  13674. }
  13675. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  13676. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13678. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  13679. if !m.op.Is(OpUpdateOne) {
  13680. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  13681. }
  13682. if m.id == nil || m.oldValue == nil {
  13683. return v, errors.New("OldHireCount requires an ID field in the mutation")
  13684. }
  13685. oldValue, err := m.oldValue(ctx)
  13686. if err != nil {
  13687. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  13688. }
  13689. return oldValue.HireCount, nil
  13690. }
  13691. // AddHireCount adds i to the "hire_count" field.
  13692. func (m *EmployeeMutation) AddHireCount(i int) {
  13693. if m.addhire_count != nil {
  13694. *m.addhire_count += i
  13695. } else {
  13696. m.addhire_count = &i
  13697. }
  13698. }
  13699. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  13700. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  13701. v := m.addhire_count
  13702. if v == nil {
  13703. return
  13704. }
  13705. return *v, true
  13706. }
  13707. // ResetHireCount resets all changes to the "hire_count" field.
  13708. func (m *EmployeeMutation) ResetHireCount() {
  13709. m.hire_count = nil
  13710. m.addhire_count = nil
  13711. }
  13712. // SetServiceCount sets the "service_count" field.
  13713. func (m *EmployeeMutation) SetServiceCount(i int) {
  13714. m.service_count = &i
  13715. m.addservice_count = nil
  13716. }
  13717. // ServiceCount returns the value of the "service_count" field in the mutation.
  13718. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  13719. v := m.service_count
  13720. if v == nil {
  13721. return
  13722. }
  13723. return *v, true
  13724. }
  13725. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  13726. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13728. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  13729. if !m.op.Is(OpUpdateOne) {
  13730. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  13731. }
  13732. if m.id == nil || m.oldValue == nil {
  13733. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  13734. }
  13735. oldValue, err := m.oldValue(ctx)
  13736. if err != nil {
  13737. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  13738. }
  13739. return oldValue.ServiceCount, nil
  13740. }
  13741. // AddServiceCount adds i to the "service_count" field.
  13742. func (m *EmployeeMutation) AddServiceCount(i int) {
  13743. if m.addservice_count != nil {
  13744. *m.addservice_count += i
  13745. } else {
  13746. m.addservice_count = &i
  13747. }
  13748. }
  13749. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  13750. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  13751. v := m.addservice_count
  13752. if v == nil {
  13753. return
  13754. }
  13755. return *v, true
  13756. }
  13757. // ResetServiceCount resets all changes to the "service_count" field.
  13758. func (m *EmployeeMutation) ResetServiceCount() {
  13759. m.service_count = nil
  13760. m.addservice_count = nil
  13761. }
  13762. // SetAchievementCount sets the "achievement_count" field.
  13763. func (m *EmployeeMutation) SetAchievementCount(i int) {
  13764. m.achievement_count = &i
  13765. m.addachievement_count = nil
  13766. }
  13767. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  13768. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  13769. v := m.achievement_count
  13770. if v == nil {
  13771. return
  13772. }
  13773. return *v, true
  13774. }
  13775. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  13776. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13778. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  13779. if !m.op.Is(OpUpdateOne) {
  13780. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  13781. }
  13782. if m.id == nil || m.oldValue == nil {
  13783. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  13784. }
  13785. oldValue, err := m.oldValue(ctx)
  13786. if err != nil {
  13787. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  13788. }
  13789. return oldValue.AchievementCount, nil
  13790. }
  13791. // AddAchievementCount adds i to the "achievement_count" field.
  13792. func (m *EmployeeMutation) AddAchievementCount(i int) {
  13793. if m.addachievement_count != nil {
  13794. *m.addachievement_count += i
  13795. } else {
  13796. m.addachievement_count = &i
  13797. }
  13798. }
  13799. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  13800. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  13801. v := m.addachievement_count
  13802. if v == nil {
  13803. return
  13804. }
  13805. return *v, true
  13806. }
  13807. // ResetAchievementCount resets all changes to the "achievement_count" field.
  13808. func (m *EmployeeMutation) ResetAchievementCount() {
  13809. m.achievement_count = nil
  13810. m.addachievement_count = nil
  13811. }
  13812. // SetIntro sets the "intro" field.
  13813. func (m *EmployeeMutation) SetIntro(s string) {
  13814. m.intro = &s
  13815. }
  13816. // Intro returns the value of the "intro" field in the mutation.
  13817. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  13818. v := m.intro
  13819. if v == nil {
  13820. return
  13821. }
  13822. return *v, true
  13823. }
  13824. // OldIntro returns the old "intro" field's value of the Employee entity.
  13825. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13827. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  13828. if !m.op.Is(OpUpdateOne) {
  13829. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  13830. }
  13831. if m.id == nil || m.oldValue == nil {
  13832. return v, errors.New("OldIntro requires an ID field in the mutation")
  13833. }
  13834. oldValue, err := m.oldValue(ctx)
  13835. if err != nil {
  13836. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  13837. }
  13838. return oldValue.Intro, nil
  13839. }
  13840. // ResetIntro resets all changes to the "intro" field.
  13841. func (m *EmployeeMutation) ResetIntro() {
  13842. m.intro = nil
  13843. }
  13844. // SetEstimate sets the "estimate" field.
  13845. func (m *EmployeeMutation) SetEstimate(s string) {
  13846. m.estimate = &s
  13847. }
  13848. // Estimate returns the value of the "estimate" field in the mutation.
  13849. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  13850. v := m.estimate
  13851. if v == nil {
  13852. return
  13853. }
  13854. return *v, true
  13855. }
  13856. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  13857. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13859. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  13860. if !m.op.Is(OpUpdateOne) {
  13861. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  13862. }
  13863. if m.id == nil || m.oldValue == nil {
  13864. return v, errors.New("OldEstimate requires an ID field in the mutation")
  13865. }
  13866. oldValue, err := m.oldValue(ctx)
  13867. if err != nil {
  13868. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  13869. }
  13870. return oldValue.Estimate, nil
  13871. }
  13872. // ResetEstimate resets all changes to the "estimate" field.
  13873. func (m *EmployeeMutation) ResetEstimate() {
  13874. m.estimate = nil
  13875. }
  13876. // SetSkill sets the "skill" field.
  13877. func (m *EmployeeMutation) SetSkill(s string) {
  13878. m.skill = &s
  13879. }
  13880. // Skill returns the value of the "skill" field in the mutation.
  13881. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  13882. v := m.skill
  13883. if v == nil {
  13884. return
  13885. }
  13886. return *v, true
  13887. }
  13888. // OldSkill returns the old "skill" field's value of the Employee entity.
  13889. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13891. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  13892. if !m.op.Is(OpUpdateOne) {
  13893. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  13894. }
  13895. if m.id == nil || m.oldValue == nil {
  13896. return v, errors.New("OldSkill requires an ID field in the mutation")
  13897. }
  13898. oldValue, err := m.oldValue(ctx)
  13899. if err != nil {
  13900. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  13901. }
  13902. return oldValue.Skill, nil
  13903. }
  13904. // ResetSkill resets all changes to the "skill" field.
  13905. func (m *EmployeeMutation) ResetSkill() {
  13906. m.skill = nil
  13907. }
  13908. // SetAbilityType sets the "ability_type" field.
  13909. func (m *EmployeeMutation) SetAbilityType(s string) {
  13910. m.ability_type = &s
  13911. }
  13912. // AbilityType returns the value of the "ability_type" field in the mutation.
  13913. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  13914. v := m.ability_type
  13915. if v == nil {
  13916. return
  13917. }
  13918. return *v, true
  13919. }
  13920. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  13921. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13923. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  13924. if !m.op.Is(OpUpdateOne) {
  13925. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  13926. }
  13927. if m.id == nil || m.oldValue == nil {
  13928. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  13929. }
  13930. oldValue, err := m.oldValue(ctx)
  13931. if err != nil {
  13932. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  13933. }
  13934. return oldValue.AbilityType, nil
  13935. }
  13936. // ResetAbilityType resets all changes to the "ability_type" field.
  13937. func (m *EmployeeMutation) ResetAbilityType() {
  13938. m.ability_type = nil
  13939. }
  13940. // SetScene sets the "scene" field.
  13941. func (m *EmployeeMutation) SetScene(s string) {
  13942. m.scene = &s
  13943. }
  13944. // Scene returns the value of the "scene" field in the mutation.
  13945. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  13946. v := m.scene
  13947. if v == nil {
  13948. return
  13949. }
  13950. return *v, true
  13951. }
  13952. // OldScene returns the old "scene" field's value of the Employee entity.
  13953. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13955. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  13956. if !m.op.Is(OpUpdateOne) {
  13957. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  13958. }
  13959. if m.id == nil || m.oldValue == nil {
  13960. return v, errors.New("OldScene requires an ID field in the mutation")
  13961. }
  13962. oldValue, err := m.oldValue(ctx)
  13963. if err != nil {
  13964. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  13965. }
  13966. return oldValue.Scene, nil
  13967. }
  13968. // ResetScene resets all changes to the "scene" field.
  13969. func (m *EmployeeMutation) ResetScene() {
  13970. m.scene = nil
  13971. }
  13972. // SetSwitchIn sets the "switch_in" field.
  13973. func (m *EmployeeMutation) SetSwitchIn(s string) {
  13974. m.switch_in = &s
  13975. }
  13976. // SwitchIn returns the value of the "switch_in" field in the mutation.
  13977. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  13978. v := m.switch_in
  13979. if v == nil {
  13980. return
  13981. }
  13982. return *v, true
  13983. }
  13984. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  13985. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13987. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  13988. if !m.op.Is(OpUpdateOne) {
  13989. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  13990. }
  13991. if m.id == nil || m.oldValue == nil {
  13992. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  13993. }
  13994. oldValue, err := m.oldValue(ctx)
  13995. if err != nil {
  13996. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  13997. }
  13998. return oldValue.SwitchIn, nil
  13999. }
  14000. // ResetSwitchIn resets all changes to the "switch_in" field.
  14001. func (m *EmployeeMutation) ResetSwitchIn() {
  14002. m.switch_in = nil
  14003. }
  14004. // SetVideoURL sets the "video_url" field.
  14005. func (m *EmployeeMutation) SetVideoURL(s string) {
  14006. m.video_url = &s
  14007. }
  14008. // VideoURL returns the value of the "video_url" field in the mutation.
  14009. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  14010. v := m.video_url
  14011. if v == nil {
  14012. return
  14013. }
  14014. return *v, true
  14015. }
  14016. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  14017. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14019. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  14020. if !m.op.Is(OpUpdateOne) {
  14021. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  14022. }
  14023. if m.id == nil || m.oldValue == nil {
  14024. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  14025. }
  14026. oldValue, err := m.oldValue(ctx)
  14027. if err != nil {
  14028. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  14029. }
  14030. return oldValue.VideoURL, nil
  14031. }
  14032. // ResetVideoURL resets all changes to the "video_url" field.
  14033. func (m *EmployeeMutation) ResetVideoURL() {
  14034. m.video_url = nil
  14035. }
  14036. // SetOrganizationID sets the "organization_id" field.
  14037. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  14038. m.organization_id = &u
  14039. m.addorganization_id = nil
  14040. }
  14041. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14042. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  14043. v := m.organization_id
  14044. if v == nil {
  14045. return
  14046. }
  14047. return *v, true
  14048. }
  14049. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  14050. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14052. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14053. if !m.op.Is(OpUpdateOne) {
  14054. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14055. }
  14056. if m.id == nil || m.oldValue == nil {
  14057. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14058. }
  14059. oldValue, err := m.oldValue(ctx)
  14060. if err != nil {
  14061. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14062. }
  14063. return oldValue.OrganizationID, nil
  14064. }
  14065. // AddOrganizationID adds u to the "organization_id" field.
  14066. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  14067. if m.addorganization_id != nil {
  14068. *m.addorganization_id += u
  14069. } else {
  14070. m.addorganization_id = &u
  14071. }
  14072. }
  14073. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14074. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  14075. v := m.addorganization_id
  14076. if v == nil {
  14077. return
  14078. }
  14079. return *v, true
  14080. }
  14081. // ResetOrganizationID resets all changes to the "organization_id" field.
  14082. func (m *EmployeeMutation) ResetOrganizationID() {
  14083. m.organization_id = nil
  14084. m.addorganization_id = nil
  14085. }
  14086. // SetCategoryID sets the "category_id" field.
  14087. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14088. m.category_id = &u
  14089. m.addcategory_id = nil
  14090. }
  14091. // CategoryID returns the value of the "category_id" field in the mutation.
  14092. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14093. v := m.category_id
  14094. if v == nil {
  14095. return
  14096. }
  14097. return *v, true
  14098. }
  14099. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14100. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14102. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14103. if !m.op.Is(OpUpdateOne) {
  14104. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14105. }
  14106. if m.id == nil || m.oldValue == nil {
  14107. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14108. }
  14109. oldValue, err := m.oldValue(ctx)
  14110. if err != nil {
  14111. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14112. }
  14113. return oldValue.CategoryID, nil
  14114. }
  14115. // AddCategoryID adds u to the "category_id" field.
  14116. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14117. if m.addcategory_id != nil {
  14118. *m.addcategory_id += u
  14119. } else {
  14120. m.addcategory_id = &u
  14121. }
  14122. }
  14123. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14124. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14125. v := m.addcategory_id
  14126. if v == nil {
  14127. return
  14128. }
  14129. return *v, true
  14130. }
  14131. // ResetCategoryID resets all changes to the "category_id" field.
  14132. func (m *EmployeeMutation) ResetCategoryID() {
  14133. m.category_id = nil
  14134. m.addcategory_id = nil
  14135. }
  14136. // SetAPIBase sets the "api_base" field.
  14137. func (m *EmployeeMutation) SetAPIBase(s string) {
  14138. m.api_base = &s
  14139. }
  14140. // APIBase returns the value of the "api_base" field in the mutation.
  14141. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14142. v := m.api_base
  14143. if v == nil {
  14144. return
  14145. }
  14146. return *v, true
  14147. }
  14148. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14149. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14151. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14152. if !m.op.Is(OpUpdateOne) {
  14153. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14154. }
  14155. if m.id == nil || m.oldValue == nil {
  14156. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14157. }
  14158. oldValue, err := m.oldValue(ctx)
  14159. if err != nil {
  14160. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14161. }
  14162. return oldValue.APIBase, nil
  14163. }
  14164. // ResetAPIBase resets all changes to the "api_base" field.
  14165. func (m *EmployeeMutation) ResetAPIBase() {
  14166. m.api_base = nil
  14167. }
  14168. // SetAPIKey sets the "api_key" field.
  14169. func (m *EmployeeMutation) SetAPIKey(s string) {
  14170. m.api_key = &s
  14171. }
  14172. // APIKey returns the value of the "api_key" field in the mutation.
  14173. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14174. v := m.api_key
  14175. if v == nil {
  14176. return
  14177. }
  14178. return *v, true
  14179. }
  14180. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14181. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14183. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14184. if !m.op.Is(OpUpdateOne) {
  14185. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14186. }
  14187. if m.id == nil || m.oldValue == nil {
  14188. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14189. }
  14190. oldValue, err := m.oldValue(ctx)
  14191. if err != nil {
  14192. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14193. }
  14194. return oldValue.APIKey, nil
  14195. }
  14196. // ResetAPIKey resets all changes to the "api_key" field.
  14197. func (m *EmployeeMutation) ResetAPIKey() {
  14198. m.api_key = nil
  14199. }
  14200. // SetAiInfo sets the "ai_info" field.
  14201. func (m *EmployeeMutation) SetAiInfo(s string) {
  14202. m.ai_info = &s
  14203. }
  14204. // AiInfo returns the value of the "ai_info" field in the mutation.
  14205. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14206. v := m.ai_info
  14207. if v == nil {
  14208. return
  14209. }
  14210. return *v, true
  14211. }
  14212. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14213. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14215. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14216. if !m.op.Is(OpUpdateOne) {
  14217. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14218. }
  14219. if m.id == nil || m.oldValue == nil {
  14220. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14221. }
  14222. oldValue, err := m.oldValue(ctx)
  14223. if err != nil {
  14224. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14225. }
  14226. return oldValue.AiInfo, nil
  14227. }
  14228. // ClearAiInfo clears the value of the "ai_info" field.
  14229. func (m *EmployeeMutation) ClearAiInfo() {
  14230. m.ai_info = nil
  14231. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14232. }
  14233. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14234. func (m *EmployeeMutation) AiInfoCleared() bool {
  14235. _, ok := m.clearedFields[employee.FieldAiInfo]
  14236. return ok
  14237. }
  14238. // ResetAiInfo resets all changes to the "ai_info" field.
  14239. func (m *EmployeeMutation) ResetAiInfo() {
  14240. m.ai_info = nil
  14241. delete(m.clearedFields, employee.FieldAiInfo)
  14242. }
  14243. // SetIsVip sets the "is_vip" field.
  14244. func (m *EmployeeMutation) SetIsVip(i int) {
  14245. m.is_vip = &i
  14246. m.addis_vip = nil
  14247. }
  14248. // IsVip returns the value of the "is_vip" field in the mutation.
  14249. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14250. v := m.is_vip
  14251. if v == nil {
  14252. return
  14253. }
  14254. return *v, true
  14255. }
  14256. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14257. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14259. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14260. if !m.op.Is(OpUpdateOne) {
  14261. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14262. }
  14263. if m.id == nil || m.oldValue == nil {
  14264. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14265. }
  14266. oldValue, err := m.oldValue(ctx)
  14267. if err != nil {
  14268. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14269. }
  14270. return oldValue.IsVip, nil
  14271. }
  14272. // AddIsVip adds i to the "is_vip" field.
  14273. func (m *EmployeeMutation) AddIsVip(i int) {
  14274. if m.addis_vip != nil {
  14275. *m.addis_vip += i
  14276. } else {
  14277. m.addis_vip = &i
  14278. }
  14279. }
  14280. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14281. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14282. v := m.addis_vip
  14283. if v == nil {
  14284. return
  14285. }
  14286. return *v, true
  14287. }
  14288. // ResetIsVip resets all changes to the "is_vip" field.
  14289. func (m *EmployeeMutation) ResetIsVip() {
  14290. m.is_vip = nil
  14291. m.addis_vip = nil
  14292. }
  14293. // SetChatURL sets the "chat_url" field.
  14294. func (m *EmployeeMutation) SetChatURL(s string) {
  14295. m.chat_url = &s
  14296. }
  14297. // ChatURL returns the value of the "chat_url" field in the mutation.
  14298. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14299. v := m.chat_url
  14300. if v == nil {
  14301. return
  14302. }
  14303. return *v, true
  14304. }
  14305. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14306. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14308. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14309. if !m.op.Is(OpUpdateOne) {
  14310. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14311. }
  14312. if m.id == nil || m.oldValue == nil {
  14313. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14314. }
  14315. oldValue, err := m.oldValue(ctx)
  14316. if err != nil {
  14317. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14318. }
  14319. return oldValue.ChatURL, nil
  14320. }
  14321. // ResetChatURL resets all changes to the "chat_url" field.
  14322. func (m *EmployeeMutation) ResetChatURL() {
  14323. m.chat_url = nil
  14324. }
  14325. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14326. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14327. if m.em_work_experiences == nil {
  14328. m.em_work_experiences = make(map[uint64]struct{})
  14329. }
  14330. for i := range ids {
  14331. m.em_work_experiences[ids[i]] = struct{}{}
  14332. }
  14333. }
  14334. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14335. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14336. m.clearedem_work_experiences = true
  14337. }
  14338. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14339. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14340. return m.clearedem_work_experiences
  14341. }
  14342. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14343. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14344. if m.removedem_work_experiences == nil {
  14345. m.removedem_work_experiences = make(map[uint64]struct{})
  14346. }
  14347. for i := range ids {
  14348. delete(m.em_work_experiences, ids[i])
  14349. m.removedem_work_experiences[ids[i]] = struct{}{}
  14350. }
  14351. }
  14352. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14353. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14354. for id := range m.removedem_work_experiences {
  14355. ids = append(ids, id)
  14356. }
  14357. return
  14358. }
  14359. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14360. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14361. for id := range m.em_work_experiences {
  14362. ids = append(ids, id)
  14363. }
  14364. return
  14365. }
  14366. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14367. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14368. m.em_work_experiences = nil
  14369. m.clearedem_work_experiences = false
  14370. m.removedem_work_experiences = nil
  14371. }
  14372. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14373. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14374. if m.em_tutorial == nil {
  14375. m.em_tutorial = make(map[uint64]struct{})
  14376. }
  14377. for i := range ids {
  14378. m.em_tutorial[ids[i]] = struct{}{}
  14379. }
  14380. }
  14381. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14382. func (m *EmployeeMutation) ClearEmTutorial() {
  14383. m.clearedem_tutorial = true
  14384. }
  14385. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14386. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14387. return m.clearedem_tutorial
  14388. }
  14389. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14390. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14391. if m.removedem_tutorial == nil {
  14392. m.removedem_tutorial = make(map[uint64]struct{})
  14393. }
  14394. for i := range ids {
  14395. delete(m.em_tutorial, ids[i])
  14396. m.removedem_tutorial[ids[i]] = struct{}{}
  14397. }
  14398. }
  14399. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14400. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14401. for id := range m.removedem_tutorial {
  14402. ids = append(ids, id)
  14403. }
  14404. return
  14405. }
  14406. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14407. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14408. for id := range m.em_tutorial {
  14409. ids = append(ids, id)
  14410. }
  14411. return
  14412. }
  14413. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14414. func (m *EmployeeMutation) ResetEmTutorial() {
  14415. m.em_tutorial = nil
  14416. m.clearedem_tutorial = false
  14417. m.removedem_tutorial = nil
  14418. }
  14419. // Where appends a list predicates to the EmployeeMutation builder.
  14420. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14421. m.predicates = append(m.predicates, ps...)
  14422. }
  14423. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14424. // users can use type-assertion to append predicates that do not depend on any generated package.
  14425. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14426. p := make([]predicate.Employee, len(ps))
  14427. for i := range ps {
  14428. p[i] = ps[i]
  14429. }
  14430. m.Where(p...)
  14431. }
  14432. // Op returns the operation name.
  14433. func (m *EmployeeMutation) Op() Op {
  14434. return m.op
  14435. }
  14436. // SetOp allows setting the mutation operation.
  14437. func (m *EmployeeMutation) SetOp(op Op) {
  14438. m.op = op
  14439. }
  14440. // Type returns the node type of this mutation (Employee).
  14441. func (m *EmployeeMutation) Type() string {
  14442. return m.typ
  14443. }
  14444. // Fields returns all fields that were changed during this mutation. Note that in
  14445. // order to get all numeric fields that were incremented/decremented, call
  14446. // AddedFields().
  14447. func (m *EmployeeMutation) Fields() []string {
  14448. fields := make([]string, 0, 23)
  14449. if m.created_at != nil {
  14450. fields = append(fields, employee.FieldCreatedAt)
  14451. }
  14452. if m.updated_at != nil {
  14453. fields = append(fields, employee.FieldUpdatedAt)
  14454. }
  14455. if m.deleted_at != nil {
  14456. fields = append(fields, employee.FieldDeletedAt)
  14457. }
  14458. if m.title != nil {
  14459. fields = append(fields, employee.FieldTitle)
  14460. }
  14461. if m.avatar != nil {
  14462. fields = append(fields, employee.FieldAvatar)
  14463. }
  14464. if m.tags != nil {
  14465. fields = append(fields, employee.FieldTags)
  14466. }
  14467. if m.hire_count != nil {
  14468. fields = append(fields, employee.FieldHireCount)
  14469. }
  14470. if m.service_count != nil {
  14471. fields = append(fields, employee.FieldServiceCount)
  14472. }
  14473. if m.achievement_count != nil {
  14474. fields = append(fields, employee.FieldAchievementCount)
  14475. }
  14476. if m.intro != nil {
  14477. fields = append(fields, employee.FieldIntro)
  14478. }
  14479. if m.estimate != nil {
  14480. fields = append(fields, employee.FieldEstimate)
  14481. }
  14482. if m.skill != nil {
  14483. fields = append(fields, employee.FieldSkill)
  14484. }
  14485. if m.ability_type != nil {
  14486. fields = append(fields, employee.FieldAbilityType)
  14487. }
  14488. if m.scene != nil {
  14489. fields = append(fields, employee.FieldScene)
  14490. }
  14491. if m.switch_in != nil {
  14492. fields = append(fields, employee.FieldSwitchIn)
  14493. }
  14494. if m.video_url != nil {
  14495. fields = append(fields, employee.FieldVideoURL)
  14496. }
  14497. if m.organization_id != nil {
  14498. fields = append(fields, employee.FieldOrganizationID)
  14499. }
  14500. if m.category_id != nil {
  14501. fields = append(fields, employee.FieldCategoryID)
  14502. }
  14503. if m.api_base != nil {
  14504. fields = append(fields, employee.FieldAPIBase)
  14505. }
  14506. if m.api_key != nil {
  14507. fields = append(fields, employee.FieldAPIKey)
  14508. }
  14509. if m.ai_info != nil {
  14510. fields = append(fields, employee.FieldAiInfo)
  14511. }
  14512. if m.is_vip != nil {
  14513. fields = append(fields, employee.FieldIsVip)
  14514. }
  14515. if m.chat_url != nil {
  14516. fields = append(fields, employee.FieldChatURL)
  14517. }
  14518. return fields
  14519. }
  14520. // Field returns the value of a field with the given name. The second boolean
  14521. // return value indicates that this field was not set, or was not defined in the
  14522. // schema.
  14523. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14524. switch name {
  14525. case employee.FieldCreatedAt:
  14526. return m.CreatedAt()
  14527. case employee.FieldUpdatedAt:
  14528. return m.UpdatedAt()
  14529. case employee.FieldDeletedAt:
  14530. return m.DeletedAt()
  14531. case employee.FieldTitle:
  14532. return m.Title()
  14533. case employee.FieldAvatar:
  14534. return m.Avatar()
  14535. case employee.FieldTags:
  14536. return m.Tags()
  14537. case employee.FieldHireCount:
  14538. return m.HireCount()
  14539. case employee.FieldServiceCount:
  14540. return m.ServiceCount()
  14541. case employee.FieldAchievementCount:
  14542. return m.AchievementCount()
  14543. case employee.FieldIntro:
  14544. return m.Intro()
  14545. case employee.FieldEstimate:
  14546. return m.Estimate()
  14547. case employee.FieldSkill:
  14548. return m.Skill()
  14549. case employee.FieldAbilityType:
  14550. return m.AbilityType()
  14551. case employee.FieldScene:
  14552. return m.Scene()
  14553. case employee.FieldSwitchIn:
  14554. return m.SwitchIn()
  14555. case employee.FieldVideoURL:
  14556. return m.VideoURL()
  14557. case employee.FieldOrganizationID:
  14558. return m.OrganizationID()
  14559. case employee.FieldCategoryID:
  14560. return m.CategoryID()
  14561. case employee.FieldAPIBase:
  14562. return m.APIBase()
  14563. case employee.FieldAPIKey:
  14564. return m.APIKey()
  14565. case employee.FieldAiInfo:
  14566. return m.AiInfo()
  14567. case employee.FieldIsVip:
  14568. return m.IsVip()
  14569. case employee.FieldChatURL:
  14570. return m.ChatURL()
  14571. }
  14572. return nil, false
  14573. }
  14574. // OldField returns the old value of the field from the database. An error is
  14575. // returned if the mutation operation is not UpdateOne, or the query to the
  14576. // database failed.
  14577. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14578. switch name {
  14579. case employee.FieldCreatedAt:
  14580. return m.OldCreatedAt(ctx)
  14581. case employee.FieldUpdatedAt:
  14582. return m.OldUpdatedAt(ctx)
  14583. case employee.FieldDeletedAt:
  14584. return m.OldDeletedAt(ctx)
  14585. case employee.FieldTitle:
  14586. return m.OldTitle(ctx)
  14587. case employee.FieldAvatar:
  14588. return m.OldAvatar(ctx)
  14589. case employee.FieldTags:
  14590. return m.OldTags(ctx)
  14591. case employee.FieldHireCount:
  14592. return m.OldHireCount(ctx)
  14593. case employee.FieldServiceCount:
  14594. return m.OldServiceCount(ctx)
  14595. case employee.FieldAchievementCount:
  14596. return m.OldAchievementCount(ctx)
  14597. case employee.FieldIntro:
  14598. return m.OldIntro(ctx)
  14599. case employee.FieldEstimate:
  14600. return m.OldEstimate(ctx)
  14601. case employee.FieldSkill:
  14602. return m.OldSkill(ctx)
  14603. case employee.FieldAbilityType:
  14604. return m.OldAbilityType(ctx)
  14605. case employee.FieldScene:
  14606. return m.OldScene(ctx)
  14607. case employee.FieldSwitchIn:
  14608. return m.OldSwitchIn(ctx)
  14609. case employee.FieldVideoURL:
  14610. return m.OldVideoURL(ctx)
  14611. case employee.FieldOrganizationID:
  14612. return m.OldOrganizationID(ctx)
  14613. case employee.FieldCategoryID:
  14614. return m.OldCategoryID(ctx)
  14615. case employee.FieldAPIBase:
  14616. return m.OldAPIBase(ctx)
  14617. case employee.FieldAPIKey:
  14618. return m.OldAPIKey(ctx)
  14619. case employee.FieldAiInfo:
  14620. return m.OldAiInfo(ctx)
  14621. case employee.FieldIsVip:
  14622. return m.OldIsVip(ctx)
  14623. case employee.FieldChatURL:
  14624. return m.OldChatURL(ctx)
  14625. }
  14626. return nil, fmt.Errorf("unknown Employee field %s", name)
  14627. }
  14628. // SetField sets the value of a field with the given name. It returns an error if
  14629. // the field is not defined in the schema, or if the type mismatched the field
  14630. // type.
  14631. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14632. switch name {
  14633. case employee.FieldCreatedAt:
  14634. v, ok := value.(time.Time)
  14635. if !ok {
  14636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14637. }
  14638. m.SetCreatedAt(v)
  14639. return nil
  14640. case employee.FieldUpdatedAt:
  14641. v, ok := value.(time.Time)
  14642. if !ok {
  14643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14644. }
  14645. m.SetUpdatedAt(v)
  14646. return nil
  14647. case employee.FieldDeletedAt:
  14648. v, ok := value.(time.Time)
  14649. if !ok {
  14650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14651. }
  14652. m.SetDeletedAt(v)
  14653. return nil
  14654. case employee.FieldTitle:
  14655. v, ok := value.(string)
  14656. if !ok {
  14657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14658. }
  14659. m.SetTitle(v)
  14660. return nil
  14661. case employee.FieldAvatar:
  14662. v, ok := value.(string)
  14663. if !ok {
  14664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14665. }
  14666. m.SetAvatar(v)
  14667. return nil
  14668. case employee.FieldTags:
  14669. v, ok := value.(string)
  14670. if !ok {
  14671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14672. }
  14673. m.SetTags(v)
  14674. return nil
  14675. case employee.FieldHireCount:
  14676. v, ok := value.(int)
  14677. if !ok {
  14678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14679. }
  14680. m.SetHireCount(v)
  14681. return nil
  14682. case employee.FieldServiceCount:
  14683. v, ok := value.(int)
  14684. if !ok {
  14685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14686. }
  14687. m.SetServiceCount(v)
  14688. return nil
  14689. case employee.FieldAchievementCount:
  14690. v, ok := value.(int)
  14691. if !ok {
  14692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14693. }
  14694. m.SetAchievementCount(v)
  14695. return nil
  14696. case employee.FieldIntro:
  14697. v, ok := value.(string)
  14698. if !ok {
  14699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14700. }
  14701. m.SetIntro(v)
  14702. return nil
  14703. case employee.FieldEstimate:
  14704. v, ok := value.(string)
  14705. if !ok {
  14706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14707. }
  14708. m.SetEstimate(v)
  14709. return nil
  14710. case employee.FieldSkill:
  14711. v, ok := value.(string)
  14712. if !ok {
  14713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14714. }
  14715. m.SetSkill(v)
  14716. return nil
  14717. case employee.FieldAbilityType:
  14718. v, ok := value.(string)
  14719. if !ok {
  14720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14721. }
  14722. m.SetAbilityType(v)
  14723. return nil
  14724. case employee.FieldScene:
  14725. v, ok := value.(string)
  14726. if !ok {
  14727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14728. }
  14729. m.SetScene(v)
  14730. return nil
  14731. case employee.FieldSwitchIn:
  14732. v, ok := value.(string)
  14733. if !ok {
  14734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14735. }
  14736. m.SetSwitchIn(v)
  14737. return nil
  14738. case employee.FieldVideoURL:
  14739. v, ok := value.(string)
  14740. if !ok {
  14741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14742. }
  14743. m.SetVideoURL(v)
  14744. return nil
  14745. case employee.FieldOrganizationID:
  14746. v, ok := value.(uint64)
  14747. if !ok {
  14748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14749. }
  14750. m.SetOrganizationID(v)
  14751. return nil
  14752. case employee.FieldCategoryID:
  14753. v, ok := value.(uint64)
  14754. if !ok {
  14755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14756. }
  14757. m.SetCategoryID(v)
  14758. return nil
  14759. case employee.FieldAPIBase:
  14760. v, ok := value.(string)
  14761. if !ok {
  14762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14763. }
  14764. m.SetAPIBase(v)
  14765. return nil
  14766. case employee.FieldAPIKey:
  14767. v, ok := value.(string)
  14768. if !ok {
  14769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14770. }
  14771. m.SetAPIKey(v)
  14772. return nil
  14773. case employee.FieldAiInfo:
  14774. v, ok := value.(string)
  14775. if !ok {
  14776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14777. }
  14778. m.SetAiInfo(v)
  14779. return nil
  14780. case employee.FieldIsVip:
  14781. v, ok := value.(int)
  14782. if !ok {
  14783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14784. }
  14785. m.SetIsVip(v)
  14786. return nil
  14787. case employee.FieldChatURL:
  14788. v, ok := value.(string)
  14789. if !ok {
  14790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14791. }
  14792. m.SetChatURL(v)
  14793. return nil
  14794. }
  14795. return fmt.Errorf("unknown Employee field %s", name)
  14796. }
  14797. // AddedFields returns all numeric fields that were incremented/decremented during
  14798. // this mutation.
  14799. func (m *EmployeeMutation) AddedFields() []string {
  14800. var fields []string
  14801. if m.addhire_count != nil {
  14802. fields = append(fields, employee.FieldHireCount)
  14803. }
  14804. if m.addservice_count != nil {
  14805. fields = append(fields, employee.FieldServiceCount)
  14806. }
  14807. if m.addachievement_count != nil {
  14808. fields = append(fields, employee.FieldAchievementCount)
  14809. }
  14810. if m.addorganization_id != nil {
  14811. fields = append(fields, employee.FieldOrganizationID)
  14812. }
  14813. if m.addcategory_id != nil {
  14814. fields = append(fields, employee.FieldCategoryID)
  14815. }
  14816. if m.addis_vip != nil {
  14817. fields = append(fields, employee.FieldIsVip)
  14818. }
  14819. return fields
  14820. }
  14821. // AddedField returns the numeric value that was incremented/decremented on a field
  14822. // with the given name. The second boolean return value indicates that this field
  14823. // was not set, or was not defined in the schema.
  14824. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  14825. switch name {
  14826. case employee.FieldHireCount:
  14827. return m.AddedHireCount()
  14828. case employee.FieldServiceCount:
  14829. return m.AddedServiceCount()
  14830. case employee.FieldAchievementCount:
  14831. return m.AddedAchievementCount()
  14832. case employee.FieldOrganizationID:
  14833. return m.AddedOrganizationID()
  14834. case employee.FieldCategoryID:
  14835. return m.AddedCategoryID()
  14836. case employee.FieldIsVip:
  14837. return m.AddedIsVip()
  14838. }
  14839. return nil, false
  14840. }
  14841. // AddField adds the value to the field with the given name. It returns an error if
  14842. // the field is not defined in the schema, or if the type mismatched the field
  14843. // type.
  14844. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  14845. switch name {
  14846. case employee.FieldHireCount:
  14847. v, ok := value.(int)
  14848. if !ok {
  14849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14850. }
  14851. m.AddHireCount(v)
  14852. return nil
  14853. case employee.FieldServiceCount:
  14854. v, ok := value.(int)
  14855. if !ok {
  14856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14857. }
  14858. m.AddServiceCount(v)
  14859. return nil
  14860. case employee.FieldAchievementCount:
  14861. v, ok := value.(int)
  14862. if !ok {
  14863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14864. }
  14865. m.AddAchievementCount(v)
  14866. return nil
  14867. case employee.FieldOrganizationID:
  14868. v, ok := value.(int64)
  14869. if !ok {
  14870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14871. }
  14872. m.AddOrganizationID(v)
  14873. return nil
  14874. case employee.FieldCategoryID:
  14875. v, ok := value.(int64)
  14876. if !ok {
  14877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14878. }
  14879. m.AddCategoryID(v)
  14880. return nil
  14881. case employee.FieldIsVip:
  14882. v, ok := value.(int)
  14883. if !ok {
  14884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14885. }
  14886. m.AddIsVip(v)
  14887. return nil
  14888. }
  14889. return fmt.Errorf("unknown Employee numeric field %s", name)
  14890. }
  14891. // ClearedFields returns all nullable fields that were cleared during this
  14892. // mutation.
  14893. func (m *EmployeeMutation) ClearedFields() []string {
  14894. var fields []string
  14895. if m.FieldCleared(employee.FieldDeletedAt) {
  14896. fields = append(fields, employee.FieldDeletedAt)
  14897. }
  14898. if m.FieldCleared(employee.FieldAiInfo) {
  14899. fields = append(fields, employee.FieldAiInfo)
  14900. }
  14901. return fields
  14902. }
  14903. // FieldCleared returns a boolean indicating if a field with the given name was
  14904. // cleared in this mutation.
  14905. func (m *EmployeeMutation) FieldCleared(name string) bool {
  14906. _, ok := m.clearedFields[name]
  14907. return ok
  14908. }
  14909. // ClearField clears the value of the field with the given name. It returns an
  14910. // error if the field is not defined in the schema.
  14911. func (m *EmployeeMutation) ClearField(name string) error {
  14912. switch name {
  14913. case employee.FieldDeletedAt:
  14914. m.ClearDeletedAt()
  14915. return nil
  14916. case employee.FieldAiInfo:
  14917. m.ClearAiInfo()
  14918. return nil
  14919. }
  14920. return fmt.Errorf("unknown Employee nullable field %s", name)
  14921. }
  14922. // ResetField resets all changes in the mutation for the field with the given name.
  14923. // It returns an error if the field is not defined in the schema.
  14924. func (m *EmployeeMutation) ResetField(name string) error {
  14925. switch name {
  14926. case employee.FieldCreatedAt:
  14927. m.ResetCreatedAt()
  14928. return nil
  14929. case employee.FieldUpdatedAt:
  14930. m.ResetUpdatedAt()
  14931. return nil
  14932. case employee.FieldDeletedAt:
  14933. m.ResetDeletedAt()
  14934. return nil
  14935. case employee.FieldTitle:
  14936. m.ResetTitle()
  14937. return nil
  14938. case employee.FieldAvatar:
  14939. m.ResetAvatar()
  14940. return nil
  14941. case employee.FieldTags:
  14942. m.ResetTags()
  14943. return nil
  14944. case employee.FieldHireCount:
  14945. m.ResetHireCount()
  14946. return nil
  14947. case employee.FieldServiceCount:
  14948. m.ResetServiceCount()
  14949. return nil
  14950. case employee.FieldAchievementCount:
  14951. m.ResetAchievementCount()
  14952. return nil
  14953. case employee.FieldIntro:
  14954. m.ResetIntro()
  14955. return nil
  14956. case employee.FieldEstimate:
  14957. m.ResetEstimate()
  14958. return nil
  14959. case employee.FieldSkill:
  14960. m.ResetSkill()
  14961. return nil
  14962. case employee.FieldAbilityType:
  14963. m.ResetAbilityType()
  14964. return nil
  14965. case employee.FieldScene:
  14966. m.ResetScene()
  14967. return nil
  14968. case employee.FieldSwitchIn:
  14969. m.ResetSwitchIn()
  14970. return nil
  14971. case employee.FieldVideoURL:
  14972. m.ResetVideoURL()
  14973. return nil
  14974. case employee.FieldOrganizationID:
  14975. m.ResetOrganizationID()
  14976. return nil
  14977. case employee.FieldCategoryID:
  14978. m.ResetCategoryID()
  14979. return nil
  14980. case employee.FieldAPIBase:
  14981. m.ResetAPIBase()
  14982. return nil
  14983. case employee.FieldAPIKey:
  14984. m.ResetAPIKey()
  14985. return nil
  14986. case employee.FieldAiInfo:
  14987. m.ResetAiInfo()
  14988. return nil
  14989. case employee.FieldIsVip:
  14990. m.ResetIsVip()
  14991. return nil
  14992. case employee.FieldChatURL:
  14993. m.ResetChatURL()
  14994. return nil
  14995. }
  14996. return fmt.Errorf("unknown Employee field %s", name)
  14997. }
  14998. // AddedEdges returns all edge names that were set/added in this mutation.
  14999. func (m *EmployeeMutation) AddedEdges() []string {
  15000. edges := make([]string, 0, 2)
  15001. if m.em_work_experiences != nil {
  15002. edges = append(edges, employee.EdgeEmWorkExperiences)
  15003. }
  15004. if m.em_tutorial != nil {
  15005. edges = append(edges, employee.EdgeEmTutorial)
  15006. }
  15007. return edges
  15008. }
  15009. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15010. // name in this mutation.
  15011. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  15012. switch name {
  15013. case employee.EdgeEmWorkExperiences:
  15014. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  15015. for id := range m.em_work_experiences {
  15016. ids = append(ids, id)
  15017. }
  15018. return ids
  15019. case employee.EdgeEmTutorial:
  15020. ids := make([]ent.Value, 0, len(m.em_tutorial))
  15021. for id := range m.em_tutorial {
  15022. ids = append(ids, id)
  15023. }
  15024. return ids
  15025. }
  15026. return nil
  15027. }
  15028. // RemovedEdges returns all edge names that were removed in this mutation.
  15029. func (m *EmployeeMutation) RemovedEdges() []string {
  15030. edges := make([]string, 0, 2)
  15031. if m.removedem_work_experiences != nil {
  15032. edges = append(edges, employee.EdgeEmWorkExperiences)
  15033. }
  15034. if m.removedem_tutorial != nil {
  15035. edges = append(edges, employee.EdgeEmTutorial)
  15036. }
  15037. return edges
  15038. }
  15039. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15040. // the given name in this mutation.
  15041. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  15042. switch name {
  15043. case employee.EdgeEmWorkExperiences:
  15044. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  15045. for id := range m.removedem_work_experiences {
  15046. ids = append(ids, id)
  15047. }
  15048. return ids
  15049. case employee.EdgeEmTutorial:
  15050. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  15051. for id := range m.removedem_tutorial {
  15052. ids = append(ids, id)
  15053. }
  15054. return ids
  15055. }
  15056. return nil
  15057. }
  15058. // ClearedEdges returns all edge names that were cleared in this mutation.
  15059. func (m *EmployeeMutation) ClearedEdges() []string {
  15060. edges := make([]string, 0, 2)
  15061. if m.clearedem_work_experiences {
  15062. edges = append(edges, employee.EdgeEmWorkExperiences)
  15063. }
  15064. if m.clearedem_tutorial {
  15065. edges = append(edges, employee.EdgeEmTutorial)
  15066. }
  15067. return edges
  15068. }
  15069. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15070. // was cleared in this mutation.
  15071. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  15072. switch name {
  15073. case employee.EdgeEmWorkExperiences:
  15074. return m.clearedem_work_experiences
  15075. case employee.EdgeEmTutorial:
  15076. return m.clearedem_tutorial
  15077. }
  15078. return false
  15079. }
  15080. // ClearEdge clears the value of the edge with the given name. It returns an error
  15081. // if that edge is not defined in the schema.
  15082. func (m *EmployeeMutation) ClearEdge(name string) error {
  15083. switch name {
  15084. }
  15085. return fmt.Errorf("unknown Employee unique edge %s", name)
  15086. }
  15087. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15088. // It returns an error if the edge is not defined in the schema.
  15089. func (m *EmployeeMutation) ResetEdge(name string) error {
  15090. switch name {
  15091. case employee.EdgeEmWorkExperiences:
  15092. m.ResetEmWorkExperiences()
  15093. return nil
  15094. case employee.EdgeEmTutorial:
  15095. m.ResetEmTutorial()
  15096. return nil
  15097. }
  15098. return fmt.Errorf("unknown Employee edge %s", name)
  15099. }
  15100. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15101. type EmployeeConfigMutation struct {
  15102. config
  15103. op Op
  15104. typ string
  15105. id *uint64
  15106. created_at *time.Time
  15107. updated_at *time.Time
  15108. deleted_at *time.Time
  15109. stype *string
  15110. title *string
  15111. photo *string
  15112. organization_id *uint64
  15113. addorganization_id *int64
  15114. clearedFields map[string]struct{}
  15115. done bool
  15116. oldValue func(context.Context) (*EmployeeConfig, error)
  15117. predicates []predicate.EmployeeConfig
  15118. }
  15119. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15120. // employeeconfigOption allows management of the mutation configuration using functional options.
  15121. type employeeconfigOption func(*EmployeeConfigMutation)
  15122. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15123. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15124. m := &EmployeeConfigMutation{
  15125. config: c,
  15126. op: op,
  15127. typ: TypeEmployeeConfig,
  15128. clearedFields: make(map[string]struct{}),
  15129. }
  15130. for _, opt := range opts {
  15131. opt(m)
  15132. }
  15133. return m
  15134. }
  15135. // withEmployeeConfigID sets the ID field of the mutation.
  15136. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15137. return func(m *EmployeeConfigMutation) {
  15138. var (
  15139. err error
  15140. once sync.Once
  15141. value *EmployeeConfig
  15142. )
  15143. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15144. once.Do(func() {
  15145. if m.done {
  15146. err = errors.New("querying old values post mutation is not allowed")
  15147. } else {
  15148. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15149. }
  15150. })
  15151. return value, err
  15152. }
  15153. m.id = &id
  15154. }
  15155. }
  15156. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15157. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15158. return func(m *EmployeeConfigMutation) {
  15159. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15160. return node, nil
  15161. }
  15162. m.id = &node.ID
  15163. }
  15164. }
  15165. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15166. // executed in a transaction (ent.Tx), a transactional client is returned.
  15167. func (m EmployeeConfigMutation) Client() *Client {
  15168. client := &Client{config: m.config}
  15169. client.init()
  15170. return client
  15171. }
  15172. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15173. // it returns an error otherwise.
  15174. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15175. if _, ok := m.driver.(*txDriver); !ok {
  15176. return nil, errors.New("ent: mutation is not running in a transaction")
  15177. }
  15178. tx := &Tx{config: m.config}
  15179. tx.init()
  15180. return tx, nil
  15181. }
  15182. // SetID sets the value of the id field. Note that this
  15183. // operation is only accepted on creation of EmployeeConfig entities.
  15184. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15185. m.id = &id
  15186. }
  15187. // ID returns the ID value in the mutation. Note that the ID is only available
  15188. // if it was provided to the builder or after it was returned from the database.
  15189. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15190. if m.id == nil {
  15191. return
  15192. }
  15193. return *m.id, true
  15194. }
  15195. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15196. // That means, if the mutation is applied within a transaction with an isolation level such
  15197. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15198. // or updated by the mutation.
  15199. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15200. switch {
  15201. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15202. id, exists := m.ID()
  15203. if exists {
  15204. return []uint64{id}, nil
  15205. }
  15206. fallthrough
  15207. case m.op.Is(OpUpdate | OpDelete):
  15208. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15209. default:
  15210. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15211. }
  15212. }
  15213. // SetCreatedAt sets the "created_at" field.
  15214. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15215. m.created_at = &t
  15216. }
  15217. // CreatedAt returns the value of the "created_at" field in the mutation.
  15218. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15219. v := m.created_at
  15220. if v == nil {
  15221. return
  15222. }
  15223. return *v, true
  15224. }
  15225. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15226. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15228. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15229. if !m.op.Is(OpUpdateOne) {
  15230. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15231. }
  15232. if m.id == nil || m.oldValue == nil {
  15233. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15234. }
  15235. oldValue, err := m.oldValue(ctx)
  15236. if err != nil {
  15237. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15238. }
  15239. return oldValue.CreatedAt, nil
  15240. }
  15241. // ResetCreatedAt resets all changes to the "created_at" field.
  15242. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15243. m.created_at = nil
  15244. }
  15245. // SetUpdatedAt sets the "updated_at" field.
  15246. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15247. m.updated_at = &t
  15248. }
  15249. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15250. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15251. v := m.updated_at
  15252. if v == nil {
  15253. return
  15254. }
  15255. return *v, true
  15256. }
  15257. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15258. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15260. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15261. if !m.op.Is(OpUpdateOne) {
  15262. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15263. }
  15264. if m.id == nil || m.oldValue == nil {
  15265. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15266. }
  15267. oldValue, err := m.oldValue(ctx)
  15268. if err != nil {
  15269. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15270. }
  15271. return oldValue.UpdatedAt, nil
  15272. }
  15273. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15274. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15275. m.updated_at = nil
  15276. }
  15277. // SetDeletedAt sets the "deleted_at" field.
  15278. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15279. m.deleted_at = &t
  15280. }
  15281. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15282. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15283. v := m.deleted_at
  15284. if v == nil {
  15285. return
  15286. }
  15287. return *v, true
  15288. }
  15289. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15290. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15292. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15293. if !m.op.Is(OpUpdateOne) {
  15294. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15295. }
  15296. if m.id == nil || m.oldValue == nil {
  15297. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15298. }
  15299. oldValue, err := m.oldValue(ctx)
  15300. if err != nil {
  15301. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15302. }
  15303. return oldValue.DeletedAt, nil
  15304. }
  15305. // ClearDeletedAt clears the value of the "deleted_at" field.
  15306. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15307. m.deleted_at = nil
  15308. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15309. }
  15310. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15311. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15312. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15313. return ok
  15314. }
  15315. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15316. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15317. m.deleted_at = nil
  15318. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15319. }
  15320. // SetStype sets the "stype" field.
  15321. func (m *EmployeeConfigMutation) SetStype(s string) {
  15322. m.stype = &s
  15323. }
  15324. // Stype returns the value of the "stype" field in the mutation.
  15325. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15326. v := m.stype
  15327. if v == nil {
  15328. return
  15329. }
  15330. return *v, true
  15331. }
  15332. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15333. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15335. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15336. if !m.op.Is(OpUpdateOne) {
  15337. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15338. }
  15339. if m.id == nil || m.oldValue == nil {
  15340. return v, errors.New("OldStype requires an ID field in the mutation")
  15341. }
  15342. oldValue, err := m.oldValue(ctx)
  15343. if err != nil {
  15344. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15345. }
  15346. return oldValue.Stype, nil
  15347. }
  15348. // ResetStype resets all changes to the "stype" field.
  15349. func (m *EmployeeConfigMutation) ResetStype() {
  15350. m.stype = nil
  15351. }
  15352. // SetTitle sets the "title" field.
  15353. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15354. m.title = &s
  15355. }
  15356. // Title returns the value of the "title" field in the mutation.
  15357. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15358. v := m.title
  15359. if v == nil {
  15360. return
  15361. }
  15362. return *v, true
  15363. }
  15364. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15365. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15367. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15368. if !m.op.Is(OpUpdateOne) {
  15369. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15370. }
  15371. if m.id == nil || m.oldValue == nil {
  15372. return v, errors.New("OldTitle requires an ID field in the mutation")
  15373. }
  15374. oldValue, err := m.oldValue(ctx)
  15375. if err != nil {
  15376. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15377. }
  15378. return oldValue.Title, nil
  15379. }
  15380. // ResetTitle resets all changes to the "title" field.
  15381. func (m *EmployeeConfigMutation) ResetTitle() {
  15382. m.title = nil
  15383. }
  15384. // SetPhoto sets the "photo" field.
  15385. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15386. m.photo = &s
  15387. }
  15388. // Photo returns the value of the "photo" field in the mutation.
  15389. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15390. v := m.photo
  15391. if v == nil {
  15392. return
  15393. }
  15394. return *v, true
  15395. }
  15396. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15397. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15399. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15400. if !m.op.Is(OpUpdateOne) {
  15401. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15402. }
  15403. if m.id == nil || m.oldValue == nil {
  15404. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15405. }
  15406. oldValue, err := m.oldValue(ctx)
  15407. if err != nil {
  15408. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15409. }
  15410. return oldValue.Photo, nil
  15411. }
  15412. // ResetPhoto resets all changes to the "photo" field.
  15413. func (m *EmployeeConfigMutation) ResetPhoto() {
  15414. m.photo = nil
  15415. }
  15416. // SetOrganizationID sets the "organization_id" field.
  15417. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15418. m.organization_id = &u
  15419. m.addorganization_id = nil
  15420. }
  15421. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15422. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15423. v := m.organization_id
  15424. if v == nil {
  15425. return
  15426. }
  15427. return *v, true
  15428. }
  15429. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15430. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15432. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15433. if !m.op.Is(OpUpdateOne) {
  15434. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15435. }
  15436. if m.id == nil || m.oldValue == nil {
  15437. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15438. }
  15439. oldValue, err := m.oldValue(ctx)
  15440. if err != nil {
  15441. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15442. }
  15443. return oldValue.OrganizationID, nil
  15444. }
  15445. // AddOrganizationID adds u to the "organization_id" field.
  15446. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15447. if m.addorganization_id != nil {
  15448. *m.addorganization_id += u
  15449. } else {
  15450. m.addorganization_id = &u
  15451. }
  15452. }
  15453. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15454. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15455. v := m.addorganization_id
  15456. if v == nil {
  15457. return
  15458. }
  15459. return *v, true
  15460. }
  15461. // ClearOrganizationID clears the value of the "organization_id" field.
  15462. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15463. m.organization_id = nil
  15464. m.addorganization_id = nil
  15465. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15466. }
  15467. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15468. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15469. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15470. return ok
  15471. }
  15472. // ResetOrganizationID resets all changes to the "organization_id" field.
  15473. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15474. m.organization_id = nil
  15475. m.addorganization_id = nil
  15476. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15477. }
  15478. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15479. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15480. m.predicates = append(m.predicates, ps...)
  15481. }
  15482. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15483. // users can use type-assertion to append predicates that do not depend on any generated package.
  15484. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15485. p := make([]predicate.EmployeeConfig, len(ps))
  15486. for i := range ps {
  15487. p[i] = ps[i]
  15488. }
  15489. m.Where(p...)
  15490. }
  15491. // Op returns the operation name.
  15492. func (m *EmployeeConfigMutation) Op() Op {
  15493. return m.op
  15494. }
  15495. // SetOp allows setting the mutation operation.
  15496. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15497. m.op = op
  15498. }
  15499. // Type returns the node type of this mutation (EmployeeConfig).
  15500. func (m *EmployeeConfigMutation) Type() string {
  15501. return m.typ
  15502. }
  15503. // Fields returns all fields that were changed during this mutation. Note that in
  15504. // order to get all numeric fields that were incremented/decremented, call
  15505. // AddedFields().
  15506. func (m *EmployeeConfigMutation) Fields() []string {
  15507. fields := make([]string, 0, 7)
  15508. if m.created_at != nil {
  15509. fields = append(fields, employeeconfig.FieldCreatedAt)
  15510. }
  15511. if m.updated_at != nil {
  15512. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15513. }
  15514. if m.deleted_at != nil {
  15515. fields = append(fields, employeeconfig.FieldDeletedAt)
  15516. }
  15517. if m.stype != nil {
  15518. fields = append(fields, employeeconfig.FieldStype)
  15519. }
  15520. if m.title != nil {
  15521. fields = append(fields, employeeconfig.FieldTitle)
  15522. }
  15523. if m.photo != nil {
  15524. fields = append(fields, employeeconfig.FieldPhoto)
  15525. }
  15526. if m.organization_id != nil {
  15527. fields = append(fields, employeeconfig.FieldOrganizationID)
  15528. }
  15529. return fields
  15530. }
  15531. // Field returns the value of a field with the given name. The second boolean
  15532. // return value indicates that this field was not set, or was not defined in the
  15533. // schema.
  15534. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15535. switch name {
  15536. case employeeconfig.FieldCreatedAt:
  15537. return m.CreatedAt()
  15538. case employeeconfig.FieldUpdatedAt:
  15539. return m.UpdatedAt()
  15540. case employeeconfig.FieldDeletedAt:
  15541. return m.DeletedAt()
  15542. case employeeconfig.FieldStype:
  15543. return m.Stype()
  15544. case employeeconfig.FieldTitle:
  15545. return m.Title()
  15546. case employeeconfig.FieldPhoto:
  15547. return m.Photo()
  15548. case employeeconfig.FieldOrganizationID:
  15549. return m.OrganizationID()
  15550. }
  15551. return nil, false
  15552. }
  15553. // OldField returns the old value of the field from the database. An error is
  15554. // returned if the mutation operation is not UpdateOne, or the query to the
  15555. // database failed.
  15556. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15557. switch name {
  15558. case employeeconfig.FieldCreatedAt:
  15559. return m.OldCreatedAt(ctx)
  15560. case employeeconfig.FieldUpdatedAt:
  15561. return m.OldUpdatedAt(ctx)
  15562. case employeeconfig.FieldDeletedAt:
  15563. return m.OldDeletedAt(ctx)
  15564. case employeeconfig.FieldStype:
  15565. return m.OldStype(ctx)
  15566. case employeeconfig.FieldTitle:
  15567. return m.OldTitle(ctx)
  15568. case employeeconfig.FieldPhoto:
  15569. return m.OldPhoto(ctx)
  15570. case employeeconfig.FieldOrganizationID:
  15571. return m.OldOrganizationID(ctx)
  15572. }
  15573. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15574. }
  15575. // SetField sets the value of a field with the given name. It returns an error if
  15576. // the field is not defined in the schema, or if the type mismatched the field
  15577. // type.
  15578. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15579. switch name {
  15580. case employeeconfig.FieldCreatedAt:
  15581. v, ok := value.(time.Time)
  15582. if !ok {
  15583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15584. }
  15585. m.SetCreatedAt(v)
  15586. return nil
  15587. case employeeconfig.FieldUpdatedAt:
  15588. v, ok := value.(time.Time)
  15589. if !ok {
  15590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15591. }
  15592. m.SetUpdatedAt(v)
  15593. return nil
  15594. case employeeconfig.FieldDeletedAt:
  15595. v, ok := value.(time.Time)
  15596. if !ok {
  15597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15598. }
  15599. m.SetDeletedAt(v)
  15600. return nil
  15601. case employeeconfig.FieldStype:
  15602. v, ok := value.(string)
  15603. if !ok {
  15604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15605. }
  15606. m.SetStype(v)
  15607. return nil
  15608. case employeeconfig.FieldTitle:
  15609. v, ok := value.(string)
  15610. if !ok {
  15611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15612. }
  15613. m.SetTitle(v)
  15614. return nil
  15615. case employeeconfig.FieldPhoto:
  15616. v, ok := value.(string)
  15617. if !ok {
  15618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15619. }
  15620. m.SetPhoto(v)
  15621. return nil
  15622. case employeeconfig.FieldOrganizationID:
  15623. v, ok := value.(uint64)
  15624. if !ok {
  15625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15626. }
  15627. m.SetOrganizationID(v)
  15628. return nil
  15629. }
  15630. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15631. }
  15632. // AddedFields returns all numeric fields that were incremented/decremented during
  15633. // this mutation.
  15634. func (m *EmployeeConfigMutation) AddedFields() []string {
  15635. var fields []string
  15636. if m.addorganization_id != nil {
  15637. fields = append(fields, employeeconfig.FieldOrganizationID)
  15638. }
  15639. return fields
  15640. }
  15641. // AddedField returns the numeric value that was incremented/decremented on a field
  15642. // with the given name. The second boolean return value indicates that this field
  15643. // was not set, or was not defined in the schema.
  15644. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  15645. switch name {
  15646. case employeeconfig.FieldOrganizationID:
  15647. return m.AddedOrganizationID()
  15648. }
  15649. return nil, false
  15650. }
  15651. // AddField adds the value to the field with the given name. It returns an error if
  15652. // the field is not defined in the schema, or if the type mismatched the field
  15653. // type.
  15654. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  15655. switch name {
  15656. case employeeconfig.FieldOrganizationID:
  15657. v, ok := value.(int64)
  15658. if !ok {
  15659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15660. }
  15661. m.AddOrganizationID(v)
  15662. return nil
  15663. }
  15664. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  15665. }
  15666. // ClearedFields returns all nullable fields that were cleared during this
  15667. // mutation.
  15668. func (m *EmployeeConfigMutation) ClearedFields() []string {
  15669. var fields []string
  15670. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  15671. fields = append(fields, employeeconfig.FieldDeletedAt)
  15672. }
  15673. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  15674. fields = append(fields, employeeconfig.FieldOrganizationID)
  15675. }
  15676. return fields
  15677. }
  15678. // FieldCleared returns a boolean indicating if a field with the given name was
  15679. // cleared in this mutation.
  15680. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  15681. _, ok := m.clearedFields[name]
  15682. return ok
  15683. }
  15684. // ClearField clears the value of the field with the given name. It returns an
  15685. // error if the field is not defined in the schema.
  15686. func (m *EmployeeConfigMutation) ClearField(name string) error {
  15687. switch name {
  15688. case employeeconfig.FieldDeletedAt:
  15689. m.ClearDeletedAt()
  15690. return nil
  15691. case employeeconfig.FieldOrganizationID:
  15692. m.ClearOrganizationID()
  15693. return nil
  15694. }
  15695. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  15696. }
  15697. // ResetField resets all changes in the mutation for the field with the given name.
  15698. // It returns an error if the field is not defined in the schema.
  15699. func (m *EmployeeConfigMutation) ResetField(name string) error {
  15700. switch name {
  15701. case employeeconfig.FieldCreatedAt:
  15702. m.ResetCreatedAt()
  15703. return nil
  15704. case employeeconfig.FieldUpdatedAt:
  15705. m.ResetUpdatedAt()
  15706. return nil
  15707. case employeeconfig.FieldDeletedAt:
  15708. m.ResetDeletedAt()
  15709. return nil
  15710. case employeeconfig.FieldStype:
  15711. m.ResetStype()
  15712. return nil
  15713. case employeeconfig.FieldTitle:
  15714. m.ResetTitle()
  15715. return nil
  15716. case employeeconfig.FieldPhoto:
  15717. m.ResetPhoto()
  15718. return nil
  15719. case employeeconfig.FieldOrganizationID:
  15720. m.ResetOrganizationID()
  15721. return nil
  15722. }
  15723. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15724. }
  15725. // AddedEdges returns all edge names that were set/added in this mutation.
  15726. func (m *EmployeeConfigMutation) AddedEdges() []string {
  15727. edges := make([]string, 0, 0)
  15728. return edges
  15729. }
  15730. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15731. // name in this mutation.
  15732. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  15733. return nil
  15734. }
  15735. // RemovedEdges returns all edge names that were removed in this mutation.
  15736. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  15737. edges := make([]string, 0, 0)
  15738. return edges
  15739. }
  15740. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15741. // the given name in this mutation.
  15742. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  15743. return nil
  15744. }
  15745. // ClearedEdges returns all edge names that were cleared in this mutation.
  15746. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  15747. edges := make([]string, 0, 0)
  15748. return edges
  15749. }
  15750. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15751. // was cleared in this mutation.
  15752. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  15753. return false
  15754. }
  15755. // ClearEdge clears the value of the edge with the given name. It returns an error
  15756. // if that edge is not defined in the schema.
  15757. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  15758. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  15759. }
  15760. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15761. // It returns an error if the edge is not defined in the schema.
  15762. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  15763. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  15764. }
  15765. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  15766. type LabelMutation struct {
  15767. config
  15768. op Op
  15769. typ string
  15770. id *uint64
  15771. created_at *time.Time
  15772. updated_at *time.Time
  15773. status *uint8
  15774. addstatus *int8
  15775. _type *int
  15776. add_type *int
  15777. name *string
  15778. from *int
  15779. addfrom *int
  15780. mode *int
  15781. addmode *int
  15782. conditions *string
  15783. organization_id *uint64
  15784. addorganization_id *int64
  15785. clearedFields map[string]struct{}
  15786. label_relationships map[uint64]struct{}
  15787. removedlabel_relationships map[uint64]struct{}
  15788. clearedlabel_relationships bool
  15789. done bool
  15790. oldValue func(context.Context) (*Label, error)
  15791. predicates []predicate.Label
  15792. }
  15793. var _ ent.Mutation = (*LabelMutation)(nil)
  15794. // labelOption allows management of the mutation configuration using functional options.
  15795. type labelOption func(*LabelMutation)
  15796. // newLabelMutation creates new mutation for the Label entity.
  15797. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  15798. m := &LabelMutation{
  15799. config: c,
  15800. op: op,
  15801. typ: TypeLabel,
  15802. clearedFields: make(map[string]struct{}),
  15803. }
  15804. for _, opt := range opts {
  15805. opt(m)
  15806. }
  15807. return m
  15808. }
  15809. // withLabelID sets the ID field of the mutation.
  15810. func withLabelID(id uint64) labelOption {
  15811. return func(m *LabelMutation) {
  15812. var (
  15813. err error
  15814. once sync.Once
  15815. value *Label
  15816. )
  15817. m.oldValue = func(ctx context.Context) (*Label, error) {
  15818. once.Do(func() {
  15819. if m.done {
  15820. err = errors.New("querying old values post mutation is not allowed")
  15821. } else {
  15822. value, err = m.Client().Label.Get(ctx, id)
  15823. }
  15824. })
  15825. return value, err
  15826. }
  15827. m.id = &id
  15828. }
  15829. }
  15830. // withLabel sets the old Label of the mutation.
  15831. func withLabel(node *Label) labelOption {
  15832. return func(m *LabelMutation) {
  15833. m.oldValue = func(context.Context) (*Label, error) {
  15834. return node, nil
  15835. }
  15836. m.id = &node.ID
  15837. }
  15838. }
  15839. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15840. // executed in a transaction (ent.Tx), a transactional client is returned.
  15841. func (m LabelMutation) Client() *Client {
  15842. client := &Client{config: m.config}
  15843. client.init()
  15844. return client
  15845. }
  15846. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15847. // it returns an error otherwise.
  15848. func (m LabelMutation) Tx() (*Tx, error) {
  15849. if _, ok := m.driver.(*txDriver); !ok {
  15850. return nil, errors.New("ent: mutation is not running in a transaction")
  15851. }
  15852. tx := &Tx{config: m.config}
  15853. tx.init()
  15854. return tx, nil
  15855. }
  15856. // SetID sets the value of the id field. Note that this
  15857. // operation is only accepted on creation of Label entities.
  15858. func (m *LabelMutation) SetID(id uint64) {
  15859. m.id = &id
  15860. }
  15861. // ID returns the ID value in the mutation. Note that the ID is only available
  15862. // if it was provided to the builder or after it was returned from the database.
  15863. func (m *LabelMutation) ID() (id uint64, exists bool) {
  15864. if m.id == nil {
  15865. return
  15866. }
  15867. return *m.id, true
  15868. }
  15869. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15870. // That means, if the mutation is applied within a transaction with an isolation level such
  15871. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15872. // or updated by the mutation.
  15873. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  15874. switch {
  15875. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15876. id, exists := m.ID()
  15877. if exists {
  15878. return []uint64{id}, nil
  15879. }
  15880. fallthrough
  15881. case m.op.Is(OpUpdate | OpDelete):
  15882. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  15883. default:
  15884. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15885. }
  15886. }
  15887. // SetCreatedAt sets the "created_at" field.
  15888. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  15889. m.created_at = &t
  15890. }
  15891. // CreatedAt returns the value of the "created_at" field in the mutation.
  15892. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  15893. v := m.created_at
  15894. if v == nil {
  15895. return
  15896. }
  15897. return *v, true
  15898. }
  15899. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  15900. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15902. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15903. if !m.op.Is(OpUpdateOne) {
  15904. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15905. }
  15906. if m.id == nil || m.oldValue == nil {
  15907. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15908. }
  15909. oldValue, err := m.oldValue(ctx)
  15910. if err != nil {
  15911. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15912. }
  15913. return oldValue.CreatedAt, nil
  15914. }
  15915. // ResetCreatedAt resets all changes to the "created_at" field.
  15916. func (m *LabelMutation) ResetCreatedAt() {
  15917. m.created_at = nil
  15918. }
  15919. // SetUpdatedAt sets the "updated_at" field.
  15920. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  15921. m.updated_at = &t
  15922. }
  15923. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15924. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  15925. v := m.updated_at
  15926. if v == nil {
  15927. return
  15928. }
  15929. return *v, true
  15930. }
  15931. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  15932. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15934. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15935. if !m.op.Is(OpUpdateOne) {
  15936. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15937. }
  15938. if m.id == nil || m.oldValue == nil {
  15939. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15940. }
  15941. oldValue, err := m.oldValue(ctx)
  15942. if err != nil {
  15943. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15944. }
  15945. return oldValue.UpdatedAt, nil
  15946. }
  15947. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15948. func (m *LabelMutation) ResetUpdatedAt() {
  15949. m.updated_at = nil
  15950. }
  15951. // SetStatus sets the "status" field.
  15952. func (m *LabelMutation) SetStatus(u uint8) {
  15953. m.status = &u
  15954. m.addstatus = nil
  15955. }
  15956. // Status returns the value of the "status" field in the mutation.
  15957. func (m *LabelMutation) Status() (r uint8, exists bool) {
  15958. v := m.status
  15959. if v == nil {
  15960. return
  15961. }
  15962. return *v, true
  15963. }
  15964. // OldStatus returns the old "status" field's value of the Label entity.
  15965. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15967. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15968. if !m.op.Is(OpUpdateOne) {
  15969. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15970. }
  15971. if m.id == nil || m.oldValue == nil {
  15972. return v, errors.New("OldStatus requires an ID field in the mutation")
  15973. }
  15974. oldValue, err := m.oldValue(ctx)
  15975. if err != nil {
  15976. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15977. }
  15978. return oldValue.Status, nil
  15979. }
  15980. // AddStatus adds u to the "status" field.
  15981. func (m *LabelMutation) AddStatus(u int8) {
  15982. if m.addstatus != nil {
  15983. *m.addstatus += u
  15984. } else {
  15985. m.addstatus = &u
  15986. }
  15987. }
  15988. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15989. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  15990. v := m.addstatus
  15991. if v == nil {
  15992. return
  15993. }
  15994. return *v, true
  15995. }
  15996. // ClearStatus clears the value of the "status" field.
  15997. func (m *LabelMutation) ClearStatus() {
  15998. m.status = nil
  15999. m.addstatus = nil
  16000. m.clearedFields[label.FieldStatus] = struct{}{}
  16001. }
  16002. // StatusCleared returns if the "status" field was cleared in this mutation.
  16003. func (m *LabelMutation) StatusCleared() bool {
  16004. _, ok := m.clearedFields[label.FieldStatus]
  16005. return ok
  16006. }
  16007. // ResetStatus resets all changes to the "status" field.
  16008. func (m *LabelMutation) ResetStatus() {
  16009. m.status = nil
  16010. m.addstatus = nil
  16011. delete(m.clearedFields, label.FieldStatus)
  16012. }
  16013. // SetType sets the "type" field.
  16014. func (m *LabelMutation) SetType(i int) {
  16015. m._type = &i
  16016. m.add_type = nil
  16017. }
  16018. // GetType returns the value of the "type" field in the mutation.
  16019. func (m *LabelMutation) GetType() (r int, exists bool) {
  16020. v := m._type
  16021. if v == nil {
  16022. return
  16023. }
  16024. return *v, true
  16025. }
  16026. // OldType returns the old "type" field's value of the Label entity.
  16027. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16029. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  16030. if !m.op.Is(OpUpdateOne) {
  16031. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16032. }
  16033. if m.id == nil || m.oldValue == nil {
  16034. return v, errors.New("OldType requires an ID field in the mutation")
  16035. }
  16036. oldValue, err := m.oldValue(ctx)
  16037. if err != nil {
  16038. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16039. }
  16040. return oldValue.Type, nil
  16041. }
  16042. // AddType adds i to the "type" field.
  16043. func (m *LabelMutation) AddType(i int) {
  16044. if m.add_type != nil {
  16045. *m.add_type += i
  16046. } else {
  16047. m.add_type = &i
  16048. }
  16049. }
  16050. // AddedType returns the value that was added to the "type" field in this mutation.
  16051. func (m *LabelMutation) AddedType() (r int, exists bool) {
  16052. v := m.add_type
  16053. if v == nil {
  16054. return
  16055. }
  16056. return *v, true
  16057. }
  16058. // ResetType resets all changes to the "type" field.
  16059. func (m *LabelMutation) ResetType() {
  16060. m._type = nil
  16061. m.add_type = nil
  16062. }
  16063. // SetName sets the "name" field.
  16064. func (m *LabelMutation) SetName(s string) {
  16065. m.name = &s
  16066. }
  16067. // Name returns the value of the "name" field in the mutation.
  16068. func (m *LabelMutation) Name() (r string, exists bool) {
  16069. v := m.name
  16070. if v == nil {
  16071. return
  16072. }
  16073. return *v, true
  16074. }
  16075. // OldName returns the old "name" field's value of the Label entity.
  16076. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16078. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  16079. if !m.op.Is(OpUpdateOne) {
  16080. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16081. }
  16082. if m.id == nil || m.oldValue == nil {
  16083. return v, errors.New("OldName requires an ID field in the mutation")
  16084. }
  16085. oldValue, err := m.oldValue(ctx)
  16086. if err != nil {
  16087. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16088. }
  16089. return oldValue.Name, nil
  16090. }
  16091. // ResetName resets all changes to the "name" field.
  16092. func (m *LabelMutation) ResetName() {
  16093. m.name = nil
  16094. }
  16095. // SetFrom sets the "from" field.
  16096. func (m *LabelMutation) SetFrom(i int) {
  16097. m.from = &i
  16098. m.addfrom = nil
  16099. }
  16100. // From returns the value of the "from" field in the mutation.
  16101. func (m *LabelMutation) From() (r int, exists bool) {
  16102. v := m.from
  16103. if v == nil {
  16104. return
  16105. }
  16106. return *v, true
  16107. }
  16108. // OldFrom returns the old "from" field's value of the Label entity.
  16109. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16111. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16112. if !m.op.Is(OpUpdateOne) {
  16113. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16114. }
  16115. if m.id == nil || m.oldValue == nil {
  16116. return v, errors.New("OldFrom requires an ID field in the mutation")
  16117. }
  16118. oldValue, err := m.oldValue(ctx)
  16119. if err != nil {
  16120. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16121. }
  16122. return oldValue.From, nil
  16123. }
  16124. // AddFrom adds i to the "from" field.
  16125. func (m *LabelMutation) AddFrom(i int) {
  16126. if m.addfrom != nil {
  16127. *m.addfrom += i
  16128. } else {
  16129. m.addfrom = &i
  16130. }
  16131. }
  16132. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16133. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16134. v := m.addfrom
  16135. if v == nil {
  16136. return
  16137. }
  16138. return *v, true
  16139. }
  16140. // ResetFrom resets all changes to the "from" field.
  16141. func (m *LabelMutation) ResetFrom() {
  16142. m.from = nil
  16143. m.addfrom = nil
  16144. }
  16145. // SetMode sets the "mode" field.
  16146. func (m *LabelMutation) SetMode(i int) {
  16147. m.mode = &i
  16148. m.addmode = nil
  16149. }
  16150. // Mode returns the value of the "mode" field in the mutation.
  16151. func (m *LabelMutation) Mode() (r int, exists bool) {
  16152. v := m.mode
  16153. if v == nil {
  16154. return
  16155. }
  16156. return *v, true
  16157. }
  16158. // OldMode returns the old "mode" field's value of the Label entity.
  16159. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16161. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16162. if !m.op.Is(OpUpdateOne) {
  16163. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16164. }
  16165. if m.id == nil || m.oldValue == nil {
  16166. return v, errors.New("OldMode requires an ID field in the mutation")
  16167. }
  16168. oldValue, err := m.oldValue(ctx)
  16169. if err != nil {
  16170. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16171. }
  16172. return oldValue.Mode, nil
  16173. }
  16174. // AddMode adds i to the "mode" field.
  16175. func (m *LabelMutation) AddMode(i int) {
  16176. if m.addmode != nil {
  16177. *m.addmode += i
  16178. } else {
  16179. m.addmode = &i
  16180. }
  16181. }
  16182. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16183. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16184. v := m.addmode
  16185. if v == nil {
  16186. return
  16187. }
  16188. return *v, true
  16189. }
  16190. // ResetMode resets all changes to the "mode" field.
  16191. func (m *LabelMutation) ResetMode() {
  16192. m.mode = nil
  16193. m.addmode = nil
  16194. }
  16195. // SetConditions sets the "conditions" field.
  16196. func (m *LabelMutation) SetConditions(s string) {
  16197. m.conditions = &s
  16198. }
  16199. // Conditions returns the value of the "conditions" field in the mutation.
  16200. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16201. v := m.conditions
  16202. if v == nil {
  16203. return
  16204. }
  16205. return *v, true
  16206. }
  16207. // OldConditions returns the old "conditions" field's value of the Label entity.
  16208. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16210. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16211. if !m.op.Is(OpUpdateOne) {
  16212. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16213. }
  16214. if m.id == nil || m.oldValue == nil {
  16215. return v, errors.New("OldConditions requires an ID field in the mutation")
  16216. }
  16217. oldValue, err := m.oldValue(ctx)
  16218. if err != nil {
  16219. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16220. }
  16221. return oldValue.Conditions, nil
  16222. }
  16223. // ClearConditions clears the value of the "conditions" field.
  16224. func (m *LabelMutation) ClearConditions() {
  16225. m.conditions = nil
  16226. m.clearedFields[label.FieldConditions] = struct{}{}
  16227. }
  16228. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16229. func (m *LabelMutation) ConditionsCleared() bool {
  16230. _, ok := m.clearedFields[label.FieldConditions]
  16231. return ok
  16232. }
  16233. // ResetConditions resets all changes to the "conditions" field.
  16234. func (m *LabelMutation) ResetConditions() {
  16235. m.conditions = nil
  16236. delete(m.clearedFields, label.FieldConditions)
  16237. }
  16238. // SetOrganizationID sets the "organization_id" field.
  16239. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16240. m.organization_id = &u
  16241. m.addorganization_id = nil
  16242. }
  16243. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16244. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16245. v := m.organization_id
  16246. if v == nil {
  16247. return
  16248. }
  16249. return *v, true
  16250. }
  16251. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16252. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16254. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16255. if !m.op.Is(OpUpdateOne) {
  16256. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16257. }
  16258. if m.id == nil || m.oldValue == nil {
  16259. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16260. }
  16261. oldValue, err := m.oldValue(ctx)
  16262. if err != nil {
  16263. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16264. }
  16265. return oldValue.OrganizationID, nil
  16266. }
  16267. // AddOrganizationID adds u to the "organization_id" field.
  16268. func (m *LabelMutation) AddOrganizationID(u int64) {
  16269. if m.addorganization_id != nil {
  16270. *m.addorganization_id += u
  16271. } else {
  16272. m.addorganization_id = &u
  16273. }
  16274. }
  16275. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16276. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16277. v := m.addorganization_id
  16278. if v == nil {
  16279. return
  16280. }
  16281. return *v, true
  16282. }
  16283. // ClearOrganizationID clears the value of the "organization_id" field.
  16284. func (m *LabelMutation) ClearOrganizationID() {
  16285. m.organization_id = nil
  16286. m.addorganization_id = nil
  16287. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16288. }
  16289. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16290. func (m *LabelMutation) OrganizationIDCleared() bool {
  16291. _, ok := m.clearedFields[label.FieldOrganizationID]
  16292. return ok
  16293. }
  16294. // ResetOrganizationID resets all changes to the "organization_id" field.
  16295. func (m *LabelMutation) ResetOrganizationID() {
  16296. m.organization_id = nil
  16297. m.addorganization_id = nil
  16298. delete(m.clearedFields, label.FieldOrganizationID)
  16299. }
  16300. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16301. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16302. if m.label_relationships == nil {
  16303. m.label_relationships = make(map[uint64]struct{})
  16304. }
  16305. for i := range ids {
  16306. m.label_relationships[ids[i]] = struct{}{}
  16307. }
  16308. }
  16309. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16310. func (m *LabelMutation) ClearLabelRelationships() {
  16311. m.clearedlabel_relationships = true
  16312. }
  16313. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16314. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16315. return m.clearedlabel_relationships
  16316. }
  16317. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16318. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16319. if m.removedlabel_relationships == nil {
  16320. m.removedlabel_relationships = make(map[uint64]struct{})
  16321. }
  16322. for i := range ids {
  16323. delete(m.label_relationships, ids[i])
  16324. m.removedlabel_relationships[ids[i]] = struct{}{}
  16325. }
  16326. }
  16327. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16328. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16329. for id := range m.removedlabel_relationships {
  16330. ids = append(ids, id)
  16331. }
  16332. return
  16333. }
  16334. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16335. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16336. for id := range m.label_relationships {
  16337. ids = append(ids, id)
  16338. }
  16339. return
  16340. }
  16341. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16342. func (m *LabelMutation) ResetLabelRelationships() {
  16343. m.label_relationships = nil
  16344. m.clearedlabel_relationships = false
  16345. m.removedlabel_relationships = nil
  16346. }
  16347. // Where appends a list predicates to the LabelMutation builder.
  16348. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16349. m.predicates = append(m.predicates, ps...)
  16350. }
  16351. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16352. // users can use type-assertion to append predicates that do not depend on any generated package.
  16353. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16354. p := make([]predicate.Label, len(ps))
  16355. for i := range ps {
  16356. p[i] = ps[i]
  16357. }
  16358. m.Where(p...)
  16359. }
  16360. // Op returns the operation name.
  16361. func (m *LabelMutation) Op() Op {
  16362. return m.op
  16363. }
  16364. // SetOp allows setting the mutation operation.
  16365. func (m *LabelMutation) SetOp(op Op) {
  16366. m.op = op
  16367. }
  16368. // Type returns the node type of this mutation (Label).
  16369. func (m *LabelMutation) Type() string {
  16370. return m.typ
  16371. }
  16372. // Fields returns all fields that were changed during this mutation. Note that in
  16373. // order to get all numeric fields that were incremented/decremented, call
  16374. // AddedFields().
  16375. func (m *LabelMutation) Fields() []string {
  16376. fields := make([]string, 0, 9)
  16377. if m.created_at != nil {
  16378. fields = append(fields, label.FieldCreatedAt)
  16379. }
  16380. if m.updated_at != nil {
  16381. fields = append(fields, label.FieldUpdatedAt)
  16382. }
  16383. if m.status != nil {
  16384. fields = append(fields, label.FieldStatus)
  16385. }
  16386. if m._type != nil {
  16387. fields = append(fields, label.FieldType)
  16388. }
  16389. if m.name != nil {
  16390. fields = append(fields, label.FieldName)
  16391. }
  16392. if m.from != nil {
  16393. fields = append(fields, label.FieldFrom)
  16394. }
  16395. if m.mode != nil {
  16396. fields = append(fields, label.FieldMode)
  16397. }
  16398. if m.conditions != nil {
  16399. fields = append(fields, label.FieldConditions)
  16400. }
  16401. if m.organization_id != nil {
  16402. fields = append(fields, label.FieldOrganizationID)
  16403. }
  16404. return fields
  16405. }
  16406. // Field returns the value of a field with the given name. The second boolean
  16407. // return value indicates that this field was not set, or was not defined in the
  16408. // schema.
  16409. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16410. switch name {
  16411. case label.FieldCreatedAt:
  16412. return m.CreatedAt()
  16413. case label.FieldUpdatedAt:
  16414. return m.UpdatedAt()
  16415. case label.FieldStatus:
  16416. return m.Status()
  16417. case label.FieldType:
  16418. return m.GetType()
  16419. case label.FieldName:
  16420. return m.Name()
  16421. case label.FieldFrom:
  16422. return m.From()
  16423. case label.FieldMode:
  16424. return m.Mode()
  16425. case label.FieldConditions:
  16426. return m.Conditions()
  16427. case label.FieldOrganizationID:
  16428. return m.OrganizationID()
  16429. }
  16430. return nil, false
  16431. }
  16432. // OldField returns the old value of the field from the database. An error is
  16433. // returned if the mutation operation is not UpdateOne, or the query to the
  16434. // database failed.
  16435. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16436. switch name {
  16437. case label.FieldCreatedAt:
  16438. return m.OldCreatedAt(ctx)
  16439. case label.FieldUpdatedAt:
  16440. return m.OldUpdatedAt(ctx)
  16441. case label.FieldStatus:
  16442. return m.OldStatus(ctx)
  16443. case label.FieldType:
  16444. return m.OldType(ctx)
  16445. case label.FieldName:
  16446. return m.OldName(ctx)
  16447. case label.FieldFrom:
  16448. return m.OldFrom(ctx)
  16449. case label.FieldMode:
  16450. return m.OldMode(ctx)
  16451. case label.FieldConditions:
  16452. return m.OldConditions(ctx)
  16453. case label.FieldOrganizationID:
  16454. return m.OldOrganizationID(ctx)
  16455. }
  16456. return nil, fmt.Errorf("unknown Label field %s", name)
  16457. }
  16458. // SetField sets the value of a field with the given name. It returns an error if
  16459. // the field is not defined in the schema, or if the type mismatched the field
  16460. // type.
  16461. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16462. switch name {
  16463. case label.FieldCreatedAt:
  16464. v, ok := value.(time.Time)
  16465. if !ok {
  16466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16467. }
  16468. m.SetCreatedAt(v)
  16469. return nil
  16470. case label.FieldUpdatedAt:
  16471. v, ok := value.(time.Time)
  16472. if !ok {
  16473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16474. }
  16475. m.SetUpdatedAt(v)
  16476. return nil
  16477. case label.FieldStatus:
  16478. v, ok := value.(uint8)
  16479. if !ok {
  16480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16481. }
  16482. m.SetStatus(v)
  16483. return nil
  16484. case label.FieldType:
  16485. v, ok := value.(int)
  16486. if !ok {
  16487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16488. }
  16489. m.SetType(v)
  16490. return nil
  16491. case label.FieldName:
  16492. v, ok := value.(string)
  16493. if !ok {
  16494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16495. }
  16496. m.SetName(v)
  16497. return nil
  16498. case label.FieldFrom:
  16499. v, ok := value.(int)
  16500. if !ok {
  16501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16502. }
  16503. m.SetFrom(v)
  16504. return nil
  16505. case label.FieldMode:
  16506. v, ok := value.(int)
  16507. if !ok {
  16508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16509. }
  16510. m.SetMode(v)
  16511. return nil
  16512. case label.FieldConditions:
  16513. v, ok := value.(string)
  16514. if !ok {
  16515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16516. }
  16517. m.SetConditions(v)
  16518. return nil
  16519. case label.FieldOrganizationID:
  16520. v, ok := value.(uint64)
  16521. if !ok {
  16522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16523. }
  16524. m.SetOrganizationID(v)
  16525. return nil
  16526. }
  16527. return fmt.Errorf("unknown Label field %s", name)
  16528. }
  16529. // AddedFields returns all numeric fields that were incremented/decremented during
  16530. // this mutation.
  16531. func (m *LabelMutation) AddedFields() []string {
  16532. var fields []string
  16533. if m.addstatus != nil {
  16534. fields = append(fields, label.FieldStatus)
  16535. }
  16536. if m.add_type != nil {
  16537. fields = append(fields, label.FieldType)
  16538. }
  16539. if m.addfrom != nil {
  16540. fields = append(fields, label.FieldFrom)
  16541. }
  16542. if m.addmode != nil {
  16543. fields = append(fields, label.FieldMode)
  16544. }
  16545. if m.addorganization_id != nil {
  16546. fields = append(fields, label.FieldOrganizationID)
  16547. }
  16548. return fields
  16549. }
  16550. // AddedField returns the numeric value that was incremented/decremented on a field
  16551. // with the given name. The second boolean return value indicates that this field
  16552. // was not set, or was not defined in the schema.
  16553. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16554. switch name {
  16555. case label.FieldStatus:
  16556. return m.AddedStatus()
  16557. case label.FieldType:
  16558. return m.AddedType()
  16559. case label.FieldFrom:
  16560. return m.AddedFrom()
  16561. case label.FieldMode:
  16562. return m.AddedMode()
  16563. case label.FieldOrganizationID:
  16564. return m.AddedOrganizationID()
  16565. }
  16566. return nil, false
  16567. }
  16568. // AddField adds the value to the field with the given name. It returns an error if
  16569. // the field is not defined in the schema, or if the type mismatched the field
  16570. // type.
  16571. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16572. switch name {
  16573. case label.FieldStatus:
  16574. v, ok := value.(int8)
  16575. if !ok {
  16576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16577. }
  16578. m.AddStatus(v)
  16579. return nil
  16580. case label.FieldType:
  16581. v, ok := value.(int)
  16582. if !ok {
  16583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16584. }
  16585. m.AddType(v)
  16586. return nil
  16587. case label.FieldFrom:
  16588. v, ok := value.(int)
  16589. if !ok {
  16590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16591. }
  16592. m.AddFrom(v)
  16593. return nil
  16594. case label.FieldMode:
  16595. v, ok := value.(int)
  16596. if !ok {
  16597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16598. }
  16599. m.AddMode(v)
  16600. return nil
  16601. case label.FieldOrganizationID:
  16602. v, ok := value.(int64)
  16603. if !ok {
  16604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16605. }
  16606. m.AddOrganizationID(v)
  16607. return nil
  16608. }
  16609. return fmt.Errorf("unknown Label numeric field %s", name)
  16610. }
  16611. // ClearedFields returns all nullable fields that were cleared during this
  16612. // mutation.
  16613. func (m *LabelMutation) ClearedFields() []string {
  16614. var fields []string
  16615. if m.FieldCleared(label.FieldStatus) {
  16616. fields = append(fields, label.FieldStatus)
  16617. }
  16618. if m.FieldCleared(label.FieldConditions) {
  16619. fields = append(fields, label.FieldConditions)
  16620. }
  16621. if m.FieldCleared(label.FieldOrganizationID) {
  16622. fields = append(fields, label.FieldOrganizationID)
  16623. }
  16624. return fields
  16625. }
  16626. // FieldCleared returns a boolean indicating if a field with the given name was
  16627. // cleared in this mutation.
  16628. func (m *LabelMutation) FieldCleared(name string) bool {
  16629. _, ok := m.clearedFields[name]
  16630. return ok
  16631. }
  16632. // ClearField clears the value of the field with the given name. It returns an
  16633. // error if the field is not defined in the schema.
  16634. func (m *LabelMutation) ClearField(name string) error {
  16635. switch name {
  16636. case label.FieldStatus:
  16637. m.ClearStatus()
  16638. return nil
  16639. case label.FieldConditions:
  16640. m.ClearConditions()
  16641. return nil
  16642. case label.FieldOrganizationID:
  16643. m.ClearOrganizationID()
  16644. return nil
  16645. }
  16646. return fmt.Errorf("unknown Label nullable field %s", name)
  16647. }
  16648. // ResetField resets all changes in the mutation for the field with the given name.
  16649. // It returns an error if the field is not defined in the schema.
  16650. func (m *LabelMutation) ResetField(name string) error {
  16651. switch name {
  16652. case label.FieldCreatedAt:
  16653. m.ResetCreatedAt()
  16654. return nil
  16655. case label.FieldUpdatedAt:
  16656. m.ResetUpdatedAt()
  16657. return nil
  16658. case label.FieldStatus:
  16659. m.ResetStatus()
  16660. return nil
  16661. case label.FieldType:
  16662. m.ResetType()
  16663. return nil
  16664. case label.FieldName:
  16665. m.ResetName()
  16666. return nil
  16667. case label.FieldFrom:
  16668. m.ResetFrom()
  16669. return nil
  16670. case label.FieldMode:
  16671. m.ResetMode()
  16672. return nil
  16673. case label.FieldConditions:
  16674. m.ResetConditions()
  16675. return nil
  16676. case label.FieldOrganizationID:
  16677. m.ResetOrganizationID()
  16678. return nil
  16679. }
  16680. return fmt.Errorf("unknown Label field %s", name)
  16681. }
  16682. // AddedEdges returns all edge names that were set/added in this mutation.
  16683. func (m *LabelMutation) AddedEdges() []string {
  16684. edges := make([]string, 0, 1)
  16685. if m.label_relationships != nil {
  16686. edges = append(edges, label.EdgeLabelRelationships)
  16687. }
  16688. return edges
  16689. }
  16690. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16691. // name in this mutation.
  16692. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  16693. switch name {
  16694. case label.EdgeLabelRelationships:
  16695. ids := make([]ent.Value, 0, len(m.label_relationships))
  16696. for id := range m.label_relationships {
  16697. ids = append(ids, id)
  16698. }
  16699. return ids
  16700. }
  16701. return nil
  16702. }
  16703. // RemovedEdges returns all edge names that were removed in this mutation.
  16704. func (m *LabelMutation) RemovedEdges() []string {
  16705. edges := make([]string, 0, 1)
  16706. if m.removedlabel_relationships != nil {
  16707. edges = append(edges, label.EdgeLabelRelationships)
  16708. }
  16709. return edges
  16710. }
  16711. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16712. // the given name in this mutation.
  16713. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  16714. switch name {
  16715. case label.EdgeLabelRelationships:
  16716. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  16717. for id := range m.removedlabel_relationships {
  16718. ids = append(ids, id)
  16719. }
  16720. return ids
  16721. }
  16722. return nil
  16723. }
  16724. // ClearedEdges returns all edge names that were cleared in this mutation.
  16725. func (m *LabelMutation) ClearedEdges() []string {
  16726. edges := make([]string, 0, 1)
  16727. if m.clearedlabel_relationships {
  16728. edges = append(edges, label.EdgeLabelRelationships)
  16729. }
  16730. return edges
  16731. }
  16732. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16733. // was cleared in this mutation.
  16734. func (m *LabelMutation) EdgeCleared(name string) bool {
  16735. switch name {
  16736. case label.EdgeLabelRelationships:
  16737. return m.clearedlabel_relationships
  16738. }
  16739. return false
  16740. }
  16741. // ClearEdge clears the value of the edge with the given name. It returns an error
  16742. // if that edge is not defined in the schema.
  16743. func (m *LabelMutation) ClearEdge(name string) error {
  16744. switch name {
  16745. }
  16746. return fmt.Errorf("unknown Label unique edge %s", name)
  16747. }
  16748. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16749. // It returns an error if the edge is not defined in the schema.
  16750. func (m *LabelMutation) ResetEdge(name string) error {
  16751. switch name {
  16752. case label.EdgeLabelRelationships:
  16753. m.ResetLabelRelationships()
  16754. return nil
  16755. }
  16756. return fmt.Errorf("unknown Label edge %s", name)
  16757. }
  16758. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  16759. type LabelRelationshipMutation struct {
  16760. config
  16761. op Op
  16762. typ string
  16763. id *uint64
  16764. created_at *time.Time
  16765. updated_at *time.Time
  16766. status *uint8
  16767. addstatus *int8
  16768. organization_id *uint64
  16769. addorganization_id *int64
  16770. clearedFields map[string]struct{}
  16771. contacts *uint64
  16772. clearedcontacts bool
  16773. labels *uint64
  16774. clearedlabels bool
  16775. done bool
  16776. oldValue func(context.Context) (*LabelRelationship, error)
  16777. predicates []predicate.LabelRelationship
  16778. }
  16779. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  16780. // labelrelationshipOption allows management of the mutation configuration using functional options.
  16781. type labelrelationshipOption func(*LabelRelationshipMutation)
  16782. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  16783. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  16784. m := &LabelRelationshipMutation{
  16785. config: c,
  16786. op: op,
  16787. typ: TypeLabelRelationship,
  16788. clearedFields: make(map[string]struct{}),
  16789. }
  16790. for _, opt := range opts {
  16791. opt(m)
  16792. }
  16793. return m
  16794. }
  16795. // withLabelRelationshipID sets the ID field of the mutation.
  16796. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  16797. return func(m *LabelRelationshipMutation) {
  16798. var (
  16799. err error
  16800. once sync.Once
  16801. value *LabelRelationship
  16802. )
  16803. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  16804. once.Do(func() {
  16805. if m.done {
  16806. err = errors.New("querying old values post mutation is not allowed")
  16807. } else {
  16808. value, err = m.Client().LabelRelationship.Get(ctx, id)
  16809. }
  16810. })
  16811. return value, err
  16812. }
  16813. m.id = &id
  16814. }
  16815. }
  16816. // withLabelRelationship sets the old LabelRelationship of the mutation.
  16817. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  16818. return func(m *LabelRelationshipMutation) {
  16819. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  16820. return node, nil
  16821. }
  16822. m.id = &node.ID
  16823. }
  16824. }
  16825. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16826. // executed in a transaction (ent.Tx), a transactional client is returned.
  16827. func (m LabelRelationshipMutation) Client() *Client {
  16828. client := &Client{config: m.config}
  16829. client.init()
  16830. return client
  16831. }
  16832. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16833. // it returns an error otherwise.
  16834. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  16835. if _, ok := m.driver.(*txDriver); !ok {
  16836. return nil, errors.New("ent: mutation is not running in a transaction")
  16837. }
  16838. tx := &Tx{config: m.config}
  16839. tx.init()
  16840. return tx, nil
  16841. }
  16842. // SetID sets the value of the id field. Note that this
  16843. // operation is only accepted on creation of LabelRelationship entities.
  16844. func (m *LabelRelationshipMutation) SetID(id uint64) {
  16845. m.id = &id
  16846. }
  16847. // ID returns the ID value in the mutation. Note that the ID is only available
  16848. // if it was provided to the builder or after it was returned from the database.
  16849. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  16850. if m.id == nil {
  16851. return
  16852. }
  16853. return *m.id, true
  16854. }
  16855. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16856. // That means, if the mutation is applied within a transaction with an isolation level such
  16857. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16858. // or updated by the mutation.
  16859. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  16860. switch {
  16861. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16862. id, exists := m.ID()
  16863. if exists {
  16864. return []uint64{id}, nil
  16865. }
  16866. fallthrough
  16867. case m.op.Is(OpUpdate | OpDelete):
  16868. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  16869. default:
  16870. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16871. }
  16872. }
  16873. // SetCreatedAt sets the "created_at" field.
  16874. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  16875. m.created_at = &t
  16876. }
  16877. // CreatedAt returns the value of the "created_at" field in the mutation.
  16878. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  16879. v := m.created_at
  16880. if v == nil {
  16881. return
  16882. }
  16883. return *v, true
  16884. }
  16885. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  16886. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16888. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16889. if !m.op.Is(OpUpdateOne) {
  16890. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16891. }
  16892. if m.id == nil || m.oldValue == nil {
  16893. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16894. }
  16895. oldValue, err := m.oldValue(ctx)
  16896. if err != nil {
  16897. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16898. }
  16899. return oldValue.CreatedAt, nil
  16900. }
  16901. // ResetCreatedAt resets all changes to the "created_at" field.
  16902. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  16903. m.created_at = nil
  16904. }
  16905. // SetUpdatedAt sets the "updated_at" field.
  16906. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  16907. m.updated_at = &t
  16908. }
  16909. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16910. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  16911. v := m.updated_at
  16912. if v == nil {
  16913. return
  16914. }
  16915. return *v, true
  16916. }
  16917. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  16918. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16920. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16921. if !m.op.Is(OpUpdateOne) {
  16922. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16923. }
  16924. if m.id == nil || m.oldValue == nil {
  16925. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16926. }
  16927. oldValue, err := m.oldValue(ctx)
  16928. if err != nil {
  16929. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16930. }
  16931. return oldValue.UpdatedAt, nil
  16932. }
  16933. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16934. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  16935. m.updated_at = nil
  16936. }
  16937. // SetStatus sets the "status" field.
  16938. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  16939. m.status = &u
  16940. m.addstatus = nil
  16941. }
  16942. // Status returns the value of the "status" field in the mutation.
  16943. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  16944. v := m.status
  16945. if v == nil {
  16946. return
  16947. }
  16948. return *v, true
  16949. }
  16950. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  16951. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16953. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16954. if !m.op.Is(OpUpdateOne) {
  16955. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16956. }
  16957. if m.id == nil || m.oldValue == nil {
  16958. return v, errors.New("OldStatus requires an ID field in the mutation")
  16959. }
  16960. oldValue, err := m.oldValue(ctx)
  16961. if err != nil {
  16962. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16963. }
  16964. return oldValue.Status, nil
  16965. }
  16966. // AddStatus adds u to the "status" field.
  16967. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  16968. if m.addstatus != nil {
  16969. *m.addstatus += u
  16970. } else {
  16971. m.addstatus = &u
  16972. }
  16973. }
  16974. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16975. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  16976. v := m.addstatus
  16977. if v == nil {
  16978. return
  16979. }
  16980. return *v, true
  16981. }
  16982. // ClearStatus clears the value of the "status" field.
  16983. func (m *LabelRelationshipMutation) ClearStatus() {
  16984. m.status = nil
  16985. m.addstatus = nil
  16986. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  16987. }
  16988. // StatusCleared returns if the "status" field was cleared in this mutation.
  16989. func (m *LabelRelationshipMutation) StatusCleared() bool {
  16990. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  16991. return ok
  16992. }
  16993. // ResetStatus resets all changes to the "status" field.
  16994. func (m *LabelRelationshipMutation) ResetStatus() {
  16995. m.status = nil
  16996. m.addstatus = nil
  16997. delete(m.clearedFields, labelrelationship.FieldStatus)
  16998. }
  16999. // SetLabelID sets the "label_id" field.
  17000. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  17001. m.labels = &u
  17002. }
  17003. // LabelID returns the value of the "label_id" field in the mutation.
  17004. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  17005. v := m.labels
  17006. if v == nil {
  17007. return
  17008. }
  17009. return *v, true
  17010. }
  17011. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  17012. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17014. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  17015. if !m.op.Is(OpUpdateOne) {
  17016. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  17017. }
  17018. if m.id == nil || m.oldValue == nil {
  17019. return v, errors.New("OldLabelID requires an ID field in the mutation")
  17020. }
  17021. oldValue, err := m.oldValue(ctx)
  17022. if err != nil {
  17023. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  17024. }
  17025. return oldValue.LabelID, nil
  17026. }
  17027. // ResetLabelID resets all changes to the "label_id" field.
  17028. func (m *LabelRelationshipMutation) ResetLabelID() {
  17029. m.labels = nil
  17030. }
  17031. // SetContactID sets the "contact_id" field.
  17032. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  17033. m.contacts = &u
  17034. }
  17035. // ContactID returns the value of the "contact_id" field in the mutation.
  17036. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  17037. v := m.contacts
  17038. if v == nil {
  17039. return
  17040. }
  17041. return *v, true
  17042. }
  17043. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  17044. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17046. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17047. if !m.op.Is(OpUpdateOne) {
  17048. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17049. }
  17050. if m.id == nil || m.oldValue == nil {
  17051. return v, errors.New("OldContactID requires an ID field in the mutation")
  17052. }
  17053. oldValue, err := m.oldValue(ctx)
  17054. if err != nil {
  17055. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17056. }
  17057. return oldValue.ContactID, nil
  17058. }
  17059. // ResetContactID resets all changes to the "contact_id" field.
  17060. func (m *LabelRelationshipMutation) ResetContactID() {
  17061. m.contacts = nil
  17062. }
  17063. // SetOrganizationID sets the "organization_id" field.
  17064. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  17065. m.organization_id = &u
  17066. m.addorganization_id = nil
  17067. }
  17068. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17069. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  17070. v := m.organization_id
  17071. if v == nil {
  17072. return
  17073. }
  17074. return *v, true
  17075. }
  17076. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  17077. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17079. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17080. if !m.op.Is(OpUpdateOne) {
  17081. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17082. }
  17083. if m.id == nil || m.oldValue == nil {
  17084. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17085. }
  17086. oldValue, err := m.oldValue(ctx)
  17087. if err != nil {
  17088. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17089. }
  17090. return oldValue.OrganizationID, nil
  17091. }
  17092. // AddOrganizationID adds u to the "organization_id" field.
  17093. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17094. if m.addorganization_id != nil {
  17095. *m.addorganization_id += u
  17096. } else {
  17097. m.addorganization_id = &u
  17098. }
  17099. }
  17100. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17101. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17102. v := m.addorganization_id
  17103. if v == nil {
  17104. return
  17105. }
  17106. return *v, true
  17107. }
  17108. // ClearOrganizationID clears the value of the "organization_id" field.
  17109. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17110. m.organization_id = nil
  17111. m.addorganization_id = nil
  17112. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17113. }
  17114. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17115. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17116. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17117. return ok
  17118. }
  17119. // ResetOrganizationID resets all changes to the "organization_id" field.
  17120. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17121. m.organization_id = nil
  17122. m.addorganization_id = nil
  17123. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17124. }
  17125. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17126. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17127. m.contacts = &id
  17128. }
  17129. // ClearContacts clears the "contacts" edge to the Contact entity.
  17130. func (m *LabelRelationshipMutation) ClearContacts() {
  17131. m.clearedcontacts = true
  17132. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17133. }
  17134. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17135. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17136. return m.clearedcontacts
  17137. }
  17138. // ContactsID returns the "contacts" edge ID in the mutation.
  17139. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17140. if m.contacts != nil {
  17141. return *m.contacts, true
  17142. }
  17143. return
  17144. }
  17145. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17146. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17147. // ContactsID instead. It exists only for internal usage by the builders.
  17148. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17149. if id := m.contacts; id != nil {
  17150. ids = append(ids, *id)
  17151. }
  17152. return
  17153. }
  17154. // ResetContacts resets all changes to the "contacts" edge.
  17155. func (m *LabelRelationshipMutation) ResetContacts() {
  17156. m.contacts = nil
  17157. m.clearedcontacts = false
  17158. }
  17159. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17160. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17161. m.labels = &id
  17162. }
  17163. // ClearLabels clears the "labels" edge to the Label entity.
  17164. func (m *LabelRelationshipMutation) ClearLabels() {
  17165. m.clearedlabels = true
  17166. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17167. }
  17168. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17169. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17170. return m.clearedlabels
  17171. }
  17172. // LabelsID returns the "labels" edge ID in the mutation.
  17173. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17174. if m.labels != nil {
  17175. return *m.labels, true
  17176. }
  17177. return
  17178. }
  17179. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17180. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17181. // LabelsID instead. It exists only for internal usage by the builders.
  17182. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17183. if id := m.labels; id != nil {
  17184. ids = append(ids, *id)
  17185. }
  17186. return
  17187. }
  17188. // ResetLabels resets all changes to the "labels" edge.
  17189. func (m *LabelRelationshipMutation) ResetLabels() {
  17190. m.labels = nil
  17191. m.clearedlabels = false
  17192. }
  17193. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17194. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17195. m.predicates = append(m.predicates, ps...)
  17196. }
  17197. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17198. // users can use type-assertion to append predicates that do not depend on any generated package.
  17199. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17200. p := make([]predicate.LabelRelationship, len(ps))
  17201. for i := range ps {
  17202. p[i] = ps[i]
  17203. }
  17204. m.Where(p...)
  17205. }
  17206. // Op returns the operation name.
  17207. func (m *LabelRelationshipMutation) Op() Op {
  17208. return m.op
  17209. }
  17210. // SetOp allows setting the mutation operation.
  17211. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17212. m.op = op
  17213. }
  17214. // Type returns the node type of this mutation (LabelRelationship).
  17215. func (m *LabelRelationshipMutation) Type() string {
  17216. return m.typ
  17217. }
  17218. // Fields returns all fields that were changed during this mutation. Note that in
  17219. // order to get all numeric fields that were incremented/decremented, call
  17220. // AddedFields().
  17221. func (m *LabelRelationshipMutation) Fields() []string {
  17222. fields := make([]string, 0, 6)
  17223. if m.created_at != nil {
  17224. fields = append(fields, labelrelationship.FieldCreatedAt)
  17225. }
  17226. if m.updated_at != nil {
  17227. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17228. }
  17229. if m.status != nil {
  17230. fields = append(fields, labelrelationship.FieldStatus)
  17231. }
  17232. if m.labels != nil {
  17233. fields = append(fields, labelrelationship.FieldLabelID)
  17234. }
  17235. if m.contacts != nil {
  17236. fields = append(fields, labelrelationship.FieldContactID)
  17237. }
  17238. if m.organization_id != nil {
  17239. fields = append(fields, labelrelationship.FieldOrganizationID)
  17240. }
  17241. return fields
  17242. }
  17243. // Field returns the value of a field with the given name. The second boolean
  17244. // return value indicates that this field was not set, or was not defined in the
  17245. // schema.
  17246. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17247. switch name {
  17248. case labelrelationship.FieldCreatedAt:
  17249. return m.CreatedAt()
  17250. case labelrelationship.FieldUpdatedAt:
  17251. return m.UpdatedAt()
  17252. case labelrelationship.FieldStatus:
  17253. return m.Status()
  17254. case labelrelationship.FieldLabelID:
  17255. return m.LabelID()
  17256. case labelrelationship.FieldContactID:
  17257. return m.ContactID()
  17258. case labelrelationship.FieldOrganizationID:
  17259. return m.OrganizationID()
  17260. }
  17261. return nil, false
  17262. }
  17263. // OldField returns the old value of the field from the database. An error is
  17264. // returned if the mutation operation is not UpdateOne, or the query to the
  17265. // database failed.
  17266. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17267. switch name {
  17268. case labelrelationship.FieldCreatedAt:
  17269. return m.OldCreatedAt(ctx)
  17270. case labelrelationship.FieldUpdatedAt:
  17271. return m.OldUpdatedAt(ctx)
  17272. case labelrelationship.FieldStatus:
  17273. return m.OldStatus(ctx)
  17274. case labelrelationship.FieldLabelID:
  17275. return m.OldLabelID(ctx)
  17276. case labelrelationship.FieldContactID:
  17277. return m.OldContactID(ctx)
  17278. case labelrelationship.FieldOrganizationID:
  17279. return m.OldOrganizationID(ctx)
  17280. }
  17281. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17282. }
  17283. // SetField sets the value of a field with the given name. It returns an error if
  17284. // the field is not defined in the schema, or if the type mismatched the field
  17285. // type.
  17286. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17287. switch name {
  17288. case labelrelationship.FieldCreatedAt:
  17289. v, ok := value.(time.Time)
  17290. if !ok {
  17291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17292. }
  17293. m.SetCreatedAt(v)
  17294. return nil
  17295. case labelrelationship.FieldUpdatedAt:
  17296. v, ok := value.(time.Time)
  17297. if !ok {
  17298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17299. }
  17300. m.SetUpdatedAt(v)
  17301. return nil
  17302. case labelrelationship.FieldStatus:
  17303. v, ok := value.(uint8)
  17304. if !ok {
  17305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17306. }
  17307. m.SetStatus(v)
  17308. return nil
  17309. case labelrelationship.FieldLabelID:
  17310. v, ok := value.(uint64)
  17311. if !ok {
  17312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17313. }
  17314. m.SetLabelID(v)
  17315. return nil
  17316. case labelrelationship.FieldContactID:
  17317. v, ok := value.(uint64)
  17318. if !ok {
  17319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17320. }
  17321. m.SetContactID(v)
  17322. return nil
  17323. case labelrelationship.FieldOrganizationID:
  17324. v, ok := value.(uint64)
  17325. if !ok {
  17326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17327. }
  17328. m.SetOrganizationID(v)
  17329. return nil
  17330. }
  17331. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17332. }
  17333. // AddedFields returns all numeric fields that were incremented/decremented during
  17334. // this mutation.
  17335. func (m *LabelRelationshipMutation) AddedFields() []string {
  17336. var fields []string
  17337. if m.addstatus != nil {
  17338. fields = append(fields, labelrelationship.FieldStatus)
  17339. }
  17340. if m.addorganization_id != nil {
  17341. fields = append(fields, labelrelationship.FieldOrganizationID)
  17342. }
  17343. return fields
  17344. }
  17345. // AddedField returns the numeric value that was incremented/decremented on a field
  17346. // with the given name. The second boolean return value indicates that this field
  17347. // was not set, or was not defined in the schema.
  17348. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17349. switch name {
  17350. case labelrelationship.FieldStatus:
  17351. return m.AddedStatus()
  17352. case labelrelationship.FieldOrganizationID:
  17353. return m.AddedOrganizationID()
  17354. }
  17355. return nil, false
  17356. }
  17357. // AddField adds the value to the field with the given name. It returns an error if
  17358. // the field is not defined in the schema, or if the type mismatched the field
  17359. // type.
  17360. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17361. switch name {
  17362. case labelrelationship.FieldStatus:
  17363. v, ok := value.(int8)
  17364. if !ok {
  17365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17366. }
  17367. m.AddStatus(v)
  17368. return nil
  17369. case labelrelationship.FieldOrganizationID:
  17370. v, ok := value.(int64)
  17371. if !ok {
  17372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17373. }
  17374. m.AddOrganizationID(v)
  17375. return nil
  17376. }
  17377. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17378. }
  17379. // ClearedFields returns all nullable fields that were cleared during this
  17380. // mutation.
  17381. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17382. var fields []string
  17383. if m.FieldCleared(labelrelationship.FieldStatus) {
  17384. fields = append(fields, labelrelationship.FieldStatus)
  17385. }
  17386. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17387. fields = append(fields, labelrelationship.FieldOrganizationID)
  17388. }
  17389. return fields
  17390. }
  17391. // FieldCleared returns a boolean indicating if a field with the given name was
  17392. // cleared in this mutation.
  17393. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17394. _, ok := m.clearedFields[name]
  17395. return ok
  17396. }
  17397. // ClearField clears the value of the field with the given name. It returns an
  17398. // error if the field is not defined in the schema.
  17399. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17400. switch name {
  17401. case labelrelationship.FieldStatus:
  17402. m.ClearStatus()
  17403. return nil
  17404. case labelrelationship.FieldOrganizationID:
  17405. m.ClearOrganizationID()
  17406. return nil
  17407. }
  17408. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17409. }
  17410. // ResetField resets all changes in the mutation for the field with the given name.
  17411. // It returns an error if the field is not defined in the schema.
  17412. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17413. switch name {
  17414. case labelrelationship.FieldCreatedAt:
  17415. m.ResetCreatedAt()
  17416. return nil
  17417. case labelrelationship.FieldUpdatedAt:
  17418. m.ResetUpdatedAt()
  17419. return nil
  17420. case labelrelationship.FieldStatus:
  17421. m.ResetStatus()
  17422. return nil
  17423. case labelrelationship.FieldLabelID:
  17424. m.ResetLabelID()
  17425. return nil
  17426. case labelrelationship.FieldContactID:
  17427. m.ResetContactID()
  17428. return nil
  17429. case labelrelationship.FieldOrganizationID:
  17430. m.ResetOrganizationID()
  17431. return nil
  17432. }
  17433. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17434. }
  17435. // AddedEdges returns all edge names that were set/added in this mutation.
  17436. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17437. edges := make([]string, 0, 2)
  17438. if m.contacts != nil {
  17439. edges = append(edges, labelrelationship.EdgeContacts)
  17440. }
  17441. if m.labels != nil {
  17442. edges = append(edges, labelrelationship.EdgeLabels)
  17443. }
  17444. return edges
  17445. }
  17446. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17447. // name in this mutation.
  17448. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17449. switch name {
  17450. case labelrelationship.EdgeContacts:
  17451. if id := m.contacts; id != nil {
  17452. return []ent.Value{*id}
  17453. }
  17454. case labelrelationship.EdgeLabels:
  17455. if id := m.labels; id != nil {
  17456. return []ent.Value{*id}
  17457. }
  17458. }
  17459. return nil
  17460. }
  17461. // RemovedEdges returns all edge names that were removed in this mutation.
  17462. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17463. edges := make([]string, 0, 2)
  17464. return edges
  17465. }
  17466. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17467. // the given name in this mutation.
  17468. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17469. return nil
  17470. }
  17471. // ClearedEdges returns all edge names that were cleared in this mutation.
  17472. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17473. edges := make([]string, 0, 2)
  17474. if m.clearedcontacts {
  17475. edges = append(edges, labelrelationship.EdgeContacts)
  17476. }
  17477. if m.clearedlabels {
  17478. edges = append(edges, labelrelationship.EdgeLabels)
  17479. }
  17480. return edges
  17481. }
  17482. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17483. // was cleared in this mutation.
  17484. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17485. switch name {
  17486. case labelrelationship.EdgeContacts:
  17487. return m.clearedcontacts
  17488. case labelrelationship.EdgeLabels:
  17489. return m.clearedlabels
  17490. }
  17491. return false
  17492. }
  17493. // ClearEdge clears the value of the edge with the given name. It returns an error
  17494. // if that edge is not defined in the schema.
  17495. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17496. switch name {
  17497. case labelrelationship.EdgeContacts:
  17498. m.ClearContacts()
  17499. return nil
  17500. case labelrelationship.EdgeLabels:
  17501. m.ClearLabels()
  17502. return nil
  17503. }
  17504. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17505. }
  17506. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17507. // It returns an error if the edge is not defined in the schema.
  17508. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17509. switch name {
  17510. case labelrelationship.EdgeContacts:
  17511. m.ResetContacts()
  17512. return nil
  17513. case labelrelationship.EdgeLabels:
  17514. m.ResetLabels()
  17515. return nil
  17516. }
  17517. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17518. }
  17519. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17520. type LabelTaggingMutation struct {
  17521. config
  17522. op Op
  17523. typ string
  17524. id *uint64
  17525. created_at *time.Time
  17526. updated_at *time.Time
  17527. status *uint8
  17528. addstatus *int8
  17529. deleted_at *time.Time
  17530. organization_id *uint64
  17531. addorganization_id *int64
  17532. _type *int
  17533. add_type *int
  17534. conditions *string
  17535. action_label_add *[]uint64
  17536. appendaction_label_add []uint64
  17537. action_label_del *[]uint64
  17538. appendaction_label_del []uint64
  17539. clearedFields map[string]struct{}
  17540. done bool
  17541. oldValue func(context.Context) (*LabelTagging, error)
  17542. predicates []predicate.LabelTagging
  17543. }
  17544. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17545. // labeltaggingOption allows management of the mutation configuration using functional options.
  17546. type labeltaggingOption func(*LabelTaggingMutation)
  17547. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17548. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17549. m := &LabelTaggingMutation{
  17550. config: c,
  17551. op: op,
  17552. typ: TypeLabelTagging,
  17553. clearedFields: make(map[string]struct{}),
  17554. }
  17555. for _, opt := range opts {
  17556. opt(m)
  17557. }
  17558. return m
  17559. }
  17560. // withLabelTaggingID sets the ID field of the mutation.
  17561. func withLabelTaggingID(id uint64) labeltaggingOption {
  17562. return func(m *LabelTaggingMutation) {
  17563. var (
  17564. err error
  17565. once sync.Once
  17566. value *LabelTagging
  17567. )
  17568. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17569. once.Do(func() {
  17570. if m.done {
  17571. err = errors.New("querying old values post mutation is not allowed")
  17572. } else {
  17573. value, err = m.Client().LabelTagging.Get(ctx, id)
  17574. }
  17575. })
  17576. return value, err
  17577. }
  17578. m.id = &id
  17579. }
  17580. }
  17581. // withLabelTagging sets the old LabelTagging of the mutation.
  17582. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17583. return func(m *LabelTaggingMutation) {
  17584. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17585. return node, nil
  17586. }
  17587. m.id = &node.ID
  17588. }
  17589. }
  17590. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17591. // executed in a transaction (ent.Tx), a transactional client is returned.
  17592. func (m LabelTaggingMutation) Client() *Client {
  17593. client := &Client{config: m.config}
  17594. client.init()
  17595. return client
  17596. }
  17597. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17598. // it returns an error otherwise.
  17599. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17600. if _, ok := m.driver.(*txDriver); !ok {
  17601. return nil, errors.New("ent: mutation is not running in a transaction")
  17602. }
  17603. tx := &Tx{config: m.config}
  17604. tx.init()
  17605. return tx, nil
  17606. }
  17607. // SetID sets the value of the id field. Note that this
  17608. // operation is only accepted on creation of LabelTagging entities.
  17609. func (m *LabelTaggingMutation) SetID(id uint64) {
  17610. m.id = &id
  17611. }
  17612. // ID returns the ID value in the mutation. Note that the ID is only available
  17613. // if it was provided to the builder or after it was returned from the database.
  17614. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17615. if m.id == nil {
  17616. return
  17617. }
  17618. return *m.id, true
  17619. }
  17620. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17621. // That means, if the mutation is applied within a transaction with an isolation level such
  17622. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17623. // or updated by the mutation.
  17624. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17625. switch {
  17626. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17627. id, exists := m.ID()
  17628. if exists {
  17629. return []uint64{id}, nil
  17630. }
  17631. fallthrough
  17632. case m.op.Is(OpUpdate | OpDelete):
  17633. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17634. default:
  17635. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17636. }
  17637. }
  17638. // SetCreatedAt sets the "created_at" field.
  17639. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  17640. m.created_at = &t
  17641. }
  17642. // CreatedAt returns the value of the "created_at" field in the mutation.
  17643. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  17644. v := m.created_at
  17645. if v == nil {
  17646. return
  17647. }
  17648. return *v, true
  17649. }
  17650. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  17651. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17653. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17654. if !m.op.Is(OpUpdateOne) {
  17655. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17656. }
  17657. if m.id == nil || m.oldValue == nil {
  17658. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17659. }
  17660. oldValue, err := m.oldValue(ctx)
  17661. if err != nil {
  17662. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17663. }
  17664. return oldValue.CreatedAt, nil
  17665. }
  17666. // ResetCreatedAt resets all changes to the "created_at" field.
  17667. func (m *LabelTaggingMutation) ResetCreatedAt() {
  17668. m.created_at = nil
  17669. }
  17670. // SetUpdatedAt sets the "updated_at" field.
  17671. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  17672. m.updated_at = &t
  17673. }
  17674. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17675. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  17676. v := m.updated_at
  17677. if v == nil {
  17678. return
  17679. }
  17680. return *v, true
  17681. }
  17682. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  17683. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17685. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17686. if !m.op.Is(OpUpdateOne) {
  17687. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17688. }
  17689. if m.id == nil || m.oldValue == nil {
  17690. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17691. }
  17692. oldValue, err := m.oldValue(ctx)
  17693. if err != nil {
  17694. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17695. }
  17696. return oldValue.UpdatedAt, nil
  17697. }
  17698. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17699. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  17700. m.updated_at = nil
  17701. }
  17702. // SetStatus sets the "status" field.
  17703. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  17704. m.status = &u
  17705. m.addstatus = nil
  17706. }
  17707. // Status returns the value of the "status" field in the mutation.
  17708. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  17709. v := m.status
  17710. if v == nil {
  17711. return
  17712. }
  17713. return *v, true
  17714. }
  17715. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  17716. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17718. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17719. if !m.op.Is(OpUpdateOne) {
  17720. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17721. }
  17722. if m.id == nil || m.oldValue == nil {
  17723. return v, errors.New("OldStatus requires an ID field in the mutation")
  17724. }
  17725. oldValue, err := m.oldValue(ctx)
  17726. if err != nil {
  17727. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17728. }
  17729. return oldValue.Status, nil
  17730. }
  17731. // AddStatus adds u to the "status" field.
  17732. func (m *LabelTaggingMutation) AddStatus(u int8) {
  17733. if m.addstatus != nil {
  17734. *m.addstatus += u
  17735. } else {
  17736. m.addstatus = &u
  17737. }
  17738. }
  17739. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17740. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  17741. v := m.addstatus
  17742. if v == nil {
  17743. return
  17744. }
  17745. return *v, true
  17746. }
  17747. // ClearStatus clears the value of the "status" field.
  17748. func (m *LabelTaggingMutation) ClearStatus() {
  17749. m.status = nil
  17750. m.addstatus = nil
  17751. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  17752. }
  17753. // StatusCleared returns if the "status" field was cleared in this mutation.
  17754. func (m *LabelTaggingMutation) StatusCleared() bool {
  17755. _, ok := m.clearedFields[labeltagging.FieldStatus]
  17756. return ok
  17757. }
  17758. // ResetStatus resets all changes to the "status" field.
  17759. func (m *LabelTaggingMutation) ResetStatus() {
  17760. m.status = nil
  17761. m.addstatus = nil
  17762. delete(m.clearedFields, labeltagging.FieldStatus)
  17763. }
  17764. // SetDeletedAt sets the "deleted_at" field.
  17765. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  17766. m.deleted_at = &t
  17767. }
  17768. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17769. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  17770. v := m.deleted_at
  17771. if v == nil {
  17772. return
  17773. }
  17774. return *v, true
  17775. }
  17776. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  17777. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17779. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17780. if !m.op.Is(OpUpdateOne) {
  17781. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17782. }
  17783. if m.id == nil || m.oldValue == nil {
  17784. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17785. }
  17786. oldValue, err := m.oldValue(ctx)
  17787. if err != nil {
  17788. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17789. }
  17790. return oldValue.DeletedAt, nil
  17791. }
  17792. // ClearDeletedAt clears the value of the "deleted_at" field.
  17793. func (m *LabelTaggingMutation) ClearDeletedAt() {
  17794. m.deleted_at = nil
  17795. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  17796. }
  17797. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17798. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  17799. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  17800. return ok
  17801. }
  17802. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17803. func (m *LabelTaggingMutation) ResetDeletedAt() {
  17804. m.deleted_at = nil
  17805. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  17806. }
  17807. // SetOrganizationID sets the "organization_id" field.
  17808. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  17809. m.organization_id = &u
  17810. m.addorganization_id = nil
  17811. }
  17812. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17813. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  17814. v := m.organization_id
  17815. if v == nil {
  17816. return
  17817. }
  17818. return *v, true
  17819. }
  17820. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  17821. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17823. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17824. if !m.op.Is(OpUpdateOne) {
  17825. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17826. }
  17827. if m.id == nil || m.oldValue == nil {
  17828. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17829. }
  17830. oldValue, err := m.oldValue(ctx)
  17831. if err != nil {
  17832. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17833. }
  17834. return oldValue.OrganizationID, nil
  17835. }
  17836. // AddOrganizationID adds u to the "organization_id" field.
  17837. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  17838. if m.addorganization_id != nil {
  17839. *m.addorganization_id += u
  17840. } else {
  17841. m.addorganization_id = &u
  17842. }
  17843. }
  17844. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17845. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  17846. v := m.addorganization_id
  17847. if v == nil {
  17848. return
  17849. }
  17850. return *v, true
  17851. }
  17852. // ResetOrganizationID resets all changes to the "organization_id" field.
  17853. func (m *LabelTaggingMutation) ResetOrganizationID() {
  17854. m.organization_id = nil
  17855. m.addorganization_id = nil
  17856. }
  17857. // SetType sets the "type" field.
  17858. func (m *LabelTaggingMutation) SetType(i int) {
  17859. m._type = &i
  17860. m.add_type = nil
  17861. }
  17862. // GetType returns the value of the "type" field in the mutation.
  17863. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  17864. v := m._type
  17865. if v == nil {
  17866. return
  17867. }
  17868. return *v, true
  17869. }
  17870. // OldType returns the old "type" field's value of the LabelTagging entity.
  17871. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17873. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  17874. if !m.op.Is(OpUpdateOne) {
  17875. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17876. }
  17877. if m.id == nil || m.oldValue == nil {
  17878. return v, errors.New("OldType requires an ID field in the mutation")
  17879. }
  17880. oldValue, err := m.oldValue(ctx)
  17881. if err != nil {
  17882. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17883. }
  17884. return oldValue.Type, nil
  17885. }
  17886. // AddType adds i to the "type" field.
  17887. func (m *LabelTaggingMutation) AddType(i int) {
  17888. if m.add_type != nil {
  17889. *m.add_type += i
  17890. } else {
  17891. m.add_type = &i
  17892. }
  17893. }
  17894. // AddedType returns the value that was added to the "type" field in this mutation.
  17895. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  17896. v := m.add_type
  17897. if v == nil {
  17898. return
  17899. }
  17900. return *v, true
  17901. }
  17902. // ResetType resets all changes to the "type" field.
  17903. func (m *LabelTaggingMutation) ResetType() {
  17904. m._type = nil
  17905. m.add_type = nil
  17906. }
  17907. // SetConditions sets the "conditions" field.
  17908. func (m *LabelTaggingMutation) SetConditions(s string) {
  17909. m.conditions = &s
  17910. }
  17911. // Conditions returns the value of the "conditions" field in the mutation.
  17912. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  17913. v := m.conditions
  17914. if v == nil {
  17915. return
  17916. }
  17917. return *v, true
  17918. }
  17919. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  17920. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17922. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  17923. if !m.op.Is(OpUpdateOne) {
  17924. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17925. }
  17926. if m.id == nil || m.oldValue == nil {
  17927. return v, errors.New("OldConditions requires an ID field in the mutation")
  17928. }
  17929. oldValue, err := m.oldValue(ctx)
  17930. if err != nil {
  17931. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17932. }
  17933. return oldValue.Conditions, nil
  17934. }
  17935. // ResetConditions resets all changes to the "conditions" field.
  17936. func (m *LabelTaggingMutation) ResetConditions() {
  17937. m.conditions = nil
  17938. }
  17939. // SetActionLabelAdd sets the "action_label_add" field.
  17940. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  17941. m.action_label_add = &u
  17942. m.appendaction_label_add = nil
  17943. }
  17944. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17945. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17946. v := m.action_label_add
  17947. if v == nil {
  17948. return
  17949. }
  17950. return *v, true
  17951. }
  17952. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  17953. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17955. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17956. if !m.op.Is(OpUpdateOne) {
  17957. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17958. }
  17959. if m.id == nil || m.oldValue == nil {
  17960. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17961. }
  17962. oldValue, err := m.oldValue(ctx)
  17963. if err != nil {
  17964. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17965. }
  17966. return oldValue.ActionLabelAdd, nil
  17967. }
  17968. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17969. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  17970. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17971. }
  17972. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17973. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17974. if len(m.appendaction_label_add) == 0 {
  17975. return nil, false
  17976. }
  17977. return m.appendaction_label_add, true
  17978. }
  17979. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17980. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  17981. m.action_label_add = nil
  17982. m.appendaction_label_add = nil
  17983. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  17984. }
  17985. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17986. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  17987. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  17988. return ok
  17989. }
  17990. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17991. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  17992. m.action_label_add = nil
  17993. m.appendaction_label_add = nil
  17994. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  17995. }
  17996. // SetActionLabelDel sets the "action_label_del" field.
  17997. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  17998. m.action_label_del = &u
  17999. m.appendaction_label_del = nil
  18000. }
  18001. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18002. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  18003. v := m.action_label_del
  18004. if v == nil {
  18005. return
  18006. }
  18007. return *v, true
  18008. }
  18009. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  18010. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18012. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18013. if !m.op.Is(OpUpdateOne) {
  18014. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18015. }
  18016. if m.id == nil || m.oldValue == nil {
  18017. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18018. }
  18019. oldValue, err := m.oldValue(ctx)
  18020. if err != nil {
  18021. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18022. }
  18023. return oldValue.ActionLabelDel, nil
  18024. }
  18025. // AppendActionLabelDel adds u to the "action_label_del" field.
  18026. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  18027. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18028. }
  18029. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18030. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18031. if len(m.appendaction_label_del) == 0 {
  18032. return nil, false
  18033. }
  18034. return m.appendaction_label_del, true
  18035. }
  18036. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18037. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  18038. m.action_label_del = nil
  18039. m.appendaction_label_del = nil
  18040. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  18041. }
  18042. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18043. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  18044. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  18045. return ok
  18046. }
  18047. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18048. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  18049. m.action_label_del = nil
  18050. m.appendaction_label_del = nil
  18051. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  18052. }
  18053. // Where appends a list predicates to the LabelTaggingMutation builder.
  18054. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  18055. m.predicates = append(m.predicates, ps...)
  18056. }
  18057. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  18058. // users can use type-assertion to append predicates that do not depend on any generated package.
  18059. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  18060. p := make([]predicate.LabelTagging, len(ps))
  18061. for i := range ps {
  18062. p[i] = ps[i]
  18063. }
  18064. m.Where(p...)
  18065. }
  18066. // Op returns the operation name.
  18067. func (m *LabelTaggingMutation) Op() Op {
  18068. return m.op
  18069. }
  18070. // SetOp allows setting the mutation operation.
  18071. func (m *LabelTaggingMutation) SetOp(op Op) {
  18072. m.op = op
  18073. }
  18074. // Type returns the node type of this mutation (LabelTagging).
  18075. func (m *LabelTaggingMutation) Type() string {
  18076. return m.typ
  18077. }
  18078. // Fields returns all fields that were changed during this mutation. Note that in
  18079. // order to get all numeric fields that were incremented/decremented, call
  18080. // AddedFields().
  18081. func (m *LabelTaggingMutation) Fields() []string {
  18082. fields := make([]string, 0, 9)
  18083. if m.created_at != nil {
  18084. fields = append(fields, labeltagging.FieldCreatedAt)
  18085. }
  18086. if m.updated_at != nil {
  18087. fields = append(fields, labeltagging.FieldUpdatedAt)
  18088. }
  18089. if m.status != nil {
  18090. fields = append(fields, labeltagging.FieldStatus)
  18091. }
  18092. if m.deleted_at != nil {
  18093. fields = append(fields, labeltagging.FieldDeletedAt)
  18094. }
  18095. if m.organization_id != nil {
  18096. fields = append(fields, labeltagging.FieldOrganizationID)
  18097. }
  18098. if m._type != nil {
  18099. fields = append(fields, labeltagging.FieldType)
  18100. }
  18101. if m.conditions != nil {
  18102. fields = append(fields, labeltagging.FieldConditions)
  18103. }
  18104. if m.action_label_add != nil {
  18105. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18106. }
  18107. if m.action_label_del != nil {
  18108. fields = append(fields, labeltagging.FieldActionLabelDel)
  18109. }
  18110. return fields
  18111. }
  18112. // Field returns the value of a field with the given name. The second boolean
  18113. // return value indicates that this field was not set, or was not defined in the
  18114. // schema.
  18115. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18116. switch name {
  18117. case labeltagging.FieldCreatedAt:
  18118. return m.CreatedAt()
  18119. case labeltagging.FieldUpdatedAt:
  18120. return m.UpdatedAt()
  18121. case labeltagging.FieldStatus:
  18122. return m.Status()
  18123. case labeltagging.FieldDeletedAt:
  18124. return m.DeletedAt()
  18125. case labeltagging.FieldOrganizationID:
  18126. return m.OrganizationID()
  18127. case labeltagging.FieldType:
  18128. return m.GetType()
  18129. case labeltagging.FieldConditions:
  18130. return m.Conditions()
  18131. case labeltagging.FieldActionLabelAdd:
  18132. return m.ActionLabelAdd()
  18133. case labeltagging.FieldActionLabelDel:
  18134. return m.ActionLabelDel()
  18135. }
  18136. return nil, false
  18137. }
  18138. // OldField returns the old value of the field from the database. An error is
  18139. // returned if the mutation operation is not UpdateOne, or the query to the
  18140. // database failed.
  18141. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18142. switch name {
  18143. case labeltagging.FieldCreatedAt:
  18144. return m.OldCreatedAt(ctx)
  18145. case labeltagging.FieldUpdatedAt:
  18146. return m.OldUpdatedAt(ctx)
  18147. case labeltagging.FieldStatus:
  18148. return m.OldStatus(ctx)
  18149. case labeltagging.FieldDeletedAt:
  18150. return m.OldDeletedAt(ctx)
  18151. case labeltagging.FieldOrganizationID:
  18152. return m.OldOrganizationID(ctx)
  18153. case labeltagging.FieldType:
  18154. return m.OldType(ctx)
  18155. case labeltagging.FieldConditions:
  18156. return m.OldConditions(ctx)
  18157. case labeltagging.FieldActionLabelAdd:
  18158. return m.OldActionLabelAdd(ctx)
  18159. case labeltagging.FieldActionLabelDel:
  18160. return m.OldActionLabelDel(ctx)
  18161. }
  18162. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18163. }
  18164. // SetField sets the value of a field with the given name. It returns an error if
  18165. // the field is not defined in the schema, or if the type mismatched the field
  18166. // type.
  18167. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18168. switch name {
  18169. case labeltagging.FieldCreatedAt:
  18170. v, ok := value.(time.Time)
  18171. if !ok {
  18172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18173. }
  18174. m.SetCreatedAt(v)
  18175. return nil
  18176. case labeltagging.FieldUpdatedAt:
  18177. v, ok := value.(time.Time)
  18178. if !ok {
  18179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18180. }
  18181. m.SetUpdatedAt(v)
  18182. return nil
  18183. case labeltagging.FieldStatus:
  18184. v, ok := value.(uint8)
  18185. if !ok {
  18186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18187. }
  18188. m.SetStatus(v)
  18189. return nil
  18190. case labeltagging.FieldDeletedAt:
  18191. v, ok := value.(time.Time)
  18192. if !ok {
  18193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18194. }
  18195. m.SetDeletedAt(v)
  18196. return nil
  18197. case labeltagging.FieldOrganizationID:
  18198. v, ok := value.(uint64)
  18199. if !ok {
  18200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18201. }
  18202. m.SetOrganizationID(v)
  18203. return nil
  18204. case labeltagging.FieldType:
  18205. v, ok := value.(int)
  18206. if !ok {
  18207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18208. }
  18209. m.SetType(v)
  18210. return nil
  18211. case labeltagging.FieldConditions:
  18212. v, ok := value.(string)
  18213. if !ok {
  18214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18215. }
  18216. m.SetConditions(v)
  18217. return nil
  18218. case labeltagging.FieldActionLabelAdd:
  18219. v, ok := value.([]uint64)
  18220. if !ok {
  18221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18222. }
  18223. m.SetActionLabelAdd(v)
  18224. return nil
  18225. case labeltagging.FieldActionLabelDel:
  18226. v, ok := value.([]uint64)
  18227. if !ok {
  18228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18229. }
  18230. m.SetActionLabelDel(v)
  18231. return nil
  18232. }
  18233. return fmt.Errorf("unknown LabelTagging field %s", name)
  18234. }
  18235. // AddedFields returns all numeric fields that were incremented/decremented during
  18236. // this mutation.
  18237. func (m *LabelTaggingMutation) AddedFields() []string {
  18238. var fields []string
  18239. if m.addstatus != nil {
  18240. fields = append(fields, labeltagging.FieldStatus)
  18241. }
  18242. if m.addorganization_id != nil {
  18243. fields = append(fields, labeltagging.FieldOrganizationID)
  18244. }
  18245. if m.add_type != nil {
  18246. fields = append(fields, labeltagging.FieldType)
  18247. }
  18248. return fields
  18249. }
  18250. // AddedField returns the numeric value that was incremented/decremented on a field
  18251. // with the given name. The second boolean return value indicates that this field
  18252. // was not set, or was not defined in the schema.
  18253. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18254. switch name {
  18255. case labeltagging.FieldStatus:
  18256. return m.AddedStatus()
  18257. case labeltagging.FieldOrganizationID:
  18258. return m.AddedOrganizationID()
  18259. case labeltagging.FieldType:
  18260. return m.AddedType()
  18261. }
  18262. return nil, false
  18263. }
  18264. // AddField adds the value to the field with the given name. It returns an error if
  18265. // the field is not defined in the schema, or if the type mismatched the field
  18266. // type.
  18267. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18268. switch name {
  18269. case labeltagging.FieldStatus:
  18270. v, ok := value.(int8)
  18271. if !ok {
  18272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18273. }
  18274. m.AddStatus(v)
  18275. return nil
  18276. case labeltagging.FieldOrganizationID:
  18277. v, ok := value.(int64)
  18278. if !ok {
  18279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18280. }
  18281. m.AddOrganizationID(v)
  18282. return nil
  18283. case labeltagging.FieldType:
  18284. v, ok := value.(int)
  18285. if !ok {
  18286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18287. }
  18288. m.AddType(v)
  18289. return nil
  18290. }
  18291. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18292. }
  18293. // ClearedFields returns all nullable fields that were cleared during this
  18294. // mutation.
  18295. func (m *LabelTaggingMutation) ClearedFields() []string {
  18296. var fields []string
  18297. if m.FieldCleared(labeltagging.FieldStatus) {
  18298. fields = append(fields, labeltagging.FieldStatus)
  18299. }
  18300. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18301. fields = append(fields, labeltagging.FieldDeletedAt)
  18302. }
  18303. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18304. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18305. }
  18306. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18307. fields = append(fields, labeltagging.FieldActionLabelDel)
  18308. }
  18309. return fields
  18310. }
  18311. // FieldCleared returns a boolean indicating if a field with the given name was
  18312. // cleared in this mutation.
  18313. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18314. _, ok := m.clearedFields[name]
  18315. return ok
  18316. }
  18317. // ClearField clears the value of the field with the given name. It returns an
  18318. // error if the field is not defined in the schema.
  18319. func (m *LabelTaggingMutation) ClearField(name string) error {
  18320. switch name {
  18321. case labeltagging.FieldStatus:
  18322. m.ClearStatus()
  18323. return nil
  18324. case labeltagging.FieldDeletedAt:
  18325. m.ClearDeletedAt()
  18326. return nil
  18327. case labeltagging.FieldActionLabelAdd:
  18328. m.ClearActionLabelAdd()
  18329. return nil
  18330. case labeltagging.FieldActionLabelDel:
  18331. m.ClearActionLabelDel()
  18332. return nil
  18333. }
  18334. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18335. }
  18336. // ResetField resets all changes in the mutation for the field with the given name.
  18337. // It returns an error if the field is not defined in the schema.
  18338. func (m *LabelTaggingMutation) ResetField(name string) error {
  18339. switch name {
  18340. case labeltagging.FieldCreatedAt:
  18341. m.ResetCreatedAt()
  18342. return nil
  18343. case labeltagging.FieldUpdatedAt:
  18344. m.ResetUpdatedAt()
  18345. return nil
  18346. case labeltagging.FieldStatus:
  18347. m.ResetStatus()
  18348. return nil
  18349. case labeltagging.FieldDeletedAt:
  18350. m.ResetDeletedAt()
  18351. return nil
  18352. case labeltagging.FieldOrganizationID:
  18353. m.ResetOrganizationID()
  18354. return nil
  18355. case labeltagging.FieldType:
  18356. m.ResetType()
  18357. return nil
  18358. case labeltagging.FieldConditions:
  18359. m.ResetConditions()
  18360. return nil
  18361. case labeltagging.FieldActionLabelAdd:
  18362. m.ResetActionLabelAdd()
  18363. return nil
  18364. case labeltagging.FieldActionLabelDel:
  18365. m.ResetActionLabelDel()
  18366. return nil
  18367. }
  18368. return fmt.Errorf("unknown LabelTagging field %s", name)
  18369. }
  18370. // AddedEdges returns all edge names that were set/added in this mutation.
  18371. func (m *LabelTaggingMutation) AddedEdges() []string {
  18372. edges := make([]string, 0, 0)
  18373. return edges
  18374. }
  18375. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18376. // name in this mutation.
  18377. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18378. return nil
  18379. }
  18380. // RemovedEdges returns all edge names that were removed in this mutation.
  18381. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18382. edges := make([]string, 0, 0)
  18383. return edges
  18384. }
  18385. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18386. // the given name in this mutation.
  18387. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18388. return nil
  18389. }
  18390. // ClearedEdges returns all edge names that were cleared in this mutation.
  18391. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18392. edges := make([]string, 0, 0)
  18393. return edges
  18394. }
  18395. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18396. // was cleared in this mutation.
  18397. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18398. return false
  18399. }
  18400. // ClearEdge clears the value of the edge with the given name. It returns an error
  18401. // if that edge is not defined in the schema.
  18402. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18403. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18404. }
  18405. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18406. // It returns an error if the edge is not defined in the schema.
  18407. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18408. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18409. }
  18410. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18411. type MessageMutation struct {
  18412. config
  18413. op Op
  18414. typ string
  18415. id *int
  18416. wx_wxid *string
  18417. wxid *string
  18418. content *string
  18419. clearedFields map[string]struct{}
  18420. done bool
  18421. oldValue func(context.Context) (*Message, error)
  18422. predicates []predicate.Message
  18423. }
  18424. var _ ent.Mutation = (*MessageMutation)(nil)
  18425. // messageOption allows management of the mutation configuration using functional options.
  18426. type messageOption func(*MessageMutation)
  18427. // newMessageMutation creates new mutation for the Message entity.
  18428. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18429. m := &MessageMutation{
  18430. config: c,
  18431. op: op,
  18432. typ: TypeMessage,
  18433. clearedFields: make(map[string]struct{}),
  18434. }
  18435. for _, opt := range opts {
  18436. opt(m)
  18437. }
  18438. return m
  18439. }
  18440. // withMessageID sets the ID field of the mutation.
  18441. func withMessageID(id int) messageOption {
  18442. return func(m *MessageMutation) {
  18443. var (
  18444. err error
  18445. once sync.Once
  18446. value *Message
  18447. )
  18448. m.oldValue = func(ctx context.Context) (*Message, error) {
  18449. once.Do(func() {
  18450. if m.done {
  18451. err = errors.New("querying old values post mutation is not allowed")
  18452. } else {
  18453. value, err = m.Client().Message.Get(ctx, id)
  18454. }
  18455. })
  18456. return value, err
  18457. }
  18458. m.id = &id
  18459. }
  18460. }
  18461. // withMessage sets the old Message of the mutation.
  18462. func withMessage(node *Message) messageOption {
  18463. return func(m *MessageMutation) {
  18464. m.oldValue = func(context.Context) (*Message, error) {
  18465. return node, nil
  18466. }
  18467. m.id = &node.ID
  18468. }
  18469. }
  18470. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18471. // executed in a transaction (ent.Tx), a transactional client is returned.
  18472. func (m MessageMutation) Client() *Client {
  18473. client := &Client{config: m.config}
  18474. client.init()
  18475. return client
  18476. }
  18477. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18478. // it returns an error otherwise.
  18479. func (m MessageMutation) Tx() (*Tx, error) {
  18480. if _, ok := m.driver.(*txDriver); !ok {
  18481. return nil, errors.New("ent: mutation is not running in a transaction")
  18482. }
  18483. tx := &Tx{config: m.config}
  18484. tx.init()
  18485. return tx, nil
  18486. }
  18487. // ID returns the ID value in the mutation. Note that the ID is only available
  18488. // if it was provided to the builder or after it was returned from the database.
  18489. func (m *MessageMutation) ID() (id int, exists bool) {
  18490. if m.id == nil {
  18491. return
  18492. }
  18493. return *m.id, true
  18494. }
  18495. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18496. // That means, if the mutation is applied within a transaction with an isolation level such
  18497. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18498. // or updated by the mutation.
  18499. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18500. switch {
  18501. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18502. id, exists := m.ID()
  18503. if exists {
  18504. return []int{id}, nil
  18505. }
  18506. fallthrough
  18507. case m.op.Is(OpUpdate | OpDelete):
  18508. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18509. default:
  18510. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18511. }
  18512. }
  18513. // SetWxWxid sets the "wx_wxid" field.
  18514. func (m *MessageMutation) SetWxWxid(s string) {
  18515. m.wx_wxid = &s
  18516. }
  18517. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18518. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18519. v := m.wx_wxid
  18520. if v == nil {
  18521. return
  18522. }
  18523. return *v, true
  18524. }
  18525. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18526. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18528. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18529. if !m.op.Is(OpUpdateOne) {
  18530. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18531. }
  18532. if m.id == nil || m.oldValue == nil {
  18533. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18534. }
  18535. oldValue, err := m.oldValue(ctx)
  18536. if err != nil {
  18537. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18538. }
  18539. return oldValue.WxWxid, nil
  18540. }
  18541. // ClearWxWxid clears the value of the "wx_wxid" field.
  18542. func (m *MessageMutation) ClearWxWxid() {
  18543. m.wx_wxid = nil
  18544. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18545. }
  18546. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18547. func (m *MessageMutation) WxWxidCleared() bool {
  18548. _, ok := m.clearedFields[message.FieldWxWxid]
  18549. return ok
  18550. }
  18551. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18552. func (m *MessageMutation) ResetWxWxid() {
  18553. m.wx_wxid = nil
  18554. delete(m.clearedFields, message.FieldWxWxid)
  18555. }
  18556. // SetWxid sets the "wxid" field.
  18557. func (m *MessageMutation) SetWxid(s string) {
  18558. m.wxid = &s
  18559. }
  18560. // Wxid returns the value of the "wxid" field in the mutation.
  18561. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18562. v := m.wxid
  18563. if v == nil {
  18564. return
  18565. }
  18566. return *v, true
  18567. }
  18568. // OldWxid returns the old "wxid" field's value of the Message entity.
  18569. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18571. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18572. if !m.op.Is(OpUpdateOne) {
  18573. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18574. }
  18575. if m.id == nil || m.oldValue == nil {
  18576. return v, errors.New("OldWxid requires an ID field in the mutation")
  18577. }
  18578. oldValue, err := m.oldValue(ctx)
  18579. if err != nil {
  18580. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18581. }
  18582. return oldValue.Wxid, nil
  18583. }
  18584. // ResetWxid resets all changes to the "wxid" field.
  18585. func (m *MessageMutation) ResetWxid() {
  18586. m.wxid = nil
  18587. }
  18588. // SetContent sets the "content" field.
  18589. func (m *MessageMutation) SetContent(s string) {
  18590. m.content = &s
  18591. }
  18592. // Content returns the value of the "content" field in the mutation.
  18593. func (m *MessageMutation) Content() (r string, exists bool) {
  18594. v := m.content
  18595. if v == nil {
  18596. return
  18597. }
  18598. return *v, true
  18599. }
  18600. // OldContent returns the old "content" field's value of the Message entity.
  18601. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18603. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18604. if !m.op.Is(OpUpdateOne) {
  18605. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18606. }
  18607. if m.id == nil || m.oldValue == nil {
  18608. return v, errors.New("OldContent requires an ID field in the mutation")
  18609. }
  18610. oldValue, err := m.oldValue(ctx)
  18611. if err != nil {
  18612. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18613. }
  18614. return oldValue.Content, nil
  18615. }
  18616. // ResetContent resets all changes to the "content" field.
  18617. func (m *MessageMutation) ResetContent() {
  18618. m.content = nil
  18619. }
  18620. // Where appends a list predicates to the MessageMutation builder.
  18621. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18622. m.predicates = append(m.predicates, ps...)
  18623. }
  18624. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18625. // users can use type-assertion to append predicates that do not depend on any generated package.
  18626. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18627. p := make([]predicate.Message, len(ps))
  18628. for i := range ps {
  18629. p[i] = ps[i]
  18630. }
  18631. m.Where(p...)
  18632. }
  18633. // Op returns the operation name.
  18634. func (m *MessageMutation) Op() Op {
  18635. return m.op
  18636. }
  18637. // SetOp allows setting the mutation operation.
  18638. func (m *MessageMutation) SetOp(op Op) {
  18639. m.op = op
  18640. }
  18641. // Type returns the node type of this mutation (Message).
  18642. func (m *MessageMutation) Type() string {
  18643. return m.typ
  18644. }
  18645. // Fields returns all fields that were changed during this mutation. Note that in
  18646. // order to get all numeric fields that were incremented/decremented, call
  18647. // AddedFields().
  18648. func (m *MessageMutation) Fields() []string {
  18649. fields := make([]string, 0, 3)
  18650. if m.wx_wxid != nil {
  18651. fields = append(fields, message.FieldWxWxid)
  18652. }
  18653. if m.wxid != nil {
  18654. fields = append(fields, message.FieldWxid)
  18655. }
  18656. if m.content != nil {
  18657. fields = append(fields, message.FieldContent)
  18658. }
  18659. return fields
  18660. }
  18661. // Field returns the value of a field with the given name. The second boolean
  18662. // return value indicates that this field was not set, or was not defined in the
  18663. // schema.
  18664. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  18665. switch name {
  18666. case message.FieldWxWxid:
  18667. return m.WxWxid()
  18668. case message.FieldWxid:
  18669. return m.Wxid()
  18670. case message.FieldContent:
  18671. return m.Content()
  18672. }
  18673. return nil, false
  18674. }
  18675. // OldField returns the old value of the field from the database. An error is
  18676. // returned if the mutation operation is not UpdateOne, or the query to the
  18677. // database failed.
  18678. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18679. switch name {
  18680. case message.FieldWxWxid:
  18681. return m.OldWxWxid(ctx)
  18682. case message.FieldWxid:
  18683. return m.OldWxid(ctx)
  18684. case message.FieldContent:
  18685. return m.OldContent(ctx)
  18686. }
  18687. return nil, fmt.Errorf("unknown Message field %s", name)
  18688. }
  18689. // SetField sets the value of a field with the given name. It returns an error if
  18690. // the field is not defined in the schema, or if the type mismatched the field
  18691. // type.
  18692. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  18693. switch name {
  18694. case message.FieldWxWxid:
  18695. v, ok := value.(string)
  18696. if !ok {
  18697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18698. }
  18699. m.SetWxWxid(v)
  18700. return nil
  18701. case message.FieldWxid:
  18702. v, ok := value.(string)
  18703. if !ok {
  18704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18705. }
  18706. m.SetWxid(v)
  18707. return nil
  18708. case message.FieldContent:
  18709. v, ok := value.(string)
  18710. if !ok {
  18711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18712. }
  18713. m.SetContent(v)
  18714. return nil
  18715. }
  18716. return fmt.Errorf("unknown Message field %s", name)
  18717. }
  18718. // AddedFields returns all numeric fields that were incremented/decremented during
  18719. // this mutation.
  18720. func (m *MessageMutation) AddedFields() []string {
  18721. return nil
  18722. }
  18723. // AddedField returns the numeric value that was incremented/decremented on a field
  18724. // with the given name. The second boolean return value indicates that this field
  18725. // was not set, or was not defined in the schema.
  18726. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  18727. return nil, false
  18728. }
  18729. // AddField adds the value to the field with the given name. It returns an error if
  18730. // the field is not defined in the schema, or if the type mismatched the field
  18731. // type.
  18732. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  18733. switch name {
  18734. }
  18735. return fmt.Errorf("unknown Message numeric field %s", name)
  18736. }
  18737. // ClearedFields returns all nullable fields that were cleared during this
  18738. // mutation.
  18739. func (m *MessageMutation) ClearedFields() []string {
  18740. var fields []string
  18741. if m.FieldCleared(message.FieldWxWxid) {
  18742. fields = append(fields, message.FieldWxWxid)
  18743. }
  18744. return fields
  18745. }
  18746. // FieldCleared returns a boolean indicating if a field with the given name was
  18747. // cleared in this mutation.
  18748. func (m *MessageMutation) FieldCleared(name string) bool {
  18749. _, ok := m.clearedFields[name]
  18750. return ok
  18751. }
  18752. // ClearField clears the value of the field with the given name. It returns an
  18753. // error if the field is not defined in the schema.
  18754. func (m *MessageMutation) ClearField(name string) error {
  18755. switch name {
  18756. case message.FieldWxWxid:
  18757. m.ClearWxWxid()
  18758. return nil
  18759. }
  18760. return fmt.Errorf("unknown Message nullable field %s", name)
  18761. }
  18762. // ResetField resets all changes in the mutation for the field with the given name.
  18763. // It returns an error if the field is not defined in the schema.
  18764. func (m *MessageMutation) ResetField(name string) error {
  18765. switch name {
  18766. case message.FieldWxWxid:
  18767. m.ResetWxWxid()
  18768. return nil
  18769. case message.FieldWxid:
  18770. m.ResetWxid()
  18771. return nil
  18772. case message.FieldContent:
  18773. m.ResetContent()
  18774. return nil
  18775. }
  18776. return fmt.Errorf("unknown Message field %s", name)
  18777. }
  18778. // AddedEdges returns all edge names that were set/added in this mutation.
  18779. func (m *MessageMutation) AddedEdges() []string {
  18780. edges := make([]string, 0, 0)
  18781. return edges
  18782. }
  18783. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18784. // name in this mutation.
  18785. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  18786. return nil
  18787. }
  18788. // RemovedEdges returns all edge names that were removed in this mutation.
  18789. func (m *MessageMutation) RemovedEdges() []string {
  18790. edges := make([]string, 0, 0)
  18791. return edges
  18792. }
  18793. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18794. // the given name in this mutation.
  18795. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  18796. return nil
  18797. }
  18798. // ClearedEdges returns all edge names that were cleared in this mutation.
  18799. func (m *MessageMutation) ClearedEdges() []string {
  18800. edges := make([]string, 0, 0)
  18801. return edges
  18802. }
  18803. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18804. // was cleared in this mutation.
  18805. func (m *MessageMutation) EdgeCleared(name string) bool {
  18806. return false
  18807. }
  18808. // ClearEdge clears the value of the edge with the given name. It returns an error
  18809. // if that edge is not defined in the schema.
  18810. func (m *MessageMutation) ClearEdge(name string) error {
  18811. return fmt.Errorf("unknown Message unique edge %s", name)
  18812. }
  18813. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18814. // It returns an error if the edge is not defined in the schema.
  18815. func (m *MessageMutation) ResetEdge(name string) error {
  18816. return fmt.Errorf("unknown Message edge %s", name)
  18817. }
  18818. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  18819. type MessageRecordsMutation struct {
  18820. config
  18821. op Op
  18822. typ string
  18823. id *uint64
  18824. created_at *time.Time
  18825. updated_at *time.Time
  18826. status *uint8
  18827. addstatus *int8
  18828. bot_wxid *string
  18829. contact_type *int
  18830. addcontact_type *int
  18831. contact_wxid *string
  18832. content_type *int
  18833. addcontent_type *int
  18834. content *string
  18835. meta *custom_types.Meta
  18836. error_detail *string
  18837. send_time *time.Time
  18838. source_type *int
  18839. addsource_type *int
  18840. organization_id *uint64
  18841. addorganization_id *int64
  18842. clearedFields map[string]struct{}
  18843. sop_stage *uint64
  18844. clearedsop_stage bool
  18845. sop_node *uint64
  18846. clearedsop_node bool
  18847. message_contact *uint64
  18848. clearedmessage_contact bool
  18849. done bool
  18850. oldValue func(context.Context) (*MessageRecords, error)
  18851. predicates []predicate.MessageRecords
  18852. }
  18853. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  18854. // messagerecordsOption allows management of the mutation configuration using functional options.
  18855. type messagerecordsOption func(*MessageRecordsMutation)
  18856. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  18857. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  18858. m := &MessageRecordsMutation{
  18859. config: c,
  18860. op: op,
  18861. typ: TypeMessageRecords,
  18862. clearedFields: make(map[string]struct{}),
  18863. }
  18864. for _, opt := range opts {
  18865. opt(m)
  18866. }
  18867. return m
  18868. }
  18869. // withMessageRecordsID sets the ID field of the mutation.
  18870. func withMessageRecordsID(id uint64) messagerecordsOption {
  18871. return func(m *MessageRecordsMutation) {
  18872. var (
  18873. err error
  18874. once sync.Once
  18875. value *MessageRecords
  18876. )
  18877. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  18878. once.Do(func() {
  18879. if m.done {
  18880. err = errors.New("querying old values post mutation is not allowed")
  18881. } else {
  18882. value, err = m.Client().MessageRecords.Get(ctx, id)
  18883. }
  18884. })
  18885. return value, err
  18886. }
  18887. m.id = &id
  18888. }
  18889. }
  18890. // withMessageRecords sets the old MessageRecords of the mutation.
  18891. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  18892. return func(m *MessageRecordsMutation) {
  18893. m.oldValue = func(context.Context) (*MessageRecords, error) {
  18894. return node, nil
  18895. }
  18896. m.id = &node.ID
  18897. }
  18898. }
  18899. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18900. // executed in a transaction (ent.Tx), a transactional client is returned.
  18901. func (m MessageRecordsMutation) Client() *Client {
  18902. client := &Client{config: m.config}
  18903. client.init()
  18904. return client
  18905. }
  18906. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18907. // it returns an error otherwise.
  18908. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  18909. if _, ok := m.driver.(*txDriver); !ok {
  18910. return nil, errors.New("ent: mutation is not running in a transaction")
  18911. }
  18912. tx := &Tx{config: m.config}
  18913. tx.init()
  18914. return tx, nil
  18915. }
  18916. // SetID sets the value of the id field. Note that this
  18917. // operation is only accepted on creation of MessageRecords entities.
  18918. func (m *MessageRecordsMutation) SetID(id uint64) {
  18919. m.id = &id
  18920. }
  18921. // ID returns the ID value in the mutation. Note that the ID is only available
  18922. // if it was provided to the builder or after it was returned from the database.
  18923. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  18924. if m.id == nil {
  18925. return
  18926. }
  18927. return *m.id, true
  18928. }
  18929. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18930. // That means, if the mutation is applied within a transaction with an isolation level such
  18931. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18932. // or updated by the mutation.
  18933. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  18934. switch {
  18935. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18936. id, exists := m.ID()
  18937. if exists {
  18938. return []uint64{id}, nil
  18939. }
  18940. fallthrough
  18941. case m.op.Is(OpUpdate | OpDelete):
  18942. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  18943. default:
  18944. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18945. }
  18946. }
  18947. // SetCreatedAt sets the "created_at" field.
  18948. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  18949. m.created_at = &t
  18950. }
  18951. // CreatedAt returns the value of the "created_at" field in the mutation.
  18952. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  18953. v := m.created_at
  18954. if v == nil {
  18955. return
  18956. }
  18957. return *v, true
  18958. }
  18959. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  18960. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18962. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18963. if !m.op.Is(OpUpdateOne) {
  18964. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18965. }
  18966. if m.id == nil || m.oldValue == nil {
  18967. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18968. }
  18969. oldValue, err := m.oldValue(ctx)
  18970. if err != nil {
  18971. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18972. }
  18973. return oldValue.CreatedAt, nil
  18974. }
  18975. // ResetCreatedAt resets all changes to the "created_at" field.
  18976. func (m *MessageRecordsMutation) ResetCreatedAt() {
  18977. m.created_at = nil
  18978. }
  18979. // SetUpdatedAt sets the "updated_at" field.
  18980. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  18981. m.updated_at = &t
  18982. }
  18983. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18984. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  18985. v := m.updated_at
  18986. if v == nil {
  18987. return
  18988. }
  18989. return *v, true
  18990. }
  18991. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  18992. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18994. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18995. if !m.op.Is(OpUpdateOne) {
  18996. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18997. }
  18998. if m.id == nil || m.oldValue == nil {
  18999. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19000. }
  19001. oldValue, err := m.oldValue(ctx)
  19002. if err != nil {
  19003. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19004. }
  19005. return oldValue.UpdatedAt, nil
  19006. }
  19007. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19008. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  19009. m.updated_at = nil
  19010. }
  19011. // SetStatus sets the "status" field.
  19012. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  19013. m.status = &u
  19014. m.addstatus = nil
  19015. }
  19016. // Status returns the value of the "status" field in the mutation.
  19017. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  19018. v := m.status
  19019. if v == nil {
  19020. return
  19021. }
  19022. return *v, true
  19023. }
  19024. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  19025. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19027. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19028. if !m.op.Is(OpUpdateOne) {
  19029. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19030. }
  19031. if m.id == nil || m.oldValue == nil {
  19032. return v, errors.New("OldStatus requires an ID field in the mutation")
  19033. }
  19034. oldValue, err := m.oldValue(ctx)
  19035. if err != nil {
  19036. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19037. }
  19038. return oldValue.Status, nil
  19039. }
  19040. // AddStatus adds u to the "status" field.
  19041. func (m *MessageRecordsMutation) AddStatus(u int8) {
  19042. if m.addstatus != nil {
  19043. *m.addstatus += u
  19044. } else {
  19045. m.addstatus = &u
  19046. }
  19047. }
  19048. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19049. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  19050. v := m.addstatus
  19051. if v == nil {
  19052. return
  19053. }
  19054. return *v, true
  19055. }
  19056. // ClearStatus clears the value of the "status" field.
  19057. func (m *MessageRecordsMutation) ClearStatus() {
  19058. m.status = nil
  19059. m.addstatus = nil
  19060. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  19061. }
  19062. // StatusCleared returns if the "status" field was cleared in this mutation.
  19063. func (m *MessageRecordsMutation) StatusCleared() bool {
  19064. _, ok := m.clearedFields[messagerecords.FieldStatus]
  19065. return ok
  19066. }
  19067. // ResetStatus resets all changes to the "status" field.
  19068. func (m *MessageRecordsMutation) ResetStatus() {
  19069. m.status = nil
  19070. m.addstatus = nil
  19071. delete(m.clearedFields, messagerecords.FieldStatus)
  19072. }
  19073. // SetBotWxid sets the "bot_wxid" field.
  19074. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  19075. m.bot_wxid = &s
  19076. }
  19077. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  19078. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  19079. v := m.bot_wxid
  19080. if v == nil {
  19081. return
  19082. }
  19083. return *v, true
  19084. }
  19085. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19086. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19088. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19089. if !m.op.Is(OpUpdateOne) {
  19090. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19091. }
  19092. if m.id == nil || m.oldValue == nil {
  19093. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19094. }
  19095. oldValue, err := m.oldValue(ctx)
  19096. if err != nil {
  19097. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19098. }
  19099. return oldValue.BotWxid, nil
  19100. }
  19101. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19102. func (m *MessageRecordsMutation) ResetBotWxid() {
  19103. m.bot_wxid = nil
  19104. }
  19105. // SetContactID sets the "contact_id" field.
  19106. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19107. m.message_contact = &u
  19108. }
  19109. // ContactID returns the value of the "contact_id" field in the mutation.
  19110. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19111. v := m.message_contact
  19112. if v == nil {
  19113. return
  19114. }
  19115. return *v, true
  19116. }
  19117. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19118. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19120. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19121. if !m.op.Is(OpUpdateOne) {
  19122. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19123. }
  19124. if m.id == nil || m.oldValue == nil {
  19125. return v, errors.New("OldContactID requires an ID field in the mutation")
  19126. }
  19127. oldValue, err := m.oldValue(ctx)
  19128. if err != nil {
  19129. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19130. }
  19131. return oldValue.ContactID, nil
  19132. }
  19133. // ClearContactID clears the value of the "contact_id" field.
  19134. func (m *MessageRecordsMutation) ClearContactID() {
  19135. m.message_contact = nil
  19136. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19137. }
  19138. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19139. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19140. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19141. return ok
  19142. }
  19143. // ResetContactID resets all changes to the "contact_id" field.
  19144. func (m *MessageRecordsMutation) ResetContactID() {
  19145. m.message_contact = nil
  19146. delete(m.clearedFields, messagerecords.FieldContactID)
  19147. }
  19148. // SetContactType sets the "contact_type" field.
  19149. func (m *MessageRecordsMutation) SetContactType(i int) {
  19150. m.contact_type = &i
  19151. m.addcontact_type = nil
  19152. }
  19153. // ContactType returns the value of the "contact_type" field in the mutation.
  19154. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19155. v := m.contact_type
  19156. if v == nil {
  19157. return
  19158. }
  19159. return *v, true
  19160. }
  19161. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19162. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19164. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19165. if !m.op.Is(OpUpdateOne) {
  19166. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19167. }
  19168. if m.id == nil || m.oldValue == nil {
  19169. return v, errors.New("OldContactType requires an ID field in the mutation")
  19170. }
  19171. oldValue, err := m.oldValue(ctx)
  19172. if err != nil {
  19173. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19174. }
  19175. return oldValue.ContactType, nil
  19176. }
  19177. // AddContactType adds i to the "contact_type" field.
  19178. func (m *MessageRecordsMutation) AddContactType(i int) {
  19179. if m.addcontact_type != nil {
  19180. *m.addcontact_type += i
  19181. } else {
  19182. m.addcontact_type = &i
  19183. }
  19184. }
  19185. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19186. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19187. v := m.addcontact_type
  19188. if v == nil {
  19189. return
  19190. }
  19191. return *v, true
  19192. }
  19193. // ResetContactType resets all changes to the "contact_type" field.
  19194. func (m *MessageRecordsMutation) ResetContactType() {
  19195. m.contact_type = nil
  19196. m.addcontact_type = nil
  19197. }
  19198. // SetContactWxid sets the "contact_wxid" field.
  19199. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19200. m.contact_wxid = &s
  19201. }
  19202. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19203. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19204. v := m.contact_wxid
  19205. if v == nil {
  19206. return
  19207. }
  19208. return *v, true
  19209. }
  19210. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19211. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19213. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19214. if !m.op.Is(OpUpdateOne) {
  19215. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19216. }
  19217. if m.id == nil || m.oldValue == nil {
  19218. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19219. }
  19220. oldValue, err := m.oldValue(ctx)
  19221. if err != nil {
  19222. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19223. }
  19224. return oldValue.ContactWxid, nil
  19225. }
  19226. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19227. func (m *MessageRecordsMutation) ResetContactWxid() {
  19228. m.contact_wxid = nil
  19229. }
  19230. // SetContentType sets the "content_type" field.
  19231. func (m *MessageRecordsMutation) SetContentType(i int) {
  19232. m.content_type = &i
  19233. m.addcontent_type = nil
  19234. }
  19235. // ContentType returns the value of the "content_type" field in the mutation.
  19236. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19237. v := m.content_type
  19238. if v == nil {
  19239. return
  19240. }
  19241. return *v, true
  19242. }
  19243. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19244. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19246. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19247. if !m.op.Is(OpUpdateOne) {
  19248. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19249. }
  19250. if m.id == nil || m.oldValue == nil {
  19251. return v, errors.New("OldContentType requires an ID field in the mutation")
  19252. }
  19253. oldValue, err := m.oldValue(ctx)
  19254. if err != nil {
  19255. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19256. }
  19257. return oldValue.ContentType, nil
  19258. }
  19259. // AddContentType adds i to the "content_type" field.
  19260. func (m *MessageRecordsMutation) AddContentType(i int) {
  19261. if m.addcontent_type != nil {
  19262. *m.addcontent_type += i
  19263. } else {
  19264. m.addcontent_type = &i
  19265. }
  19266. }
  19267. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19268. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19269. v := m.addcontent_type
  19270. if v == nil {
  19271. return
  19272. }
  19273. return *v, true
  19274. }
  19275. // ResetContentType resets all changes to the "content_type" field.
  19276. func (m *MessageRecordsMutation) ResetContentType() {
  19277. m.content_type = nil
  19278. m.addcontent_type = nil
  19279. }
  19280. // SetContent sets the "content" field.
  19281. func (m *MessageRecordsMutation) SetContent(s string) {
  19282. m.content = &s
  19283. }
  19284. // Content returns the value of the "content" field in the mutation.
  19285. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19286. v := m.content
  19287. if v == nil {
  19288. return
  19289. }
  19290. return *v, true
  19291. }
  19292. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19293. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19295. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19296. if !m.op.Is(OpUpdateOne) {
  19297. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19298. }
  19299. if m.id == nil || m.oldValue == nil {
  19300. return v, errors.New("OldContent requires an ID field in the mutation")
  19301. }
  19302. oldValue, err := m.oldValue(ctx)
  19303. if err != nil {
  19304. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19305. }
  19306. return oldValue.Content, nil
  19307. }
  19308. // ResetContent resets all changes to the "content" field.
  19309. func (m *MessageRecordsMutation) ResetContent() {
  19310. m.content = nil
  19311. }
  19312. // SetMeta sets the "meta" field.
  19313. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19314. m.meta = &ct
  19315. }
  19316. // Meta returns the value of the "meta" field in the mutation.
  19317. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19318. v := m.meta
  19319. if v == nil {
  19320. return
  19321. }
  19322. return *v, true
  19323. }
  19324. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19325. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19327. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19328. if !m.op.Is(OpUpdateOne) {
  19329. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19330. }
  19331. if m.id == nil || m.oldValue == nil {
  19332. return v, errors.New("OldMeta requires an ID field in the mutation")
  19333. }
  19334. oldValue, err := m.oldValue(ctx)
  19335. if err != nil {
  19336. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19337. }
  19338. return oldValue.Meta, nil
  19339. }
  19340. // ClearMeta clears the value of the "meta" field.
  19341. func (m *MessageRecordsMutation) ClearMeta() {
  19342. m.meta = nil
  19343. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19344. }
  19345. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19346. func (m *MessageRecordsMutation) MetaCleared() bool {
  19347. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19348. return ok
  19349. }
  19350. // ResetMeta resets all changes to the "meta" field.
  19351. func (m *MessageRecordsMutation) ResetMeta() {
  19352. m.meta = nil
  19353. delete(m.clearedFields, messagerecords.FieldMeta)
  19354. }
  19355. // SetErrorDetail sets the "error_detail" field.
  19356. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19357. m.error_detail = &s
  19358. }
  19359. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19360. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19361. v := m.error_detail
  19362. if v == nil {
  19363. return
  19364. }
  19365. return *v, true
  19366. }
  19367. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19368. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19370. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19371. if !m.op.Is(OpUpdateOne) {
  19372. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19373. }
  19374. if m.id == nil || m.oldValue == nil {
  19375. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19376. }
  19377. oldValue, err := m.oldValue(ctx)
  19378. if err != nil {
  19379. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19380. }
  19381. return oldValue.ErrorDetail, nil
  19382. }
  19383. // ResetErrorDetail resets all changes to the "error_detail" field.
  19384. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19385. m.error_detail = nil
  19386. }
  19387. // SetSendTime sets the "send_time" field.
  19388. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19389. m.send_time = &t
  19390. }
  19391. // SendTime returns the value of the "send_time" field in the mutation.
  19392. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19393. v := m.send_time
  19394. if v == nil {
  19395. return
  19396. }
  19397. return *v, true
  19398. }
  19399. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  19400. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19402. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19403. if !m.op.Is(OpUpdateOne) {
  19404. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19405. }
  19406. if m.id == nil || m.oldValue == nil {
  19407. return v, errors.New("OldSendTime requires an ID field in the mutation")
  19408. }
  19409. oldValue, err := m.oldValue(ctx)
  19410. if err != nil {
  19411. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  19412. }
  19413. return oldValue.SendTime, nil
  19414. }
  19415. // ClearSendTime clears the value of the "send_time" field.
  19416. func (m *MessageRecordsMutation) ClearSendTime() {
  19417. m.send_time = nil
  19418. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19419. }
  19420. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19421. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19422. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19423. return ok
  19424. }
  19425. // ResetSendTime resets all changes to the "send_time" field.
  19426. func (m *MessageRecordsMutation) ResetSendTime() {
  19427. m.send_time = nil
  19428. delete(m.clearedFields, messagerecords.FieldSendTime)
  19429. }
  19430. // SetSourceType sets the "source_type" field.
  19431. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19432. m.source_type = &i
  19433. m.addsource_type = nil
  19434. }
  19435. // SourceType returns the value of the "source_type" field in the mutation.
  19436. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19437. v := m.source_type
  19438. if v == nil {
  19439. return
  19440. }
  19441. return *v, true
  19442. }
  19443. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19444. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19446. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19447. if !m.op.Is(OpUpdateOne) {
  19448. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19449. }
  19450. if m.id == nil || m.oldValue == nil {
  19451. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19452. }
  19453. oldValue, err := m.oldValue(ctx)
  19454. if err != nil {
  19455. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19456. }
  19457. return oldValue.SourceType, nil
  19458. }
  19459. // AddSourceType adds i to the "source_type" field.
  19460. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19461. if m.addsource_type != nil {
  19462. *m.addsource_type += i
  19463. } else {
  19464. m.addsource_type = &i
  19465. }
  19466. }
  19467. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19468. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19469. v := m.addsource_type
  19470. if v == nil {
  19471. return
  19472. }
  19473. return *v, true
  19474. }
  19475. // ResetSourceType resets all changes to the "source_type" field.
  19476. func (m *MessageRecordsMutation) ResetSourceType() {
  19477. m.source_type = nil
  19478. m.addsource_type = nil
  19479. }
  19480. // SetSourceID sets the "source_id" field.
  19481. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19482. m.sop_stage = &u
  19483. }
  19484. // SourceID returns the value of the "source_id" field in the mutation.
  19485. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19486. v := m.sop_stage
  19487. if v == nil {
  19488. return
  19489. }
  19490. return *v, true
  19491. }
  19492. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19493. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19495. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19496. if !m.op.Is(OpUpdateOne) {
  19497. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19498. }
  19499. if m.id == nil || m.oldValue == nil {
  19500. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19501. }
  19502. oldValue, err := m.oldValue(ctx)
  19503. if err != nil {
  19504. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19505. }
  19506. return oldValue.SourceID, nil
  19507. }
  19508. // ClearSourceID clears the value of the "source_id" field.
  19509. func (m *MessageRecordsMutation) ClearSourceID() {
  19510. m.sop_stage = nil
  19511. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19512. }
  19513. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19514. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19515. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19516. return ok
  19517. }
  19518. // ResetSourceID resets all changes to the "source_id" field.
  19519. func (m *MessageRecordsMutation) ResetSourceID() {
  19520. m.sop_stage = nil
  19521. delete(m.clearedFields, messagerecords.FieldSourceID)
  19522. }
  19523. // SetSubSourceID sets the "sub_source_id" field.
  19524. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19525. m.sop_node = &u
  19526. }
  19527. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19528. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19529. v := m.sop_node
  19530. if v == nil {
  19531. return
  19532. }
  19533. return *v, true
  19534. }
  19535. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19536. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19538. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19539. if !m.op.Is(OpUpdateOne) {
  19540. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19541. }
  19542. if m.id == nil || m.oldValue == nil {
  19543. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19544. }
  19545. oldValue, err := m.oldValue(ctx)
  19546. if err != nil {
  19547. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19548. }
  19549. return oldValue.SubSourceID, nil
  19550. }
  19551. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19552. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19553. m.sop_node = nil
  19554. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19555. }
  19556. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19557. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19558. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19559. return ok
  19560. }
  19561. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19562. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19563. m.sop_node = nil
  19564. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19565. }
  19566. // SetOrganizationID sets the "organization_id" field.
  19567. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19568. m.organization_id = &u
  19569. m.addorganization_id = nil
  19570. }
  19571. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19572. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19573. v := m.organization_id
  19574. if v == nil {
  19575. return
  19576. }
  19577. return *v, true
  19578. }
  19579. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19580. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19582. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19583. if !m.op.Is(OpUpdateOne) {
  19584. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19585. }
  19586. if m.id == nil || m.oldValue == nil {
  19587. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19588. }
  19589. oldValue, err := m.oldValue(ctx)
  19590. if err != nil {
  19591. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19592. }
  19593. return oldValue.OrganizationID, nil
  19594. }
  19595. // AddOrganizationID adds u to the "organization_id" field.
  19596. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19597. if m.addorganization_id != nil {
  19598. *m.addorganization_id += u
  19599. } else {
  19600. m.addorganization_id = &u
  19601. }
  19602. }
  19603. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19604. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19605. v := m.addorganization_id
  19606. if v == nil {
  19607. return
  19608. }
  19609. return *v, true
  19610. }
  19611. // ClearOrganizationID clears the value of the "organization_id" field.
  19612. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19613. m.organization_id = nil
  19614. m.addorganization_id = nil
  19615. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19616. }
  19617. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19618. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19619. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19620. return ok
  19621. }
  19622. // ResetOrganizationID resets all changes to the "organization_id" field.
  19623. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19624. m.organization_id = nil
  19625. m.addorganization_id = nil
  19626. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19627. }
  19628. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19629. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19630. m.sop_stage = &id
  19631. }
  19632. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19633. func (m *MessageRecordsMutation) ClearSopStage() {
  19634. m.clearedsop_stage = true
  19635. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19636. }
  19637. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  19638. func (m *MessageRecordsMutation) SopStageCleared() bool {
  19639. return m.SourceIDCleared() || m.clearedsop_stage
  19640. }
  19641. // SopStageID returns the "sop_stage" edge ID in the mutation.
  19642. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  19643. if m.sop_stage != nil {
  19644. return *m.sop_stage, true
  19645. }
  19646. return
  19647. }
  19648. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  19649. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19650. // SopStageID instead. It exists only for internal usage by the builders.
  19651. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  19652. if id := m.sop_stage; id != nil {
  19653. ids = append(ids, *id)
  19654. }
  19655. return
  19656. }
  19657. // ResetSopStage resets all changes to the "sop_stage" edge.
  19658. func (m *MessageRecordsMutation) ResetSopStage() {
  19659. m.sop_stage = nil
  19660. m.clearedsop_stage = false
  19661. }
  19662. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  19663. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  19664. m.sop_node = &id
  19665. }
  19666. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  19667. func (m *MessageRecordsMutation) ClearSopNode() {
  19668. m.clearedsop_node = true
  19669. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19670. }
  19671. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  19672. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  19673. return m.SubSourceIDCleared() || m.clearedsop_node
  19674. }
  19675. // SopNodeID returns the "sop_node" edge ID in the mutation.
  19676. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  19677. if m.sop_node != nil {
  19678. return *m.sop_node, true
  19679. }
  19680. return
  19681. }
  19682. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  19683. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19684. // SopNodeID instead. It exists only for internal usage by the builders.
  19685. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  19686. if id := m.sop_node; id != nil {
  19687. ids = append(ids, *id)
  19688. }
  19689. return
  19690. }
  19691. // ResetSopNode resets all changes to the "sop_node" edge.
  19692. func (m *MessageRecordsMutation) ResetSopNode() {
  19693. m.sop_node = nil
  19694. m.clearedsop_node = false
  19695. }
  19696. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  19697. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  19698. m.message_contact = &id
  19699. }
  19700. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  19701. func (m *MessageRecordsMutation) ClearMessageContact() {
  19702. m.clearedmessage_contact = true
  19703. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19704. }
  19705. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  19706. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  19707. return m.ContactIDCleared() || m.clearedmessage_contact
  19708. }
  19709. // MessageContactID returns the "message_contact" edge ID in the mutation.
  19710. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  19711. if m.message_contact != nil {
  19712. return *m.message_contact, true
  19713. }
  19714. return
  19715. }
  19716. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  19717. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19718. // MessageContactID instead. It exists only for internal usage by the builders.
  19719. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  19720. if id := m.message_contact; id != nil {
  19721. ids = append(ids, *id)
  19722. }
  19723. return
  19724. }
  19725. // ResetMessageContact resets all changes to the "message_contact" edge.
  19726. func (m *MessageRecordsMutation) ResetMessageContact() {
  19727. m.message_contact = nil
  19728. m.clearedmessage_contact = false
  19729. }
  19730. // Where appends a list predicates to the MessageRecordsMutation builder.
  19731. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  19732. m.predicates = append(m.predicates, ps...)
  19733. }
  19734. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  19735. // users can use type-assertion to append predicates that do not depend on any generated package.
  19736. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  19737. p := make([]predicate.MessageRecords, len(ps))
  19738. for i := range ps {
  19739. p[i] = ps[i]
  19740. }
  19741. m.Where(p...)
  19742. }
  19743. // Op returns the operation name.
  19744. func (m *MessageRecordsMutation) Op() Op {
  19745. return m.op
  19746. }
  19747. // SetOp allows setting the mutation operation.
  19748. func (m *MessageRecordsMutation) SetOp(op Op) {
  19749. m.op = op
  19750. }
  19751. // Type returns the node type of this mutation (MessageRecords).
  19752. func (m *MessageRecordsMutation) Type() string {
  19753. return m.typ
  19754. }
  19755. // Fields returns all fields that were changed during this mutation. Note that in
  19756. // order to get all numeric fields that were incremented/decremented, call
  19757. // AddedFields().
  19758. func (m *MessageRecordsMutation) Fields() []string {
  19759. fields := make([]string, 0, 16)
  19760. if m.created_at != nil {
  19761. fields = append(fields, messagerecords.FieldCreatedAt)
  19762. }
  19763. if m.updated_at != nil {
  19764. fields = append(fields, messagerecords.FieldUpdatedAt)
  19765. }
  19766. if m.status != nil {
  19767. fields = append(fields, messagerecords.FieldStatus)
  19768. }
  19769. if m.bot_wxid != nil {
  19770. fields = append(fields, messagerecords.FieldBotWxid)
  19771. }
  19772. if m.message_contact != nil {
  19773. fields = append(fields, messagerecords.FieldContactID)
  19774. }
  19775. if m.contact_type != nil {
  19776. fields = append(fields, messagerecords.FieldContactType)
  19777. }
  19778. if m.contact_wxid != nil {
  19779. fields = append(fields, messagerecords.FieldContactWxid)
  19780. }
  19781. if m.content_type != nil {
  19782. fields = append(fields, messagerecords.FieldContentType)
  19783. }
  19784. if m.content != nil {
  19785. fields = append(fields, messagerecords.FieldContent)
  19786. }
  19787. if m.meta != nil {
  19788. fields = append(fields, messagerecords.FieldMeta)
  19789. }
  19790. if m.error_detail != nil {
  19791. fields = append(fields, messagerecords.FieldErrorDetail)
  19792. }
  19793. if m.send_time != nil {
  19794. fields = append(fields, messagerecords.FieldSendTime)
  19795. }
  19796. if m.source_type != nil {
  19797. fields = append(fields, messagerecords.FieldSourceType)
  19798. }
  19799. if m.sop_stage != nil {
  19800. fields = append(fields, messagerecords.FieldSourceID)
  19801. }
  19802. if m.sop_node != nil {
  19803. fields = append(fields, messagerecords.FieldSubSourceID)
  19804. }
  19805. if m.organization_id != nil {
  19806. fields = append(fields, messagerecords.FieldOrganizationID)
  19807. }
  19808. return fields
  19809. }
  19810. // Field returns the value of a field with the given name. The second boolean
  19811. // return value indicates that this field was not set, or was not defined in the
  19812. // schema.
  19813. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  19814. switch name {
  19815. case messagerecords.FieldCreatedAt:
  19816. return m.CreatedAt()
  19817. case messagerecords.FieldUpdatedAt:
  19818. return m.UpdatedAt()
  19819. case messagerecords.FieldStatus:
  19820. return m.Status()
  19821. case messagerecords.FieldBotWxid:
  19822. return m.BotWxid()
  19823. case messagerecords.FieldContactID:
  19824. return m.ContactID()
  19825. case messagerecords.FieldContactType:
  19826. return m.ContactType()
  19827. case messagerecords.FieldContactWxid:
  19828. return m.ContactWxid()
  19829. case messagerecords.FieldContentType:
  19830. return m.ContentType()
  19831. case messagerecords.FieldContent:
  19832. return m.Content()
  19833. case messagerecords.FieldMeta:
  19834. return m.Meta()
  19835. case messagerecords.FieldErrorDetail:
  19836. return m.ErrorDetail()
  19837. case messagerecords.FieldSendTime:
  19838. return m.SendTime()
  19839. case messagerecords.FieldSourceType:
  19840. return m.SourceType()
  19841. case messagerecords.FieldSourceID:
  19842. return m.SourceID()
  19843. case messagerecords.FieldSubSourceID:
  19844. return m.SubSourceID()
  19845. case messagerecords.FieldOrganizationID:
  19846. return m.OrganizationID()
  19847. }
  19848. return nil, false
  19849. }
  19850. // OldField returns the old value of the field from the database. An error is
  19851. // returned if the mutation operation is not UpdateOne, or the query to the
  19852. // database failed.
  19853. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19854. switch name {
  19855. case messagerecords.FieldCreatedAt:
  19856. return m.OldCreatedAt(ctx)
  19857. case messagerecords.FieldUpdatedAt:
  19858. return m.OldUpdatedAt(ctx)
  19859. case messagerecords.FieldStatus:
  19860. return m.OldStatus(ctx)
  19861. case messagerecords.FieldBotWxid:
  19862. return m.OldBotWxid(ctx)
  19863. case messagerecords.FieldContactID:
  19864. return m.OldContactID(ctx)
  19865. case messagerecords.FieldContactType:
  19866. return m.OldContactType(ctx)
  19867. case messagerecords.FieldContactWxid:
  19868. return m.OldContactWxid(ctx)
  19869. case messagerecords.FieldContentType:
  19870. return m.OldContentType(ctx)
  19871. case messagerecords.FieldContent:
  19872. return m.OldContent(ctx)
  19873. case messagerecords.FieldMeta:
  19874. return m.OldMeta(ctx)
  19875. case messagerecords.FieldErrorDetail:
  19876. return m.OldErrorDetail(ctx)
  19877. case messagerecords.FieldSendTime:
  19878. return m.OldSendTime(ctx)
  19879. case messagerecords.FieldSourceType:
  19880. return m.OldSourceType(ctx)
  19881. case messagerecords.FieldSourceID:
  19882. return m.OldSourceID(ctx)
  19883. case messagerecords.FieldSubSourceID:
  19884. return m.OldSubSourceID(ctx)
  19885. case messagerecords.FieldOrganizationID:
  19886. return m.OldOrganizationID(ctx)
  19887. }
  19888. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  19889. }
  19890. // SetField sets the value of a field with the given name. It returns an error if
  19891. // the field is not defined in the schema, or if the type mismatched the field
  19892. // type.
  19893. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  19894. switch name {
  19895. case messagerecords.FieldCreatedAt:
  19896. v, ok := value.(time.Time)
  19897. if !ok {
  19898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19899. }
  19900. m.SetCreatedAt(v)
  19901. return nil
  19902. case messagerecords.FieldUpdatedAt:
  19903. v, ok := value.(time.Time)
  19904. if !ok {
  19905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19906. }
  19907. m.SetUpdatedAt(v)
  19908. return nil
  19909. case messagerecords.FieldStatus:
  19910. v, ok := value.(uint8)
  19911. if !ok {
  19912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19913. }
  19914. m.SetStatus(v)
  19915. return nil
  19916. case messagerecords.FieldBotWxid:
  19917. v, ok := value.(string)
  19918. if !ok {
  19919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19920. }
  19921. m.SetBotWxid(v)
  19922. return nil
  19923. case messagerecords.FieldContactID:
  19924. v, ok := value.(uint64)
  19925. if !ok {
  19926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19927. }
  19928. m.SetContactID(v)
  19929. return nil
  19930. case messagerecords.FieldContactType:
  19931. v, ok := value.(int)
  19932. if !ok {
  19933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19934. }
  19935. m.SetContactType(v)
  19936. return nil
  19937. case messagerecords.FieldContactWxid:
  19938. v, ok := value.(string)
  19939. if !ok {
  19940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19941. }
  19942. m.SetContactWxid(v)
  19943. return nil
  19944. case messagerecords.FieldContentType:
  19945. v, ok := value.(int)
  19946. if !ok {
  19947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19948. }
  19949. m.SetContentType(v)
  19950. return nil
  19951. case messagerecords.FieldContent:
  19952. v, ok := value.(string)
  19953. if !ok {
  19954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19955. }
  19956. m.SetContent(v)
  19957. return nil
  19958. case messagerecords.FieldMeta:
  19959. v, ok := value.(custom_types.Meta)
  19960. if !ok {
  19961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19962. }
  19963. m.SetMeta(v)
  19964. return nil
  19965. case messagerecords.FieldErrorDetail:
  19966. v, ok := value.(string)
  19967. if !ok {
  19968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19969. }
  19970. m.SetErrorDetail(v)
  19971. return nil
  19972. case messagerecords.FieldSendTime:
  19973. v, ok := value.(time.Time)
  19974. if !ok {
  19975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19976. }
  19977. m.SetSendTime(v)
  19978. return nil
  19979. case messagerecords.FieldSourceType:
  19980. v, ok := value.(int)
  19981. if !ok {
  19982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19983. }
  19984. m.SetSourceType(v)
  19985. return nil
  19986. case messagerecords.FieldSourceID:
  19987. v, ok := value.(uint64)
  19988. if !ok {
  19989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19990. }
  19991. m.SetSourceID(v)
  19992. return nil
  19993. case messagerecords.FieldSubSourceID:
  19994. v, ok := value.(uint64)
  19995. if !ok {
  19996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19997. }
  19998. m.SetSubSourceID(v)
  19999. return nil
  20000. case messagerecords.FieldOrganizationID:
  20001. v, ok := value.(uint64)
  20002. if !ok {
  20003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20004. }
  20005. m.SetOrganizationID(v)
  20006. return nil
  20007. }
  20008. return fmt.Errorf("unknown MessageRecords field %s", name)
  20009. }
  20010. // AddedFields returns all numeric fields that were incremented/decremented during
  20011. // this mutation.
  20012. func (m *MessageRecordsMutation) AddedFields() []string {
  20013. var fields []string
  20014. if m.addstatus != nil {
  20015. fields = append(fields, messagerecords.FieldStatus)
  20016. }
  20017. if m.addcontact_type != nil {
  20018. fields = append(fields, messagerecords.FieldContactType)
  20019. }
  20020. if m.addcontent_type != nil {
  20021. fields = append(fields, messagerecords.FieldContentType)
  20022. }
  20023. if m.addsource_type != nil {
  20024. fields = append(fields, messagerecords.FieldSourceType)
  20025. }
  20026. if m.addorganization_id != nil {
  20027. fields = append(fields, messagerecords.FieldOrganizationID)
  20028. }
  20029. return fields
  20030. }
  20031. // AddedField returns the numeric value that was incremented/decremented on a field
  20032. // with the given name. The second boolean return value indicates that this field
  20033. // was not set, or was not defined in the schema.
  20034. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  20035. switch name {
  20036. case messagerecords.FieldStatus:
  20037. return m.AddedStatus()
  20038. case messagerecords.FieldContactType:
  20039. return m.AddedContactType()
  20040. case messagerecords.FieldContentType:
  20041. return m.AddedContentType()
  20042. case messagerecords.FieldSourceType:
  20043. return m.AddedSourceType()
  20044. case messagerecords.FieldOrganizationID:
  20045. return m.AddedOrganizationID()
  20046. }
  20047. return nil, false
  20048. }
  20049. // AddField adds the value to the field with the given name. It returns an error if
  20050. // the field is not defined in the schema, or if the type mismatched the field
  20051. // type.
  20052. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  20053. switch name {
  20054. case messagerecords.FieldStatus:
  20055. v, ok := value.(int8)
  20056. if !ok {
  20057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20058. }
  20059. m.AddStatus(v)
  20060. return nil
  20061. case messagerecords.FieldContactType:
  20062. v, ok := value.(int)
  20063. if !ok {
  20064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20065. }
  20066. m.AddContactType(v)
  20067. return nil
  20068. case messagerecords.FieldContentType:
  20069. v, ok := value.(int)
  20070. if !ok {
  20071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20072. }
  20073. m.AddContentType(v)
  20074. return nil
  20075. case messagerecords.FieldSourceType:
  20076. v, ok := value.(int)
  20077. if !ok {
  20078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20079. }
  20080. m.AddSourceType(v)
  20081. return nil
  20082. case messagerecords.FieldOrganizationID:
  20083. v, ok := value.(int64)
  20084. if !ok {
  20085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20086. }
  20087. m.AddOrganizationID(v)
  20088. return nil
  20089. }
  20090. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20091. }
  20092. // ClearedFields returns all nullable fields that were cleared during this
  20093. // mutation.
  20094. func (m *MessageRecordsMutation) ClearedFields() []string {
  20095. var fields []string
  20096. if m.FieldCleared(messagerecords.FieldStatus) {
  20097. fields = append(fields, messagerecords.FieldStatus)
  20098. }
  20099. if m.FieldCleared(messagerecords.FieldContactID) {
  20100. fields = append(fields, messagerecords.FieldContactID)
  20101. }
  20102. if m.FieldCleared(messagerecords.FieldMeta) {
  20103. fields = append(fields, messagerecords.FieldMeta)
  20104. }
  20105. if m.FieldCleared(messagerecords.FieldSendTime) {
  20106. fields = append(fields, messagerecords.FieldSendTime)
  20107. }
  20108. if m.FieldCleared(messagerecords.FieldSourceID) {
  20109. fields = append(fields, messagerecords.FieldSourceID)
  20110. }
  20111. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20112. fields = append(fields, messagerecords.FieldSubSourceID)
  20113. }
  20114. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20115. fields = append(fields, messagerecords.FieldOrganizationID)
  20116. }
  20117. return fields
  20118. }
  20119. // FieldCleared returns a boolean indicating if a field with the given name was
  20120. // cleared in this mutation.
  20121. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20122. _, ok := m.clearedFields[name]
  20123. return ok
  20124. }
  20125. // ClearField clears the value of the field with the given name. It returns an
  20126. // error if the field is not defined in the schema.
  20127. func (m *MessageRecordsMutation) ClearField(name string) error {
  20128. switch name {
  20129. case messagerecords.FieldStatus:
  20130. m.ClearStatus()
  20131. return nil
  20132. case messagerecords.FieldContactID:
  20133. m.ClearContactID()
  20134. return nil
  20135. case messagerecords.FieldMeta:
  20136. m.ClearMeta()
  20137. return nil
  20138. case messagerecords.FieldSendTime:
  20139. m.ClearSendTime()
  20140. return nil
  20141. case messagerecords.FieldSourceID:
  20142. m.ClearSourceID()
  20143. return nil
  20144. case messagerecords.FieldSubSourceID:
  20145. m.ClearSubSourceID()
  20146. return nil
  20147. case messagerecords.FieldOrganizationID:
  20148. m.ClearOrganizationID()
  20149. return nil
  20150. }
  20151. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20152. }
  20153. // ResetField resets all changes in the mutation for the field with the given name.
  20154. // It returns an error if the field is not defined in the schema.
  20155. func (m *MessageRecordsMutation) ResetField(name string) error {
  20156. switch name {
  20157. case messagerecords.FieldCreatedAt:
  20158. m.ResetCreatedAt()
  20159. return nil
  20160. case messagerecords.FieldUpdatedAt:
  20161. m.ResetUpdatedAt()
  20162. return nil
  20163. case messagerecords.FieldStatus:
  20164. m.ResetStatus()
  20165. return nil
  20166. case messagerecords.FieldBotWxid:
  20167. m.ResetBotWxid()
  20168. return nil
  20169. case messagerecords.FieldContactID:
  20170. m.ResetContactID()
  20171. return nil
  20172. case messagerecords.FieldContactType:
  20173. m.ResetContactType()
  20174. return nil
  20175. case messagerecords.FieldContactWxid:
  20176. m.ResetContactWxid()
  20177. return nil
  20178. case messagerecords.FieldContentType:
  20179. m.ResetContentType()
  20180. return nil
  20181. case messagerecords.FieldContent:
  20182. m.ResetContent()
  20183. return nil
  20184. case messagerecords.FieldMeta:
  20185. m.ResetMeta()
  20186. return nil
  20187. case messagerecords.FieldErrorDetail:
  20188. m.ResetErrorDetail()
  20189. return nil
  20190. case messagerecords.FieldSendTime:
  20191. m.ResetSendTime()
  20192. return nil
  20193. case messagerecords.FieldSourceType:
  20194. m.ResetSourceType()
  20195. return nil
  20196. case messagerecords.FieldSourceID:
  20197. m.ResetSourceID()
  20198. return nil
  20199. case messagerecords.FieldSubSourceID:
  20200. m.ResetSubSourceID()
  20201. return nil
  20202. case messagerecords.FieldOrganizationID:
  20203. m.ResetOrganizationID()
  20204. return nil
  20205. }
  20206. return fmt.Errorf("unknown MessageRecords field %s", name)
  20207. }
  20208. // AddedEdges returns all edge names that were set/added in this mutation.
  20209. func (m *MessageRecordsMutation) AddedEdges() []string {
  20210. edges := make([]string, 0, 3)
  20211. if m.sop_stage != nil {
  20212. edges = append(edges, messagerecords.EdgeSopStage)
  20213. }
  20214. if m.sop_node != nil {
  20215. edges = append(edges, messagerecords.EdgeSopNode)
  20216. }
  20217. if m.message_contact != nil {
  20218. edges = append(edges, messagerecords.EdgeMessageContact)
  20219. }
  20220. return edges
  20221. }
  20222. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20223. // name in this mutation.
  20224. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20225. switch name {
  20226. case messagerecords.EdgeSopStage:
  20227. if id := m.sop_stage; id != nil {
  20228. return []ent.Value{*id}
  20229. }
  20230. case messagerecords.EdgeSopNode:
  20231. if id := m.sop_node; id != nil {
  20232. return []ent.Value{*id}
  20233. }
  20234. case messagerecords.EdgeMessageContact:
  20235. if id := m.message_contact; id != nil {
  20236. return []ent.Value{*id}
  20237. }
  20238. }
  20239. return nil
  20240. }
  20241. // RemovedEdges returns all edge names that were removed in this mutation.
  20242. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20243. edges := make([]string, 0, 3)
  20244. return edges
  20245. }
  20246. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20247. // the given name in this mutation.
  20248. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20249. return nil
  20250. }
  20251. // ClearedEdges returns all edge names that were cleared in this mutation.
  20252. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20253. edges := make([]string, 0, 3)
  20254. if m.clearedsop_stage {
  20255. edges = append(edges, messagerecords.EdgeSopStage)
  20256. }
  20257. if m.clearedsop_node {
  20258. edges = append(edges, messagerecords.EdgeSopNode)
  20259. }
  20260. if m.clearedmessage_contact {
  20261. edges = append(edges, messagerecords.EdgeMessageContact)
  20262. }
  20263. return edges
  20264. }
  20265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20266. // was cleared in this mutation.
  20267. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20268. switch name {
  20269. case messagerecords.EdgeSopStage:
  20270. return m.clearedsop_stage
  20271. case messagerecords.EdgeSopNode:
  20272. return m.clearedsop_node
  20273. case messagerecords.EdgeMessageContact:
  20274. return m.clearedmessage_contact
  20275. }
  20276. return false
  20277. }
  20278. // ClearEdge clears the value of the edge with the given name. It returns an error
  20279. // if that edge is not defined in the schema.
  20280. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20281. switch name {
  20282. case messagerecords.EdgeSopStage:
  20283. m.ClearSopStage()
  20284. return nil
  20285. case messagerecords.EdgeSopNode:
  20286. m.ClearSopNode()
  20287. return nil
  20288. case messagerecords.EdgeMessageContact:
  20289. m.ClearMessageContact()
  20290. return nil
  20291. }
  20292. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20293. }
  20294. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20295. // It returns an error if the edge is not defined in the schema.
  20296. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20297. switch name {
  20298. case messagerecords.EdgeSopStage:
  20299. m.ResetSopStage()
  20300. return nil
  20301. case messagerecords.EdgeSopNode:
  20302. m.ResetSopNode()
  20303. return nil
  20304. case messagerecords.EdgeMessageContact:
  20305. m.ResetMessageContact()
  20306. return nil
  20307. }
  20308. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20309. }
  20310. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20311. type MsgMutation struct {
  20312. config
  20313. op Op
  20314. typ string
  20315. id *uint64
  20316. created_at *time.Time
  20317. updated_at *time.Time
  20318. deleted_at *time.Time
  20319. status *uint8
  20320. addstatus *int8
  20321. fromwxid *string
  20322. toid *string
  20323. msgtype *int32
  20324. addmsgtype *int32
  20325. msg *string
  20326. batch_no *string
  20327. cc *string
  20328. phone *string
  20329. clearedFields map[string]struct{}
  20330. done bool
  20331. oldValue func(context.Context) (*Msg, error)
  20332. predicates []predicate.Msg
  20333. }
  20334. var _ ent.Mutation = (*MsgMutation)(nil)
  20335. // msgOption allows management of the mutation configuration using functional options.
  20336. type msgOption func(*MsgMutation)
  20337. // newMsgMutation creates new mutation for the Msg entity.
  20338. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20339. m := &MsgMutation{
  20340. config: c,
  20341. op: op,
  20342. typ: TypeMsg,
  20343. clearedFields: make(map[string]struct{}),
  20344. }
  20345. for _, opt := range opts {
  20346. opt(m)
  20347. }
  20348. return m
  20349. }
  20350. // withMsgID sets the ID field of the mutation.
  20351. func withMsgID(id uint64) msgOption {
  20352. return func(m *MsgMutation) {
  20353. var (
  20354. err error
  20355. once sync.Once
  20356. value *Msg
  20357. )
  20358. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20359. once.Do(func() {
  20360. if m.done {
  20361. err = errors.New("querying old values post mutation is not allowed")
  20362. } else {
  20363. value, err = m.Client().Msg.Get(ctx, id)
  20364. }
  20365. })
  20366. return value, err
  20367. }
  20368. m.id = &id
  20369. }
  20370. }
  20371. // withMsg sets the old Msg of the mutation.
  20372. func withMsg(node *Msg) msgOption {
  20373. return func(m *MsgMutation) {
  20374. m.oldValue = func(context.Context) (*Msg, error) {
  20375. return node, nil
  20376. }
  20377. m.id = &node.ID
  20378. }
  20379. }
  20380. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20381. // executed in a transaction (ent.Tx), a transactional client is returned.
  20382. func (m MsgMutation) Client() *Client {
  20383. client := &Client{config: m.config}
  20384. client.init()
  20385. return client
  20386. }
  20387. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20388. // it returns an error otherwise.
  20389. func (m MsgMutation) Tx() (*Tx, error) {
  20390. if _, ok := m.driver.(*txDriver); !ok {
  20391. return nil, errors.New("ent: mutation is not running in a transaction")
  20392. }
  20393. tx := &Tx{config: m.config}
  20394. tx.init()
  20395. return tx, nil
  20396. }
  20397. // SetID sets the value of the id field. Note that this
  20398. // operation is only accepted on creation of Msg entities.
  20399. func (m *MsgMutation) SetID(id uint64) {
  20400. m.id = &id
  20401. }
  20402. // ID returns the ID value in the mutation. Note that the ID is only available
  20403. // if it was provided to the builder or after it was returned from the database.
  20404. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20405. if m.id == nil {
  20406. return
  20407. }
  20408. return *m.id, true
  20409. }
  20410. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20411. // That means, if the mutation is applied within a transaction with an isolation level such
  20412. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20413. // or updated by the mutation.
  20414. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20415. switch {
  20416. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20417. id, exists := m.ID()
  20418. if exists {
  20419. return []uint64{id}, nil
  20420. }
  20421. fallthrough
  20422. case m.op.Is(OpUpdate | OpDelete):
  20423. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20424. default:
  20425. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20426. }
  20427. }
  20428. // SetCreatedAt sets the "created_at" field.
  20429. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20430. m.created_at = &t
  20431. }
  20432. // CreatedAt returns the value of the "created_at" field in the mutation.
  20433. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20434. v := m.created_at
  20435. if v == nil {
  20436. return
  20437. }
  20438. return *v, true
  20439. }
  20440. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20441. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20443. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20444. if !m.op.Is(OpUpdateOne) {
  20445. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20446. }
  20447. if m.id == nil || m.oldValue == nil {
  20448. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20449. }
  20450. oldValue, err := m.oldValue(ctx)
  20451. if err != nil {
  20452. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20453. }
  20454. return oldValue.CreatedAt, nil
  20455. }
  20456. // ResetCreatedAt resets all changes to the "created_at" field.
  20457. func (m *MsgMutation) ResetCreatedAt() {
  20458. m.created_at = nil
  20459. }
  20460. // SetUpdatedAt sets the "updated_at" field.
  20461. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20462. m.updated_at = &t
  20463. }
  20464. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20465. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20466. v := m.updated_at
  20467. if v == nil {
  20468. return
  20469. }
  20470. return *v, true
  20471. }
  20472. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20473. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20475. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20476. if !m.op.Is(OpUpdateOne) {
  20477. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20478. }
  20479. if m.id == nil || m.oldValue == nil {
  20480. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20481. }
  20482. oldValue, err := m.oldValue(ctx)
  20483. if err != nil {
  20484. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20485. }
  20486. return oldValue.UpdatedAt, nil
  20487. }
  20488. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20489. func (m *MsgMutation) ResetUpdatedAt() {
  20490. m.updated_at = nil
  20491. }
  20492. // SetDeletedAt sets the "deleted_at" field.
  20493. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20494. m.deleted_at = &t
  20495. }
  20496. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20497. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20498. v := m.deleted_at
  20499. if v == nil {
  20500. return
  20501. }
  20502. return *v, true
  20503. }
  20504. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20505. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20507. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20508. if !m.op.Is(OpUpdateOne) {
  20509. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20510. }
  20511. if m.id == nil || m.oldValue == nil {
  20512. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20513. }
  20514. oldValue, err := m.oldValue(ctx)
  20515. if err != nil {
  20516. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20517. }
  20518. return oldValue.DeletedAt, nil
  20519. }
  20520. // ClearDeletedAt clears the value of the "deleted_at" field.
  20521. func (m *MsgMutation) ClearDeletedAt() {
  20522. m.deleted_at = nil
  20523. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20524. }
  20525. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20526. func (m *MsgMutation) DeletedAtCleared() bool {
  20527. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20528. return ok
  20529. }
  20530. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20531. func (m *MsgMutation) ResetDeletedAt() {
  20532. m.deleted_at = nil
  20533. delete(m.clearedFields, msg.FieldDeletedAt)
  20534. }
  20535. // SetStatus sets the "status" field.
  20536. func (m *MsgMutation) SetStatus(u uint8) {
  20537. m.status = &u
  20538. m.addstatus = nil
  20539. }
  20540. // Status returns the value of the "status" field in the mutation.
  20541. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20542. v := m.status
  20543. if v == nil {
  20544. return
  20545. }
  20546. return *v, true
  20547. }
  20548. // OldStatus returns the old "status" field's value of the Msg entity.
  20549. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20551. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20552. if !m.op.Is(OpUpdateOne) {
  20553. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20554. }
  20555. if m.id == nil || m.oldValue == nil {
  20556. return v, errors.New("OldStatus requires an ID field in the mutation")
  20557. }
  20558. oldValue, err := m.oldValue(ctx)
  20559. if err != nil {
  20560. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20561. }
  20562. return oldValue.Status, nil
  20563. }
  20564. // AddStatus adds u to the "status" field.
  20565. func (m *MsgMutation) AddStatus(u int8) {
  20566. if m.addstatus != nil {
  20567. *m.addstatus += u
  20568. } else {
  20569. m.addstatus = &u
  20570. }
  20571. }
  20572. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20573. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20574. v := m.addstatus
  20575. if v == nil {
  20576. return
  20577. }
  20578. return *v, true
  20579. }
  20580. // ClearStatus clears the value of the "status" field.
  20581. func (m *MsgMutation) ClearStatus() {
  20582. m.status = nil
  20583. m.addstatus = nil
  20584. m.clearedFields[msg.FieldStatus] = struct{}{}
  20585. }
  20586. // StatusCleared returns if the "status" field was cleared in this mutation.
  20587. func (m *MsgMutation) StatusCleared() bool {
  20588. _, ok := m.clearedFields[msg.FieldStatus]
  20589. return ok
  20590. }
  20591. // ResetStatus resets all changes to the "status" field.
  20592. func (m *MsgMutation) ResetStatus() {
  20593. m.status = nil
  20594. m.addstatus = nil
  20595. delete(m.clearedFields, msg.FieldStatus)
  20596. }
  20597. // SetFromwxid sets the "fromwxid" field.
  20598. func (m *MsgMutation) SetFromwxid(s string) {
  20599. m.fromwxid = &s
  20600. }
  20601. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20602. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20603. v := m.fromwxid
  20604. if v == nil {
  20605. return
  20606. }
  20607. return *v, true
  20608. }
  20609. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20610. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20612. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20613. if !m.op.Is(OpUpdateOne) {
  20614. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20615. }
  20616. if m.id == nil || m.oldValue == nil {
  20617. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20618. }
  20619. oldValue, err := m.oldValue(ctx)
  20620. if err != nil {
  20621. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20622. }
  20623. return oldValue.Fromwxid, nil
  20624. }
  20625. // ClearFromwxid clears the value of the "fromwxid" field.
  20626. func (m *MsgMutation) ClearFromwxid() {
  20627. m.fromwxid = nil
  20628. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20629. }
  20630. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20631. func (m *MsgMutation) FromwxidCleared() bool {
  20632. _, ok := m.clearedFields[msg.FieldFromwxid]
  20633. return ok
  20634. }
  20635. // ResetFromwxid resets all changes to the "fromwxid" field.
  20636. func (m *MsgMutation) ResetFromwxid() {
  20637. m.fromwxid = nil
  20638. delete(m.clearedFields, msg.FieldFromwxid)
  20639. }
  20640. // SetToid sets the "toid" field.
  20641. func (m *MsgMutation) SetToid(s string) {
  20642. m.toid = &s
  20643. }
  20644. // Toid returns the value of the "toid" field in the mutation.
  20645. func (m *MsgMutation) Toid() (r string, exists bool) {
  20646. v := m.toid
  20647. if v == nil {
  20648. return
  20649. }
  20650. return *v, true
  20651. }
  20652. // OldToid returns the old "toid" field's value of the Msg entity.
  20653. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20655. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  20656. if !m.op.Is(OpUpdateOne) {
  20657. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  20658. }
  20659. if m.id == nil || m.oldValue == nil {
  20660. return v, errors.New("OldToid requires an ID field in the mutation")
  20661. }
  20662. oldValue, err := m.oldValue(ctx)
  20663. if err != nil {
  20664. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  20665. }
  20666. return oldValue.Toid, nil
  20667. }
  20668. // ClearToid clears the value of the "toid" field.
  20669. func (m *MsgMutation) ClearToid() {
  20670. m.toid = nil
  20671. m.clearedFields[msg.FieldToid] = struct{}{}
  20672. }
  20673. // ToidCleared returns if the "toid" field was cleared in this mutation.
  20674. func (m *MsgMutation) ToidCleared() bool {
  20675. _, ok := m.clearedFields[msg.FieldToid]
  20676. return ok
  20677. }
  20678. // ResetToid resets all changes to the "toid" field.
  20679. func (m *MsgMutation) ResetToid() {
  20680. m.toid = nil
  20681. delete(m.clearedFields, msg.FieldToid)
  20682. }
  20683. // SetMsgtype sets the "msgtype" field.
  20684. func (m *MsgMutation) SetMsgtype(i int32) {
  20685. m.msgtype = &i
  20686. m.addmsgtype = nil
  20687. }
  20688. // Msgtype returns the value of the "msgtype" field in the mutation.
  20689. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  20690. v := m.msgtype
  20691. if v == nil {
  20692. return
  20693. }
  20694. return *v, true
  20695. }
  20696. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  20697. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20699. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  20700. if !m.op.Is(OpUpdateOne) {
  20701. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  20702. }
  20703. if m.id == nil || m.oldValue == nil {
  20704. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  20705. }
  20706. oldValue, err := m.oldValue(ctx)
  20707. if err != nil {
  20708. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  20709. }
  20710. return oldValue.Msgtype, nil
  20711. }
  20712. // AddMsgtype adds i to the "msgtype" field.
  20713. func (m *MsgMutation) AddMsgtype(i int32) {
  20714. if m.addmsgtype != nil {
  20715. *m.addmsgtype += i
  20716. } else {
  20717. m.addmsgtype = &i
  20718. }
  20719. }
  20720. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  20721. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  20722. v := m.addmsgtype
  20723. if v == nil {
  20724. return
  20725. }
  20726. return *v, true
  20727. }
  20728. // ClearMsgtype clears the value of the "msgtype" field.
  20729. func (m *MsgMutation) ClearMsgtype() {
  20730. m.msgtype = nil
  20731. m.addmsgtype = nil
  20732. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  20733. }
  20734. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  20735. func (m *MsgMutation) MsgtypeCleared() bool {
  20736. _, ok := m.clearedFields[msg.FieldMsgtype]
  20737. return ok
  20738. }
  20739. // ResetMsgtype resets all changes to the "msgtype" field.
  20740. func (m *MsgMutation) ResetMsgtype() {
  20741. m.msgtype = nil
  20742. m.addmsgtype = nil
  20743. delete(m.clearedFields, msg.FieldMsgtype)
  20744. }
  20745. // SetMsg sets the "msg" field.
  20746. func (m *MsgMutation) SetMsg(s string) {
  20747. m.msg = &s
  20748. }
  20749. // Msg returns the value of the "msg" field in the mutation.
  20750. func (m *MsgMutation) Msg() (r string, exists bool) {
  20751. v := m.msg
  20752. if v == nil {
  20753. return
  20754. }
  20755. return *v, true
  20756. }
  20757. // OldMsg returns the old "msg" field's value of the Msg entity.
  20758. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20760. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  20761. if !m.op.Is(OpUpdateOne) {
  20762. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  20763. }
  20764. if m.id == nil || m.oldValue == nil {
  20765. return v, errors.New("OldMsg requires an ID field in the mutation")
  20766. }
  20767. oldValue, err := m.oldValue(ctx)
  20768. if err != nil {
  20769. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  20770. }
  20771. return oldValue.Msg, nil
  20772. }
  20773. // ClearMsg clears the value of the "msg" field.
  20774. func (m *MsgMutation) ClearMsg() {
  20775. m.msg = nil
  20776. m.clearedFields[msg.FieldMsg] = struct{}{}
  20777. }
  20778. // MsgCleared returns if the "msg" field was cleared in this mutation.
  20779. func (m *MsgMutation) MsgCleared() bool {
  20780. _, ok := m.clearedFields[msg.FieldMsg]
  20781. return ok
  20782. }
  20783. // ResetMsg resets all changes to the "msg" field.
  20784. func (m *MsgMutation) ResetMsg() {
  20785. m.msg = nil
  20786. delete(m.clearedFields, msg.FieldMsg)
  20787. }
  20788. // SetBatchNo sets the "batch_no" field.
  20789. func (m *MsgMutation) SetBatchNo(s string) {
  20790. m.batch_no = &s
  20791. }
  20792. // BatchNo returns the value of the "batch_no" field in the mutation.
  20793. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  20794. v := m.batch_no
  20795. if v == nil {
  20796. return
  20797. }
  20798. return *v, true
  20799. }
  20800. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  20801. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20803. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  20804. if !m.op.Is(OpUpdateOne) {
  20805. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  20806. }
  20807. if m.id == nil || m.oldValue == nil {
  20808. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  20809. }
  20810. oldValue, err := m.oldValue(ctx)
  20811. if err != nil {
  20812. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  20813. }
  20814. return oldValue.BatchNo, nil
  20815. }
  20816. // ClearBatchNo clears the value of the "batch_no" field.
  20817. func (m *MsgMutation) ClearBatchNo() {
  20818. m.batch_no = nil
  20819. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  20820. }
  20821. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  20822. func (m *MsgMutation) BatchNoCleared() bool {
  20823. _, ok := m.clearedFields[msg.FieldBatchNo]
  20824. return ok
  20825. }
  20826. // ResetBatchNo resets all changes to the "batch_no" field.
  20827. func (m *MsgMutation) ResetBatchNo() {
  20828. m.batch_no = nil
  20829. delete(m.clearedFields, msg.FieldBatchNo)
  20830. }
  20831. // SetCc sets the "cc" field.
  20832. func (m *MsgMutation) SetCc(s string) {
  20833. m.cc = &s
  20834. }
  20835. // Cc returns the value of the "cc" field in the mutation.
  20836. func (m *MsgMutation) Cc() (r string, exists bool) {
  20837. v := m.cc
  20838. if v == nil {
  20839. return
  20840. }
  20841. return *v, true
  20842. }
  20843. // OldCc returns the old "cc" field's value of the Msg entity.
  20844. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20846. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  20847. if !m.op.Is(OpUpdateOne) {
  20848. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  20849. }
  20850. if m.id == nil || m.oldValue == nil {
  20851. return v, errors.New("OldCc requires an ID field in the mutation")
  20852. }
  20853. oldValue, err := m.oldValue(ctx)
  20854. if err != nil {
  20855. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  20856. }
  20857. return oldValue.Cc, nil
  20858. }
  20859. // ResetCc resets all changes to the "cc" field.
  20860. func (m *MsgMutation) ResetCc() {
  20861. m.cc = nil
  20862. }
  20863. // SetPhone sets the "phone" field.
  20864. func (m *MsgMutation) SetPhone(s string) {
  20865. m.phone = &s
  20866. }
  20867. // Phone returns the value of the "phone" field in the mutation.
  20868. func (m *MsgMutation) Phone() (r string, exists bool) {
  20869. v := m.phone
  20870. if v == nil {
  20871. return
  20872. }
  20873. return *v, true
  20874. }
  20875. // OldPhone returns the old "phone" field's value of the Msg entity.
  20876. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20878. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  20879. if !m.op.Is(OpUpdateOne) {
  20880. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  20881. }
  20882. if m.id == nil || m.oldValue == nil {
  20883. return v, errors.New("OldPhone requires an ID field in the mutation")
  20884. }
  20885. oldValue, err := m.oldValue(ctx)
  20886. if err != nil {
  20887. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  20888. }
  20889. return oldValue.Phone, nil
  20890. }
  20891. // ResetPhone resets all changes to the "phone" field.
  20892. func (m *MsgMutation) ResetPhone() {
  20893. m.phone = nil
  20894. }
  20895. // Where appends a list predicates to the MsgMutation builder.
  20896. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  20897. m.predicates = append(m.predicates, ps...)
  20898. }
  20899. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  20900. // users can use type-assertion to append predicates that do not depend on any generated package.
  20901. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  20902. p := make([]predicate.Msg, len(ps))
  20903. for i := range ps {
  20904. p[i] = ps[i]
  20905. }
  20906. m.Where(p...)
  20907. }
  20908. // Op returns the operation name.
  20909. func (m *MsgMutation) Op() Op {
  20910. return m.op
  20911. }
  20912. // SetOp allows setting the mutation operation.
  20913. func (m *MsgMutation) SetOp(op Op) {
  20914. m.op = op
  20915. }
  20916. // Type returns the node type of this mutation (Msg).
  20917. func (m *MsgMutation) Type() string {
  20918. return m.typ
  20919. }
  20920. // Fields returns all fields that were changed during this mutation. Note that in
  20921. // order to get all numeric fields that were incremented/decremented, call
  20922. // AddedFields().
  20923. func (m *MsgMutation) Fields() []string {
  20924. fields := make([]string, 0, 11)
  20925. if m.created_at != nil {
  20926. fields = append(fields, msg.FieldCreatedAt)
  20927. }
  20928. if m.updated_at != nil {
  20929. fields = append(fields, msg.FieldUpdatedAt)
  20930. }
  20931. if m.deleted_at != nil {
  20932. fields = append(fields, msg.FieldDeletedAt)
  20933. }
  20934. if m.status != nil {
  20935. fields = append(fields, msg.FieldStatus)
  20936. }
  20937. if m.fromwxid != nil {
  20938. fields = append(fields, msg.FieldFromwxid)
  20939. }
  20940. if m.toid != nil {
  20941. fields = append(fields, msg.FieldToid)
  20942. }
  20943. if m.msgtype != nil {
  20944. fields = append(fields, msg.FieldMsgtype)
  20945. }
  20946. if m.msg != nil {
  20947. fields = append(fields, msg.FieldMsg)
  20948. }
  20949. if m.batch_no != nil {
  20950. fields = append(fields, msg.FieldBatchNo)
  20951. }
  20952. if m.cc != nil {
  20953. fields = append(fields, msg.FieldCc)
  20954. }
  20955. if m.phone != nil {
  20956. fields = append(fields, msg.FieldPhone)
  20957. }
  20958. return fields
  20959. }
  20960. // Field returns the value of a field with the given name. The second boolean
  20961. // return value indicates that this field was not set, or was not defined in the
  20962. // schema.
  20963. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  20964. switch name {
  20965. case msg.FieldCreatedAt:
  20966. return m.CreatedAt()
  20967. case msg.FieldUpdatedAt:
  20968. return m.UpdatedAt()
  20969. case msg.FieldDeletedAt:
  20970. return m.DeletedAt()
  20971. case msg.FieldStatus:
  20972. return m.Status()
  20973. case msg.FieldFromwxid:
  20974. return m.Fromwxid()
  20975. case msg.FieldToid:
  20976. return m.Toid()
  20977. case msg.FieldMsgtype:
  20978. return m.Msgtype()
  20979. case msg.FieldMsg:
  20980. return m.Msg()
  20981. case msg.FieldBatchNo:
  20982. return m.BatchNo()
  20983. case msg.FieldCc:
  20984. return m.Cc()
  20985. case msg.FieldPhone:
  20986. return m.Phone()
  20987. }
  20988. return nil, false
  20989. }
  20990. // OldField returns the old value of the field from the database. An error is
  20991. // returned if the mutation operation is not UpdateOne, or the query to the
  20992. // database failed.
  20993. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20994. switch name {
  20995. case msg.FieldCreatedAt:
  20996. return m.OldCreatedAt(ctx)
  20997. case msg.FieldUpdatedAt:
  20998. return m.OldUpdatedAt(ctx)
  20999. case msg.FieldDeletedAt:
  21000. return m.OldDeletedAt(ctx)
  21001. case msg.FieldStatus:
  21002. return m.OldStatus(ctx)
  21003. case msg.FieldFromwxid:
  21004. return m.OldFromwxid(ctx)
  21005. case msg.FieldToid:
  21006. return m.OldToid(ctx)
  21007. case msg.FieldMsgtype:
  21008. return m.OldMsgtype(ctx)
  21009. case msg.FieldMsg:
  21010. return m.OldMsg(ctx)
  21011. case msg.FieldBatchNo:
  21012. return m.OldBatchNo(ctx)
  21013. case msg.FieldCc:
  21014. return m.OldCc(ctx)
  21015. case msg.FieldPhone:
  21016. return m.OldPhone(ctx)
  21017. }
  21018. return nil, fmt.Errorf("unknown Msg field %s", name)
  21019. }
  21020. // SetField sets the value of a field with the given name. It returns an error if
  21021. // the field is not defined in the schema, or if the type mismatched the field
  21022. // type.
  21023. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  21024. switch name {
  21025. case msg.FieldCreatedAt:
  21026. v, ok := value.(time.Time)
  21027. if !ok {
  21028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21029. }
  21030. m.SetCreatedAt(v)
  21031. return nil
  21032. case msg.FieldUpdatedAt:
  21033. v, ok := value.(time.Time)
  21034. if !ok {
  21035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21036. }
  21037. m.SetUpdatedAt(v)
  21038. return nil
  21039. case msg.FieldDeletedAt:
  21040. v, ok := value.(time.Time)
  21041. if !ok {
  21042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21043. }
  21044. m.SetDeletedAt(v)
  21045. return nil
  21046. case msg.FieldStatus:
  21047. v, ok := value.(uint8)
  21048. if !ok {
  21049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21050. }
  21051. m.SetStatus(v)
  21052. return nil
  21053. case msg.FieldFromwxid:
  21054. v, ok := value.(string)
  21055. if !ok {
  21056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21057. }
  21058. m.SetFromwxid(v)
  21059. return nil
  21060. case msg.FieldToid:
  21061. v, ok := value.(string)
  21062. if !ok {
  21063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21064. }
  21065. m.SetToid(v)
  21066. return nil
  21067. case msg.FieldMsgtype:
  21068. v, ok := value.(int32)
  21069. if !ok {
  21070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21071. }
  21072. m.SetMsgtype(v)
  21073. return nil
  21074. case msg.FieldMsg:
  21075. v, ok := value.(string)
  21076. if !ok {
  21077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21078. }
  21079. m.SetMsg(v)
  21080. return nil
  21081. case msg.FieldBatchNo:
  21082. v, ok := value.(string)
  21083. if !ok {
  21084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21085. }
  21086. m.SetBatchNo(v)
  21087. return nil
  21088. case msg.FieldCc:
  21089. v, ok := value.(string)
  21090. if !ok {
  21091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21092. }
  21093. m.SetCc(v)
  21094. return nil
  21095. case msg.FieldPhone:
  21096. v, ok := value.(string)
  21097. if !ok {
  21098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21099. }
  21100. m.SetPhone(v)
  21101. return nil
  21102. }
  21103. return fmt.Errorf("unknown Msg field %s", name)
  21104. }
  21105. // AddedFields returns all numeric fields that were incremented/decremented during
  21106. // this mutation.
  21107. func (m *MsgMutation) AddedFields() []string {
  21108. var fields []string
  21109. if m.addstatus != nil {
  21110. fields = append(fields, msg.FieldStatus)
  21111. }
  21112. if m.addmsgtype != nil {
  21113. fields = append(fields, msg.FieldMsgtype)
  21114. }
  21115. return fields
  21116. }
  21117. // AddedField returns the numeric value that was incremented/decremented on a field
  21118. // with the given name. The second boolean return value indicates that this field
  21119. // was not set, or was not defined in the schema.
  21120. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21121. switch name {
  21122. case msg.FieldStatus:
  21123. return m.AddedStatus()
  21124. case msg.FieldMsgtype:
  21125. return m.AddedMsgtype()
  21126. }
  21127. return nil, false
  21128. }
  21129. // AddField adds the value to the field with the given name. It returns an error if
  21130. // the field is not defined in the schema, or if the type mismatched the field
  21131. // type.
  21132. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21133. switch name {
  21134. case msg.FieldStatus:
  21135. v, ok := value.(int8)
  21136. if !ok {
  21137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21138. }
  21139. m.AddStatus(v)
  21140. return nil
  21141. case msg.FieldMsgtype:
  21142. v, ok := value.(int32)
  21143. if !ok {
  21144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21145. }
  21146. m.AddMsgtype(v)
  21147. return nil
  21148. }
  21149. return fmt.Errorf("unknown Msg numeric field %s", name)
  21150. }
  21151. // ClearedFields returns all nullable fields that were cleared during this
  21152. // mutation.
  21153. func (m *MsgMutation) ClearedFields() []string {
  21154. var fields []string
  21155. if m.FieldCleared(msg.FieldDeletedAt) {
  21156. fields = append(fields, msg.FieldDeletedAt)
  21157. }
  21158. if m.FieldCleared(msg.FieldStatus) {
  21159. fields = append(fields, msg.FieldStatus)
  21160. }
  21161. if m.FieldCleared(msg.FieldFromwxid) {
  21162. fields = append(fields, msg.FieldFromwxid)
  21163. }
  21164. if m.FieldCleared(msg.FieldToid) {
  21165. fields = append(fields, msg.FieldToid)
  21166. }
  21167. if m.FieldCleared(msg.FieldMsgtype) {
  21168. fields = append(fields, msg.FieldMsgtype)
  21169. }
  21170. if m.FieldCleared(msg.FieldMsg) {
  21171. fields = append(fields, msg.FieldMsg)
  21172. }
  21173. if m.FieldCleared(msg.FieldBatchNo) {
  21174. fields = append(fields, msg.FieldBatchNo)
  21175. }
  21176. return fields
  21177. }
  21178. // FieldCleared returns a boolean indicating if a field with the given name was
  21179. // cleared in this mutation.
  21180. func (m *MsgMutation) FieldCleared(name string) bool {
  21181. _, ok := m.clearedFields[name]
  21182. return ok
  21183. }
  21184. // ClearField clears the value of the field with the given name. It returns an
  21185. // error if the field is not defined in the schema.
  21186. func (m *MsgMutation) ClearField(name string) error {
  21187. switch name {
  21188. case msg.FieldDeletedAt:
  21189. m.ClearDeletedAt()
  21190. return nil
  21191. case msg.FieldStatus:
  21192. m.ClearStatus()
  21193. return nil
  21194. case msg.FieldFromwxid:
  21195. m.ClearFromwxid()
  21196. return nil
  21197. case msg.FieldToid:
  21198. m.ClearToid()
  21199. return nil
  21200. case msg.FieldMsgtype:
  21201. m.ClearMsgtype()
  21202. return nil
  21203. case msg.FieldMsg:
  21204. m.ClearMsg()
  21205. return nil
  21206. case msg.FieldBatchNo:
  21207. m.ClearBatchNo()
  21208. return nil
  21209. }
  21210. return fmt.Errorf("unknown Msg nullable field %s", name)
  21211. }
  21212. // ResetField resets all changes in the mutation for the field with the given name.
  21213. // It returns an error if the field is not defined in the schema.
  21214. func (m *MsgMutation) ResetField(name string) error {
  21215. switch name {
  21216. case msg.FieldCreatedAt:
  21217. m.ResetCreatedAt()
  21218. return nil
  21219. case msg.FieldUpdatedAt:
  21220. m.ResetUpdatedAt()
  21221. return nil
  21222. case msg.FieldDeletedAt:
  21223. m.ResetDeletedAt()
  21224. return nil
  21225. case msg.FieldStatus:
  21226. m.ResetStatus()
  21227. return nil
  21228. case msg.FieldFromwxid:
  21229. m.ResetFromwxid()
  21230. return nil
  21231. case msg.FieldToid:
  21232. m.ResetToid()
  21233. return nil
  21234. case msg.FieldMsgtype:
  21235. m.ResetMsgtype()
  21236. return nil
  21237. case msg.FieldMsg:
  21238. m.ResetMsg()
  21239. return nil
  21240. case msg.FieldBatchNo:
  21241. m.ResetBatchNo()
  21242. return nil
  21243. case msg.FieldCc:
  21244. m.ResetCc()
  21245. return nil
  21246. case msg.FieldPhone:
  21247. m.ResetPhone()
  21248. return nil
  21249. }
  21250. return fmt.Errorf("unknown Msg field %s", name)
  21251. }
  21252. // AddedEdges returns all edge names that were set/added in this mutation.
  21253. func (m *MsgMutation) AddedEdges() []string {
  21254. edges := make([]string, 0, 0)
  21255. return edges
  21256. }
  21257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21258. // name in this mutation.
  21259. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21260. return nil
  21261. }
  21262. // RemovedEdges returns all edge names that were removed in this mutation.
  21263. func (m *MsgMutation) RemovedEdges() []string {
  21264. edges := make([]string, 0, 0)
  21265. return edges
  21266. }
  21267. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21268. // the given name in this mutation.
  21269. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21270. return nil
  21271. }
  21272. // ClearedEdges returns all edge names that were cleared in this mutation.
  21273. func (m *MsgMutation) ClearedEdges() []string {
  21274. edges := make([]string, 0, 0)
  21275. return edges
  21276. }
  21277. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21278. // was cleared in this mutation.
  21279. func (m *MsgMutation) EdgeCleared(name string) bool {
  21280. return false
  21281. }
  21282. // ClearEdge clears the value of the edge with the given name. It returns an error
  21283. // if that edge is not defined in the schema.
  21284. func (m *MsgMutation) ClearEdge(name string) error {
  21285. return fmt.Errorf("unknown Msg unique edge %s", name)
  21286. }
  21287. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21288. // It returns an error if the edge is not defined in the schema.
  21289. func (m *MsgMutation) ResetEdge(name string) error {
  21290. return fmt.Errorf("unknown Msg edge %s", name)
  21291. }
  21292. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21293. type PayRechargeMutation struct {
  21294. config
  21295. op Op
  21296. typ string
  21297. id *uint64
  21298. created_at *time.Time
  21299. updated_at *time.Time
  21300. deleted_at *time.Time
  21301. user_id *string
  21302. number *float32
  21303. addnumber *float32
  21304. status *int
  21305. addstatus *int
  21306. money *float32
  21307. addmoney *float32
  21308. out_trade_no *string
  21309. organization_id *uint64
  21310. addorganization_id *int64
  21311. clearedFields map[string]struct{}
  21312. done bool
  21313. oldValue func(context.Context) (*PayRecharge, error)
  21314. predicates []predicate.PayRecharge
  21315. }
  21316. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21317. // payrechargeOption allows management of the mutation configuration using functional options.
  21318. type payrechargeOption func(*PayRechargeMutation)
  21319. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21320. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21321. m := &PayRechargeMutation{
  21322. config: c,
  21323. op: op,
  21324. typ: TypePayRecharge,
  21325. clearedFields: make(map[string]struct{}),
  21326. }
  21327. for _, opt := range opts {
  21328. opt(m)
  21329. }
  21330. return m
  21331. }
  21332. // withPayRechargeID sets the ID field of the mutation.
  21333. func withPayRechargeID(id uint64) payrechargeOption {
  21334. return func(m *PayRechargeMutation) {
  21335. var (
  21336. err error
  21337. once sync.Once
  21338. value *PayRecharge
  21339. )
  21340. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21341. once.Do(func() {
  21342. if m.done {
  21343. err = errors.New("querying old values post mutation is not allowed")
  21344. } else {
  21345. value, err = m.Client().PayRecharge.Get(ctx, id)
  21346. }
  21347. })
  21348. return value, err
  21349. }
  21350. m.id = &id
  21351. }
  21352. }
  21353. // withPayRecharge sets the old PayRecharge of the mutation.
  21354. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21355. return func(m *PayRechargeMutation) {
  21356. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21357. return node, nil
  21358. }
  21359. m.id = &node.ID
  21360. }
  21361. }
  21362. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21363. // executed in a transaction (ent.Tx), a transactional client is returned.
  21364. func (m PayRechargeMutation) Client() *Client {
  21365. client := &Client{config: m.config}
  21366. client.init()
  21367. return client
  21368. }
  21369. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21370. // it returns an error otherwise.
  21371. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21372. if _, ok := m.driver.(*txDriver); !ok {
  21373. return nil, errors.New("ent: mutation is not running in a transaction")
  21374. }
  21375. tx := &Tx{config: m.config}
  21376. tx.init()
  21377. return tx, nil
  21378. }
  21379. // SetID sets the value of the id field. Note that this
  21380. // operation is only accepted on creation of PayRecharge entities.
  21381. func (m *PayRechargeMutation) SetID(id uint64) {
  21382. m.id = &id
  21383. }
  21384. // ID returns the ID value in the mutation. Note that the ID is only available
  21385. // if it was provided to the builder or after it was returned from the database.
  21386. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21387. if m.id == nil {
  21388. return
  21389. }
  21390. return *m.id, true
  21391. }
  21392. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21393. // That means, if the mutation is applied within a transaction with an isolation level such
  21394. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21395. // or updated by the mutation.
  21396. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21397. switch {
  21398. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21399. id, exists := m.ID()
  21400. if exists {
  21401. return []uint64{id}, nil
  21402. }
  21403. fallthrough
  21404. case m.op.Is(OpUpdate | OpDelete):
  21405. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21406. default:
  21407. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21408. }
  21409. }
  21410. // SetCreatedAt sets the "created_at" field.
  21411. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21412. m.created_at = &t
  21413. }
  21414. // CreatedAt returns the value of the "created_at" field in the mutation.
  21415. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21416. v := m.created_at
  21417. if v == nil {
  21418. return
  21419. }
  21420. return *v, true
  21421. }
  21422. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21423. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21425. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21426. if !m.op.Is(OpUpdateOne) {
  21427. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21428. }
  21429. if m.id == nil || m.oldValue == nil {
  21430. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21431. }
  21432. oldValue, err := m.oldValue(ctx)
  21433. if err != nil {
  21434. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21435. }
  21436. return oldValue.CreatedAt, nil
  21437. }
  21438. // ResetCreatedAt resets all changes to the "created_at" field.
  21439. func (m *PayRechargeMutation) ResetCreatedAt() {
  21440. m.created_at = nil
  21441. }
  21442. // SetUpdatedAt sets the "updated_at" field.
  21443. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21444. m.updated_at = &t
  21445. }
  21446. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21447. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21448. v := m.updated_at
  21449. if v == nil {
  21450. return
  21451. }
  21452. return *v, true
  21453. }
  21454. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21455. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21457. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21458. if !m.op.Is(OpUpdateOne) {
  21459. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21460. }
  21461. if m.id == nil || m.oldValue == nil {
  21462. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21463. }
  21464. oldValue, err := m.oldValue(ctx)
  21465. if err != nil {
  21466. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21467. }
  21468. return oldValue.UpdatedAt, nil
  21469. }
  21470. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21471. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21472. m.updated_at = nil
  21473. }
  21474. // SetDeletedAt sets the "deleted_at" field.
  21475. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21476. m.deleted_at = &t
  21477. }
  21478. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21479. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21480. v := m.deleted_at
  21481. if v == nil {
  21482. return
  21483. }
  21484. return *v, true
  21485. }
  21486. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21487. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21489. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21490. if !m.op.Is(OpUpdateOne) {
  21491. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21492. }
  21493. if m.id == nil || m.oldValue == nil {
  21494. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21495. }
  21496. oldValue, err := m.oldValue(ctx)
  21497. if err != nil {
  21498. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21499. }
  21500. return oldValue.DeletedAt, nil
  21501. }
  21502. // ClearDeletedAt clears the value of the "deleted_at" field.
  21503. func (m *PayRechargeMutation) ClearDeletedAt() {
  21504. m.deleted_at = nil
  21505. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21506. }
  21507. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21508. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21509. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21510. return ok
  21511. }
  21512. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21513. func (m *PayRechargeMutation) ResetDeletedAt() {
  21514. m.deleted_at = nil
  21515. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21516. }
  21517. // SetUserID sets the "user_id" field.
  21518. func (m *PayRechargeMutation) SetUserID(s string) {
  21519. m.user_id = &s
  21520. }
  21521. // UserID returns the value of the "user_id" field in the mutation.
  21522. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21523. v := m.user_id
  21524. if v == nil {
  21525. return
  21526. }
  21527. return *v, true
  21528. }
  21529. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21530. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21532. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21533. if !m.op.Is(OpUpdateOne) {
  21534. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21535. }
  21536. if m.id == nil || m.oldValue == nil {
  21537. return v, errors.New("OldUserID requires an ID field in the mutation")
  21538. }
  21539. oldValue, err := m.oldValue(ctx)
  21540. if err != nil {
  21541. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21542. }
  21543. return oldValue.UserID, nil
  21544. }
  21545. // ResetUserID resets all changes to the "user_id" field.
  21546. func (m *PayRechargeMutation) ResetUserID() {
  21547. m.user_id = nil
  21548. }
  21549. // SetNumber sets the "number" field.
  21550. func (m *PayRechargeMutation) SetNumber(f float32) {
  21551. m.number = &f
  21552. m.addnumber = nil
  21553. }
  21554. // Number returns the value of the "number" field in the mutation.
  21555. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21556. v := m.number
  21557. if v == nil {
  21558. return
  21559. }
  21560. return *v, true
  21561. }
  21562. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21563. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21565. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21566. if !m.op.Is(OpUpdateOne) {
  21567. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21568. }
  21569. if m.id == nil || m.oldValue == nil {
  21570. return v, errors.New("OldNumber requires an ID field in the mutation")
  21571. }
  21572. oldValue, err := m.oldValue(ctx)
  21573. if err != nil {
  21574. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21575. }
  21576. return oldValue.Number, nil
  21577. }
  21578. // AddNumber adds f to the "number" field.
  21579. func (m *PayRechargeMutation) AddNumber(f float32) {
  21580. if m.addnumber != nil {
  21581. *m.addnumber += f
  21582. } else {
  21583. m.addnumber = &f
  21584. }
  21585. }
  21586. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21587. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21588. v := m.addnumber
  21589. if v == nil {
  21590. return
  21591. }
  21592. return *v, true
  21593. }
  21594. // ResetNumber resets all changes to the "number" field.
  21595. func (m *PayRechargeMutation) ResetNumber() {
  21596. m.number = nil
  21597. m.addnumber = nil
  21598. }
  21599. // SetStatus sets the "status" field.
  21600. func (m *PayRechargeMutation) SetStatus(i int) {
  21601. m.status = &i
  21602. m.addstatus = nil
  21603. }
  21604. // Status returns the value of the "status" field in the mutation.
  21605. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21606. v := m.status
  21607. if v == nil {
  21608. return
  21609. }
  21610. return *v, true
  21611. }
  21612. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21613. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21615. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21616. if !m.op.Is(OpUpdateOne) {
  21617. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21618. }
  21619. if m.id == nil || m.oldValue == nil {
  21620. return v, errors.New("OldStatus requires an ID field in the mutation")
  21621. }
  21622. oldValue, err := m.oldValue(ctx)
  21623. if err != nil {
  21624. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21625. }
  21626. return oldValue.Status, nil
  21627. }
  21628. // AddStatus adds i to the "status" field.
  21629. func (m *PayRechargeMutation) AddStatus(i int) {
  21630. if m.addstatus != nil {
  21631. *m.addstatus += i
  21632. } else {
  21633. m.addstatus = &i
  21634. }
  21635. }
  21636. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21637. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  21638. v := m.addstatus
  21639. if v == nil {
  21640. return
  21641. }
  21642. return *v, true
  21643. }
  21644. // ClearStatus clears the value of the "status" field.
  21645. func (m *PayRechargeMutation) ClearStatus() {
  21646. m.status = nil
  21647. m.addstatus = nil
  21648. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  21649. }
  21650. // StatusCleared returns if the "status" field was cleared in this mutation.
  21651. func (m *PayRechargeMutation) StatusCleared() bool {
  21652. _, ok := m.clearedFields[payrecharge.FieldStatus]
  21653. return ok
  21654. }
  21655. // ResetStatus resets all changes to the "status" field.
  21656. func (m *PayRechargeMutation) ResetStatus() {
  21657. m.status = nil
  21658. m.addstatus = nil
  21659. delete(m.clearedFields, payrecharge.FieldStatus)
  21660. }
  21661. // SetMoney sets the "money" field.
  21662. func (m *PayRechargeMutation) SetMoney(f float32) {
  21663. m.money = &f
  21664. m.addmoney = nil
  21665. }
  21666. // Money returns the value of the "money" field in the mutation.
  21667. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  21668. v := m.money
  21669. if v == nil {
  21670. return
  21671. }
  21672. return *v, true
  21673. }
  21674. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  21675. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21677. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  21678. if !m.op.Is(OpUpdateOne) {
  21679. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  21680. }
  21681. if m.id == nil || m.oldValue == nil {
  21682. return v, errors.New("OldMoney requires an ID field in the mutation")
  21683. }
  21684. oldValue, err := m.oldValue(ctx)
  21685. if err != nil {
  21686. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  21687. }
  21688. return oldValue.Money, nil
  21689. }
  21690. // AddMoney adds f to the "money" field.
  21691. func (m *PayRechargeMutation) AddMoney(f float32) {
  21692. if m.addmoney != nil {
  21693. *m.addmoney += f
  21694. } else {
  21695. m.addmoney = &f
  21696. }
  21697. }
  21698. // AddedMoney returns the value that was added to the "money" field in this mutation.
  21699. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  21700. v := m.addmoney
  21701. if v == nil {
  21702. return
  21703. }
  21704. return *v, true
  21705. }
  21706. // ClearMoney clears the value of the "money" field.
  21707. func (m *PayRechargeMutation) ClearMoney() {
  21708. m.money = nil
  21709. m.addmoney = nil
  21710. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  21711. }
  21712. // MoneyCleared returns if the "money" field was cleared in this mutation.
  21713. func (m *PayRechargeMutation) MoneyCleared() bool {
  21714. _, ok := m.clearedFields[payrecharge.FieldMoney]
  21715. return ok
  21716. }
  21717. // ResetMoney resets all changes to the "money" field.
  21718. func (m *PayRechargeMutation) ResetMoney() {
  21719. m.money = nil
  21720. m.addmoney = nil
  21721. delete(m.clearedFields, payrecharge.FieldMoney)
  21722. }
  21723. // SetOutTradeNo sets the "out_trade_no" field.
  21724. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  21725. m.out_trade_no = &s
  21726. }
  21727. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  21728. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  21729. v := m.out_trade_no
  21730. if v == nil {
  21731. return
  21732. }
  21733. return *v, true
  21734. }
  21735. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  21736. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21738. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  21739. if !m.op.Is(OpUpdateOne) {
  21740. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  21741. }
  21742. if m.id == nil || m.oldValue == nil {
  21743. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  21744. }
  21745. oldValue, err := m.oldValue(ctx)
  21746. if err != nil {
  21747. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  21748. }
  21749. return oldValue.OutTradeNo, nil
  21750. }
  21751. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  21752. func (m *PayRechargeMutation) ClearOutTradeNo() {
  21753. m.out_trade_no = nil
  21754. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  21755. }
  21756. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  21757. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  21758. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  21759. return ok
  21760. }
  21761. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  21762. func (m *PayRechargeMutation) ResetOutTradeNo() {
  21763. m.out_trade_no = nil
  21764. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  21765. }
  21766. // SetOrganizationID sets the "organization_id" field.
  21767. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  21768. m.organization_id = &u
  21769. m.addorganization_id = nil
  21770. }
  21771. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21772. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  21773. v := m.organization_id
  21774. if v == nil {
  21775. return
  21776. }
  21777. return *v, true
  21778. }
  21779. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  21780. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21782. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21783. if !m.op.Is(OpUpdateOne) {
  21784. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21785. }
  21786. if m.id == nil || m.oldValue == nil {
  21787. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21788. }
  21789. oldValue, err := m.oldValue(ctx)
  21790. if err != nil {
  21791. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21792. }
  21793. return oldValue.OrganizationID, nil
  21794. }
  21795. // AddOrganizationID adds u to the "organization_id" field.
  21796. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  21797. if m.addorganization_id != nil {
  21798. *m.addorganization_id += u
  21799. } else {
  21800. m.addorganization_id = &u
  21801. }
  21802. }
  21803. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21804. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  21805. v := m.addorganization_id
  21806. if v == nil {
  21807. return
  21808. }
  21809. return *v, true
  21810. }
  21811. // ResetOrganizationID resets all changes to the "organization_id" field.
  21812. func (m *PayRechargeMutation) ResetOrganizationID() {
  21813. m.organization_id = nil
  21814. m.addorganization_id = nil
  21815. }
  21816. // Where appends a list predicates to the PayRechargeMutation builder.
  21817. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  21818. m.predicates = append(m.predicates, ps...)
  21819. }
  21820. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  21821. // users can use type-assertion to append predicates that do not depend on any generated package.
  21822. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  21823. p := make([]predicate.PayRecharge, len(ps))
  21824. for i := range ps {
  21825. p[i] = ps[i]
  21826. }
  21827. m.Where(p...)
  21828. }
  21829. // Op returns the operation name.
  21830. func (m *PayRechargeMutation) Op() Op {
  21831. return m.op
  21832. }
  21833. // SetOp allows setting the mutation operation.
  21834. func (m *PayRechargeMutation) SetOp(op Op) {
  21835. m.op = op
  21836. }
  21837. // Type returns the node type of this mutation (PayRecharge).
  21838. func (m *PayRechargeMutation) Type() string {
  21839. return m.typ
  21840. }
  21841. // Fields returns all fields that were changed during this mutation. Note that in
  21842. // order to get all numeric fields that were incremented/decremented, call
  21843. // AddedFields().
  21844. func (m *PayRechargeMutation) Fields() []string {
  21845. fields := make([]string, 0, 9)
  21846. if m.created_at != nil {
  21847. fields = append(fields, payrecharge.FieldCreatedAt)
  21848. }
  21849. if m.updated_at != nil {
  21850. fields = append(fields, payrecharge.FieldUpdatedAt)
  21851. }
  21852. if m.deleted_at != nil {
  21853. fields = append(fields, payrecharge.FieldDeletedAt)
  21854. }
  21855. if m.user_id != nil {
  21856. fields = append(fields, payrecharge.FieldUserID)
  21857. }
  21858. if m.number != nil {
  21859. fields = append(fields, payrecharge.FieldNumber)
  21860. }
  21861. if m.status != nil {
  21862. fields = append(fields, payrecharge.FieldStatus)
  21863. }
  21864. if m.money != nil {
  21865. fields = append(fields, payrecharge.FieldMoney)
  21866. }
  21867. if m.out_trade_no != nil {
  21868. fields = append(fields, payrecharge.FieldOutTradeNo)
  21869. }
  21870. if m.organization_id != nil {
  21871. fields = append(fields, payrecharge.FieldOrganizationID)
  21872. }
  21873. return fields
  21874. }
  21875. // Field returns the value of a field with the given name. The second boolean
  21876. // return value indicates that this field was not set, or was not defined in the
  21877. // schema.
  21878. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  21879. switch name {
  21880. case payrecharge.FieldCreatedAt:
  21881. return m.CreatedAt()
  21882. case payrecharge.FieldUpdatedAt:
  21883. return m.UpdatedAt()
  21884. case payrecharge.FieldDeletedAt:
  21885. return m.DeletedAt()
  21886. case payrecharge.FieldUserID:
  21887. return m.UserID()
  21888. case payrecharge.FieldNumber:
  21889. return m.Number()
  21890. case payrecharge.FieldStatus:
  21891. return m.Status()
  21892. case payrecharge.FieldMoney:
  21893. return m.Money()
  21894. case payrecharge.FieldOutTradeNo:
  21895. return m.OutTradeNo()
  21896. case payrecharge.FieldOrganizationID:
  21897. return m.OrganizationID()
  21898. }
  21899. return nil, false
  21900. }
  21901. // OldField returns the old value of the field from the database. An error is
  21902. // returned if the mutation operation is not UpdateOne, or the query to the
  21903. // database failed.
  21904. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21905. switch name {
  21906. case payrecharge.FieldCreatedAt:
  21907. return m.OldCreatedAt(ctx)
  21908. case payrecharge.FieldUpdatedAt:
  21909. return m.OldUpdatedAt(ctx)
  21910. case payrecharge.FieldDeletedAt:
  21911. return m.OldDeletedAt(ctx)
  21912. case payrecharge.FieldUserID:
  21913. return m.OldUserID(ctx)
  21914. case payrecharge.FieldNumber:
  21915. return m.OldNumber(ctx)
  21916. case payrecharge.FieldStatus:
  21917. return m.OldStatus(ctx)
  21918. case payrecharge.FieldMoney:
  21919. return m.OldMoney(ctx)
  21920. case payrecharge.FieldOutTradeNo:
  21921. return m.OldOutTradeNo(ctx)
  21922. case payrecharge.FieldOrganizationID:
  21923. return m.OldOrganizationID(ctx)
  21924. }
  21925. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  21926. }
  21927. // SetField sets the value of a field with the given name. It returns an error if
  21928. // the field is not defined in the schema, or if the type mismatched the field
  21929. // type.
  21930. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  21931. switch name {
  21932. case payrecharge.FieldCreatedAt:
  21933. v, ok := value.(time.Time)
  21934. if !ok {
  21935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21936. }
  21937. m.SetCreatedAt(v)
  21938. return nil
  21939. case payrecharge.FieldUpdatedAt:
  21940. v, ok := value.(time.Time)
  21941. if !ok {
  21942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21943. }
  21944. m.SetUpdatedAt(v)
  21945. return nil
  21946. case payrecharge.FieldDeletedAt:
  21947. v, ok := value.(time.Time)
  21948. if !ok {
  21949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21950. }
  21951. m.SetDeletedAt(v)
  21952. return nil
  21953. case payrecharge.FieldUserID:
  21954. v, ok := value.(string)
  21955. if !ok {
  21956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21957. }
  21958. m.SetUserID(v)
  21959. return nil
  21960. case payrecharge.FieldNumber:
  21961. v, ok := value.(float32)
  21962. if !ok {
  21963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21964. }
  21965. m.SetNumber(v)
  21966. return nil
  21967. case payrecharge.FieldStatus:
  21968. v, ok := value.(int)
  21969. if !ok {
  21970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21971. }
  21972. m.SetStatus(v)
  21973. return nil
  21974. case payrecharge.FieldMoney:
  21975. v, ok := value.(float32)
  21976. if !ok {
  21977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21978. }
  21979. m.SetMoney(v)
  21980. return nil
  21981. case payrecharge.FieldOutTradeNo:
  21982. v, ok := value.(string)
  21983. if !ok {
  21984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21985. }
  21986. m.SetOutTradeNo(v)
  21987. return nil
  21988. case payrecharge.FieldOrganizationID:
  21989. v, ok := value.(uint64)
  21990. if !ok {
  21991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21992. }
  21993. m.SetOrganizationID(v)
  21994. return nil
  21995. }
  21996. return fmt.Errorf("unknown PayRecharge field %s", name)
  21997. }
  21998. // AddedFields returns all numeric fields that were incremented/decremented during
  21999. // this mutation.
  22000. func (m *PayRechargeMutation) AddedFields() []string {
  22001. var fields []string
  22002. if m.addnumber != nil {
  22003. fields = append(fields, payrecharge.FieldNumber)
  22004. }
  22005. if m.addstatus != nil {
  22006. fields = append(fields, payrecharge.FieldStatus)
  22007. }
  22008. if m.addmoney != nil {
  22009. fields = append(fields, payrecharge.FieldMoney)
  22010. }
  22011. if m.addorganization_id != nil {
  22012. fields = append(fields, payrecharge.FieldOrganizationID)
  22013. }
  22014. return fields
  22015. }
  22016. // AddedField returns the numeric value that was incremented/decremented on a field
  22017. // with the given name. The second boolean return value indicates that this field
  22018. // was not set, or was not defined in the schema.
  22019. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  22020. switch name {
  22021. case payrecharge.FieldNumber:
  22022. return m.AddedNumber()
  22023. case payrecharge.FieldStatus:
  22024. return m.AddedStatus()
  22025. case payrecharge.FieldMoney:
  22026. return m.AddedMoney()
  22027. case payrecharge.FieldOrganizationID:
  22028. return m.AddedOrganizationID()
  22029. }
  22030. return nil, false
  22031. }
  22032. // AddField adds the value to the field with the given name. It returns an error if
  22033. // the field is not defined in the schema, or if the type mismatched the field
  22034. // type.
  22035. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  22036. switch name {
  22037. case payrecharge.FieldNumber:
  22038. v, ok := value.(float32)
  22039. if !ok {
  22040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22041. }
  22042. m.AddNumber(v)
  22043. return nil
  22044. case payrecharge.FieldStatus:
  22045. v, ok := value.(int)
  22046. if !ok {
  22047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22048. }
  22049. m.AddStatus(v)
  22050. return nil
  22051. case payrecharge.FieldMoney:
  22052. v, ok := value.(float32)
  22053. if !ok {
  22054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22055. }
  22056. m.AddMoney(v)
  22057. return nil
  22058. case payrecharge.FieldOrganizationID:
  22059. v, ok := value.(int64)
  22060. if !ok {
  22061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22062. }
  22063. m.AddOrganizationID(v)
  22064. return nil
  22065. }
  22066. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  22067. }
  22068. // ClearedFields returns all nullable fields that were cleared during this
  22069. // mutation.
  22070. func (m *PayRechargeMutation) ClearedFields() []string {
  22071. var fields []string
  22072. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  22073. fields = append(fields, payrecharge.FieldDeletedAt)
  22074. }
  22075. if m.FieldCleared(payrecharge.FieldStatus) {
  22076. fields = append(fields, payrecharge.FieldStatus)
  22077. }
  22078. if m.FieldCleared(payrecharge.FieldMoney) {
  22079. fields = append(fields, payrecharge.FieldMoney)
  22080. }
  22081. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22082. fields = append(fields, payrecharge.FieldOutTradeNo)
  22083. }
  22084. return fields
  22085. }
  22086. // FieldCleared returns a boolean indicating if a field with the given name was
  22087. // cleared in this mutation.
  22088. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22089. _, ok := m.clearedFields[name]
  22090. return ok
  22091. }
  22092. // ClearField clears the value of the field with the given name. It returns an
  22093. // error if the field is not defined in the schema.
  22094. func (m *PayRechargeMutation) ClearField(name string) error {
  22095. switch name {
  22096. case payrecharge.FieldDeletedAt:
  22097. m.ClearDeletedAt()
  22098. return nil
  22099. case payrecharge.FieldStatus:
  22100. m.ClearStatus()
  22101. return nil
  22102. case payrecharge.FieldMoney:
  22103. m.ClearMoney()
  22104. return nil
  22105. case payrecharge.FieldOutTradeNo:
  22106. m.ClearOutTradeNo()
  22107. return nil
  22108. }
  22109. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22110. }
  22111. // ResetField resets all changes in the mutation for the field with the given name.
  22112. // It returns an error if the field is not defined in the schema.
  22113. func (m *PayRechargeMutation) ResetField(name string) error {
  22114. switch name {
  22115. case payrecharge.FieldCreatedAt:
  22116. m.ResetCreatedAt()
  22117. return nil
  22118. case payrecharge.FieldUpdatedAt:
  22119. m.ResetUpdatedAt()
  22120. return nil
  22121. case payrecharge.FieldDeletedAt:
  22122. m.ResetDeletedAt()
  22123. return nil
  22124. case payrecharge.FieldUserID:
  22125. m.ResetUserID()
  22126. return nil
  22127. case payrecharge.FieldNumber:
  22128. m.ResetNumber()
  22129. return nil
  22130. case payrecharge.FieldStatus:
  22131. m.ResetStatus()
  22132. return nil
  22133. case payrecharge.FieldMoney:
  22134. m.ResetMoney()
  22135. return nil
  22136. case payrecharge.FieldOutTradeNo:
  22137. m.ResetOutTradeNo()
  22138. return nil
  22139. case payrecharge.FieldOrganizationID:
  22140. m.ResetOrganizationID()
  22141. return nil
  22142. }
  22143. return fmt.Errorf("unknown PayRecharge field %s", name)
  22144. }
  22145. // AddedEdges returns all edge names that were set/added in this mutation.
  22146. func (m *PayRechargeMutation) AddedEdges() []string {
  22147. edges := make([]string, 0, 0)
  22148. return edges
  22149. }
  22150. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22151. // name in this mutation.
  22152. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22153. return nil
  22154. }
  22155. // RemovedEdges returns all edge names that were removed in this mutation.
  22156. func (m *PayRechargeMutation) RemovedEdges() []string {
  22157. edges := make([]string, 0, 0)
  22158. return edges
  22159. }
  22160. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22161. // the given name in this mutation.
  22162. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22163. return nil
  22164. }
  22165. // ClearedEdges returns all edge names that were cleared in this mutation.
  22166. func (m *PayRechargeMutation) ClearedEdges() []string {
  22167. edges := make([]string, 0, 0)
  22168. return edges
  22169. }
  22170. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22171. // was cleared in this mutation.
  22172. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22173. return false
  22174. }
  22175. // ClearEdge clears the value of the edge with the given name. It returns an error
  22176. // if that edge is not defined in the schema.
  22177. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22178. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  22179. }
  22180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22181. // It returns an error if the edge is not defined in the schema.
  22182. func (m *PayRechargeMutation) ResetEdge(name string) error {
  22183. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22184. }
  22185. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22186. type ServerMutation struct {
  22187. config
  22188. op Op
  22189. typ string
  22190. id *uint64
  22191. created_at *time.Time
  22192. updated_at *time.Time
  22193. status *uint8
  22194. addstatus *int8
  22195. deleted_at *time.Time
  22196. name *string
  22197. public_ip *string
  22198. private_ip *string
  22199. admin_port *string
  22200. clearedFields map[string]struct{}
  22201. wxs map[uint64]struct{}
  22202. removedwxs map[uint64]struct{}
  22203. clearedwxs bool
  22204. done bool
  22205. oldValue func(context.Context) (*Server, error)
  22206. predicates []predicate.Server
  22207. }
  22208. var _ ent.Mutation = (*ServerMutation)(nil)
  22209. // serverOption allows management of the mutation configuration using functional options.
  22210. type serverOption func(*ServerMutation)
  22211. // newServerMutation creates new mutation for the Server entity.
  22212. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22213. m := &ServerMutation{
  22214. config: c,
  22215. op: op,
  22216. typ: TypeServer,
  22217. clearedFields: make(map[string]struct{}),
  22218. }
  22219. for _, opt := range opts {
  22220. opt(m)
  22221. }
  22222. return m
  22223. }
  22224. // withServerID sets the ID field of the mutation.
  22225. func withServerID(id uint64) serverOption {
  22226. return func(m *ServerMutation) {
  22227. var (
  22228. err error
  22229. once sync.Once
  22230. value *Server
  22231. )
  22232. m.oldValue = func(ctx context.Context) (*Server, error) {
  22233. once.Do(func() {
  22234. if m.done {
  22235. err = errors.New("querying old values post mutation is not allowed")
  22236. } else {
  22237. value, err = m.Client().Server.Get(ctx, id)
  22238. }
  22239. })
  22240. return value, err
  22241. }
  22242. m.id = &id
  22243. }
  22244. }
  22245. // withServer sets the old Server of the mutation.
  22246. func withServer(node *Server) serverOption {
  22247. return func(m *ServerMutation) {
  22248. m.oldValue = func(context.Context) (*Server, error) {
  22249. return node, nil
  22250. }
  22251. m.id = &node.ID
  22252. }
  22253. }
  22254. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22255. // executed in a transaction (ent.Tx), a transactional client is returned.
  22256. func (m ServerMutation) Client() *Client {
  22257. client := &Client{config: m.config}
  22258. client.init()
  22259. return client
  22260. }
  22261. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22262. // it returns an error otherwise.
  22263. func (m ServerMutation) Tx() (*Tx, error) {
  22264. if _, ok := m.driver.(*txDriver); !ok {
  22265. return nil, errors.New("ent: mutation is not running in a transaction")
  22266. }
  22267. tx := &Tx{config: m.config}
  22268. tx.init()
  22269. return tx, nil
  22270. }
  22271. // SetID sets the value of the id field. Note that this
  22272. // operation is only accepted on creation of Server entities.
  22273. func (m *ServerMutation) SetID(id uint64) {
  22274. m.id = &id
  22275. }
  22276. // ID returns the ID value in the mutation. Note that the ID is only available
  22277. // if it was provided to the builder or after it was returned from the database.
  22278. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22279. if m.id == nil {
  22280. return
  22281. }
  22282. return *m.id, true
  22283. }
  22284. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22285. // That means, if the mutation is applied within a transaction with an isolation level such
  22286. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22287. // or updated by the mutation.
  22288. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22289. switch {
  22290. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22291. id, exists := m.ID()
  22292. if exists {
  22293. return []uint64{id}, nil
  22294. }
  22295. fallthrough
  22296. case m.op.Is(OpUpdate | OpDelete):
  22297. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22298. default:
  22299. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22300. }
  22301. }
  22302. // SetCreatedAt sets the "created_at" field.
  22303. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22304. m.created_at = &t
  22305. }
  22306. // CreatedAt returns the value of the "created_at" field in the mutation.
  22307. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22308. v := m.created_at
  22309. if v == nil {
  22310. return
  22311. }
  22312. return *v, true
  22313. }
  22314. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22315. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22317. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22318. if !m.op.Is(OpUpdateOne) {
  22319. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22320. }
  22321. if m.id == nil || m.oldValue == nil {
  22322. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22323. }
  22324. oldValue, err := m.oldValue(ctx)
  22325. if err != nil {
  22326. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22327. }
  22328. return oldValue.CreatedAt, nil
  22329. }
  22330. // ResetCreatedAt resets all changes to the "created_at" field.
  22331. func (m *ServerMutation) ResetCreatedAt() {
  22332. m.created_at = nil
  22333. }
  22334. // SetUpdatedAt sets the "updated_at" field.
  22335. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22336. m.updated_at = &t
  22337. }
  22338. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22339. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22340. v := m.updated_at
  22341. if v == nil {
  22342. return
  22343. }
  22344. return *v, true
  22345. }
  22346. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22347. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22349. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22350. if !m.op.Is(OpUpdateOne) {
  22351. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22352. }
  22353. if m.id == nil || m.oldValue == nil {
  22354. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22355. }
  22356. oldValue, err := m.oldValue(ctx)
  22357. if err != nil {
  22358. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22359. }
  22360. return oldValue.UpdatedAt, nil
  22361. }
  22362. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22363. func (m *ServerMutation) ResetUpdatedAt() {
  22364. m.updated_at = nil
  22365. }
  22366. // SetStatus sets the "status" field.
  22367. func (m *ServerMutation) SetStatus(u uint8) {
  22368. m.status = &u
  22369. m.addstatus = nil
  22370. }
  22371. // Status returns the value of the "status" field in the mutation.
  22372. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22373. v := m.status
  22374. if v == nil {
  22375. return
  22376. }
  22377. return *v, true
  22378. }
  22379. // OldStatus returns the old "status" field's value of the Server entity.
  22380. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22382. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22383. if !m.op.Is(OpUpdateOne) {
  22384. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22385. }
  22386. if m.id == nil || m.oldValue == nil {
  22387. return v, errors.New("OldStatus requires an ID field in the mutation")
  22388. }
  22389. oldValue, err := m.oldValue(ctx)
  22390. if err != nil {
  22391. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22392. }
  22393. return oldValue.Status, nil
  22394. }
  22395. // AddStatus adds u to the "status" field.
  22396. func (m *ServerMutation) AddStatus(u int8) {
  22397. if m.addstatus != nil {
  22398. *m.addstatus += u
  22399. } else {
  22400. m.addstatus = &u
  22401. }
  22402. }
  22403. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22404. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22405. v := m.addstatus
  22406. if v == nil {
  22407. return
  22408. }
  22409. return *v, true
  22410. }
  22411. // ClearStatus clears the value of the "status" field.
  22412. func (m *ServerMutation) ClearStatus() {
  22413. m.status = nil
  22414. m.addstatus = nil
  22415. m.clearedFields[server.FieldStatus] = struct{}{}
  22416. }
  22417. // StatusCleared returns if the "status" field was cleared in this mutation.
  22418. func (m *ServerMutation) StatusCleared() bool {
  22419. _, ok := m.clearedFields[server.FieldStatus]
  22420. return ok
  22421. }
  22422. // ResetStatus resets all changes to the "status" field.
  22423. func (m *ServerMutation) ResetStatus() {
  22424. m.status = nil
  22425. m.addstatus = nil
  22426. delete(m.clearedFields, server.FieldStatus)
  22427. }
  22428. // SetDeletedAt sets the "deleted_at" field.
  22429. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22430. m.deleted_at = &t
  22431. }
  22432. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22433. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22434. v := m.deleted_at
  22435. if v == nil {
  22436. return
  22437. }
  22438. return *v, true
  22439. }
  22440. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22441. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22443. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22444. if !m.op.Is(OpUpdateOne) {
  22445. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22446. }
  22447. if m.id == nil || m.oldValue == nil {
  22448. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22449. }
  22450. oldValue, err := m.oldValue(ctx)
  22451. if err != nil {
  22452. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22453. }
  22454. return oldValue.DeletedAt, nil
  22455. }
  22456. // ClearDeletedAt clears the value of the "deleted_at" field.
  22457. func (m *ServerMutation) ClearDeletedAt() {
  22458. m.deleted_at = nil
  22459. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22460. }
  22461. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22462. func (m *ServerMutation) DeletedAtCleared() bool {
  22463. _, ok := m.clearedFields[server.FieldDeletedAt]
  22464. return ok
  22465. }
  22466. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22467. func (m *ServerMutation) ResetDeletedAt() {
  22468. m.deleted_at = nil
  22469. delete(m.clearedFields, server.FieldDeletedAt)
  22470. }
  22471. // SetName sets the "name" field.
  22472. func (m *ServerMutation) SetName(s string) {
  22473. m.name = &s
  22474. }
  22475. // Name returns the value of the "name" field in the mutation.
  22476. func (m *ServerMutation) Name() (r string, exists bool) {
  22477. v := m.name
  22478. if v == nil {
  22479. return
  22480. }
  22481. return *v, true
  22482. }
  22483. // OldName returns the old "name" field's value of the Server entity.
  22484. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22486. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22487. if !m.op.Is(OpUpdateOne) {
  22488. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22489. }
  22490. if m.id == nil || m.oldValue == nil {
  22491. return v, errors.New("OldName requires an ID field in the mutation")
  22492. }
  22493. oldValue, err := m.oldValue(ctx)
  22494. if err != nil {
  22495. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22496. }
  22497. return oldValue.Name, nil
  22498. }
  22499. // ResetName resets all changes to the "name" field.
  22500. func (m *ServerMutation) ResetName() {
  22501. m.name = nil
  22502. }
  22503. // SetPublicIP sets the "public_ip" field.
  22504. func (m *ServerMutation) SetPublicIP(s string) {
  22505. m.public_ip = &s
  22506. }
  22507. // PublicIP returns the value of the "public_ip" field in the mutation.
  22508. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22509. v := m.public_ip
  22510. if v == nil {
  22511. return
  22512. }
  22513. return *v, true
  22514. }
  22515. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22516. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22518. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22519. if !m.op.Is(OpUpdateOne) {
  22520. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22521. }
  22522. if m.id == nil || m.oldValue == nil {
  22523. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22524. }
  22525. oldValue, err := m.oldValue(ctx)
  22526. if err != nil {
  22527. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22528. }
  22529. return oldValue.PublicIP, nil
  22530. }
  22531. // ResetPublicIP resets all changes to the "public_ip" field.
  22532. func (m *ServerMutation) ResetPublicIP() {
  22533. m.public_ip = nil
  22534. }
  22535. // SetPrivateIP sets the "private_ip" field.
  22536. func (m *ServerMutation) SetPrivateIP(s string) {
  22537. m.private_ip = &s
  22538. }
  22539. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22540. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22541. v := m.private_ip
  22542. if v == nil {
  22543. return
  22544. }
  22545. return *v, true
  22546. }
  22547. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22548. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22550. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22551. if !m.op.Is(OpUpdateOne) {
  22552. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22553. }
  22554. if m.id == nil || m.oldValue == nil {
  22555. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22556. }
  22557. oldValue, err := m.oldValue(ctx)
  22558. if err != nil {
  22559. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22560. }
  22561. return oldValue.PrivateIP, nil
  22562. }
  22563. // ResetPrivateIP resets all changes to the "private_ip" field.
  22564. func (m *ServerMutation) ResetPrivateIP() {
  22565. m.private_ip = nil
  22566. }
  22567. // SetAdminPort sets the "admin_port" field.
  22568. func (m *ServerMutation) SetAdminPort(s string) {
  22569. m.admin_port = &s
  22570. }
  22571. // AdminPort returns the value of the "admin_port" field in the mutation.
  22572. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22573. v := m.admin_port
  22574. if v == nil {
  22575. return
  22576. }
  22577. return *v, true
  22578. }
  22579. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22580. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22582. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22583. if !m.op.Is(OpUpdateOne) {
  22584. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22585. }
  22586. if m.id == nil || m.oldValue == nil {
  22587. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22588. }
  22589. oldValue, err := m.oldValue(ctx)
  22590. if err != nil {
  22591. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22592. }
  22593. return oldValue.AdminPort, nil
  22594. }
  22595. // ResetAdminPort resets all changes to the "admin_port" field.
  22596. func (m *ServerMutation) ResetAdminPort() {
  22597. m.admin_port = nil
  22598. }
  22599. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22600. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22601. if m.wxs == nil {
  22602. m.wxs = make(map[uint64]struct{})
  22603. }
  22604. for i := range ids {
  22605. m.wxs[ids[i]] = struct{}{}
  22606. }
  22607. }
  22608. // ClearWxs clears the "wxs" edge to the Wx entity.
  22609. func (m *ServerMutation) ClearWxs() {
  22610. m.clearedwxs = true
  22611. }
  22612. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22613. func (m *ServerMutation) WxsCleared() bool {
  22614. return m.clearedwxs
  22615. }
  22616. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22617. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22618. if m.removedwxs == nil {
  22619. m.removedwxs = make(map[uint64]struct{})
  22620. }
  22621. for i := range ids {
  22622. delete(m.wxs, ids[i])
  22623. m.removedwxs[ids[i]] = struct{}{}
  22624. }
  22625. }
  22626. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22627. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22628. for id := range m.removedwxs {
  22629. ids = append(ids, id)
  22630. }
  22631. return
  22632. }
  22633. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22634. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22635. for id := range m.wxs {
  22636. ids = append(ids, id)
  22637. }
  22638. return
  22639. }
  22640. // ResetWxs resets all changes to the "wxs" edge.
  22641. func (m *ServerMutation) ResetWxs() {
  22642. m.wxs = nil
  22643. m.clearedwxs = false
  22644. m.removedwxs = nil
  22645. }
  22646. // Where appends a list predicates to the ServerMutation builder.
  22647. func (m *ServerMutation) Where(ps ...predicate.Server) {
  22648. m.predicates = append(m.predicates, ps...)
  22649. }
  22650. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  22651. // users can use type-assertion to append predicates that do not depend on any generated package.
  22652. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  22653. p := make([]predicate.Server, len(ps))
  22654. for i := range ps {
  22655. p[i] = ps[i]
  22656. }
  22657. m.Where(p...)
  22658. }
  22659. // Op returns the operation name.
  22660. func (m *ServerMutation) Op() Op {
  22661. return m.op
  22662. }
  22663. // SetOp allows setting the mutation operation.
  22664. func (m *ServerMutation) SetOp(op Op) {
  22665. m.op = op
  22666. }
  22667. // Type returns the node type of this mutation (Server).
  22668. func (m *ServerMutation) Type() string {
  22669. return m.typ
  22670. }
  22671. // Fields returns all fields that were changed during this mutation. Note that in
  22672. // order to get all numeric fields that were incremented/decremented, call
  22673. // AddedFields().
  22674. func (m *ServerMutation) Fields() []string {
  22675. fields := make([]string, 0, 8)
  22676. if m.created_at != nil {
  22677. fields = append(fields, server.FieldCreatedAt)
  22678. }
  22679. if m.updated_at != nil {
  22680. fields = append(fields, server.FieldUpdatedAt)
  22681. }
  22682. if m.status != nil {
  22683. fields = append(fields, server.FieldStatus)
  22684. }
  22685. if m.deleted_at != nil {
  22686. fields = append(fields, server.FieldDeletedAt)
  22687. }
  22688. if m.name != nil {
  22689. fields = append(fields, server.FieldName)
  22690. }
  22691. if m.public_ip != nil {
  22692. fields = append(fields, server.FieldPublicIP)
  22693. }
  22694. if m.private_ip != nil {
  22695. fields = append(fields, server.FieldPrivateIP)
  22696. }
  22697. if m.admin_port != nil {
  22698. fields = append(fields, server.FieldAdminPort)
  22699. }
  22700. return fields
  22701. }
  22702. // Field returns the value of a field with the given name. The second boolean
  22703. // return value indicates that this field was not set, or was not defined in the
  22704. // schema.
  22705. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  22706. switch name {
  22707. case server.FieldCreatedAt:
  22708. return m.CreatedAt()
  22709. case server.FieldUpdatedAt:
  22710. return m.UpdatedAt()
  22711. case server.FieldStatus:
  22712. return m.Status()
  22713. case server.FieldDeletedAt:
  22714. return m.DeletedAt()
  22715. case server.FieldName:
  22716. return m.Name()
  22717. case server.FieldPublicIP:
  22718. return m.PublicIP()
  22719. case server.FieldPrivateIP:
  22720. return m.PrivateIP()
  22721. case server.FieldAdminPort:
  22722. return m.AdminPort()
  22723. }
  22724. return nil, false
  22725. }
  22726. // OldField returns the old value of the field from the database. An error is
  22727. // returned if the mutation operation is not UpdateOne, or the query to the
  22728. // database failed.
  22729. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22730. switch name {
  22731. case server.FieldCreatedAt:
  22732. return m.OldCreatedAt(ctx)
  22733. case server.FieldUpdatedAt:
  22734. return m.OldUpdatedAt(ctx)
  22735. case server.FieldStatus:
  22736. return m.OldStatus(ctx)
  22737. case server.FieldDeletedAt:
  22738. return m.OldDeletedAt(ctx)
  22739. case server.FieldName:
  22740. return m.OldName(ctx)
  22741. case server.FieldPublicIP:
  22742. return m.OldPublicIP(ctx)
  22743. case server.FieldPrivateIP:
  22744. return m.OldPrivateIP(ctx)
  22745. case server.FieldAdminPort:
  22746. return m.OldAdminPort(ctx)
  22747. }
  22748. return nil, fmt.Errorf("unknown Server field %s", name)
  22749. }
  22750. // SetField sets the value of a field with the given name. It returns an error if
  22751. // the field is not defined in the schema, or if the type mismatched the field
  22752. // type.
  22753. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  22754. switch name {
  22755. case server.FieldCreatedAt:
  22756. v, ok := value.(time.Time)
  22757. if !ok {
  22758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22759. }
  22760. m.SetCreatedAt(v)
  22761. return nil
  22762. case server.FieldUpdatedAt:
  22763. v, ok := value.(time.Time)
  22764. if !ok {
  22765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22766. }
  22767. m.SetUpdatedAt(v)
  22768. return nil
  22769. case server.FieldStatus:
  22770. v, ok := value.(uint8)
  22771. if !ok {
  22772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22773. }
  22774. m.SetStatus(v)
  22775. return nil
  22776. case server.FieldDeletedAt:
  22777. v, ok := value.(time.Time)
  22778. if !ok {
  22779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22780. }
  22781. m.SetDeletedAt(v)
  22782. return nil
  22783. case server.FieldName:
  22784. v, ok := value.(string)
  22785. if !ok {
  22786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22787. }
  22788. m.SetName(v)
  22789. return nil
  22790. case server.FieldPublicIP:
  22791. v, ok := value.(string)
  22792. if !ok {
  22793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22794. }
  22795. m.SetPublicIP(v)
  22796. return nil
  22797. case server.FieldPrivateIP:
  22798. v, ok := value.(string)
  22799. if !ok {
  22800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22801. }
  22802. m.SetPrivateIP(v)
  22803. return nil
  22804. case server.FieldAdminPort:
  22805. v, ok := value.(string)
  22806. if !ok {
  22807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22808. }
  22809. m.SetAdminPort(v)
  22810. return nil
  22811. }
  22812. return fmt.Errorf("unknown Server field %s", name)
  22813. }
  22814. // AddedFields returns all numeric fields that were incremented/decremented during
  22815. // this mutation.
  22816. func (m *ServerMutation) AddedFields() []string {
  22817. var fields []string
  22818. if m.addstatus != nil {
  22819. fields = append(fields, server.FieldStatus)
  22820. }
  22821. return fields
  22822. }
  22823. // AddedField returns the numeric value that was incremented/decremented on a field
  22824. // with the given name. The second boolean return value indicates that this field
  22825. // was not set, or was not defined in the schema.
  22826. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  22827. switch name {
  22828. case server.FieldStatus:
  22829. return m.AddedStatus()
  22830. }
  22831. return nil, false
  22832. }
  22833. // AddField adds the value to the field with the given name. It returns an error if
  22834. // the field is not defined in the schema, or if the type mismatched the field
  22835. // type.
  22836. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  22837. switch name {
  22838. case server.FieldStatus:
  22839. v, ok := value.(int8)
  22840. if !ok {
  22841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22842. }
  22843. m.AddStatus(v)
  22844. return nil
  22845. }
  22846. return fmt.Errorf("unknown Server numeric field %s", name)
  22847. }
  22848. // ClearedFields returns all nullable fields that were cleared during this
  22849. // mutation.
  22850. func (m *ServerMutation) ClearedFields() []string {
  22851. var fields []string
  22852. if m.FieldCleared(server.FieldStatus) {
  22853. fields = append(fields, server.FieldStatus)
  22854. }
  22855. if m.FieldCleared(server.FieldDeletedAt) {
  22856. fields = append(fields, server.FieldDeletedAt)
  22857. }
  22858. return fields
  22859. }
  22860. // FieldCleared returns a boolean indicating if a field with the given name was
  22861. // cleared in this mutation.
  22862. func (m *ServerMutation) FieldCleared(name string) bool {
  22863. _, ok := m.clearedFields[name]
  22864. return ok
  22865. }
  22866. // ClearField clears the value of the field with the given name. It returns an
  22867. // error if the field is not defined in the schema.
  22868. func (m *ServerMutation) ClearField(name string) error {
  22869. switch name {
  22870. case server.FieldStatus:
  22871. m.ClearStatus()
  22872. return nil
  22873. case server.FieldDeletedAt:
  22874. m.ClearDeletedAt()
  22875. return nil
  22876. }
  22877. return fmt.Errorf("unknown Server nullable field %s", name)
  22878. }
  22879. // ResetField resets all changes in the mutation for the field with the given name.
  22880. // It returns an error if the field is not defined in the schema.
  22881. func (m *ServerMutation) ResetField(name string) error {
  22882. switch name {
  22883. case server.FieldCreatedAt:
  22884. m.ResetCreatedAt()
  22885. return nil
  22886. case server.FieldUpdatedAt:
  22887. m.ResetUpdatedAt()
  22888. return nil
  22889. case server.FieldStatus:
  22890. m.ResetStatus()
  22891. return nil
  22892. case server.FieldDeletedAt:
  22893. m.ResetDeletedAt()
  22894. return nil
  22895. case server.FieldName:
  22896. m.ResetName()
  22897. return nil
  22898. case server.FieldPublicIP:
  22899. m.ResetPublicIP()
  22900. return nil
  22901. case server.FieldPrivateIP:
  22902. m.ResetPrivateIP()
  22903. return nil
  22904. case server.FieldAdminPort:
  22905. m.ResetAdminPort()
  22906. return nil
  22907. }
  22908. return fmt.Errorf("unknown Server field %s", name)
  22909. }
  22910. // AddedEdges returns all edge names that were set/added in this mutation.
  22911. func (m *ServerMutation) AddedEdges() []string {
  22912. edges := make([]string, 0, 1)
  22913. if m.wxs != nil {
  22914. edges = append(edges, server.EdgeWxs)
  22915. }
  22916. return edges
  22917. }
  22918. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22919. // name in this mutation.
  22920. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  22921. switch name {
  22922. case server.EdgeWxs:
  22923. ids := make([]ent.Value, 0, len(m.wxs))
  22924. for id := range m.wxs {
  22925. ids = append(ids, id)
  22926. }
  22927. return ids
  22928. }
  22929. return nil
  22930. }
  22931. // RemovedEdges returns all edge names that were removed in this mutation.
  22932. func (m *ServerMutation) RemovedEdges() []string {
  22933. edges := make([]string, 0, 1)
  22934. if m.removedwxs != nil {
  22935. edges = append(edges, server.EdgeWxs)
  22936. }
  22937. return edges
  22938. }
  22939. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22940. // the given name in this mutation.
  22941. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  22942. switch name {
  22943. case server.EdgeWxs:
  22944. ids := make([]ent.Value, 0, len(m.removedwxs))
  22945. for id := range m.removedwxs {
  22946. ids = append(ids, id)
  22947. }
  22948. return ids
  22949. }
  22950. return nil
  22951. }
  22952. // ClearedEdges returns all edge names that were cleared in this mutation.
  22953. func (m *ServerMutation) ClearedEdges() []string {
  22954. edges := make([]string, 0, 1)
  22955. if m.clearedwxs {
  22956. edges = append(edges, server.EdgeWxs)
  22957. }
  22958. return edges
  22959. }
  22960. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22961. // was cleared in this mutation.
  22962. func (m *ServerMutation) EdgeCleared(name string) bool {
  22963. switch name {
  22964. case server.EdgeWxs:
  22965. return m.clearedwxs
  22966. }
  22967. return false
  22968. }
  22969. // ClearEdge clears the value of the edge with the given name. It returns an error
  22970. // if that edge is not defined in the schema.
  22971. func (m *ServerMutation) ClearEdge(name string) error {
  22972. switch name {
  22973. }
  22974. return fmt.Errorf("unknown Server unique edge %s", name)
  22975. }
  22976. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22977. // It returns an error if the edge is not defined in the schema.
  22978. func (m *ServerMutation) ResetEdge(name string) error {
  22979. switch name {
  22980. case server.EdgeWxs:
  22981. m.ResetWxs()
  22982. return nil
  22983. }
  22984. return fmt.Errorf("unknown Server edge %s", name)
  22985. }
  22986. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  22987. type SopNodeMutation struct {
  22988. config
  22989. op Op
  22990. typ string
  22991. id *uint64
  22992. created_at *time.Time
  22993. updated_at *time.Time
  22994. status *uint8
  22995. addstatus *int8
  22996. deleted_at *time.Time
  22997. parent_id *uint64
  22998. addparent_id *int64
  22999. name *string
  23000. condition_type *int
  23001. addcondition_type *int
  23002. condition_list *[]string
  23003. appendcondition_list []string
  23004. no_reply_condition *uint64
  23005. addno_reply_condition *int64
  23006. no_reply_unit *string
  23007. action_message *[]custom_types.Action
  23008. appendaction_message []custom_types.Action
  23009. action_label_add *[]uint64
  23010. appendaction_label_add []uint64
  23011. action_label_del *[]uint64
  23012. appendaction_label_del []uint64
  23013. action_forward **custom_types.ActionForward
  23014. clearedFields map[string]struct{}
  23015. sop_stage *uint64
  23016. clearedsop_stage bool
  23017. node_messages map[uint64]struct{}
  23018. removednode_messages map[uint64]struct{}
  23019. clearednode_messages bool
  23020. done bool
  23021. oldValue func(context.Context) (*SopNode, error)
  23022. predicates []predicate.SopNode
  23023. }
  23024. var _ ent.Mutation = (*SopNodeMutation)(nil)
  23025. // sopnodeOption allows management of the mutation configuration using functional options.
  23026. type sopnodeOption func(*SopNodeMutation)
  23027. // newSopNodeMutation creates new mutation for the SopNode entity.
  23028. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  23029. m := &SopNodeMutation{
  23030. config: c,
  23031. op: op,
  23032. typ: TypeSopNode,
  23033. clearedFields: make(map[string]struct{}),
  23034. }
  23035. for _, opt := range opts {
  23036. opt(m)
  23037. }
  23038. return m
  23039. }
  23040. // withSopNodeID sets the ID field of the mutation.
  23041. func withSopNodeID(id uint64) sopnodeOption {
  23042. return func(m *SopNodeMutation) {
  23043. var (
  23044. err error
  23045. once sync.Once
  23046. value *SopNode
  23047. )
  23048. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  23049. once.Do(func() {
  23050. if m.done {
  23051. err = errors.New("querying old values post mutation is not allowed")
  23052. } else {
  23053. value, err = m.Client().SopNode.Get(ctx, id)
  23054. }
  23055. })
  23056. return value, err
  23057. }
  23058. m.id = &id
  23059. }
  23060. }
  23061. // withSopNode sets the old SopNode of the mutation.
  23062. func withSopNode(node *SopNode) sopnodeOption {
  23063. return func(m *SopNodeMutation) {
  23064. m.oldValue = func(context.Context) (*SopNode, error) {
  23065. return node, nil
  23066. }
  23067. m.id = &node.ID
  23068. }
  23069. }
  23070. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23071. // executed in a transaction (ent.Tx), a transactional client is returned.
  23072. func (m SopNodeMutation) Client() *Client {
  23073. client := &Client{config: m.config}
  23074. client.init()
  23075. return client
  23076. }
  23077. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23078. // it returns an error otherwise.
  23079. func (m SopNodeMutation) Tx() (*Tx, error) {
  23080. if _, ok := m.driver.(*txDriver); !ok {
  23081. return nil, errors.New("ent: mutation is not running in a transaction")
  23082. }
  23083. tx := &Tx{config: m.config}
  23084. tx.init()
  23085. return tx, nil
  23086. }
  23087. // SetID sets the value of the id field. Note that this
  23088. // operation is only accepted on creation of SopNode entities.
  23089. func (m *SopNodeMutation) SetID(id uint64) {
  23090. m.id = &id
  23091. }
  23092. // ID returns the ID value in the mutation. Note that the ID is only available
  23093. // if it was provided to the builder or after it was returned from the database.
  23094. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23095. if m.id == nil {
  23096. return
  23097. }
  23098. return *m.id, true
  23099. }
  23100. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23101. // That means, if the mutation is applied within a transaction with an isolation level such
  23102. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23103. // or updated by the mutation.
  23104. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23105. switch {
  23106. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23107. id, exists := m.ID()
  23108. if exists {
  23109. return []uint64{id}, nil
  23110. }
  23111. fallthrough
  23112. case m.op.Is(OpUpdate | OpDelete):
  23113. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23114. default:
  23115. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23116. }
  23117. }
  23118. // SetCreatedAt sets the "created_at" field.
  23119. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23120. m.created_at = &t
  23121. }
  23122. // CreatedAt returns the value of the "created_at" field in the mutation.
  23123. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23124. v := m.created_at
  23125. if v == nil {
  23126. return
  23127. }
  23128. return *v, true
  23129. }
  23130. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23131. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23133. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23134. if !m.op.Is(OpUpdateOne) {
  23135. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23136. }
  23137. if m.id == nil || m.oldValue == nil {
  23138. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23139. }
  23140. oldValue, err := m.oldValue(ctx)
  23141. if err != nil {
  23142. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23143. }
  23144. return oldValue.CreatedAt, nil
  23145. }
  23146. // ResetCreatedAt resets all changes to the "created_at" field.
  23147. func (m *SopNodeMutation) ResetCreatedAt() {
  23148. m.created_at = nil
  23149. }
  23150. // SetUpdatedAt sets the "updated_at" field.
  23151. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23152. m.updated_at = &t
  23153. }
  23154. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23155. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23156. v := m.updated_at
  23157. if v == nil {
  23158. return
  23159. }
  23160. return *v, true
  23161. }
  23162. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23163. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23165. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23166. if !m.op.Is(OpUpdateOne) {
  23167. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23168. }
  23169. if m.id == nil || m.oldValue == nil {
  23170. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23171. }
  23172. oldValue, err := m.oldValue(ctx)
  23173. if err != nil {
  23174. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23175. }
  23176. return oldValue.UpdatedAt, nil
  23177. }
  23178. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23179. func (m *SopNodeMutation) ResetUpdatedAt() {
  23180. m.updated_at = nil
  23181. }
  23182. // SetStatus sets the "status" field.
  23183. func (m *SopNodeMutation) SetStatus(u uint8) {
  23184. m.status = &u
  23185. m.addstatus = nil
  23186. }
  23187. // Status returns the value of the "status" field in the mutation.
  23188. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23189. v := m.status
  23190. if v == nil {
  23191. return
  23192. }
  23193. return *v, true
  23194. }
  23195. // OldStatus returns the old "status" field's value of the SopNode entity.
  23196. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23198. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23199. if !m.op.Is(OpUpdateOne) {
  23200. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23201. }
  23202. if m.id == nil || m.oldValue == nil {
  23203. return v, errors.New("OldStatus requires an ID field in the mutation")
  23204. }
  23205. oldValue, err := m.oldValue(ctx)
  23206. if err != nil {
  23207. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23208. }
  23209. return oldValue.Status, nil
  23210. }
  23211. // AddStatus adds u to the "status" field.
  23212. func (m *SopNodeMutation) AddStatus(u int8) {
  23213. if m.addstatus != nil {
  23214. *m.addstatus += u
  23215. } else {
  23216. m.addstatus = &u
  23217. }
  23218. }
  23219. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23220. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23221. v := m.addstatus
  23222. if v == nil {
  23223. return
  23224. }
  23225. return *v, true
  23226. }
  23227. // ClearStatus clears the value of the "status" field.
  23228. func (m *SopNodeMutation) ClearStatus() {
  23229. m.status = nil
  23230. m.addstatus = nil
  23231. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23232. }
  23233. // StatusCleared returns if the "status" field was cleared in this mutation.
  23234. func (m *SopNodeMutation) StatusCleared() bool {
  23235. _, ok := m.clearedFields[sopnode.FieldStatus]
  23236. return ok
  23237. }
  23238. // ResetStatus resets all changes to the "status" field.
  23239. func (m *SopNodeMutation) ResetStatus() {
  23240. m.status = nil
  23241. m.addstatus = nil
  23242. delete(m.clearedFields, sopnode.FieldStatus)
  23243. }
  23244. // SetDeletedAt sets the "deleted_at" field.
  23245. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23246. m.deleted_at = &t
  23247. }
  23248. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23249. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23250. v := m.deleted_at
  23251. if v == nil {
  23252. return
  23253. }
  23254. return *v, true
  23255. }
  23256. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23257. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23259. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23260. if !m.op.Is(OpUpdateOne) {
  23261. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23262. }
  23263. if m.id == nil || m.oldValue == nil {
  23264. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23265. }
  23266. oldValue, err := m.oldValue(ctx)
  23267. if err != nil {
  23268. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23269. }
  23270. return oldValue.DeletedAt, nil
  23271. }
  23272. // ClearDeletedAt clears the value of the "deleted_at" field.
  23273. func (m *SopNodeMutation) ClearDeletedAt() {
  23274. m.deleted_at = nil
  23275. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23276. }
  23277. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23278. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23279. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23280. return ok
  23281. }
  23282. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23283. func (m *SopNodeMutation) ResetDeletedAt() {
  23284. m.deleted_at = nil
  23285. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23286. }
  23287. // SetStageID sets the "stage_id" field.
  23288. func (m *SopNodeMutation) SetStageID(u uint64) {
  23289. m.sop_stage = &u
  23290. }
  23291. // StageID returns the value of the "stage_id" field in the mutation.
  23292. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23293. v := m.sop_stage
  23294. if v == nil {
  23295. return
  23296. }
  23297. return *v, true
  23298. }
  23299. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23300. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23302. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23303. if !m.op.Is(OpUpdateOne) {
  23304. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23305. }
  23306. if m.id == nil || m.oldValue == nil {
  23307. return v, errors.New("OldStageID requires an ID field in the mutation")
  23308. }
  23309. oldValue, err := m.oldValue(ctx)
  23310. if err != nil {
  23311. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23312. }
  23313. return oldValue.StageID, nil
  23314. }
  23315. // ResetStageID resets all changes to the "stage_id" field.
  23316. func (m *SopNodeMutation) ResetStageID() {
  23317. m.sop_stage = nil
  23318. }
  23319. // SetParentID sets the "parent_id" field.
  23320. func (m *SopNodeMutation) SetParentID(u uint64) {
  23321. m.parent_id = &u
  23322. m.addparent_id = nil
  23323. }
  23324. // ParentID returns the value of the "parent_id" field in the mutation.
  23325. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23326. v := m.parent_id
  23327. if v == nil {
  23328. return
  23329. }
  23330. return *v, true
  23331. }
  23332. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23333. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23335. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23336. if !m.op.Is(OpUpdateOne) {
  23337. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23338. }
  23339. if m.id == nil || m.oldValue == nil {
  23340. return v, errors.New("OldParentID requires an ID field in the mutation")
  23341. }
  23342. oldValue, err := m.oldValue(ctx)
  23343. if err != nil {
  23344. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23345. }
  23346. return oldValue.ParentID, nil
  23347. }
  23348. // AddParentID adds u to the "parent_id" field.
  23349. func (m *SopNodeMutation) AddParentID(u int64) {
  23350. if m.addparent_id != nil {
  23351. *m.addparent_id += u
  23352. } else {
  23353. m.addparent_id = &u
  23354. }
  23355. }
  23356. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23357. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23358. v := m.addparent_id
  23359. if v == nil {
  23360. return
  23361. }
  23362. return *v, true
  23363. }
  23364. // ResetParentID resets all changes to the "parent_id" field.
  23365. func (m *SopNodeMutation) ResetParentID() {
  23366. m.parent_id = nil
  23367. m.addparent_id = nil
  23368. }
  23369. // SetName sets the "name" field.
  23370. func (m *SopNodeMutation) SetName(s string) {
  23371. m.name = &s
  23372. }
  23373. // Name returns the value of the "name" field in the mutation.
  23374. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23375. v := m.name
  23376. if v == nil {
  23377. return
  23378. }
  23379. return *v, true
  23380. }
  23381. // OldName returns the old "name" field's value of the SopNode entity.
  23382. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23384. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23385. if !m.op.Is(OpUpdateOne) {
  23386. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23387. }
  23388. if m.id == nil || m.oldValue == nil {
  23389. return v, errors.New("OldName requires an ID field in the mutation")
  23390. }
  23391. oldValue, err := m.oldValue(ctx)
  23392. if err != nil {
  23393. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23394. }
  23395. return oldValue.Name, nil
  23396. }
  23397. // ResetName resets all changes to the "name" field.
  23398. func (m *SopNodeMutation) ResetName() {
  23399. m.name = nil
  23400. }
  23401. // SetConditionType sets the "condition_type" field.
  23402. func (m *SopNodeMutation) SetConditionType(i int) {
  23403. m.condition_type = &i
  23404. m.addcondition_type = nil
  23405. }
  23406. // ConditionType returns the value of the "condition_type" field in the mutation.
  23407. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23408. v := m.condition_type
  23409. if v == nil {
  23410. return
  23411. }
  23412. return *v, true
  23413. }
  23414. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23415. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23417. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23418. if !m.op.Is(OpUpdateOne) {
  23419. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23420. }
  23421. if m.id == nil || m.oldValue == nil {
  23422. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23423. }
  23424. oldValue, err := m.oldValue(ctx)
  23425. if err != nil {
  23426. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23427. }
  23428. return oldValue.ConditionType, nil
  23429. }
  23430. // AddConditionType adds i to the "condition_type" field.
  23431. func (m *SopNodeMutation) AddConditionType(i int) {
  23432. if m.addcondition_type != nil {
  23433. *m.addcondition_type += i
  23434. } else {
  23435. m.addcondition_type = &i
  23436. }
  23437. }
  23438. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23439. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23440. v := m.addcondition_type
  23441. if v == nil {
  23442. return
  23443. }
  23444. return *v, true
  23445. }
  23446. // ResetConditionType resets all changes to the "condition_type" field.
  23447. func (m *SopNodeMutation) ResetConditionType() {
  23448. m.condition_type = nil
  23449. m.addcondition_type = nil
  23450. }
  23451. // SetConditionList sets the "condition_list" field.
  23452. func (m *SopNodeMutation) SetConditionList(s []string) {
  23453. m.condition_list = &s
  23454. m.appendcondition_list = nil
  23455. }
  23456. // ConditionList returns the value of the "condition_list" field in the mutation.
  23457. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23458. v := m.condition_list
  23459. if v == nil {
  23460. return
  23461. }
  23462. return *v, true
  23463. }
  23464. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23465. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23467. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23468. if !m.op.Is(OpUpdateOne) {
  23469. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23470. }
  23471. if m.id == nil || m.oldValue == nil {
  23472. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23473. }
  23474. oldValue, err := m.oldValue(ctx)
  23475. if err != nil {
  23476. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23477. }
  23478. return oldValue.ConditionList, nil
  23479. }
  23480. // AppendConditionList adds s to the "condition_list" field.
  23481. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23482. m.appendcondition_list = append(m.appendcondition_list, s...)
  23483. }
  23484. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23485. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23486. if len(m.appendcondition_list) == 0 {
  23487. return nil, false
  23488. }
  23489. return m.appendcondition_list, true
  23490. }
  23491. // ClearConditionList clears the value of the "condition_list" field.
  23492. func (m *SopNodeMutation) ClearConditionList() {
  23493. m.condition_list = nil
  23494. m.appendcondition_list = nil
  23495. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23496. }
  23497. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23498. func (m *SopNodeMutation) ConditionListCleared() bool {
  23499. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23500. return ok
  23501. }
  23502. // ResetConditionList resets all changes to the "condition_list" field.
  23503. func (m *SopNodeMutation) ResetConditionList() {
  23504. m.condition_list = nil
  23505. m.appendcondition_list = nil
  23506. delete(m.clearedFields, sopnode.FieldConditionList)
  23507. }
  23508. // SetNoReplyCondition sets the "no_reply_condition" field.
  23509. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23510. m.no_reply_condition = &u
  23511. m.addno_reply_condition = nil
  23512. }
  23513. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23514. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23515. v := m.no_reply_condition
  23516. if v == nil {
  23517. return
  23518. }
  23519. return *v, true
  23520. }
  23521. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23522. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23524. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23525. if !m.op.Is(OpUpdateOne) {
  23526. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23527. }
  23528. if m.id == nil || m.oldValue == nil {
  23529. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23530. }
  23531. oldValue, err := m.oldValue(ctx)
  23532. if err != nil {
  23533. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23534. }
  23535. return oldValue.NoReplyCondition, nil
  23536. }
  23537. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23538. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23539. if m.addno_reply_condition != nil {
  23540. *m.addno_reply_condition += u
  23541. } else {
  23542. m.addno_reply_condition = &u
  23543. }
  23544. }
  23545. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23546. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23547. v := m.addno_reply_condition
  23548. if v == nil {
  23549. return
  23550. }
  23551. return *v, true
  23552. }
  23553. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23554. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23555. m.no_reply_condition = nil
  23556. m.addno_reply_condition = nil
  23557. }
  23558. // SetNoReplyUnit sets the "no_reply_unit" field.
  23559. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23560. m.no_reply_unit = &s
  23561. }
  23562. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23563. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23564. v := m.no_reply_unit
  23565. if v == nil {
  23566. return
  23567. }
  23568. return *v, true
  23569. }
  23570. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  23571. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23573. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23574. if !m.op.Is(OpUpdateOne) {
  23575. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23576. }
  23577. if m.id == nil || m.oldValue == nil {
  23578. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  23579. }
  23580. oldValue, err := m.oldValue(ctx)
  23581. if err != nil {
  23582. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  23583. }
  23584. return oldValue.NoReplyUnit, nil
  23585. }
  23586. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23587. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23588. m.no_reply_unit = nil
  23589. }
  23590. // SetActionMessage sets the "action_message" field.
  23591. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23592. m.action_message = &ct
  23593. m.appendaction_message = nil
  23594. }
  23595. // ActionMessage returns the value of the "action_message" field in the mutation.
  23596. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23597. v := m.action_message
  23598. if v == nil {
  23599. return
  23600. }
  23601. return *v, true
  23602. }
  23603. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23604. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23606. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23607. if !m.op.Is(OpUpdateOne) {
  23608. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23609. }
  23610. if m.id == nil || m.oldValue == nil {
  23611. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23612. }
  23613. oldValue, err := m.oldValue(ctx)
  23614. if err != nil {
  23615. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23616. }
  23617. return oldValue.ActionMessage, nil
  23618. }
  23619. // AppendActionMessage adds ct to the "action_message" field.
  23620. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23621. m.appendaction_message = append(m.appendaction_message, ct...)
  23622. }
  23623. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23624. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23625. if len(m.appendaction_message) == 0 {
  23626. return nil, false
  23627. }
  23628. return m.appendaction_message, true
  23629. }
  23630. // ClearActionMessage clears the value of the "action_message" field.
  23631. func (m *SopNodeMutation) ClearActionMessage() {
  23632. m.action_message = nil
  23633. m.appendaction_message = nil
  23634. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23635. }
  23636. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23637. func (m *SopNodeMutation) ActionMessageCleared() bool {
  23638. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  23639. return ok
  23640. }
  23641. // ResetActionMessage resets all changes to the "action_message" field.
  23642. func (m *SopNodeMutation) ResetActionMessage() {
  23643. m.action_message = nil
  23644. m.appendaction_message = nil
  23645. delete(m.clearedFields, sopnode.FieldActionMessage)
  23646. }
  23647. // SetActionLabelAdd sets the "action_label_add" field.
  23648. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  23649. m.action_label_add = &u
  23650. m.appendaction_label_add = nil
  23651. }
  23652. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23653. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23654. v := m.action_label_add
  23655. if v == nil {
  23656. return
  23657. }
  23658. return *v, true
  23659. }
  23660. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  23661. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23663. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23664. if !m.op.Is(OpUpdateOne) {
  23665. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23666. }
  23667. if m.id == nil || m.oldValue == nil {
  23668. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23669. }
  23670. oldValue, err := m.oldValue(ctx)
  23671. if err != nil {
  23672. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23673. }
  23674. return oldValue.ActionLabelAdd, nil
  23675. }
  23676. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23677. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  23678. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23679. }
  23680. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23681. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23682. if len(m.appendaction_label_add) == 0 {
  23683. return nil, false
  23684. }
  23685. return m.appendaction_label_add, true
  23686. }
  23687. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23688. func (m *SopNodeMutation) ClearActionLabelAdd() {
  23689. m.action_label_add = nil
  23690. m.appendaction_label_add = nil
  23691. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  23692. }
  23693. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23694. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  23695. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  23696. return ok
  23697. }
  23698. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23699. func (m *SopNodeMutation) ResetActionLabelAdd() {
  23700. m.action_label_add = nil
  23701. m.appendaction_label_add = nil
  23702. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  23703. }
  23704. // SetActionLabelDel sets the "action_label_del" field.
  23705. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  23706. m.action_label_del = &u
  23707. m.appendaction_label_del = nil
  23708. }
  23709. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23710. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  23711. v := m.action_label_del
  23712. if v == nil {
  23713. return
  23714. }
  23715. return *v, true
  23716. }
  23717. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  23718. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23720. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23721. if !m.op.Is(OpUpdateOne) {
  23722. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23723. }
  23724. if m.id == nil || m.oldValue == nil {
  23725. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23726. }
  23727. oldValue, err := m.oldValue(ctx)
  23728. if err != nil {
  23729. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23730. }
  23731. return oldValue.ActionLabelDel, nil
  23732. }
  23733. // AppendActionLabelDel adds u to the "action_label_del" field.
  23734. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  23735. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23736. }
  23737. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23738. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23739. if len(m.appendaction_label_del) == 0 {
  23740. return nil, false
  23741. }
  23742. return m.appendaction_label_del, true
  23743. }
  23744. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23745. func (m *SopNodeMutation) ClearActionLabelDel() {
  23746. m.action_label_del = nil
  23747. m.appendaction_label_del = nil
  23748. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  23749. }
  23750. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23751. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  23752. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  23753. return ok
  23754. }
  23755. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23756. func (m *SopNodeMutation) ResetActionLabelDel() {
  23757. m.action_label_del = nil
  23758. m.appendaction_label_del = nil
  23759. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  23760. }
  23761. // SetActionForward sets the "action_forward" field.
  23762. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23763. m.action_forward = &ctf
  23764. }
  23765. // ActionForward returns the value of the "action_forward" field in the mutation.
  23766. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23767. v := m.action_forward
  23768. if v == nil {
  23769. return
  23770. }
  23771. return *v, true
  23772. }
  23773. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  23774. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23776. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23777. if !m.op.Is(OpUpdateOne) {
  23778. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23779. }
  23780. if m.id == nil || m.oldValue == nil {
  23781. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23782. }
  23783. oldValue, err := m.oldValue(ctx)
  23784. if err != nil {
  23785. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23786. }
  23787. return oldValue.ActionForward, nil
  23788. }
  23789. // ClearActionForward clears the value of the "action_forward" field.
  23790. func (m *SopNodeMutation) ClearActionForward() {
  23791. m.action_forward = nil
  23792. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  23793. }
  23794. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23795. func (m *SopNodeMutation) ActionForwardCleared() bool {
  23796. _, ok := m.clearedFields[sopnode.FieldActionForward]
  23797. return ok
  23798. }
  23799. // ResetActionForward resets all changes to the "action_forward" field.
  23800. func (m *SopNodeMutation) ResetActionForward() {
  23801. m.action_forward = nil
  23802. delete(m.clearedFields, sopnode.FieldActionForward)
  23803. }
  23804. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23805. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  23806. m.sop_stage = &id
  23807. }
  23808. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23809. func (m *SopNodeMutation) ClearSopStage() {
  23810. m.clearedsop_stage = true
  23811. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  23812. }
  23813. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23814. func (m *SopNodeMutation) SopStageCleared() bool {
  23815. return m.clearedsop_stage
  23816. }
  23817. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23818. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  23819. if m.sop_stage != nil {
  23820. return *m.sop_stage, true
  23821. }
  23822. return
  23823. }
  23824. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23825. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23826. // SopStageID instead. It exists only for internal usage by the builders.
  23827. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  23828. if id := m.sop_stage; id != nil {
  23829. ids = append(ids, *id)
  23830. }
  23831. return
  23832. }
  23833. // ResetSopStage resets all changes to the "sop_stage" edge.
  23834. func (m *SopNodeMutation) ResetSopStage() {
  23835. m.sop_stage = nil
  23836. m.clearedsop_stage = false
  23837. }
  23838. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  23839. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  23840. if m.node_messages == nil {
  23841. m.node_messages = make(map[uint64]struct{})
  23842. }
  23843. for i := range ids {
  23844. m.node_messages[ids[i]] = struct{}{}
  23845. }
  23846. }
  23847. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  23848. func (m *SopNodeMutation) ClearNodeMessages() {
  23849. m.clearednode_messages = true
  23850. }
  23851. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  23852. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  23853. return m.clearednode_messages
  23854. }
  23855. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  23856. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  23857. if m.removednode_messages == nil {
  23858. m.removednode_messages = make(map[uint64]struct{})
  23859. }
  23860. for i := range ids {
  23861. delete(m.node_messages, ids[i])
  23862. m.removednode_messages[ids[i]] = struct{}{}
  23863. }
  23864. }
  23865. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  23866. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  23867. for id := range m.removednode_messages {
  23868. ids = append(ids, id)
  23869. }
  23870. return
  23871. }
  23872. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  23873. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  23874. for id := range m.node_messages {
  23875. ids = append(ids, id)
  23876. }
  23877. return
  23878. }
  23879. // ResetNodeMessages resets all changes to the "node_messages" edge.
  23880. func (m *SopNodeMutation) ResetNodeMessages() {
  23881. m.node_messages = nil
  23882. m.clearednode_messages = false
  23883. m.removednode_messages = nil
  23884. }
  23885. // Where appends a list predicates to the SopNodeMutation builder.
  23886. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  23887. m.predicates = append(m.predicates, ps...)
  23888. }
  23889. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  23890. // users can use type-assertion to append predicates that do not depend on any generated package.
  23891. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  23892. p := make([]predicate.SopNode, len(ps))
  23893. for i := range ps {
  23894. p[i] = ps[i]
  23895. }
  23896. m.Where(p...)
  23897. }
  23898. // Op returns the operation name.
  23899. func (m *SopNodeMutation) Op() Op {
  23900. return m.op
  23901. }
  23902. // SetOp allows setting the mutation operation.
  23903. func (m *SopNodeMutation) SetOp(op Op) {
  23904. m.op = op
  23905. }
  23906. // Type returns the node type of this mutation (SopNode).
  23907. func (m *SopNodeMutation) Type() string {
  23908. return m.typ
  23909. }
  23910. // Fields returns all fields that were changed during this mutation. Note that in
  23911. // order to get all numeric fields that were incremented/decremented, call
  23912. // AddedFields().
  23913. func (m *SopNodeMutation) Fields() []string {
  23914. fields := make([]string, 0, 15)
  23915. if m.created_at != nil {
  23916. fields = append(fields, sopnode.FieldCreatedAt)
  23917. }
  23918. if m.updated_at != nil {
  23919. fields = append(fields, sopnode.FieldUpdatedAt)
  23920. }
  23921. if m.status != nil {
  23922. fields = append(fields, sopnode.FieldStatus)
  23923. }
  23924. if m.deleted_at != nil {
  23925. fields = append(fields, sopnode.FieldDeletedAt)
  23926. }
  23927. if m.sop_stage != nil {
  23928. fields = append(fields, sopnode.FieldStageID)
  23929. }
  23930. if m.parent_id != nil {
  23931. fields = append(fields, sopnode.FieldParentID)
  23932. }
  23933. if m.name != nil {
  23934. fields = append(fields, sopnode.FieldName)
  23935. }
  23936. if m.condition_type != nil {
  23937. fields = append(fields, sopnode.FieldConditionType)
  23938. }
  23939. if m.condition_list != nil {
  23940. fields = append(fields, sopnode.FieldConditionList)
  23941. }
  23942. if m.no_reply_condition != nil {
  23943. fields = append(fields, sopnode.FieldNoReplyCondition)
  23944. }
  23945. if m.no_reply_unit != nil {
  23946. fields = append(fields, sopnode.FieldNoReplyUnit)
  23947. }
  23948. if m.action_message != nil {
  23949. fields = append(fields, sopnode.FieldActionMessage)
  23950. }
  23951. if m.action_label_add != nil {
  23952. fields = append(fields, sopnode.FieldActionLabelAdd)
  23953. }
  23954. if m.action_label_del != nil {
  23955. fields = append(fields, sopnode.FieldActionLabelDel)
  23956. }
  23957. if m.action_forward != nil {
  23958. fields = append(fields, sopnode.FieldActionForward)
  23959. }
  23960. return fields
  23961. }
  23962. // Field returns the value of a field with the given name. The second boolean
  23963. // return value indicates that this field was not set, or was not defined in the
  23964. // schema.
  23965. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  23966. switch name {
  23967. case sopnode.FieldCreatedAt:
  23968. return m.CreatedAt()
  23969. case sopnode.FieldUpdatedAt:
  23970. return m.UpdatedAt()
  23971. case sopnode.FieldStatus:
  23972. return m.Status()
  23973. case sopnode.FieldDeletedAt:
  23974. return m.DeletedAt()
  23975. case sopnode.FieldStageID:
  23976. return m.StageID()
  23977. case sopnode.FieldParentID:
  23978. return m.ParentID()
  23979. case sopnode.FieldName:
  23980. return m.Name()
  23981. case sopnode.FieldConditionType:
  23982. return m.ConditionType()
  23983. case sopnode.FieldConditionList:
  23984. return m.ConditionList()
  23985. case sopnode.FieldNoReplyCondition:
  23986. return m.NoReplyCondition()
  23987. case sopnode.FieldNoReplyUnit:
  23988. return m.NoReplyUnit()
  23989. case sopnode.FieldActionMessage:
  23990. return m.ActionMessage()
  23991. case sopnode.FieldActionLabelAdd:
  23992. return m.ActionLabelAdd()
  23993. case sopnode.FieldActionLabelDel:
  23994. return m.ActionLabelDel()
  23995. case sopnode.FieldActionForward:
  23996. return m.ActionForward()
  23997. }
  23998. return nil, false
  23999. }
  24000. // OldField returns the old value of the field from the database. An error is
  24001. // returned if the mutation operation is not UpdateOne, or the query to the
  24002. // database failed.
  24003. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24004. switch name {
  24005. case sopnode.FieldCreatedAt:
  24006. return m.OldCreatedAt(ctx)
  24007. case sopnode.FieldUpdatedAt:
  24008. return m.OldUpdatedAt(ctx)
  24009. case sopnode.FieldStatus:
  24010. return m.OldStatus(ctx)
  24011. case sopnode.FieldDeletedAt:
  24012. return m.OldDeletedAt(ctx)
  24013. case sopnode.FieldStageID:
  24014. return m.OldStageID(ctx)
  24015. case sopnode.FieldParentID:
  24016. return m.OldParentID(ctx)
  24017. case sopnode.FieldName:
  24018. return m.OldName(ctx)
  24019. case sopnode.FieldConditionType:
  24020. return m.OldConditionType(ctx)
  24021. case sopnode.FieldConditionList:
  24022. return m.OldConditionList(ctx)
  24023. case sopnode.FieldNoReplyCondition:
  24024. return m.OldNoReplyCondition(ctx)
  24025. case sopnode.FieldNoReplyUnit:
  24026. return m.OldNoReplyUnit(ctx)
  24027. case sopnode.FieldActionMessage:
  24028. return m.OldActionMessage(ctx)
  24029. case sopnode.FieldActionLabelAdd:
  24030. return m.OldActionLabelAdd(ctx)
  24031. case sopnode.FieldActionLabelDel:
  24032. return m.OldActionLabelDel(ctx)
  24033. case sopnode.FieldActionForward:
  24034. return m.OldActionForward(ctx)
  24035. }
  24036. return nil, fmt.Errorf("unknown SopNode field %s", name)
  24037. }
  24038. // SetField sets the value of a field with the given name. It returns an error if
  24039. // the field is not defined in the schema, or if the type mismatched the field
  24040. // type.
  24041. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  24042. switch name {
  24043. case sopnode.FieldCreatedAt:
  24044. v, ok := value.(time.Time)
  24045. if !ok {
  24046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24047. }
  24048. m.SetCreatedAt(v)
  24049. return nil
  24050. case sopnode.FieldUpdatedAt:
  24051. v, ok := value.(time.Time)
  24052. if !ok {
  24053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24054. }
  24055. m.SetUpdatedAt(v)
  24056. return nil
  24057. case sopnode.FieldStatus:
  24058. v, ok := value.(uint8)
  24059. if !ok {
  24060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24061. }
  24062. m.SetStatus(v)
  24063. return nil
  24064. case sopnode.FieldDeletedAt:
  24065. v, ok := value.(time.Time)
  24066. if !ok {
  24067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24068. }
  24069. m.SetDeletedAt(v)
  24070. return nil
  24071. case sopnode.FieldStageID:
  24072. v, ok := value.(uint64)
  24073. if !ok {
  24074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24075. }
  24076. m.SetStageID(v)
  24077. return nil
  24078. case sopnode.FieldParentID:
  24079. v, ok := value.(uint64)
  24080. if !ok {
  24081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24082. }
  24083. m.SetParentID(v)
  24084. return nil
  24085. case sopnode.FieldName:
  24086. v, ok := value.(string)
  24087. if !ok {
  24088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24089. }
  24090. m.SetName(v)
  24091. return nil
  24092. case sopnode.FieldConditionType:
  24093. v, ok := value.(int)
  24094. if !ok {
  24095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24096. }
  24097. m.SetConditionType(v)
  24098. return nil
  24099. case sopnode.FieldConditionList:
  24100. v, ok := value.([]string)
  24101. if !ok {
  24102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24103. }
  24104. m.SetConditionList(v)
  24105. return nil
  24106. case sopnode.FieldNoReplyCondition:
  24107. v, ok := value.(uint64)
  24108. if !ok {
  24109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24110. }
  24111. m.SetNoReplyCondition(v)
  24112. return nil
  24113. case sopnode.FieldNoReplyUnit:
  24114. v, ok := value.(string)
  24115. if !ok {
  24116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24117. }
  24118. m.SetNoReplyUnit(v)
  24119. return nil
  24120. case sopnode.FieldActionMessage:
  24121. v, ok := value.([]custom_types.Action)
  24122. if !ok {
  24123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24124. }
  24125. m.SetActionMessage(v)
  24126. return nil
  24127. case sopnode.FieldActionLabelAdd:
  24128. v, ok := value.([]uint64)
  24129. if !ok {
  24130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24131. }
  24132. m.SetActionLabelAdd(v)
  24133. return nil
  24134. case sopnode.FieldActionLabelDel:
  24135. v, ok := value.([]uint64)
  24136. if !ok {
  24137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24138. }
  24139. m.SetActionLabelDel(v)
  24140. return nil
  24141. case sopnode.FieldActionForward:
  24142. v, ok := value.(*custom_types.ActionForward)
  24143. if !ok {
  24144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24145. }
  24146. m.SetActionForward(v)
  24147. return nil
  24148. }
  24149. return fmt.Errorf("unknown SopNode field %s", name)
  24150. }
  24151. // AddedFields returns all numeric fields that were incremented/decremented during
  24152. // this mutation.
  24153. func (m *SopNodeMutation) AddedFields() []string {
  24154. var fields []string
  24155. if m.addstatus != nil {
  24156. fields = append(fields, sopnode.FieldStatus)
  24157. }
  24158. if m.addparent_id != nil {
  24159. fields = append(fields, sopnode.FieldParentID)
  24160. }
  24161. if m.addcondition_type != nil {
  24162. fields = append(fields, sopnode.FieldConditionType)
  24163. }
  24164. if m.addno_reply_condition != nil {
  24165. fields = append(fields, sopnode.FieldNoReplyCondition)
  24166. }
  24167. return fields
  24168. }
  24169. // AddedField returns the numeric value that was incremented/decremented on a field
  24170. // with the given name. The second boolean return value indicates that this field
  24171. // was not set, or was not defined in the schema.
  24172. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24173. switch name {
  24174. case sopnode.FieldStatus:
  24175. return m.AddedStatus()
  24176. case sopnode.FieldParentID:
  24177. return m.AddedParentID()
  24178. case sopnode.FieldConditionType:
  24179. return m.AddedConditionType()
  24180. case sopnode.FieldNoReplyCondition:
  24181. return m.AddedNoReplyCondition()
  24182. }
  24183. return nil, false
  24184. }
  24185. // AddField adds the value to the field with the given name. It returns an error if
  24186. // the field is not defined in the schema, or if the type mismatched the field
  24187. // type.
  24188. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24189. switch name {
  24190. case sopnode.FieldStatus:
  24191. v, ok := value.(int8)
  24192. if !ok {
  24193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24194. }
  24195. m.AddStatus(v)
  24196. return nil
  24197. case sopnode.FieldParentID:
  24198. v, ok := value.(int64)
  24199. if !ok {
  24200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24201. }
  24202. m.AddParentID(v)
  24203. return nil
  24204. case sopnode.FieldConditionType:
  24205. v, ok := value.(int)
  24206. if !ok {
  24207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24208. }
  24209. m.AddConditionType(v)
  24210. return nil
  24211. case sopnode.FieldNoReplyCondition:
  24212. v, ok := value.(int64)
  24213. if !ok {
  24214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24215. }
  24216. m.AddNoReplyCondition(v)
  24217. return nil
  24218. }
  24219. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24220. }
  24221. // ClearedFields returns all nullable fields that were cleared during this
  24222. // mutation.
  24223. func (m *SopNodeMutation) ClearedFields() []string {
  24224. var fields []string
  24225. if m.FieldCleared(sopnode.FieldStatus) {
  24226. fields = append(fields, sopnode.FieldStatus)
  24227. }
  24228. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24229. fields = append(fields, sopnode.FieldDeletedAt)
  24230. }
  24231. if m.FieldCleared(sopnode.FieldConditionList) {
  24232. fields = append(fields, sopnode.FieldConditionList)
  24233. }
  24234. if m.FieldCleared(sopnode.FieldActionMessage) {
  24235. fields = append(fields, sopnode.FieldActionMessage)
  24236. }
  24237. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24238. fields = append(fields, sopnode.FieldActionLabelAdd)
  24239. }
  24240. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24241. fields = append(fields, sopnode.FieldActionLabelDel)
  24242. }
  24243. if m.FieldCleared(sopnode.FieldActionForward) {
  24244. fields = append(fields, sopnode.FieldActionForward)
  24245. }
  24246. return fields
  24247. }
  24248. // FieldCleared returns a boolean indicating if a field with the given name was
  24249. // cleared in this mutation.
  24250. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24251. _, ok := m.clearedFields[name]
  24252. return ok
  24253. }
  24254. // ClearField clears the value of the field with the given name. It returns an
  24255. // error if the field is not defined in the schema.
  24256. func (m *SopNodeMutation) ClearField(name string) error {
  24257. switch name {
  24258. case sopnode.FieldStatus:
  24259. m.ClearStatus()
  24260. return nil
  24261. case sopnode.FieldDeletedAt:
  24262. m.ClearDeletedAt()
  24263. return nil
  24264. case sopnode.FieldConditionList:
  24265. m.ClearConditionList()
  24266. return nil
  24267. case sopnode.FieldActionMessage:
  24268. m.ClearActionMessage()
  24269. return nil
  24270. case sopnode.FieldActionLabelAdd:
  24271. m.ClearActionLabelAdd()
  24272. return nil
  24273. case sopnode.FieldActionLabelDel:
  24274. m.ClearActionLabelDel()
  24275. return nil
  24276. case sopnode.FieldActionForward:
  24277. m.ClearActionForward()
  24278. return nil
  24279. }
  24280. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24281. }
  24282. // ResetField resets all changes in the mutation for the field with the given name.
  24283. // It returns an error if the field is not defined in the schema.
  24284. func (m *SopNodeMutation) ResetField(name string) error {
  24285. switch name {
  24286. case sopnode.FieldCreatedAt:
  24287. m.ResetCreatedAt()
  24288. return nil
  24289. case sopnode.FieldUpdatedAt:
  24290. m.ResetUpdatedAt()
  24291. return nil
  24292. case sopnode.FieldStatus:
  24293. m.ResetStatus()
  24294. return nil
  24295. case sopnode.FieldDeletedAt:
  24296. m.ResetDeletedAt()
  24297. return nil
  24298. case sopnode.FieldStageID:
  24299. m.ResetStageID()
  24300. return nil
  24301. case sopnode.FieldParentID:
  24302. m.ResetParentID()
  24303. return nil
  24304. case sopnode.FieldName:
  24305. m.ResetName()
  24306. return nil
  24307. case sopnode.FieldConditionType:
  24308. m.ResetConditionType()
  24309. return nil
  24310. case sopnode.FieldConditionList:
  24311. m.ResetConditionList()
  24312. return nil
  24313. case sopnode.FieldNoReplyCondition:
  24314. m.ResetNoReplyCondition()
  24315. return nil
  24316. case sopnode.FieldNoReplyUnit:
  24317. m.ResetNoReplyUnit()
  24318. return nil
  24319. case sopnode.FieldActionMessage:
  24320. m.ResetActionMessage()
  24321. return nil
  24322. case sopnode.FieldActionLabelAdd:
  24323. m.ResetActionLabelAdd()
  24324. return nil
  24325. case sopnode.FieldActionLabelDel:
  24326. m.ResetActionLabelDel()
  24327. return nil
  24328. case sopnode.FieldActionForward:
  24329. m.ResetActionForward()
  24330. return nil
  24331. }
  24332. return fmt.Errorf("unknown SopNode field %s", name)
  24333. }
  24334. // AddedEdges returns all edge names that were set/added in this mutation.
  24335. func (m *SopNodeMutation) AddedEdges() []string {
  24336. edges := make([]string, 0, 2)
  24337. if m.sop_stage != nil {
  24338. edges = append(edges, sopnode.EdgeSopStage)
  24339. }
  24340. if m.node_messages != nil {
  24341. edges = append(edges, sopnode.EdgeNodeMessages)
  24342. }
  24343. return edges
  24344. }
  24345. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24346. // name in this mutation.
  24347. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24348. switch name {
  24349. case sopnode.EdgeSopStage:
  24350. if id := m.sop_stage; id != nil {
  24351. return []ent.Value{*id}
  24352. }
  24353. case sopnode.EdgeNodeMessages:
  24354. ids := make([]ent.Value, 0, len(m.node_messages))
  24355. for id := range m.node_messages {
  24356. ids = append(ids, id)
  24357. }
  24358. return ids
  24359. }
  24360. return nil
  24361. }
  24362. // RemovedEdges returns all edge names that were removed in this mutation.
  24363. func (m *SopNodeMutation) RemovedEdges() []string {
  24364. edges := make([]string, 0, 2)
  24365. if m.removednode_messages != nil {
  24366. edges = append(edges, sopnode.EdgeNodeMessages)
  24367. }
  24368. return edges
  24369. }
  24370. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24371. // the given name in this mutation.
  24372. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24373. switch name {
  24374. case sopnode.EdgeNodeMessages:
  24375. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24376. for id := range m.removednode_messages {
  24377. ids = append(ids, id)
  24378. }
  24379. return ids
  24380. }
  24381. return nil
  24382. }
  24383. // ClearedEdges returns all edge names that were cleared in this mutation.
  24384. func (m *SopNodeMutation) ClearedEdges() []string {
  24385. edges := make([]string, 0, 2)
  24386. if m.clearedsop_stage {
  24387. edges = append(edges, sopnode.EdgeSopStage)
  24388. }
  24389. if m.clearednode_messages {
  24390. edges = append(edges, sopnode.EdgeNodeMessages)
  24391. }
  24392. return edges
  24393. }
  24394. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24395. // was cleared in this mutation.
  24396. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24397. switch name {
  24398. case sopnode.EdgeSopStage:
  24399. return m.clearedsop_stage
  24400. case sopnode.EdgeNodeMessages:
  24401. return m.clearednode_messages
  24402. }
  24403. return false
  24404. }
  24405. // ClearEdge clears the value of the edge with the given name. It returns an error
  24406. // if that edge is not defined in the schema.
  24407. func (m *SopNodeMutation) ClearEdge(name string) error {
  24408. switch name {
  24409. case sopnode.EdgeSopStage:
  24410. m.ClearSopStage()
  24411. return nil
  24412. }
  24413. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24414. }
  24415. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24416. // It returns an error if the edge is not defined in the schema.
  24417. func (m *SopNodeMutation) ResetEdge(name string) error {
  24418. switch name {
  24419. case sopnode.EdgeSopStage:
  24420. m.ResetSopStage()
  24421. return nil
  24422. case sopnode.EdgeNodeMessages:
  24423. m.ResetNodeMessages()
  24424. return nil
  24425. }
  24426. return fmt.Errorf("unknown SopNode edge %s", name)
  24427. }
  24428. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24429. type SopStageMutation struct {
  24430. config
  24431. op Op
  24432. typ string
  24433. id *uint64
  24434. created_at *time.Time
  24435. updated_at *time.Time
  24436. status *uint8
  24437. addstatus *int8
  24438. deleted_at *time.Time
  24439. name *string
  24440. condition_type *int
  24441. addcondition_type *int
  24442. condition_operator *int
  24443. addcondition_operator *int
  24444. condition_list *[]custom_types.Condition
  24445. appendcondition_list []custom_types.Condition
  24446. action_message *[]custom_types.Action
  24447. appendaction_message []custom_types.Action
  24448. action_label_add *[]uint64
  24449. appendaction_label_add []uint64
  24450. action_label_del *[]uint64
  24451. appendaction_label_del []uint64
  24452. action_forward **custom_types.ActionForward
  24453. index_sort *int
  24454. addindex_sort *int
  24455. clearedFields map[string]struct{}
  24456. sop_task *uint64
  24457. clearedsop_task bool
  24458. stage_nodes map[uint64]struct{}
  24459. removedstage_nodes map[uint64]struct{}
  24460. clearedstage_nodes bool
  24461. stage_messages map[uint64]struct{}
  24462. removedstage_messages map[uint64]struct{}
  24463. clearedstage_messages bool
  24464. done bool
  24465. oldValue func(context.Context) (*SopStage, error)
  24466. predicates []predicate.SopStage
  24467. }
  24468. var _ ent.Mutation = (*SopStageMutation)(nil)
  24469. // sopstageOption allows management of the mutation configuration using functional options.
  24470. type sopstageOption func(*SopStageMutation)
  24471. // newSopStageMutation creates new mutation for the SopStage entity.
  24472. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24473. m := &SopStageMutation{
  24474. config: c,
  24475. op: op,
  24476. typ: TypeSopStage,
  24477. clearedFields: make(map[string]struct{}),
  24478. }
  24479. for _, opt := range opts {
  24480. opt(m)
  24481. }
  24482. return m
  24483. }
  24484. // withSopStageID sets the ID field of the mutation.
  24485. func withSopStageID(id uint64) sopstageOption {
  24486. return func(m *SopStageMutation) {
  24487. var (
  24488. err error
  24489. once sync.Once
  24490. value *SopStage
  24491. )
  24492. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24493. once.Do(func() {
  24494. if m.done {
  24495. err = errors.New("querying old values post mutation is not allowed")
  24496. } else {
  24497. value, err = m.Client().SopStage.Get(ctx, id)
  24498. }
  24499. })
  24500. return value, err
  24501. }
  24502. m.id = &id
  24503. }
  24504. }
  24505. // withSopStage sets the old SopStage of the mutation.
  24506. func withSopStage(node *SopStage) sopstageOption {
  24507. return func(m *SopStageMutation) {
  24508. m.oldValue = func(context.Context) (*SopStage, error) {
  24509. return node, nil
  24510. }
  24511. m.id = &node.ID
  24512. }
  24513. }
  24514. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24515. // executed in a transaction (ent.Tx), a transactional client is returned.
  24516. func (m SopStageMutation) Client() *Client {
  24517. client := &Client{config: m.config}
  24518. client.init()
  24519. return client
  24520. }
  24521. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24522. // it returns an error otherwise.
  24523. func (m SopStageMutation) Tx() (*Tx, error) {
  24524. if _, ok := m.driver.(*txDriver); !ok {
  24525. return nil, errors.New("ent: mutation is not running in a transaction")
  24526. }
  24527. tx := &Tx{config: m.config}
  24528. tx.init()
  24529. return tx, nil
  24530. }
  24531. // SetID sets the value of the id field. Note that this
  24532. // operation is only accepted on creation of SopStage entities.
  24533. func (m *SopStageMutation) SetID(id uint64) {
  24534. m.id = &id
  24535. }
  24536. // ID returns the ID value in the mutation. Note that the ID is only available
  24537. // if it was provided to the builder or after it was returned from the database.
  24538. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24539. if m.id == nil {
  24540. return
  24541. }
  24542. return *m.id, true
  24543. }
  24544. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24545. // That means, if the mutation is applied within a transaction with an isolation level such
  24546. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24547. // or updated by the mutation.
  24548. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24549. switch {
  24550. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24551. id, exists := m.ID()
  24552. if exists {
  24553. return []uint64{id}, nil
  24554. }
  24555. fallthrough
  24556. case m.op.Is(OpUpdate | OpDelete):
  24557. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24558. default:
  24559. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24560. }
  24561. }
  24562. // SetCreatedAt sets the "created_at" field.
  24563. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24564. m.created_at = &t
  24565. }
  24566. // CreatedAt returns the value of the "created_at" field in the mutation.
  24567. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24568. v := m.created_at
  24569. if v == nil {
  24570. return
  24571. }
  24572. return *v, true
  24573. }
  24574. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24575. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24577. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24578. if !m.op.Is(OpUpdateOne) {
  24579. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24580. }
  24581. if m.id == nil || m.oldValue == nil {
  24582. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24583. }
  24584. oldValue, err := m.oldValue(ctx)
  24585. if err != nil {
  24586. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24587. }
  24588. return oldValue.CreatedAt, nil
  24589. }
  24590. // ResetCreatedAt resets all changes to the "created_at" field.
  24591. func (m *SopStageMutation) ResetCreatedAt() {
  24592. m.created_at = nil
  24593. }
  24594. // SetUpdatedAt sets the "updated_at" field.
  24595. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24596. m.updated_at = &t
  24597. }
  24598. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24599. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24600. v := m.updated_at
  24601. if v == nil {
  24602. return
  24603. }
  24604. return *v, true
  24605. }
  24606. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24607. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24609. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24610. if !m.op.Is(OpUpdateOne) {
  24611. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24612. }
  24613. if m.id == nil || m.oldValue == nil {
  24614. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24615. }
  24616. oldValue, err := m.oldValue(ctx)
  24617. if err != nil {
  24618. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24619. }
  24620. return oldValue.UpdatedAt, nil
  24621. }
  24622. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24623. func (m *SopStageMutation) ResetUpdatedAt() {
  24624. m.updated_at = nil
  24625. }
  24626. // SetStatus sets the "status" field.
  24627. func (m *SopStageMutation) SetStatus(u uint8) {
  24628. m.status = &u
  24629. m.addstatus = nil
  24630. }
  24631. // Status returns the value of the "status" field in the mutation.
  24632. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24633. v := m.status
  24634. if v == nil {
  24635. return
  24636. }
  24637. return *v, true
  24638. }
  24639. // OldStatus returns the old "status" field's value of the SopStage entity.
  24640. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24642. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24643. if !m.op.Is(OpUpdateOne) {
  24644. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24645. }
  24646. if m.id == nil || m.oldValue == nil {
  24647. return v, errors.New("OldStatus requires an ID field in the mutation")
  24648. }
  24649. oldValue, err := m.oldValue(ctx)
  24650. if err != nil {
  24651. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24652. }
  24653. return oldValue.Status, nil
  24654. }
  24655. // AddStatus adds u to the "status" field.
  24656. func (m *SopStageMutation) AddStatus(u int8) {
  24657. if m.addstatus != nil {
  24658. *m.addstatus += u
  24659. } else {
  24660. m.addstatus = &u
  24661. }
  24662. }
  24663. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24664. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  24665. v := m.addstatus
  24666. if v == nil {
  24667. return
  24668. }
  24669. return *v, true
  24670. }
  24671. // ClearStatus clears the value of the "status" field.
  24672. func (m *SopStageMutation) ClearStatus() {
  24673. m.status = nil
  24674. m.addstatus = nil
  24675. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  24676. }
  24677. // StatusCleared returns if the "status" field was cleared in this mutation.
  24678. func (m *SopStageMutation) StatusCleared() bool {
  24679. _, ok := m.clearedFields[sopstage.FieldStatus]
  24680. return ok
  24681. }
  24682. // ResetStatus resets all changes to the "status" field.
  24683. func (m *SopStageMutation) ResetStatus() {
  24684. m.status = nil
  24685. m.addstatus = nil
  24686. delete(m.clearedFields, sopstage.FieldStatus)
  24687. }
  24688. // SetDeletedAt sets the "deleted_at" field.
  24689. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  24690. m.deleted_at = &t
  24691. }
  24692. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24693. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  24694. v := m.deleted_at
  24695. if v == nil {
  24696. return
  24697. }
  24698. return *v, true
  24699. }
  24700. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  24701. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24703. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24704. if !m.op.Is(OpUpdateOne) {
  24705. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24706. }
  24707. if m.id == nil || m.oldValue == nil {
  24708. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24709. }
  24710. oldValue, err := m.oldValue(ctx)
  24711. if err != nil {
  24712. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24713. }
  24714. return oldValue.DeletedAt, nil
  24715. }
  24716. // ClearDeletedAt clears the value of the "deleted_at" field.
  24717. func (m *SopStageMutation) ClearDeletedAt() {
  24718. m.deleted_at = nil
  24719. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  24720. }
  24721. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24722. func (m *SopStageMutation) DeletedAtCleared() bool {
  24723. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  24724. return ok
  24725. }
  24726. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24727. func (m *SopStageMutation) ResetDeletedAt() {
  24728. m.deleted_at = nil
  24729. delete(m.clearedFields, sopstage.FieldDeletedAt)
  24730. }
  24731. // SetTaskID sets the "task_id" field.
  24732. func (m *SopStageMutation) SetTaskID(u uint64) {
  24733. m.sop_task = &u
  24734. }
  24735. // TaskID returns the value of the "task_id" field in the mutation.
  24736. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  24737. v := m.sop_task
  24738. if v == nil {
  24739. return
  24740. }
  24741. return *v, true
  24742. }
  24743. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  24744. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24746. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  24747. if !m.op.Is(OpUpdateOne) {
  24748. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  24749. }
  24750. if m.id == nil || m.oldValue == nil {
  24751. return v, errors.New("OldTaskID requires an ID field in the mutation")
  24752. }
  24753. oldValue, err := m.oldValue(ctx)
  24754. if err != nil {
  24755. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  24756. }
  24757. return oldValue.TaskID, nil
  24758. }
  24759. // ResetTaskID resets all changes to the "task_id" field.
  24760. func (m *SopStageMutation) ResetTaskID() {
  24761. m.sop_task = nil
  24762. }
  24763. // SetName sets the "name" field.
  24764. func (m *SopStageMutation) SetName(s string) {
  24765. m.name = &s
  24766. }
  24767. // Name returns the value of the "name" field in the mutation.
  24768. func (m *SopStageMutation) Name() (r string, exists bool) {
  24769. v := m.name
  24770. if v == nil {
  24771. return
  24772. }
  24773. return *v, true
  24774. }
  24775. // OldName returns the old "name" field's value of the SopStage entity.
  24776. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24778. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  24779. if !m.op.Is(OpUpdateOne) {
  24780. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24781. }
  24782. if m.id == nil || m.oldValue == nil {
  24783. return v, errors.New("OldName requires an ID field in the mutation")
  24784. }
  24785. oldValue, err := m.oldValue(ctx)
  24786. if err != nil {
  24787. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24788. }
  24789. return oldValue.Name, nil
  24790. }
  24791. // ResetName resets all changes to the "name" field.
  24792. func (m *SopStageMutation) ResetName() {
  24793. m.name = nil
  24794. }
  24795. // SetConditionType sets the "condition_type" field.
  24796. func (m *SopStageMutation) SetConditionType(i int) {
  24797. m.condition_type = &i
  24798. m.addcondition_type = nil
  24799. }
  24800. // ConditionType returns the value of the "condition_type" field in the mutation.
  24801. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  24802. v := m.condition_type
  24803. if v == nil {
  24804. return
  24805. }
  24806. return *v, true
  24807. }
  24808. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  24809. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24811. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24812. if !m.op.Is(OpUpdateOne) {
  24813. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24814. }
  24815. if m.id == nil || m.oldValue == nil {
  24816. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24817. }
  24818. oldValue, err := m.oldValue(ctx)
  24819. if err != nil {
  24820. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24821. }
  24822. return oldValue.ConditionType, nil
  24823. }
  24824. // AddConditionType adds i to the "condition_type" field.
  24825. func (m *SopStageMutation) AddConditionType(i int) {
  24826. if m.addcondition_type != nil {
  24827. *m.addcondition_type += i
  24828. } else {
  24829. m.addcondition_type = &i
  24830. }
  24831. }
  24832. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24833. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  24834. v := m.addcondition_type
  24835. if v == nil {
  24836. return
  24837. }
  24838. return *v, true
  24839. }
  24840. // ResetConditionType resets all changes to the "condition_type" field.
  24841. func (m *SopStageMutation) ResetConditionType() {
  24842. m.condition_type = nil
  24843. m.addcondition_type = nil
  24844. }
  24845. // SetConditionOperator sets the "condition_operator" field.
  24846. func (m *SopStageMutation) SetConditionOperator(i int) {
  24847. m.condition_operator = &i
  24848. m.addcondition_operator = nil
  24849. }
  24850. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  24851. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  24852. v := m.condition_operator
  24853. if v == nil {
  24854. return
  24855. }
  24856. return *v, true
  24857. }
  24858. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  24859. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24861. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  24862. if !m.op.Is(OpUpdateOne) {
  24863. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  24864. }
  24865. if m.id == nil || m.oldValue == nil {
  24866. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  24867. }
  24868. oldValue, err := m.oldValue(ctx)
  24869. if err != nil {
  24870. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  24871. }
  24872. return oldValue.ConditionOperator, nil
  24873. }
  24874. // AddConditionOperator adds i to the "condition_operator" field.
  24875. func (m *SopStageMutation) AddConditionOperator(i int) {
  24876. if m.addcondition_operator != nil {
  24877. *m.addcondition_operator += i
  24878. } else {
  24879. m.addcondition_operator = &i
  24880. }
  24881. }
  24882. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  24883. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  24884. v := m.addcondition_operator
  24885. if v == nil {
  24886. return
  24887. }
  24888. return *v, true
  24889. }
  24890. // ResetConditionOperator resets all changes to the "condition_operator" field.
  24891. func (m *SopStageMutation) ResetConditionOperator() {
  24892. m.condition_operator = nil
  24893. m.addcondition_operator = nil
  24894. }
  24895. // SetConditionList sets the "condition_list" field.
  24896. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  24897. m.condition_list = &ct
  24898. m.appendcondition_list = nil
  24899. }
  24900. // ConditionList returns the value of the "condition_list" field in the mutation.
  24901. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  24902. v := m.condition_list
  24903. if v == nil {
  24904. return
  24905. }
  24906. return *v, true
  24907. }
  24908. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  24909. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24911. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  24912. if !m.op.Is(OpUpdateOne) {
  24913. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24914. }
  24915. if m.id == nil || m.oldValue == nil {
  24916. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24917. }
  24918. oldValue, err := m.oldValue(ctx)
  24919. if err != nil {
  24920. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24921. }
  24922. return oldValue.ConditionList, nil
  24923. }
  24924. // AppendConditionList adds ct to the "condition_list" field.
  24925. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  24926. m.appendcondition_list = append(m.appendcondition_list, ct...)
  24927. }
  24928. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  24929. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  24930. if len(m.appendcondition_list) == 0 {
  24931. return nil, false
  24932. }
  24933. return m.appendcondition_list, true
  24934. }
  24935. // ResetConditionList resets all changes to the "condition_list" field.
  24936. func (m *SopStageMutation) ResetConditionList() {
  24937. m.condition_list = nil
  24938. m.appendcondition_list = nil
  24939. }
  24940. // SetActionMessage sets the "action_message" field.
  24941. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  24942. m.action_message = &ct
  24943. m.appendaction_message = nil
  24944. }
  24945. // ActionMessage returns the value of the "action_message" field in the mutation.
  24946. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  24947. v := m.action_message
  24948. if v == nil {
  24949. return
  24950. }
  24951. return *v, true
  24952. }
  24953. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  24954. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24956. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  24957. if !m.op.Is(OpUpdateOne) {
  24958. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  24959. }
  24960. if m.id == nil || m.oldValue == nil {
  24961. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  24962. }
  24963. oldValue, err := m.oldValue(ctx)
  24964. if err != nil {
  24965. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  24966. }
  24967. return oldValue.ActionMessage, nil
  24968. }
  24969. // AppendActionMessage adds ct to the "action_message" field.
  24970. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  24971. m.appendaction_message = append(m.appendaction_message, ct...)
  24972. }
  24973. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  24974. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  24975. if len(m.appendaction_message) == 0 {
  24976. return nil, false
  24977. }
  24978. return m.appendaction_message, true
  24979. }
  24980. // ClearActionMessage clears the value of the "action_message" field.
  24981. func (m *SopStageMutation) ClearActionMessage() {
  24982. m.action_message = nil
  24983. m.appendaction_message = nil
  24984. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  24985. }
  24986. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24987. func (m *SopStageMutation) ActionMessageCleared() bool {
  24988. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  24989. return ok
  24990. }
  24991. // ResetActionMessage resets all changes to the "action_message" field.
  24992. func (m *SopStageMutation) ResetActionMessage() {
  24993. m.action_message = nil
  24994. m.appendaction_message = nil
  24995. delete(m.clearedFields, sopstage.FieldActionMessage)
  24996. }
  24997. // SetActionLabelAdd sets the "action_label_add" field.
  24998. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  24999. m.action_label_add = &u
  25000. m.appendaction_label_add = nil
  25001. }
  25002. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25003. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25004. v := m.action_label_add
  25005. if v == nil {
  25006. return
  25007. }
  25008. return *v, true
  25009. }
  25010. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  25011. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25013. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25014. if !m.op.Is(OpUpdateOne) {
  25015. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25016. }
  25017. if m.id == nil || m.oldValue == nil {
  25018. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25019. }
  25020. oldValue, err := m.oldValue(ctx)
  25021. if err != nil {
  25022. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25023. }
  25024. return oldValue.ActionLabelAdd, nil
  25025. }
  25026. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25027. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  25028. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25029. }
  25030. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25031. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25032. if len(m.appendaction_label_add) == 0 {
  25033. return nil, false
  25034. }
  25035. return m.appendaction_label_add, true
  25036. }
  25037. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25038. func (m *SopStageMutation) ClearActionLabelAdd() {
  25039. m.action_label_add = nil
  25040. m.appendaction_label_add = nil
  25041. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  25042. }
  25043. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25044. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  25045. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  25046. return ok
  25047. }
  25048. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25049. func (m *SopStageMutation) ResetActionLabelAdd() {
  25050. m.action_label_add = nil
  25051. m.appendaction_label_add = nil
  25052. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  25053. }
  25054. // SetActionLabelDel sets the "action_label_del" field.
  25055. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  25056. m.action_label_del = &u
  25057. m.appendaction_label_del = nil
  25058. }
  25059. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25060. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  25061. v := m.action_label_del
  25062. if v == nil {
  25063. return
  25064. }
  25065. return *v, true
  25066. }
  25067. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  25068. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25070. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25071. if !m.op.Is(OpUpdateOne) {
  25072. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25073. }
  25074. if m.id == nil || m.oldValue == nil {
  25075. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25076. }
  25077. oldValue, err := m.oldValue(ctx)
  25078. if err != nil {
  25079. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25080. }
  25081. return oldValue.ActionLabelDel, nil
  25082. }
  25083. // AppendActionLabelDel adds u to the "action_label_del" field.
  25084. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25085. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25086. }
  25087. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25088. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25089. if len(m.appendaction_label_del) == 0 {
  25090. return nil, false
  25091. }
  25092. return m.appendaction_label_del, true
  25093. }
  25094. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25095. func (m *SopStageMutation) ClearActionLabelDel() {
  25096. m.action_label_del = nil
  25097. m.appendaction_label_del = nil
  25098. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25099. }
  25100. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25101. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25102. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25103. return ok
  25104. }
  25105. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25106. func (m *SopStageMutation) ResetActionLabelDel() {
  25107. m.action_label_del = nil
  25108. m.appendaction_label_del = nil
  25109. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25110. }
  25111. // SetActionForward sets the "action_forward" field.
  25112. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25113. m.action_forward = &ctf
  25114. }
  25115. // ActionForward returns the value of the "action_forward" field in the mutation.
  25116. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25117. v := m.action_forward
  25118. if v == nil {
  25119. return
  25120. }
  25121. return *v, true
  25122. }
  25123. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25124. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25126. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25127. if !m.op.Is(OpUpdateOne) {
  25128. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25129. }
  25130. if m.id == nil || m.oldValue == nil {
  25131. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25132. }
  25133. oldValue, err := m.oldValue(ctx)
  25134. if err != nil {
  25135. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25136. }
  25137. return oldValue.ActionForward, nil
  25138. }
  25139. // ClearActionForward clears the value of the "action_forward" field.
  25140. func (m *SopStageMutation) ClearActionForward() {
  25141. m.action_forward = nil
  25142. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25143. }
  25144. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25145. func (m *SopStageMutation) ActionForwardCleared() bool {
  25146. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25147. return ok
  25148. }
  25149. // ResetActionForward resets all changes to the "action_forward" field.
  25150. func (m *SopStageMutation) ResetActionForward() {
  25151. m.action_forward = nil
  25152. delete(m.clearedFields, sopstage.FieldActionForward)
  25153. }
  25154. // SetIndexSort sets the "index_sort" field.
  25155. func (m *SopStageMutation) SetIndexSort(i int) {
  25156. m.index_sort = &i
  25157. m.addindex_sort = nil
  25158. }
  25159. // IndexSort returns the value of the "index_sort" field in the mutation.
  25160. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25161. v := m.index_sort
  25162. if v == nil {
  25163. return
  25164. }
  25165. return *v, true
  25166. }
  25167. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25168. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25170. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25171. if !m.op.Is(OpUpdateOne) {
  25172. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25173. }
  25174. if m.id == nil || m.oldValue == nil {
  25175. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25176. }
  25177. oldValue, err := m.oldValue(ctx)
  25178. if err != nil {
  25179. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25180. }
  25181. return oldValue.IndexSort, nil
  25182. }
  25183. // AddIndexSort adds i to the "index_sort" field.
  25184. func (m *SopStageMutation) AddIndexSort(i int) {
  25185. if m.addindex_sort != nil {
  25186. *m.addindex_sort += i
  25187. } else {
  25188. m.addindex_sort = &i
  25189. }
  25190. }
  25191. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25192. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25193. v := m.addindex_sort
  25194. if v == nil {
  25195. return
  25196. }
  25197. return *v, true
  25198. }
  25199. // ClearIndexSort clears the value of the "index_sort" field.
  25200. func (m *SopStageMutation) ClearIndexSort() {
  25201. m.index_sort = nil
  25202. m.addindex_sort = nil
  25203. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25204. }
  25205. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25206. func (m *SopStageMutation) IndexSortCleared() bool {
  25207. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25208. return ok
  25209. }
  25210. // ResetIndexSort resets all changes to the "index_sort" field.
  25211. func (m *SopStageMutation) ResetIndexSort() {
  25212. m.index_sort = nil
  25213. m.addindex_sort = nil
  25214. delete(m.clearedFields, sopstage.FieldIndexSort)
  25215. }
  25216. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25217. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25218. m.sop_task = &id
  25219. }
  25220. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25221. func (m *SopStageMutation) ClearSopTask() {
  25222. m.clearedsop_task = true
  25223. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25224. }
  25225. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25226. func (m *SopStageMutation) SopTaskCleared() bool {
  25227. return m.clearedsop_task
  25228. }
  25229. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25230. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25231. if m.sop_task != nil {
  25232. return *m.sop_task, true
  25233. }
  25234. return
  25235. }
  25236. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25237. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25238. // SopTaskID instead. It exists only for internal usage by the builders.
  25239. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25240. if id := m.sop_task; id != nil {
  25241. ids = append(ids, *id)
  25242. }
  25243. return
  25244. }
  25245. // ResetSopTask resets all changes to the "sop_task" edge.
  25246. func (m *SopStageMutation) ResetSopTask() {
  25247. m.sop_task = nil
  25248. m.clearedsop_task = false
  25249. }
  25250. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25251. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25252. if m.stage_nodes == nil {
  25253. m.stage_nodes = make(map[uint64]struct{})
  25254. }
  25255. for i := range ids {
  25256. m.stage_nodes[ids[i]] = struct{}{}
  25257. }
  25258. }
  25259. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25260. func (m *SopStageMutation) ClearStageNodes() {
  25261. m.clearedstage_nodes = true
  25262. }
  25263. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25264. func (m *SopStageMutation) StageNodesCleared() bool {
  25265. return m.clearedstage_nodes
  25266. }
  25267. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25268. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25269. if m.removedstage_nodes == nil {
  25270. m.removedstage_nodes = make(map[uint64]struct{})
  25271. }
  25272. for i := range ids {
  25273. delete(m.stage_nodes, ids[i])
  25274. m.removedstage_nodes[ids[i]] = struct{}{}
  25275. }
  25276. }
  25277. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25278. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25279. for id := range m.removedstage_nodes {
  25280. ids = append(ids, id)
  25281. }
  25282. return
  25283. }
  25284. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25285. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25286. for id := range m.stage_nodes {
  25287. ids = append(ids, id)
  25288. }
  25289. return
  25290. }
  25291. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25292. func (m *SopStageMutation) ResetStageNodes() {
  25293. m.stage_nodes = nil
  25294. m.clearedstage_nodes = false
  25295. m.removedstage_nodes = nil
  25296. }
  25297. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25298. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25299. if m.stage_messages == nil {
  25300. m.stage_messages = make(map[uint64]struct{})
  25301. }
  25302. for i := range ids {
  25303. m.stage_messages[ids[i]] = struct{}{}
  25304. }
  25305. }
  25306. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25307. func (m *SopStageMutation) ClearStageMessages() {
  25308. m.clearedstage_messages = true
  25309. }
  25310. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25311. func (m *SopStageMutation) StageMessagesCleared() bool {
  25312. return m.clearedstage_messages
  25313. }
  25314. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25315. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25316. if m.removedstage_messages == nil {
  25317. m.removedstage_messages = make(map[uint64]struct{})
  25318. }
  25319. for i := range ids {
  25320. delete(m.stage_messages, ids[i])
  25321. m.removedstage_messages[ids[i]] = struct{}{}
  25322. }
  25323. }
  25324. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25325. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25326. for id := range m.removedstage_messages {
  25327. ids = append(ids, id)
  25328. }
  25329. return
  25330. }
  25331. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25332. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25333. for id := range m.stage_messages {
  25334. ids = append(ids, id)
  25335. }
  25336. return
  25337. }
  25338. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25339. func (m *SopStageMutation) ResetStageMessages() {
  25340. m.stage_messages = nil
  25341. m.clearedstage_messages = false
  25342. m.removedstage_messages = nil
  25343. }
  25344. // Where appends a list predicates to the SopStageMutation builder.
  25345. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25346. m.predicates = append(m.predicates, ps...)
  25347. }
  25348. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25349. // users can use type-assertion to append predicates that do not depend on any generated package.
  25350. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25351. p := make([]predicate.SopStage, len(ps))
  25352. for i := range ps {
  25353. p[i] = ps[i]
  25354. }
  25355. m.Where(p...)
  25356. }
  25357. // Op returns the operation name.
  25358. func (m *SopStageMutation) Op() Op {
  25359. return m.op
  25360. }
  25361. // SetOp allows setting the mutation operation.
  25362. func (m *SopStageMutation) SetOp(op Op) {
  25363. m.op = op
  25364. }
  25365. // Type returns the node type of this mutation (SopStage).
  25366. func (m *SopStageMutation) Type() string {
  25367. return m.typ
  25368. }
  25369. // Fields returns all fields that were changed during this mutation. Note that in
  25370. // order to get all numeric fields that were incremented/decremented, call
  25371. // AddedFields().
  25372. func (m *SopStageMutation) Fields() []string {
  25373. fields := make([]string, 0, 14)
  25374. if m.created_at != nil {
  25375. fields = append(fields, sopstage.FieldCreatedAt)
  25376. }
  25377. if m.updated_at != nil {
  25378. fields = append(fields, sopstage.FieldUpdatedAt)
  25379. }
  25380. if m.status != nil {
  25381. fields = append(fields, sopstage.FieldStatus)
  25382. }
  25383. if m.deleted_at != nil {
  25384. fields = append(fields, sopstage.FieldDeletedAt)
  25385. }
  25386. if m.sop_task != nil {
  25387. fields = append(fields, sopstage.FieldTaskID)
  25388. }
  25389. if m.name != nil {
  25390. fields = append(fields, sopstage.FieldName)
  25391. }
  25392. if m.condition_type != nil {
  25393. fields = append(fields, sopstage.FieldConditionType)
  25394. }
  25395. if m.condition_operator != nil {
  25396. fields = append(fields, sopstage.FieldConditionOperator)
  25397. }
  25398. if m.condition_list != nil {
  25399. fields = append(fields, sopstage.FieldConditionList)
  25400. }
  25401. if m.action_message != nil {
  25402. fields = append(fields, sopstage.FieldActionMessage)
  25403. }
  25404. if m.action_label_add != nil {
  25405. fields = append(fields, sopstage.FieldActionLabelAdd)
  25406. }
  25407. if m.action_label_del != nil {
  25408. fields = append(fields, sopstage.FieldActionLabelDel)
  25409. }
  25410. if m.action_forward != nil {
  25411. fields = append(fields, sopstage.FieldActionForward)
  25412. }
  25413. if m.index_sort != nil {
  25414. fields = append(fields, sopstage.FieldIndexSort)
  25415. }
  25416. return fields
  25417. }
  25418. // Field returns the value of a field with the given name. The second boolean
  25419. // return value indicates that this field was not set, or was not defined in the
  25420. // schema.
  25421. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25422. switch name {
  25423. case sopstage.FieldCreatedAt:
  25424. return m.CreatedAt()
  25425. case sopstage.FieldUpdatedAt:
  25426. return m.UpdatedAt()
  25427. case sopstage.FieldStatus:
  25428. return m.Status()
  25429. case sopstage.FieldDeletedAt:
  25430. return m.DeletedAt()
  25431. case sopstage.FieldTaskID:
  25432. return m.TaskID()
  25433. case sopstage.FieldName:
  25434. return m.Name()
  25435. case sopstage.FieldConditionType:
  25436. return m.ConditionType()
  25437. case sopstage.FieldConditionOperator:
  25438. return m.ConditionOperator()
  25439. case sopstage.FieldConditionList:
  25440. return m.ConditionList()
  25441. case sopstage.FieldActionMessage:
  25442. return m.ActionMessage()
  25443. case sopstage.FieldActionLabelAdd:
  25444. return m.ActionLabelAdd()
  25445. case sopstage.FieldActionLabelDel:
  25446. return m.ActionLabelDel()
  25447. case sopstage.FieldActionForward:
  25448. return m.ActionForward()
  25449. case sopstage.FieldIndexSort:
  25450. return m.IndexSort()
  25451. }
  25452. return nil, false
  25453. }
  25454. // OldField returns the old value of the field from the database. An error is
  25455. // returned if the mutation operation is not UpdateOne, or the query to the
  25456. // database failed.
  25457. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25458. switch name {
  25459. case sopstage.FieldCreatedAt:
  25460. return m.OldCreatedAt(ctx)
  25461. case sopstage.FieldUpdatedAt:
  25462. return m.OldUpdatedAt(ctx)
  25463. case sopstage.FieldStatus:
  25464. return m.OldStatus(ctx)
  25465. case sopstage.FieldDeletedAt:
  25466. return m.OldDeletedAt(ctx)
  25467. case sopstage.FieldTaskID:
  25468. return m.OldTaskID(ctx)
  25469. case sopstage.FieldName:
  25470. return m.OldName(ctx)
  25471. case sopstage.FieldConditionType:
  25472. return m.OldConditionType(ctx)
  25473. case sopstage.FieldConditionOperator:
  25474. return m.OldConditionOperator(ctx)
  25475. case sopstage.FieldConditionList:
  25476. return m.OldConditionList(ctx)
  25477. case sopstage.FieldActionMessage:
  25478. return m.OldActionMessage(ctx)
  25479. case sopstage.FieldActionLabelAdd:
  25480. return m.OldActionLabelAdd(ctx)
  25481. case sopstage.FieldActionLabelDel:
  25482. return m.OldActionLabelDel(ctx)
  25483. case sopstage.FieldActionForward:
  25484. return m.OldActionForward(ctx)
  25485. case sopstage.FieldIndexSort:
  25486. return m.OldIndexSort(ctx)
  25487. }
  25488. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25489. }
  25490. // SetField sets the value of a field with the given name. It returns an error if
  25491. // the field is not defined in the schema, or if the type mismatched the field
  25492. // type.
  25493. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25494. switch name {
  25495. case sopstage.FieldCreatedAt:
  25496. v, ok := value.(time.Time)
  25497. if !ok {
  25498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25499. }
  25500. m.SetCreatedAt(v)
  25501. return nil
  25502. case sopstage.FieldUpdatedAt:
  25503. v, ok := value.(time.Time)
  25504. if !ok {
  25505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25506. }
  25507. m.SetUpdatedAt(v)
  25508. return nil
  25509. case sopstage.FieldStatus:
  25510. v, ok := value.(uint8)
  25511. if !ok {
  25512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25513. }
  25514. m.SetStatus(v)
  25515. return nil
  25516. case sopstage.FieldDeletedAt:
  25517. v, ok := value.(time.Time)
  25518. if !ok {
  25519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25520. }
  25521. m.SetDeletedAt(v)
  25522. return nil
  25523. case sopstage.FieldTaskID:
  25524. v, ok := value.(uint64)
  25525. if !ok {
  25526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25527. }
  25528. m.SetTaskID(v)
  25529. return nil
  25530. case sopstage.FieldName:
  25531. v, ok := value.(string)
  25532. if !ok {
  25533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25534. }
  25535. m.SetName(v)
  25536. return nil
  25537. case sopstage.FieldConditionType:
  25538. v, ok := value.(int)
  25539. if !ok {
  25540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25541. }
  25542. m.SetConditionType(v)
  25543. return nil
  25544. case sopstage.FieldConditionOperator:
  25545. v, ok := value.(int)
  25546. if !ok {
  25547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25548. }
  25549. m.SetConditionOperator(v)
  25550. return nil
  25551. case sopstage.FieldConditionList:
  25552. v, ok := value.([]custom_types.Condition)
  25553. if !ok {
  25554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25555. }
  25556. m.SetConditionList(v)
  25557. return nil
  25558. case sopstage.FieldActionMessage:
  25559. v, ok := value.([]custom_types.Action)
  25560. if !ok {
  25561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25562. }
  25563. m.SetActionMessage(v)
  25564. return nil
  25565. case sopstage.FieldActionLabelAdd:
  25566. v, ok := value.([]uint64)
  25567. if !ok {
  25568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25569. }
  25570. m.SetActionLabelAdd(v)
  25571. return nil
  25572. case sopstage.FieldActionLabelDel:
  25573. v, ok := value.([]uint64)
  25574. if !ok {
  25575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25576. }
  25577. m.SetActionLabelDel(v)
  25578. return nil
  25579. case sopstage.FieldActionForward:
  25580. v, ok := value.(*custom_types.ActionForward)
  25581. if !ok {
  25582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25583. }
  25584. m.SetActionForward(v)
  25585. return nil
  25586. case sopstage.FieldIndexSort:
  25587. v, ok := value.(int)
  25588. if !ok {
  25589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25590. }
  25591. m.SetIndexSort(v)
  25592. return nil
  25593. }
  25594. return fmt.Errorf("unknown SopStage field %s", name)
  25595. }
  25596. // AddedFields returns all numeric fields that were incremented/decremented during
  25597. // this mutation.
  25598. func (m *SopStageMutation) AddedFields() []string {
  25599. var fields []string
  25600. if m.addstatus != nil {
  25601. fields = append(fields, sopstage.FieldStatus)
  25602. }
  25603. if m.addcondition_type != nil {
  25604. fields = append(fields, sopstage.FieldConditionType)
  25605. }
  25606. if m.addcondition_operator != nil {
  25607. fields = append(fields, sopstage.FieldConditionOperator)
  25608. }
  25609. if m.addindex_sort != nil {
  25610. fields = append(fields, sopstage.FieldIndexSort)
  25611. }
  25612. return fields
  25613. }
  25614. // AddedField returns the numeric value that was incremented/decremented on a field
  25615. // with the given name. The second boolean return value indicates that this field
  25616. // was not set, or was not defined in the schema.
  25617. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25618. switch name {
  25619. case sopstage.FieldStatus:
  25620. return m.AddedStatus()
  25621. case sopstage.FieldConditionType:
  25622. return m.AddedConditionType()
  25623. case sopstage.FieldConditionOperator:
  25624. return m.AddedConditionOperator()
  25625. case sopstage.FieldIndexSort:
  25626. return m.AddedIndexSort()
  25627. }
  25628. return nil, false
  25629. }
  25630. // AddField adds the value to the field with the given name. It returns an error if
  25631. // the field is not defined in the schema, or if the type mismatched the field
  25632. // type.
  25633. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25634. switch name {
  25635. case sopstage.FieldStatus:
  25636. v, ok := value.(int8)
  25637. if !ok {
  25638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25639. }
  25640. m.AddStatus(v)
  25641. return nil
  25642. case sopstage.FieldConditionType:
  25643. v, ok := value.(int)
  25644. if !ok {
  25645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25646. }
  25647. m.AddConditionType(v)
  25648. return nil
  25649. case sopstage.FieldConditionOperator:
  25650. v, ok := value.(int)
  25651. if !ok {
  25652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25653. }
  25654. m.AddConditionOperator(v)
  25655. return nil
  25656. case sopstage.FieldIndexSort:
  25657. v, ok := value.(int)
  25658. if !ok {
  25659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25660. }
  25661. m.AddIndexSort(v)
  25662. return nil
  25663. }
  25664. return fmt.Errorf("unknown SopStage numeric field %s", name)
  25665. }
  25666. // ClearedFields returns all nullable fields that were cleared during this
  25667. // mutation.
  25668. func (m *SopStageMutation) ClearedFields() []string {
  25669. var fields []string
  25670. if m.FieldCleared(sopstage.FieldStatus) {
  25671. fields = append(fields, sopstage.FieldStatus)
  25672. }
  25673. if m.FieldCleared(sopstage.FieldDeletedAt) {
  25674. fields = append(fields, sopstage.FieldDeletedAt)
  25675. }
  25676. if m.FieldCleared(sopstage.FieldActionMessage) {
  25677. fields = append(fields, sopstage.FieldActionMessage)
  25678. }
  25679. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  25680. fields = append(fields, sopstage.FieldActionLabelAdd)
  25681. }
  25682. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  25683. fields = append(fields, sopstage.FieldActionLabelDel)
  25684. }
  25685. if m.FieldCleared(sopstage.FieldActionForward) {
  25686. fields = append(fields, sopstage.FieldActionForward)
  25687. }
  25688. if m.FieldCleared(sopstage.FieldIndexSort) {
  25689. fields = append(fields, sopstage.FieldIndexSort)
  25690. }
  25691. return fields
  25692. }
  25693. // FieldCleared returns a boolean indicating if a field with the given name was
  25694. // cleared in this mutation.
  25695. func (m *SopStageMutation) FieldCleared(name string) bool {
  25696. _, ok := m.clearedFields[name]
  25697. return ok
  25698. }
  25699. // ClearField clears the value of the field with the given name. It returns an
  25700. // error if the field is not defined in the schema.
  25701. func (m *SopStageMutation) ClearField(name string) error {
  25702. switch name {
  25703. case sopstage.FieldStatus:
  25704. m.ClearStatus()
  25705. return nil
  25706. case sopstage.FieldDeletedAt:
  25707. m.ClearDeletedAt()
  25708. return nil
  25709. case sopstage.FieldActionMessage:
  25710. m.ClearActionMessage()
  25711. return nil
  25712. case sopstage.FieldActionLabelAdd:
  25713. m.ClearActionLabelAdd()
  25714. return nil
  25715. case sopstage.FieldActionLabelDel:
  25716. m.ClearActionLabelDel()
  25717. return nil
  25718. case sopstage.FieldActionForward:
  25719. m.ClearActionForward()
  25720. return nil
  25721. case sopstage.FieldIndexSort:
  25722. m.ClearIndexSort()
  25723. return nil
  25724. }
  25725. return fmt.Errorf("unknown SopStage nullable field %s", name)
  25726. }
  25727. // ResetField resets all changes in the mutation for the field with the given name.
  25728. // It returns an error if the field is not defined in the schema.
  25729. func (m *SopStageMutation) ResetField(name string) error {
  25730. switch name {
  25731. case sopstage.FieldCreatedAt:
  25732. m.ResetCreatedAt()
  25733. return nil
  25734. case sopstage.FieldUpdatedAt:
  25735. m.ResetUpdatedAt()
  25736. return nil
  25737. case sopstage.FieldStatus:
  25738. m.ResetStatus()
  25739. return nil
  25740. case sopstage.FieldDeletedAt:
  25741. m.ResetDeletedAt()
  25742. return nil
  25743. case sopstage.FieldTaskID:
  25744. m.ResetTaskID()
  25745. return nil
  25746. case sopstage.FieldName:
  25747. m.ResetName()
  25748. return nil
  25749. case sopstage.FieldConditionType:
  25750. m.ResetConditionType()
  25751. return nil
  25752. case sopstage.FieldConditionOperator:
  25753. m.ResetConditionOperator()
  25754. return nil
  25755. case sopstage.FieldConditionList:
  25756. m.ResetConditionList()
  25757. return nil
  25758. case sopstage.FieldActionMessage:
  25759. m.ResetActionMessage()
  25760. return nil
  25761. case sopstage.FieldActionLabelAdd:
  25762. m.ResetActionLabelAdd()
  25763. return nil
  25764. case sopstage.FieldActionLabelDel:
  25765. m.ResetActionLabelDel()
  25766. return nil
  25767. case sopstage.FieldActionForward:
  25768. m.ResetActionForward()
  25769. return nil
  25770. case sopstage.FieldIndexSort:
  25771. m.ResetIndexSort()
  25772. return nil
  25773. }
  25774. return fmt.Errorf("unknown SopStage field %s", name)
  25775. }
  25776. // AddedEdges returns all edge names that were set/added in this mutation.
  25777. func (m *SopStageMutation) AddedEdges() []string {
  25778. edges := make([]string, 0, 3)
  25779. if m.sop_task != nil {
  25780. edges = append(edges, sopstage.EdgeSopTask)
  25781. }
  25782. if m.stage_nodes != nil {
  25783. edges = append(edges, sopstage.EdgeStageNodes)
  25784. }
  25785. if m.stage_messages != nil {
  25786. edges = append(edges, sopstage.EdgeStageMessages)
  25787. }
  25788. return edges
  25789. }
  25790. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25791. // name in this mutation.
  25792. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  25793. switch name {
  25794. case sopstage.EdgeSopTask:
  25795. if id := m.sop_task; id != nil {
  25796. return []ent.Value{*id}
  25797. }
  25798. case sopstage.EdgeStageNodes:
  25799. ids := make([]ent.Value, 0, len(m.stage_nodes))
  25800. for id := range m.stage_nodes {
  25801. ids = append(ids, id)
  25802. }
  25803. return ids
  25804. case sopstage.EdgeStageMessages:
  25805. ids := make([]ent.Value, 0, len(m.stage_messages))
  25806. for id := range m.stage_messages {
  25807. ids = append(ids, id)
  25808. }
  25809. return ids
  25810. }
  25811. return nil
  25812. }
  25813. // RemovedEdges returns all edge names that were removed in this mutation.
  25814. func (m *SopStageMutation) RemovedEdges() []string {
  25815. edges := make([]string, 0, 3)
  25816. if m.removedstage_nodes != nil {
  25817. edges = append(edges, sopstage.EdgeStageNodes)
  25818. }
  25819. if m.removedstage_messages != nil {
  25820. edges = append(edges, sopstage.EdgeStageMessages)
  25821. }
  25822. return edges
  25823. }
  25824. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25825. // the given name in this mutation.
  25826. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  25827. switch name {
  25828. case sopstage.EdgeStageNodes:
  25829. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  25830. for id := range m.removedstage_nodes {
  25831. ids = append(ids, id)
  25832. }
  25833. return ids
  25834. case sopstage.EdgeStageMessages:
  25835. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  25836. for id := range m.removedstage_messages {
  25837. ids = append(ids, id)
  25838. }
  25839. return ids
  25840. }
  25841. return nil
  25842. }
  25843. // ClearedEdges returns all edge names that were cleared in this mutation.
  25844. func (m *SopStageMutation) ClearedEdges() []string {
  25845. edges := make([]string, 0, 3)
  25846. if m.clearedsop_task {
  25847. edges = append(edges, sopstage.EdgeSopTask)
  25848. }
  25849. if m.clearedstage_nodes {
  25850. edges = append(edges, sopstage.EdgeStageNodes)
  25851. }
  25852. if m.clearedstage_messages {
  25853. edges = append(edges, sopstage.EdgeStageMessages)
  25854. }
  25855. return edges
  25856. }
  25857. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25858. // was cleared in this mutation.
  25859. func (m *SopStageMutation) EdgeCleared(name string) bool {
  25860. switch name {
  25861. case sopstage.EdgeSopTask:
  25862. return m.clearedsop_task
  25863. case sopstage.EdgeStageNodes:
  25864. return m.clearedstage_nodes
  25865. case sopstage.EdgeStageMessages:
  25866. return m.clearedstage_messages
  25867. }
  25868. return false
  25869. }
  25870. // ClearEdge clears the value of the edge with the given name. It returns an error
  25871. // if that edge is not defined in the schema.
  25872. func (m *SopStageMutation) ClearEdge(name string) error {
  25873. switch name {
  25874. case sopstage.EdgeSopTask:
  25875. m.ClearSopTask()
  25876. return nil
  25877. }
  25878. return fmt.Errorf("unknown SopStage unique edge %s", name)
  25879. }
  25880. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25881. // It returns an error if the edge is not defined in the schema.
  25882. func (m *SopStageMutation) ResetEdge(name string) error {
  25883. switch name {
  25884. case sopstage.EdgeSopTask:
  25885. m.ResetSopTask()
  25886. return nil
  25887. case sopstage.EdgeStageNodes:
  25888. m.ResetStageNodes()
  25889. return nil
  25890. case sopstage.EdgeStageMessages:
  25891. m.ResetStageMessages()
  25892. return nil
  25893. }
  25894. return fmt.Errorf("unknown SopStage edge %s", name)
  25895. }
  25896. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  25897. type SopTaskMutation struct {
  25898. config
  25899. op Op
  25900. typ string
  25901. id *uint64
  25902. created_at *time.Time
  25903. updated_at *time.Time
  25904. status *uint8
  25905. addstatus *int8
  25906. deleted_at *time.Time
  25907. name *string
  25908. bot_wxid_list *[]string
  25909. appendbot_wxid_list []string
  25910. _type *int
  25911. add_type *int
  25912. plan_start_time *time.Time
  25913. plan_end_time *time.Time
  25914. creator_id *string
  25915. organization_id *uint64
  25916. addorganization_id *int64
  25917. token *[]string
  25918. appendtoken []string
  25919. clearedFields map[string]struct{}
  25920. task_stages map[uint64]struct{}
  25921. removedtask_stages map[uint64]struct{}
  25922. clearedtask_stages bool
  25923. done bool
  25924. oldValue func(context.Context) (*SopTask, error)
  25925. predicates []predicate.SopTask
  25926. }
  25927. var _ ent.Mutation = (*SopTaskMutation)(nil)
  25928. // soptaskOption allows management of the mutation configuration using functional options.
  25929. type soptaskOption func(*SopTaskMutation)
  25930. // newSopTaskMutation creates new mutation for the SopTask entity.
  25931. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  25932. m := &SopTaskMutation{
  25933. config: c,
  25934. op: op,
  25935. typ: TypeSopTask,
  25936. clearedFields: make(map[string]struct{}),
  25937. }
  25938. for _, opt := range opts {
  25939. opt(m)
  25940. }
  25941. return m
  25942. }
  25943. // withSopTaskID sets the ID field of the mutation.
  25944. func withSopTaskID(id uint64) soptaskOption {
  25945. return func(m *SopTaskMutation) {
  25946. var (
  25947. err error
  25948. once sync.Once
  25949. value *SopTask
  25950. )
  25951. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  25952. once.Do(func() {
  25953. if m.done {
  25954. err = errors.New("querying old values post mutation is not allowed")
  25955. } else {
  25956. value, err = m.Client().SopTask.Get(ctx, id)
  25957. }
  25958. })
  25959. return value, err
  25960. }
  25961. m.id = &id
  25962. }
  25963. }
  25964. // withSopTask sets the old SopTask of the mutation.
  25965. func withSopTask(node *SopTask) soptaskOption {
  25966. return func(m *SopTaskMutation) {
  25967. m.oldValue = func(context.Context) (*SopTask, error) {
  25968. return node, nil
  25969. }
  25970. m.id = &node.ID
  25971. }
  25972. }
  25973. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25974. // executed in a transaction (ent.Tx), a transactional client is returned.
  25975. func (m SopTaskMutation) Client() *Client {
  25976. client := &Client{config: m.config}
  25977. client.init()
  25978. return client
  25979. }
  25980. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25981. // it returns an error otherwise.
  25982. func (m SopTaskMutation) Tx() (*Tx, error) {
  25983. if _, ok := m.driver.(*txDriver); !ok {
  25984. return nil, errors.New("ent: mutation is not running in a transaction")
  25985. }
  25986. tx := &Tx{config: m.config}
  25987. tx.init()
  25988. return tx, nil
  25989. }
  25990. // SetID sets the value of the id field. Note that this
  25991. // operation is only accepted on creation of SopTask entities.
  25992. func (m *SopTaskMutation) SetID(id uint64) {
  25993. m.id = &id
  25994. }
  25995. // ID returns the ID value in the mutation. Note that the ID is only available
  25996. // if it was provided to the builder or after it was returned from the database.
  25997. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  25998. if m.id == nil {
  25999. return
  26000. }
  26001. return *m.id, true
  26002. }
  26003. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26004. // That means, if the mutation is applied within a transaction with an isolation level such
  26005. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26006. // or updated by the mutation.
  26007. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  26008. switch {
  26009. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26010. id, exists := m.ID()
  26011. if exists {
  26012. return []uint64{id}, nil
  26013. }
  26014. fallthrough
  26015. case m.op.Is(OpUpdate | OpDelete):
  26016. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  26017. default:
  26018. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26019. }
  26020. }
  26021. // SetCreatedAt sets the "created_at" field.
  26022. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  26023. m.created_at = &t
  26024. }
  26025. // CreatedAt returns the value of the "created_at" field in the mutation.
  26026. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  26027. v := m.created_at
  26028. if v == nil {
  26029. return
  26030. }
  26031. return *v, true
  26032. }
  26033. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  26034. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26036. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26037. if !m.op.Is(OpUpdateOne) {
  26038. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26039. }
  26040. if m.id == nil || m.oldValue == nil {
  26041. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26042. }
  26043. oldValue, err := m.oldValue(ctx)
  26044. if err != nil {
  26045. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26046. }
  26047. return oldValue.CreatedAt, nil
  26048. }
  26049. // ResetCreatedAt resets all changes to the "created_at" field.
  26050. func (m *SopTaskMutation) ResetCreatedAt() {
  26051. m.created_at = nil
  26052. }
  26053. // SetUpdatedAt sets the "updated_at" field.
  26054. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  26055. m.updated_at = &t
  26056. }
  26057. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26058. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  26059. v := m.updated_at
  26060. if v == nil {
  26061. return
  26062. }
  26063. return *v, true
  26064. }
  26065. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  26066. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26068. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26069. if !m.op.Is(OpUpdateOne) {
  26070. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26071. }
  26072. if m.id == nil || m.oldValue == nil {
  26073. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26074. }
  26075. oldValue, err := m.oldValue(ctx)
  26076. if err != nil {
  26077. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26078. }
  26079. return oldValue.UpdatedAt, nil
  26080. }
  26081. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26082. func (m *SopTaskMutation) ResetUpdatedAt() {
  26083. m.updated_at = nil
  26084. }
  26085. // SetStatus sets the "status" field.
  26086. func (m *SopTaskMutation) SetStatus(u uint8) {
  26087. m.status = &u
  26088. m.addstatus = nil
  26089. }
  26090. // Status returns the value of the "status" field in the mutation.
  26091. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26092. v := m.status
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // OldStatus returns the old "status" field's value of the SopTask entity.
  26099. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26101. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26102. if !m.op.Is(OpUpdateOne) {
  26103. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26104. }
  26105. if m.id == nil || m.oldValue == nil {
  26106. return v, errors.New("OldStatus requires an ID field in the mutation")
  26107. }
  26108. oldValue, err := m.oldValue(ctx)
  26109. if err != nil {
  26110. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26111. }
  26112. return oldValue.Status, nil
  26113. }
  26114. // AddStatus adds u to the "status" field.
  26115. func (m *SopTaskMutation) AddStatus(u int8) {
  26116. if m.addstatus != nil {
  26117. *m.addstatus += u
  26118. } else {
  26119. m.addstatus = &u
  26120. }
  26121. }
  26122. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26123. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26124. v := m.addstatus
  26125. if v == nil {
  26126. return
  26127. }
  26128. return *v, true
  26129. }
  26130. // ClearStatus clears the value of the "status" field.
  26131. func (m *SopTaskMutation) ClearStatus() {
  26132. m.status = nil
  26133. m.addstatus = nil
  26134. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26135. }
  26136. // StatusCleared returns if the "status" field was cleared in this mutation.
  26137. func (m *SopTaskMutation) StatusCleared() bool {
  26138. _, ok := m.clearedFields[soptask.FieldStatus]
  26139. return ok
  26140. }
  26141. // ResetStatus resets all changes to the "status" field.
  26142. func (m *SopTaskMutation) ResetStatus() {
  26143. m.status = nil
  26144. m.addstatus = nil
  26145. delete(m.clearedFields, soptask.FieldStatus)
  26146. }
  26147. // SetDeletedAt sets the "deleted_at" field.
  26148. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26149. m.deleted_at = &t
  26150. }
  26151. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26152. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26153. v := m.deleted_at
  26154. if v == nil {
  26155. return
  26156. }
  26157. return *v, true
  26158. }
  26159. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26160. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26162. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26163. if !m.op.Is(OpUpdateOne) {
  26164. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26165. }
  26166. if m.id == nil || m.oldValue == nil {
  26167. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26168. }
  26169. oldValue, err := m.oldValue(ctx)
  26170. if err != nil {
  26171. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26172. }
  26173. return oldValue.DeletedAt, nil
  26174. }
  26175. // ClearDeletedAt clears the value of the "deleted_at" field.
  26176. func (m *SopTaskMutation) ClearDeletedAt() {
  26177. m.deleted_at = nil
  26178. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26179. }
  26180. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26181. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26182. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26183. return ok
  26184. }
  26185. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26186. func (m *SopTaskMutation) ResetDeletedAt() {
  26187. m.deleted_at = nil
  26188. delete(m.clearedFields, soptask.FieldDeletedAt)
  26189. }
  26190. // SetName sets the "name" field.
  26191. func (m *SopTaskMutation) SetName(s string) {
  26192. m.name = &s
  26193. }
  26194. // Name returns the value of the "name" field in the mutation.
  26195. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26196. v := m.name
  26197. if v == nil {
  26198. return
  26199. }
  26200. return *v, true
  26201. }
  26202. // OldName returns the old "name" field's value of the SopTask entity.
  26203. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26205. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26206. if !m.op.Is(OpUpdateOne) {
  26207. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26208. }
  26209. if m.id == nil || m.oldValue == nil {
  26210. return v, errors.New("OldName requires an ID field in the mutation")
  26211. }
  26212. oldValue, err := m.oldValue(ctx)
  26213. if err != nil {
  26214. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26215. }
  26216. return oldValue.Name, nil
  26217. }
  26218. // ResetName resets all changes to the "name" field.
  26219. func (m *SopTaskMutation) ResetName() {
  26220. m.name = nil
  26221. }
  26222. // SetBotWxidList sets the "bot_wxid_list" field.
  26223. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26224. m.bot_wxid_list = &s
  26225. m.appendbot_wxid_list = nil
  26226. }
  26227. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26228. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26229. v := m.bot_wxid_list
  26230. if v == nil {
  26231. return
  26232. }
  26233. return *v, true
  26234. }
  26235. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26236. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26238. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26239. if !m.op.Is(OpUpdateOne) {
  26240. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26241. }
  26242. if m.id == nil || m.oldValue == nil {
  26243. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26244. }
  26245. oldValue, err := m.oldValue(ctx)
  26246. if err != nil {
  26247. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26248. }
  26249. return oldValue.BotWxidList, nil
  26250. }
  26251. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26252. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26253. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26254. }
  26255. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26256. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26257. if len(m.appendbot_wxid_list) == 0 {
  26258. return nil, false
  26259. }
  26260. return m.appendbot_wxid_list, true
  26261. }
  26262. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26263. func (m *SopTaskMutation) ClearBotWxidList() {
  26264. m.bot_wxid_list = nil
  26265. m.appendbot_wxid_list = nil
  26266. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26267. }
  26268. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26269. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26270. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26271. return ok
  26272. }
  26273. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26274. func (m *SopTaskMutation) ResetBotWxidList() {
  26275. m.bot_wxid_list = nil
  26276. m.appendbot_wxid_list = nil
  26277. delete(m.clearedFields, soptask.FieldBotWxidList)
  26278. }
  26279. // SetType sets the "type" field.
  26280. func (m *SopTaskMutation) SetType(i int) {
  26281. m._type = &i
  26282. m.add_type = nil
  26283. }
  26284. // GetType returns the value of the "type" field in the mutation.
  26285. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26286. v := m._type
  26287. if v == nil {
  26288. return
  26289. }
  26290. return *v, true
  26291. }
  26292. // OldType returns the old "type" field's value of the SopTask entity.
  26293. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26295. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26296. if !m.op.Is(OpUpdateOne) {
  26297. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26298. }
  26299. if m.id == nil || m.oldValue == nil {
  26300. return v, errors.New("OldType requires an ID field in the mutation")
  26301. }
  26302. oldValue, err := m.oldValue(ctx)
  26303. if err != nil {
  26304. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26305. }
  26306. return oldValue.Type, nil
  26307. }
  26308. // AddType adds i to the "type" field.
  26309. func (m *SopTaskMutation) AddType(i int) {
  26310. if m.add_type != nil {
  26311. *m.add_type += i
  26312. } else {
  26313. m.add_type = &i
  26314. }
  26315. }
  26316. // AddedType returns the value that was added to the "type" field in this mutation.
  26317. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26318. v := m.add_type
  26319. if v == nil {
  26320. return
  26321. }
  26322. return *v, true
  26323. }
  26324. // ResetType resets all changes to the "type" field.
  26325. func (m *SopTaskMutation) ResetType() {
  26326. m._type = nil
  26327. m.add_type = nil
  26328. }
  26329. // SetPlanStartTime sets the "plan_start_time" field.
  26330. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26331. m.plan_start_time = &t
  26332. }
  26333. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26334. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26335. v := m.plan_start_time
  26336. if v == nil {
  26337. return
  26338. }
  26339. return *v, true
  26340. }
  26341. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26342. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26344. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26345. if !m.op.Is(OpUpdateOne) {
  26346. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26347. }
  26348. if m.id == nil || m.oldValue == nil {
  26349. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26350. }
  26351. oldValue, err := m.oldValue(ctx)
  26352. if err != nil {
  26353. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26354. }
  26355. return oldValue.PlanStartTime, nil
  26356. }
  26357. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26358. func (m *SopTaskMutation) ClearPlanStartTime() {
  26359. m.plan_start_time = nil
  26360. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26361. }
  26362. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26363. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26364. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26365. return ok
  26366. }
  26367. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26368. func (m *SopTaskMutation) ResetPlanStartTime() {
  26369. m.plan_start_time = nil
  26370. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26371. }
  26372. // SetPlanEndTime sets the "plan_end_time" field.
  26373. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26374. m.plan_end_time = &t
  26375. }
  26376. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26377. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26378. v := m.plan_end_time
  26379. if v == nil {
  26380. return
  26381. }
  26382. return *v, true
  26383. }
  26384. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26385. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26387. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26388. if !m.op.Is(OpUpdateOne) {
  26389. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26390. }
  26391. if m.id == nil || m.oldValue == nil {
  26392. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26393. }
  26394. oldValue, err := m.oldValue(ctx)
  26395. if err != nil {
  26396. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26397. }
  26398. return oldValue.PlanEndTime, nil
  26399. }
  26400. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26401. func (m *SopTaskMutation) ClearPlanEndTime() {
  26402. m.plan_end_time = nil
  26403. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26404. }
  26405. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26406. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26407. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26408. return ok
  26409. }
  26410. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26411. func (m *SopTaskMutation) ResetPlanEndTime() {
  26412. m.plan_end_time = nil
  26413. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26414. }
  26415. // SetCreatorID sets the "creator_id" field.
  26416. func (m *SopTaskMutation) SetCreatorID(s string) {
  26417. m.creator_id = &s
  26418. }
  26419. // CreatorID returns the value of the "creator_id" field in the mutation.
  26420. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26421. v := m.creator_id
  26422. if v == nil {
  26423. return
  26424. }
  26425. return *v, true
  26426. }
  26427. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26428. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26430. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26431. if !m.op.Is(OpUpdateOne) {
  26432. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26433. }
  26434. if m.id == nil || m.oldValue == nil {
  26435. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26436. }
  26437. oldValue, err := m.oldValue(ctx)
  26438. if err != nil {
  26439. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26440. }
  26441. return oldValue.CreatorID, nil
  26442. }
  26443. // ClearCreatorID clears the value of the "creator_id" field.
  26444. func (m *SopTaskMutation) ClearCreatorID() {
  26445. m.creator_id = nil
  26446. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26447. }
  26448. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26449. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26450. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26451. return ok
  26452. }
  26453. // ResetCreatorID resets all changes to the "creator_id" field.
  26454. func (m *SopTaskMutation) ResetCreatorID() {
  26455. m.creator_id = nil
  26456. delete(m.clearedFields, soptask.FieldCreatorID)
  26457. }
  26458. // SetOrganizationID sets the "organization_id" field.
  26459. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26460. m.organization_id = &u
  26461. m.addorganization_id = nil
  26462. }
  26463. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26464. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26465. v := m.organization_id
  26466. if v == nil {
  26467. return
  26468. }
  26469. return *v, true
  26470. }
  26471. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26472. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26474. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26475. if !m.op.Is(OpUpdateOne) {
  26476. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26477. }
  26478. if m.id == nil || m.oldValue == nil {
  26479. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26480. }
  26481. oldValue, err := m.oldValue(ctx)
  26482. if err != nil {
  26483. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26484. }
  26485. return oldValue.OrganizationID, nil
  26486. }
  26487. // AddOrganizationID adds u to the "organization_id" field.
  26488. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26489. if m.addorganization_id != nil {
  26490. *m.addorganization_id += u
  26491. } else {
  26492. m.addorganization_id = &u
  26493. }
  26494. }
  26495. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26496. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26497. v := m.addorganization_id
  26498. if v == nil {
  26499. return
  26500. }
  26501. return *v, true
  26502. }
  26503. // ClearOrganizationID clears the value of the "organization_id" field.
  26504. func (m *SopTaskMutation) ClearOrganizationID() {
  26505. m.organization_id = nil
  26506. m.addorganization_id = nil
  26507. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26508. }
  26509. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26510. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26511. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26512. return ok
  26513. }
  26514. // ResetOrganizationID resets all changes to the "organization_id" field.
  26515. func (m *SopTaskMutation) ResetOrganizationID() {
  26516. m.organization_id = nil
  26517. m.addorganization_id = nil
  26518. delete(m.clearedFields, soptask.FieldOrganizationID)
  26519. }
  26520. // SetToken sets the "token" field.
  26521. func (m *SopTaskMutation) SetToken(s []string) {
  26522. m.token = &s
  26523. m.appendtoken = nil
  26524. }
  26525. // Token returns the value of the "token" field in the mutation.
  26526. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26527. v := m.token
  26528. if v == nil {
  26529. return
  26530. }
  26531. return *v, true
  26532. }
  26533. // OldToken returns the old "token" field's value of the SopTask entity.
  26534. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26536. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26537. if !m.op.Is(OpUpdateOne) {
  26538. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26539. }
  26540. if m.id == nil || m.oldValue == nil {
  26541. return v, errors.New("OldToken requires an ID field in the mutation")
  26542. }
  26543. oldValue, err := m.oldValue(ctx)
  26544. if err != nil {
  26545. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26546. }
  26547. return oldValue.Token, nil
  26548. }
  26549. // AppendToken adds s to the "token" field.
  26550. func (m *SopTaskMutation) AppendToken(s []string) {
  26551. m.appendtoken = append(m.appendtoken, s...)
  26552. }
  26553. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26554. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26555. if len(m.appendtoken) == 0 {
  26556. return nil, false
  26557. }
  26558. return m.appendtoken, true
  26559. }
  26560. // ClearToken clears the value of the "token" field.
  26561. func (m *SopTaskMutation) ClearToken() {
  26562. m.token = nil
  26563. m.appendtoken = nil
  26564. m.clearedFields[soptask.FieldToken] = struct{}{}
  26565. }
  26566. // TokenCleared returns if the "token" field was cleared in this mutation.
  26567. func (m *SopTaskMutation) TokenCleared() bool {
  26568. _, ok := m.clearedFields[soptask.FieldToken]
  26569. return ok
  26570. }
  26571. // ResetToken resets all changes to the "token" field.
  26572. func (m *SopTaskMutation) ResetToken() {
  26573. m.token = nil
  26574. m.appendtoken = nil
  26575. delete(m.clearedFields, soptask.FieldToken)
  26576. }
  26577. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26578. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26579. if m.task_stages == nil {
  26580. m.task_stages = make(map[uint64]struct{})
  26581. }
  26582. for i := range ids {
  26583. m.task_stages[ids[i]] = struct{}{}
  26584. }
  26585. }
  26586. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26587. func (m *SopTaskMutation) ClearTaskStages() {
  26588. m.clearedtask_stages = true
  26589. }
  26590. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26591. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26592. return m.clearedtask_stages
  26593. }
  26594. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26595. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26596. if m.removedtask_stages == nil {
  26597. m.removedtask_stages = make(map[uint64]struct{})
  26598. }
  26599. for i := range ids {
  26600. delete(m.task_stages, ids[i])
  26601. m.removedtask_stages[ids[i]] = struct{}{}
  26602. }
  26603. }
  26604. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26605. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26606. for id := range m.removedtask_stages {
  26607. ids = append(ids, id)
  26608. }
  26609. return
  26610. }
  26611. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26612. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26613. for id := range m.task_stages {
  26614. ids = append(ids, id)
  26615. }
  26616. return
  26617. }
  26618. // ResetTaskStages resets all changes to the "task_stages" edge.
  26619. func (m *SopTaskMutation) ResetTaskStages() {
  26620. m.task_stages = nil
  26621. m.clearedtask_stages = false
  26622. m.removedtask_stages = nil
  26623. }
  26624. // Where appends a list predicates to the SopTaskMutation builder.
  26625. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26626. m.predicates = append(m.predicates, ps...)
  26627. }
  26628. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26629. // users can use type-assertion to append predicates that do not depend on any generated package.
  26630. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26631. p := make([]predicate.SopTask, len(ps))
  26632. for i := range ps {
  26633. p[i] = ps[i]
  26634. }
  26635. m.Where(p...)
  26636. }
  26637. // Op returns the operation name.
  26638. func (m *SopTaskMutation) Op() Op {
  26639. return m.op
  26640. }
  26641. // SetOp allows setting the mutation operation.
  26642. func (m *SopTaskMutation) SetOp(op Op) {
  26643. m.op = op
  26644. }
  26645. // Type returns the node type of this mutation (SopTask).
  26646. func (m *SopTaskMutation) Type() string {
  26647. return m.typ
  26648. }
  26649. // Fields returns all fields that were changed during this mutation. Note that in
  26650. // order to get all numeric fields that were incremented/decremented, call
  26651. // AddedFields().
  26652. func (m *SopTaskMutation) Fields() []string {
  26653. fields := make([]string, 0, 12)
  26654. if m.created_at != nil {
  26655. fields = append(fields, soptask.FieldCreatedAt)
  26656. }
  26657. if m.updated_at != nil {
  26658. fields = append(fields, soptask.FieldUpdatedAt)
  26659. }
  26660. if m.status != nil {
  26661. fields = append(fields, soptask.FieldStatus)
  26662. }
  26663. if m.deleted_at != nil {
  26664. fields = append(fields, soptask.FieldDeletedAt)
  26665. }
  26666. if m.name != nil {
  26667. fields = append(fields, soptask.FieldName)
  26668. }
  26669. if m.bot_wxid_list != nil {
  26670. fields = append(fields, soptask.FieldBotWxidList)
  26671. }
  26672. if m._type != nil {
  26673. fields = append(fields, soptask.FieldType)
  26674. }
  26675. if m.plan_start_time != nil {
  26676. fields = append(fields, soptask.FieldPlanStartTime)
  26677. }
  26678. if m.plan_end_time != nil {
  26679. fields = append(fields, soptask.FieldPlanEndTime)
  26680. }
  26681. if m.creator_id != nil {
  26682. fields = append(fields, soptask.FieldCreatorID)
  26683. }
  26684. if m.organization_id != nil {
  26685. fields = append(fields, soptask.FieldOrganizationID)
  26686. }
  26687. if m.token != nil {
  26688. fields = append(fields, soptask.FieldToken)
  26689. }
  26690. return fields
  26691. }
  26692. // Field returns the value of a field with the given name. The second boolean
  26693. // return value indicates that this field was not set, or was not defined in the
  26694. // schema.
  26695. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  26696. switch name {
  26697. case soptask.FieldCreatedAt:
  26698. return m.CreatedAt()
  26699. case soptask.FieldUpdatedAt:
  26700. return m.UpdatedAt()
  26701. case soptask.FieldStatus:
  26702. return m.Status()
  26703. case soptask.FieldDeletedAt:
  26704. return m.DeletedAt()
  26705. case soptask.FieldName:
  26706. return m.Name()
  26707. case soptask.FieldBotWxidList:
  26708. return m.BotWxidList()
  26709. case soptask.FieldType:
  26710. return m.GetType()
  26711. case soptask.FieldPlanStartTime:
  26712. return m.PlanStartTime()
  26713. case soptask.FieldPlanEndTime:
  26714. return m.PlanEndTime()
  26715. case soptask.FieldCreatorID:
  26716. return m.CreatorID()
  26717. case soptask.FieldOrganizationID:
  26718. return m.OrganizationID()
  26719. case soptask.FieldToken:
  26720. return m.Token()
  26721. }
  26722. return nil, false
  26723. }
  26724. // OldField returns the old value of the field from the database. An error is
  26725. // returned if the mutation operation is not UpdateOne, or the query to the
  26726. // database failed.
  26727. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26728. switch name {
  26729. case soptask.FieldCreatedAt:
  26730. return m.OldCreatedAt(ctx)
  26731. case soptask.FieldUpdatedAt:
  26732. return m.OldUpdatedAt(ctx)
  26733. case soptask.FieldStatus:
  26734. return m.OldStatus(ctx)
  26735. case soptask.FieldDeletedAt:
  26736. return m.OldDeletedAt(ctx)
  26737. case soptask.FieldName:
  26738. return m.OldName(ctx)
  26739. case soptask.FieldBotWxidList:
  26740. return m.OldBotWxidList(ctx)
  26741. case soptask.FieldType:
  26742. return m.OldType(ctx)
  26743. case soptask.FieldPlanStartTime:
  26744. return m.OldPlanStartTime(ctx)
  26745. case soptask.FieldPlanEndTime:
  26746. return m.OldPlanEndTime(ctx)
  26747. case soptask.FieldCreatorID:
  26748. return m.OldCreatorID(ctx)
  26749. case soptask.FieldOrganizationID:
  26750. return m.OldOrganizationID(ctx)
  26751. case soptask.FieldToken:
  26752. return m.OldToken(ctx)
  26753. }
  26754. return nil, fmt.Errorf("unknown SopTask field %s", name)
  26755. }
  26756. // SetField sets the value of a field with the given name. It returns an error if
  26757. // the field is not defined in the schema, or if the type mismatched the field
  26758. // type.
  26759. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  26760. switch name {
  26761. case soptask.FieldCreatedAt:
  26762. v, ok := value.(time.Time)
  26763. if !ok {
  26764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26765. }
  26766. m.SetCreatedAt(v)
  26767. return nil
  26768. case soptask.FieldUpdatedAt:
  26769. v, ok := value.(time.Time)
  26770. if !ok {
  26771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26772. }
  26773. m.SetUpdatedAt(v)
  26774. return nil
  26775. case soptask.FieldStatus:
  26776. v, ok := value.(uint8)
  26777. if !ok {
  26778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26779. }
  26780. m.SetStatus(v)
  26781. return nil
  26782. case soptask.FieldDeletedAt:
  26783. v, ok := value.(time.Time)
  26784. if !ok {
  26785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26786. }
  26787. m.SetDeletedAt(v)
  26788. return nil
  26789. case soptask.FieldName:
  26790. v, ok := value.(string)
  26791. if !ok {
  26792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26793. }
  26794. m.SetName(v)
  26795. return nil
  26796. case soptask.FieldBotWxidList:
  26797. v, ok := value.([]string)
  26798. if !ok {
  26799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26800. }
  26801. m.SetBotWxidList(v)
  26802. return nil
  26803. case soptask.FieldType:
  26804. v, ok := value.(int)
  26805. if !ok {
  26806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26807. }
  26808. m.SetType(v)
  26809. return nil
  26810. case soptask.FieldPlanStartTime:
  26811. v, ok := value.(time.Time)
  26812. if !ok {
  26813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26814. }
  26815. m.SetPlanStartTime(v)
  26816. return nil
  26817. case soptask.FieldPlanEndTime:
  26818. v, ok := value.(time.Time)
  26819. if !ok {
  26820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26821. }
  26822. m.SetPlanEndTime(v)
  26823. return nil
  26824. case soptask.FieldCreatorID:
  26825. v, ok := value.(string)
  26826. if !ok {
  26827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26828. }
  26829. m.SetCreatorID(v)
  26830. return nil
  26831. case soptask.FieldOrganizationID:
  26832. v, ok := value.(uint64)
  26833. if !ok {
  26834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26835. }
  26836. m.SetOrganizationID(v)
  26837. return nil
  26838. case soptask.FieldToken:
  26839. v, ok := value.([]string)
  26840. if !ok {
  26841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26842. }
  26843. m.SetToken(v)
  26844. return nil
  26845. }
  26846. return fmt.Errorf("unknown SopTask field %s", name)
  26847. }
  26848. // AddedFields returns all numeric fields that were incremented/decremented during
  26849. // this mutation.
  26850. func (m *SopTaskMutation) AddedFields() []string {
  26851. var fields []string
  26852. if m.addstatus != nil {
  26853. fields = append(fields, soptask.FieldStatus)
  26854. }
  26855. if m.add_type != nil {
  26856. fields = append(fields, soptask.FieldType)
  26857. }
  26858. if m.addorganization_id != nil {
  26859. fields = append(fields, soptask.FieldOrganizationID)
  26860. }
  26861. return fields
  26862. }
  26863. // AddedField returns the numeric value that was incremented/decremented on a field
  26864. // with the given name. The second boolean return value indicates that this field
  26865. // was not set, or was not defined in the schema.
  26866. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  26867. switch name {
  26868. case soptask.FieldStatus:
  26869. return m.AddedStatus()
  26870. case soptask.FieldType:
  26871. return m.AddedType()
  26872. case soptask.FieldOrganizationID:
  26873. return m.AddedOrganizationID()
  26874. }
  26875. return nil, false
  26876. }
  26877. // AddField adds the value to the field with the given name. It returns an error if
  26878. // the field is not defined in the schema, or if the type mismatched the field
  26879. // type.
  26880. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  26881. switch name {
  26882. case soptask.FieldStatus:
  26883. v, ok := value.(int8)
  26884. if !ok {
  26885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26886. }
  26887. m.AddStatus(v)
  26888. return nil
  26889. case soptask.FieldType:
  26890. v, ok := value.(int)
  26891. if !ok {
  26892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26893. }
  26894. m.AddType(v)
  26895. return nil
  26896. case soptask.FieldOrganizationID:
  26897. v, ok := value.(int64)
  26898. if !ok {
  26899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26900. }
  26901. m.AddOrganizationID(v)
  26902. return nil
  26903. }
  26904. return fmt.Errorf("unknown SopTask numeric field %s", name)
  26905. }
  26906. // ClearedFields returns all nullable fields that were cleared during this
  26907. // mutation.
  26908. func (m *SopTaskMutation) ClearedFields() []string {
  26909. var fields []string
  26910. if m.FieldCleared(soptask.FieldStatus) {
  26911. fields = append(fields, soptask.FieldStatus)
  26912. }
  26913. if m.FieldCleared(soptask.FieldDeletedAt) {
  26914. fields = append(fields, soptask.FieldDeletedAt)
  26915. }
  26916. if m.FieldCleared(soptask.FieldBotWxidList) {
  26917. fields = append(fields, soptask.FieldBotWxidList)
  26918. }
  26919. if m.FieldCleared(soptask.FieldPlanStartTime) {
  26920. fields = append(fields, soptask.FieldPlanStartTime)
  26921. }
  26922. if m.FieldCleared(soptask.FieldPlanEndTime) {
  26923. fields = append(fields, soptask.FieldPlanEndTime)
  26924. }
  26925. if m.FieldCleared(soptask.FieldCreatorID) {
  26926. fields = append(fields, soptask.FieldCreatorID)
  26927. }
  26928. if m.FieldCleared(soptask.FieldOrganizationID) {
  26929. fields = append(fields, soptask.FieldOrganizationID)
  26930. }
  26931. if m.FieldCleared(soptask.FieldToken) {
  26932. fields = append(fields, soptask.FieldToken)
  26933. }
  26934. return fields
  26935. }
  26936. // FieldCleared returns a boolean indicating if a field with the given name was
  26937. // cleared in this mutation.
  26938. func (m *SopTaskMutation) FieldCleared(name string) bool {
  26939. _, ok := m.clearedFields[name]
  26940. return ok
  26941. }
  26942. // ClearField clears the value of the field with the given name. It returns an
  26943. // error if the field is not defined in the schema.
  26944. func (m *SopTaskMutation) ClearField(name string) error {
  26945. switch name {
  26946. case soptask.FieldStatus:
  26947. m.ClearStatus()
  26948. return nil
  26949. case soptask.FieldDeletedAt:
  26950. m.ClearDeletedAt()
  26951. return nil
  26952. case soptask.FieldBotWxidList:
  26953. m.ClearBotWxidList()
  26954. return nil
  26955. case soptask.FieldPlanStartTime:
  26956. m.ClearPlanStartTime()
  26957. return nil
  26958. case soptask.FieldPlanEndTime:
  26959. m.ClearPlanEndTime()
  26960. return nil
  26961. case soptask.FieldCreatorID:
  26962. m.ClearCreatorID()
  26963. return nil
  26964. case soptask.FieldOrganizationID:
  26965. m.ClearOrganizationID()
  26966. return nil
  26967. case soptask.FieldToken:
  26968. m.ClearToken()
  26969. return nil
  26970. }
  26971. return fmt.Errorf("unknown SopTask nullable field %s", name)
  26972. }
  26973. // ResetField resets all changes in the mutation for the field with the given name.
  26974. // It returns an error if the field is not defined in the schema.
  26975. func (m *SopTaskMutation) ResetField(name string) error {
  26976. switch name {
  26977. case soptask.FieldCreatedAt:
  26978. m.ResetCreatedAt()
  26979. return nil
  26980. case soptask.FieldUpdatedAt:
  26981. m.ResetUpdatedAt()
  26982. return nil
  26983. case soptask.FieldStatus:
  26984. m.ResetStatus()
  26985. return nil
  26986. case soptask.FieldDeletedAt:
  26987. m.ResetDeletedAt()
  26988. return nil
  26989. case soptask.FieldName:
  26990. m.ResetName()
  26991. return nil
  26992. case soptask.FieldBotWxidList:
  26993. m.ResetBotWxidList()
  26994. return nil
  26995. case soptask.FieldType:
  26996. m.ResetType()
  26997. return nil
  26998. case soptask.FieldPlanStartTime:
  26999. m.ResetPlanStartTime()
  27000. return nil
  27001. case soptask.FieldPlanEndTime:
  27002. m.ResetPlanEndTime()
  27003. return nil
  27004. case soptask.FieldCreatorID:
  27005. m.ResetCreatorID()
  27006. return nil
  27007. case soptask.FieldOrganizationID:
  27008. m.ResetOrganizationID()
  27009. return nil
  27010. case soptask.FieldToken:
  27011. m.ResetToken()
  27012. return nil
  27013. }
  27014. return fmt.Errorf("unknown SopTask field %s", name)
  27015. }
  27016. // AddedEdges returns all edge names that were set/added in this mutation.
  27017. func (m *SopTaskMutation) AddedEdges() []string {
  27018. edges := make([]string, 0, 1)
  27019. if m.task_stages != nil {
  27020. edges = append(edges, soptask.EdgeTaskStages)
  27021. }
  27022. return edges
  27023. }
  27024. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27025. // name in this mutation.
  27026. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  27027. switch name {
  27028. case soptask.EdgeTaskStages:
  27029. ids := make([]ent.Value, 0, len(m.task_stages))
  27030. for id := range m.task_stages {
  27031. ids = append(ids, id)
  27032. }
  27033. return ids
  27034. }
  27035. return nil
  27036. }
  27037. // RemovedEdges returns all edge names that were removed in this mutation.
  27038. func (m *SopTaskMutation) RemovedEdges() []string {
  27039. edges := make([]string, 0, 1)
  27040. if m.removedtask_stages != nil {
  27041. edges = append(edges, soptask.EdgeTaskStages)
  27042. }
  27043. return edges
  27044. }
  27045. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27046. // the given name in this mutation.
  27047. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  27048. switch name {
  27049. case soptask.EdgeTaskStages:
  27050. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  27051. for id := range m.removedtask_stages {
  27052. ids = append(ids, id)
  27053. }
  27054. return ids
  27055. }
  27056. return nil
  27057. }
  27058. // ClearedEdges returns all edge names that were cleared in this mutation.
  27059. func (m *SopTaskMutation) ClearedEdges() []string {
  27060. edges := make([]string, 0, 1)
  27061. if m.clearedtask_stages {
  27062. edges = append(edges, soptask.EdgeTaskStages)
  27063. }
  27064. return edges
  27065. }
  27066. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27067. // was cleared in this mutation.
  27068. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  27069. switch name {
  27070. case soptask.EdgeTaskStages:
  27071. return m.clearedtask_stages
  27072. }
  27073. return false
  27074. }
  27075. // ClearEdge clears the value of the edge with the given name. It returns an error
  27076. // if that edge is not defined in the schema.
  27077. func (m *SopTaskMutation) ClearEdge(name string) error {
  27078. switch name {
  27079. }
  27080. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27081. }
  27082. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27083. // It returns an error if the edge is not defined in the schema.
  27084. func (m *SopTaskMutation) ResetEdge(name string) error {
  27085. switch name {
  27086. case soptask.EdgeTaskStages:
  27087. m.ResetTaskStages()
  27088. return nil
  27089. }
  27090. return fmt.Errorf("unknown SopTask edge %s", name)
  27091. }
  27092. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27093. type TokenMutation struct {
  27094. config
  27095. op Op
  27096. typ string
  27097. id *uint64
  27098. created_at *time.Time
  27099. updated_at *time.Time
  27100. deleted_at *time.Time
  27101. expire_at *time.Time
  27102. token *string
  27103. mac *string
  27104. organization_id *uint64
  27105. addorganization_id *int64
  27106. custom_agent_base *string
  27107. custom_agent_key *string
  27108. openai_base *string
  27109. openai_key *string
  27110. clearedFields map[string]struct{}
  27111. agent *uint64
  27112. clearedagent bool
  27113. done bool
  27114. oldValue func(context.Context) (*Token, error)
  27115. predicates []predicate.Token
  27116. }
  27117. var _ ent.Mutation = (*TokenMutation)(nil)
  27118. // tokenOption allows management of the mutation configuration using functional options.
  27119. type tokenOption func(*TokenMutation)
  27120. // newTokenMutation creates new mutation for the Token entity.
  27121. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27122. m := &TokenMutation{
  27123. config: c,
  27124. op: op,
  27125. typ: TypeToken,
  27126. clearedFields: make(map[string]struct{}),
  27127. }
  27128. for _, opt := range opts {
  27129. opt(m)
  27130. }
  27131. return m
  27132. }
  27133. // withTokenID sets the ID field of the mutation.
  27134. func withTokenID(id uint64) tokenOption {
  27135. return func(m *TokenMutation) {
  27136. var (
  27137. err error
  27138. once sync.Once
  27139. value *Token
  27140. )
  27141. m.oldValue = func(ctx context.Context) (*Token, error) {
  27142. once.Do(func() {
  27143. if m.done {
  27144. err = errors.New("querying old values post mutation is not allowed")
  27145. } else {
  27146. value, err = m.Client().Token.Get(ctx, id)
  27147. }
  27148. })
  27149. return value, err
  27150. }
  27151. m.id = &id
  27152. }
  27153. }
  27154. // withToken sets the old Token of the mutation.
  27155. func withToken(node *Token) tokenOption {
  27156. return func(m *TokenMutation) {
  27157. m.oldValue = func(context.Context) (*Token, error) {
  27158. return node, nil
  27159. }
  27160. m.id = &node.ID
  27161. }
  27162. }
  27163. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27164. // executed in a transaction (ent.Tx), a transactional client is returned.
  27165. func (m TokenMutation) Client() *Client {
  27166. client := &Client{config: m.config}
  27167. client.init()
  27168. return client
  27169. }
  27170. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27171. // it returns an error otherwise.
  27172. func (m TokenMutation) Tx() (*Tx, error) {
  27173. if _, ok := m.driver.(*txDriver); !ok {
  27174. return nil, errors.New("ent: mutation is not running in a transaction")
  27175. }
  27176. tx := &Tx{config: m.config}
  27177. tx.init()
  27178. return tx, nil
  27179. }
  27180. // SetID sets the value of the id field. Note that this
  27181. // operation is only accepted on creation of Token entities.
  27182. func (m *TokenMutation) SetID(id uint64) {
  27183. m.id = &id
  27184. }
  27185. // ID returns the ID value in the mutation. Note that the ID is only available
  27186. // if it was provided to the builder or after it was returned from the database.
  27187. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27188. if m.id == nil {
  27189. return
  27190. }
  27191. return *m.id, true
  27192. }
  27193. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27194. // That means, if the mutation is applied within a transaction with an isolation level such
  27195. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27196. // or updated by the mutation.
  27197. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27198. switch {
  27199. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27200. id, exists := m.ID()
  27201. if exists {
  27202. return []uint64{id}, nil
  27203. }
  27204. fallthrough
  27205. case m.op.Is(OpUpdate | OpDelete):
  27206. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27207. default:
  27208. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27209. }
  27210. }
  27211. // SetCreatedAt sets the "created_at" field.
  27212. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27213. m.created_at = &t
  27214. }
  27215. // CreatedAt returns the value of the "created_at" field in the mutation.
  27216. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27217. v := m.created_at
  27218. if v == nil {
  27219. return
  27220. }
  27221. return *v, true
  27222. }
  27223. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27224. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27226. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27227. if !m.op.Is(OpUpdateOne) {
  27228. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27229. }
  27230. if m.id == nil || m.oldValue == nil {
  27231. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27232. }
  27233. oldValue, err := m.oldValue(ctx)
  27234. if err != nil {
  27235. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27236. }
  27237. return oldValue.CreatedAt, nil
  27238. }
  27239. // ResetCreatedAt resets all changes to the "created_at" field.
  27240. func (m *TokenMutation) ResetCreatedAt() {
  27241. m.created_at = nil
  27242. }
  27243. // SetUpdatedAt sets the "updated_at" field.
  27244. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27245. m.updated_at = &t
  27246. }
  27247. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27248. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27249. v := m.updated_at
  27250. if v == nil {
  27251. return
  27252. }
  27253. return *v, true
  27254. }
  27255. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27256. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27258. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27259. if !m.op.Is(OpUpdateOne) {
  27260. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27261. }
  27262. if m.id == nil || m.oldValue == nil {
  27263. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27264. }
  27265. oldValue, err := m.oldValue(ctx)
  27266. if err != nil {
  27267. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27268. }
  27269. return oldValue.UpdatedAt, nil
  27270. }
  27271. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27272. func (m *TokenMutation) ResetUpdatedAt() {
  27273. m.updated_at = nil
  27274. }
  27275. // SetDeletedAt sets the "deleted_at" field.
  27276. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27277. m.deleted_at = &t
  27278. }
  27279. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27280. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27281. v := m.deleted_at
  27282. if v == nil {
  27283. return
  27284. }
  27285. return *v, true
  27286. }
  27287. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27288. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27290. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27291. if !m.op.Is(OpUpdateOne) {
  27292. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27293. }
  27294. if m.id == nil || m.oldValue == nil {
  27295. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27296. }
  27297. oldValue, err := m.oldValue(ctx)
  27298. if err != nil {
  27299. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27300. }
  27301. return oldValue.DeletedAt, nil
  27302. }
  27303. // ClearDeletedAt clears the value of the "deleted_at" field.
  27304. func (m *TokenMutation) ClearDeletedAt() {
  27305. m.deleted_at = nil
  27306. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27307. }
  27308. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27309. func (m *TokenMutation) DeletedAtCleared() bool {
  27310. _, ok := m.clearedFields[token.FieldDeletedAt]
  27311. return ok
  27312. }
  27313. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27314. func (m *TokenMutation) ResetDeletedAt() {
  27315. m.deleted_at = nil
  27316. delete(m.clearedFields, token.FieldDeletedAt)
  27317. }
  27318. // SetExpireAt sets the "expire_at" field.
  27319. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27320. m.expire_at = &t
  27321. }
  27322. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27323. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27324. v := m.expire_at
  27325. if v == nil {
  27326. return
  27327. }
  27328. return *v, true
  27329. }
  27330. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27331. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27333. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27334. if !m.op.Is(OpUpdateOne) {
  27335. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27336. }
  27337. if m.id == nil || m.oldValue == nil {
  27338. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27339. }
  27340. oldValue, err := m.oldValue(ctx)
  27341. if err != nil {
  27342. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27343. }
  27344. return oldValue.ExpireAt, nil
  27345. }
  27346. // ClearExpireAt clears the value of the "expire_at" field.
  27347. func (m *TokenMutation) ClearExpireAt() {
  27348. m.expire_at = nil
  27349. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27350. }
  27351. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27352. func (m *TokenMutation) ExpireAtCleared() bool {
  27353. _, ok := m.clearedFields[token.FieldExpireAt]
  27354. return ok
  27355. }
  27356. // ResetExpireAt resets all changes to the "expire_at" field.
  27357. func (m *TokenMutation) ResetExpireAt() {
  27358. m.expire_at = nil
  27359. delete(m.clearedFields, token.FieldExpireAt)
  27360. }
  27361. // SetToken sets the "token" field.
  27362. func (m *TokenMutation) SetToken(s string) {
  27363. m.token = &s
  27364. }
  27365. // Token returns the value of the "token" field in the mutation.
  27366. func (m *TokenMutation) Token() (r string, exists bool) {
  27367. v := m.token
  27368. if v == nil {
  27369. return
  27370. }
  27371. return *v, true
  27372. }
  27373. // OldToken returns the old "token" field's value of the Token entity.
  27374. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27376. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27377. if !m.op.Is(OpUpdateOne) {
  27378. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27379. }
  27380. if m.id == nil || m.oldValue == nil {
  27381. return v, errors.New("OldToken requires an ID field in the mutation")
  27382. }
  27383. oldValue, err := m.oldValue(ctx)
  27384. if err != nil {
  27385. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27386. }
  27387. return oldValue.Token, nil
  27388. }
  27389. // ClearToken clears the value of the "token" field.
  27390. func (m *TokenMutation) ClearToken() {
  27391. m.token = nil
  27392. m.clearedFields[token.FieldToken] = struct{}{}
  27393. }
  27394. // TokenCleared returns if the "token" field was cleared in this mutation.
  27395. func (m *TokenMutation) TokenCleared() bool {
  27396. _, ok := m.clearedFields[token.FieldToken]
  27397. return ok
  27398. }
  27399. // ResetToken resets all changes to the "token" field.
  27400. func (m *TokenMutation) ResetToken() {
  27401. m.token = nil
  27402. delete(m.clearedFields, token.FieldToken)
  27403. }
  27404. // SetMAC sets the "mac" field.
  27405. func (m *TokenMutation) SetMAC(s string) {
  27406. m.mac = &s
  27407. }
  27408. // MAC returns the value of the "mac" field in the mutation.
  27409. func (m *TokenMutation) MAC() (r string, exists bool) {
  27410. v := m.mac
  27411. if v == nil {
  27412. return
  27413. }
  27414. return *v, true
  27415. }
  27416. // OldMAC returns the old "mac" field's value of the Token entity.
  27417. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27419. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27420. if !m.op.Is(OpUpdateOne) {
  27421. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27422. }
  27423. if m.id == nil || m.oldValue == nil {
  27424. return v, errors.New("OldMAC requires an ID field in the mutation")
  27425. }
  27426. oldValue, err := m.oldValue(ctx)
  27427. if err != nil {
  27428. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27429. }
  27430. return oldValue.MAC, nil
  27431. }
  27432. // ClearMAC clears the value of the "mac" field.
  27433. func (m *TokenMutation) ClearMAC() {
  27434. m.mac = nil
  27435. m.clearedFields[token.FieldMAC] = struct{}{}
  27436. }
  27437. // MACCleared returns if the "mac" field was cleared in this mutation.
  27438. func (m *TokenMutation) MACCleared() bool {
  27439. _, ok := m.clearedFields[token.FieldMAC]
  27440. return ok
  27441. }
  27442. // ResetMAC resets all changes to the "mac" field.
  27443. func (m *TokenMutation) ResetMAC() {
  27444. m.mac = nil
  27445. delete(m.clearedFields, token.FieldMAC)
  27446. }
  27447. // SetOrganizationID sets the "organization_id" field.
  27448. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27449. m.organization_id = &u
  27450. m.addorganization_id = nil
  27451. }
  27452. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27453. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27454. v := m.organization_id
  27455. if v == nil {
  27456. return
  27457. }
  27458. return *v, true
  27459. }
  27460. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27461. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27463. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27464. if !m.op.Is(OpUpdateOne) {
  27465. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27466. }
  27467. if m.id == nil || m.oldValue == nil {
  27468. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27469. }
  27470. oldValue, err := m.oldValue(ctx)
  27471. if err != nil {
  27472. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27473. }
  27474. return oldValue.OrganizationID, nil
  27475. }
  27476. // AddOrganizationID adds u to the "organization_id" field.
  27477. func (m *TokenMutation) AddOrganizationID(u int64) {
  27478. if m.addorganization_id != nil {
  27479. *m.addorganization_id += u
  27480. } else {
  27481. m.addorganization_id = &u
  27482. }
  27483. }
  27484. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27485. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27486. v := m.addorganization_id
  27487. if v == nil {
  27488. return
  27489. }
  27490. return *v, true
  27491. }
  27492. // ResetOrganizationID resets all changes to the "organization_id" field.
  27493. func (m *TokenMutation) ResetOrganizationID() {
  27494. m.organization_id = nil
  27495. m.addorganization_id = nil
  27496. }
  27497. // SetAgentID sets the "agent_id" field.
  27498. func (m *TokenMutation) SetAgentID(u uint64) {
  27499. m.agent = &u
  27500. }
  27501. // AgentID returns the value of the "agent_id" field in the mutation.
  27502. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27503. v := m.agent
  27504. if v == nil {
  27505. return
  27506. }
  27507. return *v, true
  27508. }
  27509. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27510. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27512. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27513. if !m.op.Is(OpUpdateOne) {
  27514. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27515. }
  27516. if m.id == nil || m.oldValue == nil {
  27517. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27518. }
  27519. oldValue, err := m.oldValue(ctx)
  27520. if err != nil {
  27521. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27522. }
  27523. return oldValue.AgentID, nil
  27524. }
  27525. // ResetAgentID resets all changes to the "agent_id" field.
  27526. func (m *TokenMutation) ResetAgentID() {
  27527. m.agent = nil
  27528. }
  27529. // SetCustomAgentBase sets the "custom_agent_base" field.
  27530. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27531. m.custom_agent_base = &s
  27532. }
  27533. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27534. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27535. v := m.custom_agent_base
  27536. if v == nil {
  27537. return
  27538. }
  27539. return *v, true
  27540. }
  27541. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27542. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27544. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27545. if !m.op.Is(OpUpdateOne) {
  27546. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27547. }
  27548. if m.id == nil || m.oldValue == nil {
  27549. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27550. }
  27551. oldValue, err := m.oldValue(ctx)
  27552. if err != nil {
  27553. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27554. }
  27555. return oldValue.CustomAgentBase, nil
  27556. }
  27557. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27558. func (m *TokenMutation) ClearCustomAgentBase() {
  27559. m.custom_agent_base = nil
  27560. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27561. }
  27562. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27563. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27564. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27565. return ok
  27566. }
  27567. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27568. func (m *TokenMutation) ResetCustomAgentBase() {
  27569. m.custom_agent_base = nil
  27570. delete(m.clearedFields, token.FieldCustomAgentBase)
  27571. }
  27572. // SetCustomAgentKey sets the "custom_agent_key" field.
  27573. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27574. m.custom_agent_key = &s
  27575. }
  27576. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27577. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27578. v := m.custom_agent_key
  27579. if v == nil {
  27580. return
  27581. }
  27582. return *v, true
  27583. }
  27584. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27585. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27587. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27588. if !m.op.Is(OpUpdateOne) {
  27589. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27590. }
  27591. if m.id == nil || m.oldValue == nil {
  27592. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27593. }
  27594. oldValue, err := m.oldValue(ctx)
  27595. if err != nil {
  27596. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27597. }
  27598. return oldValue.CustomAgentKey, nil
  27599. }
  27600. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27601. func (m *TokenMutation) ClearCustomAgentKey() {
  27602. m.custom_agent_key = nil
  27603. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27604. }
  27605. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27606. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27607. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27608. return ok
  27609. }
  27610. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27611. func (m *TokenMutation) ResetCustomAgentKey() {
  27612. m.custom_agent_key = nil
  27613. delete(m.clearedFields, token.FieldCustomAgentKey)
  27614. }
  27615. // SetOpenaiBase sets the "openai_base" field.
  27616. func (m *TokenMutation) SetOpenaiBase(s string) {
  27617. m.openai_base = &s
  27618. }
  27619. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27620. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27621. v := m.openai_base
  27622. if v == nil {
  27623. return
  27624. }
  27625. return *v, true
  27626. }
  27627. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27628. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27630. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27631. if !m.op.Is(OpUpdateOne) {
  27632. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27633. }
  27634. if m.id == nil || m.oldValue == nil {
  27635. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  27636. }
  27637. oldValue, err := m.oldValue(ctx)
  27638. if err != nil {
  27639. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  27640. }
  27641. return oldValue.OpenaiBase, nil
  27642. }
  27643. // ClearOpenaiBase clears the value of the "openai_base" field.
  27644. func (m *TokenMutation) ClearOpenaiBase() {
  27645. m.openai_base = nil
  27646. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  27647. }
  27648. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  27649. func (m *TokenMutation) OpenaiBaseCleared() bool {
  27650. _, ok := m.clearedFields[token.FieldOpenaiBase]
  27651. return ok
  27652. }
  27653. // ResetOpenaiBase resets all changes to the "openai_base" field.
  27654. func (m *TokenMutation) ResetOpenaiBase() {
  27655. m.openai_base = nil
  27656. delete(m.clearedFields, token.FieldOpenaiBase)
  27657. }
  27658. // SetOpenaiKey sets the "openai_key" field.
  27659. func (m *TokenMutation) SetOpenaiKey(s string) {
  27660. m.openai_key = &s
  27661. }
  27662. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  27663. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  27664. v := m.openai_key
  27665. if v == nil {
  27666. return
  27667. }
  27668. return *v, true
  27669. }
  27670. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  27671. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27673. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  27674. if !m.op.Is(OpUpdateOne) {
  27675. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  27676. }
  27677. if m.id == nil || m.oldValue == nil {
  27678. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  27679. }
  27680. oldValue, err := m.oldValue(ctx)
  27681. if err != nil {
  27682. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  27683. }
  27684. return oldValue.OpenaiKey, nil
  27685. }
  27686. // ClearOpenaiKey clears the value of the "openai_key" field.
  27687. func (m *TokenMutation) ClearOpenaiKey() {
  27688. m.openai_key = nil
  27689. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  27690. }
  27691. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  27692. func (m *TokenMutation) OpenaiKeyCleared() bool {
  27693. _, ok := m.clearedFields[token.FieldOpenaiKey]
  27694. return ok
  27695. }
  27696. // ResetOpenaiKey resets all changes to the "openai_key" field.
  27697. func (m *TokenMutation) ResetOpenaiKey() {
  27698. m.openai_key = nil
  27699. delete(m.clearedFields, token.FieldOpenaiKey)
  27700. }
  27701. // ClearAgent clears the "agent" edge to the Agent entity.
  27702. func (m *TokenMutation) ClearAgent() {
  27703. m.clearedagent = true
  27704. m.clearedFields[token.FieldAgentID] = struct{}{}
  27705. }
  27706. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  27707. func (m *TokenMutation) AgentCleared() bool {
  27708. return m.clearedagent
  27709. }
  27710. // AgentIDs returns the "agent" edge IDs in the mutation.
  27711. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27712. // AgentID instead. It exists only for internal usage by the builders.
  27713. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  27714. if id := m.agent; id != nil {
  27715. ids = append(ids, *id)
  27716. }
  27717. return
  27718. }
  27719. // ResetAgent resets all changes to the "agent" edge.
  27720. func (m *TokenMutation) ResetAgent() {
  27721. m.agent = nil
  27722. m.clearedagent = false
  27723. }
  27724. // Where appends a list predicates to the TokenMutation builder.
  27725. func (m *TokenMutation) Where(ps ...predicate.Token) {
  27726. m.predicates = append(m.predicates, ps...)
  27727. }
  27728. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  27729. // users can use type-assertion to append predicates that do not depend on any generated package.
  27730. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  27731. p := make([]predicate.Token, len(ps))
  27732. for i := range ps {
  27733. p[i] = ps[i]
  27734. }
  27735. m.Where(p...)
  27736. }
  27737. // Op returns the operation name.
  27738. func (m *TokenMutation) Op() Op {
  27739. return m.op
  27740. }
  27741. // SetOp allows setting the mutation operation.
  27742. func (m *TokenMutation) SetOp(op Op) {
  27743. m.op = op
  27744. }
  27745. // Type returns the node type of this mutation (Token).
  27746. func (m *TokenMutation) Type() string {
  27747. return m.typ
  27748. }
  27749. // Fields returns all fields that were changed during this mutation. Note that in
  27750. // order to get all numeric fields that were incremented/decremented, call
  27751. // AddedFields().
  27752. func (m *TokenMutation) Fields() []string {
  27753. fields := make([]string, 0, 12)
  27754. if m.created_at != nil {
  27755. fields = append(fields, token.FieldCreatedAt)
  27756. }
  27757. if m.updated_at != nil {
  27758. fields = append(fields, token.FieldUpdatedAt)
  27759. }
  27760. if m.deleted_at != nil {
  27761. fields = append(fields, token.FieldDeletedAt)
  27762. }
  27763. if m.expire_at != nil {
  27764. fields = append(fields, token.FieldExpireAt)
  27765. }
  27766. if m.token != nil {
  27767. fields = append(fields, token.FieldToken)
  27768. }
  27769. if m.mac != nil {
  27770. fields = append(fields, token.FieldMAC)
  27771. }
  27772. if m.organization_id != nil {
  27773. fields = append(fields, token.FieldOrganizationID)
  27774. }
  27775. if m.agent != nil {
  27776. fields = append(fields, token.FieldAgentID)
  27777. }
  27778. if m.custom_agent_base != nil {
  27779. fields = append(fields, token.FieldCustomAgentBase)
  27780. }
  27781. if m.custom_agent_key != nil {
  27782. fields = append(fields, token.FieldCustomAgentKey)
  27783. }
  27784. if m.openai_base != nil {
  27785. fields = append(fields, token.FieldOpenaiBase)
  27786. }
  27787. if m.openai_key != nil {
  27788. fields = append(fields, token.FieldOpenaiKey)
  27789. }
  27790. return fields
  27791. }
  27792. // Field returns the value of a field with the given name. The second boolean
  27793. // return value indicates that this field was not set, or was not defined in the
  27794. // schema.
  27795. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  27796. switch name {
  27797. case token.FieldCreatedAt:
  27798. return m.CreatedAt()
  27799. case token.FieldUpdatedAt:
  27800. return m.UpdatedAt()
  27801. case token.FieldDeletedAt:
  27802. return m.DeletedAt()
  27803. case token.FieldExpireAt:
  27804. return m.ExpireAt()
  27805. case token.FieldToken:
  27806. return m.Token()
  27807. case token.FieldMAC:
  27808. return m.MAC()
  27809. case token.FieldOrganizationID:
  27810. return m.OrganizationID()
  27811. case token.FieldAgentID:
  27812. return m.AgentID()
  27813. case token.FieldCustomAgentBase:
  27814. return m.CustomAgentBase()
  27815. case token.FieldCustomAgentKey:
  27816. return m.CustomAgentKey()
  27817. case token.FieldOpenaiBase:
  27818. return m.OpenaiBase()
  27819. case token.FieldOpenaiKey:
  27820. return m.OpenaiKey()
  27821. }
  27822. return nil, false
  27823. }
  27824. // OldField returns the old value of the field from the database. An error is
  27825. // returned if the mutation operation is not UpdateOne, or the query to the
  27826. // database failed.
  27827. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27828. switch name {
  27829. case token.FieldCreatedAt:
  27830. return m.OldCreatedAt(ctx)
  27831. case token.FieldUpdatedAt:
  27832. return m.OldUpdatedAt(ctx)
  27833. case token.FieldDeletedAt:
  27834. return m.OldDeletedAt(ctx)
  27835. case token.FieldExpireAt:
  27836. return m.OldExpireAt(ctx)
  27837. case token.FieldToken:
  27838. return m.OldToken(ctx)
  27839. case token.FieldMAC:
  27840. return m.OldMAC(ctx)
  27841. case token.FieldOrganizationID:
  27842. return m.OldOrganizationID(ctx)
  27843. case token.FieldAgentID:
  27844. return m.OldAgentID(ctx)
  27845. case token.FieldCustomAgentBase:
  27846. return m.OldCustomAgentBase(ctx)
  27847. case token.FieldCustomAgentKey:
  27848. return m.OldCustomAgentKey(ctx)
  27849. case token.FieldOpenaiBase:
  27850. return m.OldOpenaiBase(ctx)
  27851. case token.FieldOpenaiKey:
  27852. return m.OldOpenaiKey(ctx)
  27853. }
  27854. return nil, fmt.Errorf("unknown Token field %s", name)
  27855. }
  27856. // SetField sets the value of a field with the given name. It returns an error if
  27857. // the field is not defined in the schema, or if the type mismatched the field
  27858. // type.
  27859. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  27860. switch name {
  27861. case token.FieldCreatedAt:
  27862. v, ok := value.(time.Time)
  27863. if !ok {
  27864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27865. }
  27866. m.SetCreatedAt(v)
  27867. return nil
  27868. case token.FieldUpdatedAt:
  27869. v, ok := value.(time.Time)
  27870. if !ok {
  27871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27872. }
  27873. m.SetUpdatedAt(v)
  27874. return nil
  27875. case token.FieldDeletedAt:
  27876. v, ok := value.(time.Time)
  27877. if !ok {
  27878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27879. }
  27880. m.SetDeletedAt(v)
  27881. return nil
  27882. case token.FieldExpireAt:
  27883. v, ok := value.(time.Time)
  27884. if !ok {
  27885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27886. }
  27887. m.SetExpireAt(v)
  27888. return nil
  27889. case token.FieldToken:
  27890. v, ok := value.(string)
  27891. if !ok {
  27892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27893. }
  27894. m.SetToken(v)
  27895. return nil
  27896. case token.FieldMAC:
  27897. v, ok := value.(string)
  27898. if !ok {
  27899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27900. }
  27901. m.SetMAC(v)
  27902. return nil
  27903. case token.FieldOrganizationID:
  27904. v, ok := value.(uint64)
  27905. if !ok {
  27906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27907. }
  27908. m.SetOrganizationID(v)
  27909. return nil
  27910. case token.FieldAgentID:
  27911. v, ok := value.(uint64)
  27912. if !ok {
  27913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27914. }
  27915. m.SetAgentID(v)
  27916. return nil
  27917. case token.FieldCustomAgentBase:
  27918. v, ok := value.(string)
  27919. if !ok {
  27920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27921. }
  27922. m.SetCustomAgentBase(v)
  27923. return nil
  27924. case token.FieldCustomAgentKey:
  27925. v, ok := value.(string)
  27926. if !ok {
  27927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27928. }
  27929. m.SetCustomAgentKey(v)
  27930. return nil
  27931. case token.FieldOpenaiBase:
  27932. v, ok := value.(string)
  27933. if !ok {
  27934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27935. }
  27936. m.SetOpenaiBase(v)
  27937. return nil
  27938. case token.FieldOpenaiKey:
  27939. v, ok := value.(string)
  27940. if !ok {
  27941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27942. }
  27943. m.SetOpenaiKey(v)
  27944. return nil
  27945. }
  27946. return fmt.Errorf("unknown Token field %s", name)
  27947. }
  27948. // AddedFields returns all numeric fields that were incremented/decremented during
  27949. // this mutation.
  27950. func (m *TokenMutation) AddedFields() []string {
  27951. var fields []string
  27952. if m.addorganization_id != nil {
  27953. fields = append(fields, token.FieldOrganizationID)
  27954. }
  27955. return fields
  27956. }
  27957. // AddedField returns the numeric value that was incremented/decremented on a field
  27958. // with the given name. The second boolean return value indicates that this field
  27959. // was not set, or was not defined in the schema.
  27960. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  27961. switch name {
  27962. case token.FieldOrganizationID:
  27963. return m.AddedOrganizationID()
  27964. }
  27965. return nil, false
  27966. }
  27967. // AddField adds the value to the field with the given name. It returns an error if
  27968. // the field is not defined in the schema, or if the type mismatched the field
  27969. // type.
  27970. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  27971. switch name {
  27972. case token.FieldOrganizationID:
  27973. v, ok := value.(int64)
  27974. if !ok {
  27975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27976. }
  27977. m.AddOrganizationID(v)
  27978. return nil
  27979. }
  27980. return fmt.Errorf("unknown Token numeric field %s", name)
  27981. }
  27982. // ClearedFields returns all nullable fields that were cleared during this
  27983. // mutation.
  27984. func (m *TokenMutation) ClearedFields() []string {
  27985. var fields []string
  27986. if m.FieldCleared(token.FieldDeletedAt) {
  27987. fields = append(fields, token.FieldDeletedAt)
  27988. }
  27989. if m.FieldCleared(token.FieldExpireAt) {
  27990. fields = append(fields, token.FieldExpireAt)
  27991. }
  27992. if m.FieldCleared(token.FieldToken) {
  27993. fields = append(fields, token.FieldToken)
  27994. }
  27995. if m.FieldCleared(token.FieldMAC) {
  27996. fields = append(fields, token.FieldMAC)
  27997. }
  27998. if m.FieldCleared(token.FieldCustomAgentBase) {
  27999. fields = append(fields, token.FieldCustomAgentBase)
  28000. }
  28001. if m.FieldCleared(token.FieldCustomAgentKey) {
  28002. fields = append(fields, token.FieldCustomAgentKey)
  28003. }
  28004. if m.FieldCleared(token.FieldOpenaiBase) {
  28005. fields = append(fields, token.FieldOpenaiBase)
  28006. }
  28007. if m.FieldCleared(token.FieldOpenaiKey) {
  28008. fields = append(fields, token.FieldOpenaiKey)
  28009. }
  28010. return fields
  28011. }
  28012. // FieldCleared returns a boolean indicating if a field with the given name was
  28013. // cleared in this mutation.
  28014. func (m *TokenMutation) FieldCleared(name string) bool {
  28015. _, ok := m.clearedFields[name]
  28016. return ok
  28017. }
  28018. // ClearField clears the value of the field with the given name. It returns an
  28019. // error if the field is not defined in the schema.
  28020. func (m *TokenMutation) ClearField(name string) error {
  28021. switch name {
  28022. case token.FieldDeletedAt:
  28023. m.ClearDeletedAt()
  28024. return nil
  28025. case token.FieldExpireAt:
  28026. m.ClearExpireAt()
  28027. return nil
  28028. case token.FieldToken:
  28029. m.ClearToken()
  28030. return nil
  28031. case token.FieldMAC:
  28032. m.ClearMAC()
  28033. return nil
  28034. case token.FieldCustomAgentBase:
  28035. m.ClearCustomAgentBase()
  28036. return nil
  28037. case token.FieldCustomAgentKey:
  28038. m.ClearCustomAgentKey()
  28039. return nil
  28040. case token.FieldOpenaiBase:
  28041. m.ClearOpenaiBase()
  28042. return nil
  28043. case token.FieldOpenaiKey:
  28044. m.ClearOpenaiKey()
  28045. return nil
  28046. }
  28047. return fmt.Errorf("unknown Token nullable field %s", name)
  28048. }
  28049. // ResetField resets all changes in the mutation for the field with the given name.
  28050. // It returns an error if the field is not defined in the schema.
  28051. func (m *TokenMutation) ResetField(name string) error {
  28052. switch name {
  28053. case token.FieldCreatedAt:
  28054. m.ResetCreatedAt()
  28055. return nil
  28056. case token.FieldUpdatedAt:
  28057. m.ResetUpdatedAt()
  28058. return nil
  28059. case token.FieldDeletedAt:
  28060. m.ResetDeletedAt()
  28061. return nil
  28062. case token.FieldExpireAt:
  28063. m.ResetExpireAt()
  28064. return nil
  28065. case token.FieldToken:
  28066. m.ResetToken()
  28067. return nil
  28068. case token.FieldMAC:
  28069. m.ResetMAC()
  28070. return nil
  28071. case token.FieldOrganizationID:
  28072. m.ResetOrganizationID()
  28073. return nil
  28074. case token.FieldAgentID:
  28075. m.ResetAgentID()
  28076. return nil
  28077. case token.FieldCustomAgentBase:
  28078. m.ResetCustomAgentBase()
  28079. return nil
  28080. case token.FieldCustomAgentKey:
  28081. m.ResetCustomAgentKey()
  28082. return nil
  28083. case token.FieldOpenaiBase:
  28084. m.ResetOpenaiBase()
  28085. return nil
  28086. case token.FieldOpenaiKey:
  28087. m.ResetOpenaiKey()
  28088. return nil
  28089. }
  28090. return fmt.Errorf("unknown Token field %s", name)
  28091. }
  28092. // AddedEdges returns all edge names that were set/added in this mutation.
  28093. func (m *TokenMutation) AddedEdges() []string {
  28094. edges := make([]string, 0, 1)
  28095. if m.agent != nil {
  28096. edges = append(edges, token.EdgeAgent)
  28097. }
  28098. return edges
  28099. }
  28100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28101. // name in this mutation.
  28102. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28103. switch name {
  28104. case token.EdgeAgent:
  28105. if id := m.agent; id != nil {
  28106. return []ent.Value{*id}
  28107. }
  28108. }
  28109. return nil
  28110. }
  28111. // RemovedEdges returns all edge names that were removed in this mutation.
  28112. func (m *TokenMutation) RemovedEdges() []string {
  28113. edges := make([]string, 0, 1)
  28114. return edges
  28115. }
  28116. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28117. // the given name in this mutation.
  28118. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28119. return nil
  28120. }
  28121. // ClearedEdges returns all edge names that were cleared in this mutation.
  28122. func (m *TokenMutation) ClearedEdges() []string {
  28123. edges := make([]string, 0, 1)
  28124. if m.clearedagent {
  28125. edges = append(edges, token.EdgeAgent)
  28126. }
  28127. return edges
  28128. }
  28129. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28130. // was cleared in this mutation.
  28131. func (m *TokenMutation) EdgeCleared(name string) bool {
  28132. switch name {
  28133. case token.EdgeAgent:
  28134. return m.clearedagent
  28135. }
  28136. return false
  28137. }
  28138. // ClearEdge clears the value of the edge with the given name. It returns an error
  28139. // if that edge is not defined in the schema.
  28140. func (m *TokenMutation) ClearEdge(name string) error {
  28141. switch name {
  28142. case token.EdgeAgent:
  28143. m.ClearAgent()
  28144. return nil
  28145. }
  28146. return fmt.Errorf("unknown Token unique edge %s", name)
  28147. }
  28148. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28149. // It returns an error if the edge is not defined in the schema.
  28150. func (m *TokenMutation) ResetEdge(name string) error {
  28151. switch name {
  28152. case token.EdgeAgent:
  28153. m.ResetAgent()
  28154. return nil
  28155. }
  28156. return fmt.Errorf("unknown Token edge %s", name)
  28157. }
  28158. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28159. type TutorialMutation struct {
  28160. config
  28161. op Op
  28162. typ string
  28163. id *uint64
  28164. created_at *time.Time
  28165. updated_at *time.Time
  28166. deleted_at *time.Time
  28167. index *int
  28168. addindex *int
  28169. title *string
  28170. content *string
  28171. organization_id *uint64
  28172. addorganization_id *int64
  28173. clearedFields map[string]struct{}
  28174. employee *uint64
  28175. clearedemployee bool
  28176. done bool
  28177. oldValue func(context.Context) (*Tutorial, error)
  28178. predicates []predicate.Tutorial
  28179. }
  28180. var _ ent.Mutation = (*TutorialMutation)(nil)
  28181. // tutorialOption allows management of the mutation configuration using functional options.
  28182. type tutorialOption func(*TutorialMutation)
  28183. // newTutorialMutation creates new mutation for the Tutorial entity.
  28184. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28185. m := &TutorialMutation{
  28186. config: c,
  28187. op: op,
  28188. typ: TypeTutorial,
  28189. clearedFields: make(map[string]struct{}),
  28190. }
  28191. for _, opt := range opts {
  28192. opt(m)
  28193. }
  28194. return m
  28195. }
  28196. // withTutorialID sets the ID field of the mutation.
  28197. func withTutorialID(id uint64) tutorialOption {
  28198. return func(m *TutorialMutation) {
  28199. var (
  28200. err error
  28201. once sync.Once
  28202. value *Tutorial
  28203. )
  28204. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28205. once.Do(func() {
  28206. if m.done {
  28207. err = errors.New("querying old values post mutation is not allowed")
  28208. } else {
  28209. value, err = m.Client().Tutorial.Get(ctx, id)
  28210. }
  28211. })
  28212. return value, err
  28213. }
  28214. m.id = &id
  28215. }
  28216. }
  28217. // withTutorial sets the old Tutorial of the mutation.
  28218. func withTutorial(node *Tutorial) tutorialOption {
  28219. return func(m *TutorialMutation) {
  28220. m.oldValue = func(context.Context) (*Tutorial, error) {
  28221. return node, nil
  28222. }
  28223. m.id = &node.ID
  28224. }
  28225. }
  28226. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28227. // executed in a transaction (ent.Tx), a transactional client is returned.
  28228. func (m TutorialMutation) Client() *Client {
  28229. client := &Client{config: m.config}
  28230. client.init()
  28231. return client
  28232. }
  28233. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28234. // it returns an error otherwise.
  28235. func (m TutorialMutation) Tx() (*Tx, error) {
  28236. if _, ok := m.driver.(*txDriver); !ok {
  28237. return nil, errors.New("ent: mutation is not running in a transaction")
  28238. }
  28239. tx := &Tx{config: m.config}
  28240. tx.init()
  28241. return tx, nil
  28242. }
  28243. // SetID sets the value of the id field. Note that this
  28244. // operation is only accepted on creation of Tutorial entities.
  28245. func (m *TutorialMutation) SetID(id uint64) {
  28246. m.id = &id
  28247. }
  28248. // ID returns the ID value in the mutation. Note that the ID is only available
  28249. // if it was provided to the builder or after it was returned from the database.
  28250. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28251. if m.id == nil {
  28252. return
  28253. }
  28254. return *m.id, true
  28255. }
  28256. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28257. // That means, if the mutation is applied within a transaction with an isolation level such
  28258. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28259. // or updated by the mutation.
  28260. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28261. switch {
  28262. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28263. id, exists := m.ID()
  28264. if exists {
  28265. return []uint64{id}, nil
  28266. }
  28267. fallthrough
  28268. case m.op.Is(OpUpdate | OpDelete):
  28269. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28270. default:
  28271. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28272. }
  28273. }
  28274. // SetCreatedAt sets the "created_at" field.
  28275. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28276. m.created_at = &t
  28277. }
  28278. // CreatedAt returns the value of the "created_at" field in the mutation.
  28279. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28280. v := m.created_at
  28281. if v == nil {
  28282. return
  28283. }
  28284. return *v, true
  28285. }
  28286. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28287. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28289. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28290. if !m.op.Is(OpUpdateOne) {
  28291. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28292. }
  28293. if m.id == nil || m.oldValue == nil {
  28294. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28295. }
  28296. oldValue, err := m.oldValue(ctx)
  28297. if err != nil {
  28298. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28299. }
  28300. return oldValue.CreatedAt, nil
  28301. }
  28302. // ResetCreatedAt resets all changes to the "created_at" field.
  28303. func (m *TutorialMutation) ResetCreatedAt() {
  28304. m.created_at = nil
  28305. }
  28306. // SetUpdatedAt sets the "updated_at" field.
  28307. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28308. m.updated_at = &t
  28309. }
  28310. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28311. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28312. v := m.updated_at
  28313. if v == nil {
  28314. return
  28315. }
  28316. return *v, true
  28317. }
  28318. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28319. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28321. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28322. if !m.op.Is(OpUpdateOne) {
  28323. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28324. }
  28325. if m.id == nil || m.oldValue == nil {
  28326. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28327. }
  28328. oldValue, err := m.oldValue(ctx)
  28329. if err != nil {
  28330. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28331. }
  28332. return oldValue.UpdatedAt, nil
  28333. }
  28334. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28335. func (m *TutorialMutation) ResetUpdatedAt() {
  28336. m.updated_at = nil
  28337. }
  28338. // SetDeletedAt sets the "deleted_at" field.
  28339. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28340. m.deleted_at = &t
  28341. }
  28342. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28343. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28344. v := m.deleted_at
  28345. if v == nil {
  28346. return
  28347. }
  28348. return *v, true
  28349. }
  28350. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28351. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28353. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28354. if !m.op.Is(OpUpdateOne) {
  28355. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28356. }
  28357. if m.id == nil || m.oldValue == nil {
  28358. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28359. }
  28360. oldValue, err := m.oldValue(ctx)
  28361. if err != nil {
  28362. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28363. }
  28364. return oldValue.DeletedAt, nil
  28365. }
  28366. // ClearDeletedAt clears the value of the "deleted_at" field.
  28367. func (m *TutorialMutation) ClearDeletedAt() {
  28368. m.deleted_at = nil
  28369. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28370. }
  28371. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28372. func (m *TutorialMutation) DeletedAtCleared() bool {
  28373. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28374. return ok
  28375. }
  28376. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28377. func (m *TutorialMutation) ResetDeletedAt() {
  28378. m.deleted_at = nil
  28379. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28380. }
  28381. // SetEmployeeID sets the "employee_id" field.
  28382. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28383. m.employee = &u
  28384. }
  28385. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28386. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28387. v := m.employee
  28388. if v == nil {
  28389. return
  28390. }
  28391. return *v, true
  28392. }
  28393. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28394. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28396. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28397. if !m.op.Is(OpUpdateOne) {
  28398. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28399. }
  28400. if m.id == nil || m.oldValue == nil {
  28401. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28402. }
  28403. oldValue, err := m.oldValue(ctx)
  28404. if err != nil {
  28405. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28406. }
  28407. return oldValue.EmployeeID, nil
  28408. }
  28409. // ResetEmployeeID resets all changes to the "employee_id" field.
  28410. func (m *TutorialMutation) ResetEmployeeID() {
  28411. m.employee = nil
  28412. }
  28413. // SetIndex sets the "index" field.
  28414. func (m *TutorialMutation) SetIndex(i int) {
  28415. m.index = &i
  28416. m.addindex = nil
  28417. }
  28418. // Index returns the value of the "index" field in the mutation.
  28419. func (m *TutorialMutation) Index() (r int, exists bool) {
  28420. v := m.index
  28421. if v == nil {
  28422. return
  28423. }
  28424. return *v, true
  28425. }
  28426. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28427. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28429. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28430. if !m.op.Is(OpUpdateOne) {
  28431. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28432. }
  28433. if m.id == nil || m.oldValue == nil {
  28434. return v, errors.New("OldIndex requires an ID field in the mutation")
  28435. }
  28436. oldValue, err := m.oldValue(ctx)
  28437. if err != nil {
  28438. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28439. }
  28440. return oldValue.Index, nil
  28441. }
  28442. // AddIndex adds i to the "index" field.
  28443. func (m *TutorialMutation) AddIndex(i int) {
  28444. if m.addindex != nil {
  28445. *m.addindex += i
  28446. } else {
  28447. m.addindex = &i
  28448. }
  28449. }
  28450. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28451. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28452. v := m.addindex
  28453. if v == nil {
  28454. return
  28455. }
  28456. return *v, true
  28457. }
  28458. // ResetIndex resets all changes to the "index" field.
  28459. func (m *TutorialMutation) ResetIndex() {
  28460. m.index = nil
  28461. m.addindex = nil
  28462. }
  28463. // SetTitle sets the "title" field.
  28464. func (m *TutorialMutation) SetTitle(s string) {
  28465. m.title = &s
  28466. }
  28467. // Title returns the value of the "title" field in the mutation.
  28468. func (m *TutorialMutation) Title() (r string, exists bool) {
  28469. v := m.title
  28470. if v == nil {
  28471. return
  28472. }
  28473. return *v, true
  28474. }
  28475. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28476. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28478. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28479. if !m.op.Is(OpUpdateOne) {
  28480. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28481. }
  28482. if m.id == nil || m.oldValue == nil {
  28483. return v, errors.New("OldTitle requires an ID field in the mutation")
  28484. }
  28485. oldValue, err := m.oldValue(ctx)
  28486. if err != nil {
  28487. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28488. }
  28489. return oldValue.Title, nil
  28490. }
  28491. // ResetTitle resets all changes to the "title" field.
  28492. func (m *TutorialMutation) ResetTitle() {
  28493. m.title = nil
  28494. }
  28495. // SetContent sets the "content" field.
  28496. func (m *TutorialMutation) SetContent(s string) {
  28497. m.content = &s
  28498. }
  28499. // Content returns the value of the "content" field in the mutation.
  28500. func (m *TutorialMutation) Content() (r string, exists bool) {
  28501. v := m.content
  28502. if v == nil {
  28503. return
  28504. }
  28505. return *v, true
  28506. }
  28507. // OldContent returns the old "content" field's value of the Tutorial entity.
  28508. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28510. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28511. if !m.op.Is(OpUpdateOne) {
  28512. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28513. }
  28514. if m.id == nil || m.oldValue == nil {
  28515. return v, errors.New("OldContent requires an ID field in the mutation")
  28516. }
  28517. oldValue, err := m.oldValue(ctx)
  28518. if err != nil {
  28519. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28520. }
  28521. return oldValue.Content, nil
  28522. }
  28523. // ResetContent resets all changes to the "content" field.
  28524. func (m *TutorialMutation) ResetContent() {
  28525. m.content = nil
  28526. }
  28527. // SetOrganizationID sets the "organization_id" field.
  28528. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28529. m.organization_id = &u
  28530. m.addorganization_id = nil
  28531. }
  28532. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28533. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28534. v := m.organization_id
  28535. if v == nil {
  28536. return
  28537. }
  28538. return *v, true
  28539. }
  28540. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28541. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28543. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28544. if !m.op.Is(OpUpdateOne) {
  28545. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28546. }
  28547. if m.id == nil || m.oldValue == nil {
  28548. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28549. }
  28550. oldValue, err := m.oldValue(ctx)
  28551. if err != nil {
  28552. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28553. }
  28554. return oldValue.OrganizationID, nil
  28555. }
  28556. // AddOrganizationID adds u to the "organization_id" field.
  28557. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28558. if m.addorganization_id != nil {
  28559. *m.addorganization_id += u
  28560. } else {
  28561. m.addorganization_id = &u
  28562. }
  28563. }
  28564. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28565. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28566. v := m.addorganization_id
  28567. if v == nil {
  28568. return
  28569. }
  28570. return *v, true
  28571. }
  28572. // ResetOrganizationID resets all changes to the "organization_id" field.
  28573. func (m *TutorialMutation) ResetOrganizationID() {
  28574. m.organization_id = nil
  28575. m.addorganization_id = nil
  28576. }
  28577. // ClearEmployee clears the "employee" edge to the Employee entity.
  28578. func (m *TutorialMutation) ClearEmployee() {
  28579. m.clearedemployee = true
  28580. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28581. }
  28582. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28583. func (m *TutorialMutation) EmployeeCleared() bool {
  28584. return m.clearedemployee
  28585. }
  28586. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28587. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28588. // EmployeeID instead. It exists only for internal usage by the builders.
  28589. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28590. if id := m.employee; id != nil {
  28591. ids = append(ids, *id)
  28592. }
  28593. return
  28594. }
  28595. // ResetEmployee resets all changes to the "employee" edge.
  28596. func (m *TutorialMutation) ResetEmployee() {
  28597. m.employee = nil
  28598. m.clearedemployee = false
  28599. }
  28600. // Where appends a list predicates to the TutorialMutation builder.
  28601. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28602. m.predicates = append(m.predicates, ps...)
  28603. }
  28604. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28605. // users can use type-assertion to append predicates that do not depend on any generated package.
  28606. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28607. p := make([]predicate.Tutorial, len(ps))
  28608. for i := range ps {
  28609. p[i] = ps[i]
  28610. }
  28611. m.Where(p...)
  28612. }
  28613. // Op returns the operation name.
  28614. func (m *TutorialMutation) Op() Op {
  28615. return m.op
  28616. }
  28617. // SetOp allows setting the mutation operation.
  28618. func (m *TutorialMutation) SetOp(op Op) {
  28619. m.op = op
  28620. }
  28621. // Type returns the node type of this mutation (Tutorial).
  28622. func (m *TutorialMutation) Type() string {
  28623. return m.typ
  28624. }
  28625. // Fields returns all fields that were changed during this mutation. Note that in
  28626. // order to get all numeric fields that were incremented/decremented, call
  28627. // AddedFields().
  28628. func (m *TutorialMutation) Fields() []string {
  28629. fields := make([]string, 0, 8)
  28630. if m.created_at != nil {
  28631. fields = append(fields, tutorial.FieldCreatedAt)
  28632. }
  28633. if m.updated_at != nil {
  28634. fields = append(fields, tutorial.FieldUpdatedAt)
  28635. }
  28636. if m.deleted_at != nil {
  28637. fields = append(fields, tutorial.FieldDeletedAt)
  28638. }
  28639. if m.employee != nil {
  28640. fields = append(fields, tutorial.FieldEmployeeID)
  28641. }
  28642. if m.index != nil {
  28643. fields = append(fields, tutorial.FieldIndex)
  28644. }
  28645. if m.title != nil {
  28646. fields = append(fields, tutorial.FieldTitle)
  28647. }
  28648. if m.content != nil {
  28649. fields = append(fields, tutorial.FieldContent)
  28650. }
  28651. if m.organization_id != nil {
  28652. fields = append(fields, tutorial.FieldOrganizationID)
  28653. }
  28654. return fields
  28655. }
  28656. // Field returns the value of a field with the given name. The second boolean
  28657. // return value indicates that this field was not set, or was not defined in the
  28658. // schema.
  28659. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  28660. switch name {
  28661. case tutorial.FieldCreatedAt:
  28662. return m.CreatedAt()
  28663. case tutorial.FieldUpdatedAt:
  28664. return m.UpdatedAt()
  28665. case tutorial.FieldDeletedAt:
  28666. return m.DeletedAt()
  28667. case tutorial.FieldEmployeeID:
  28668. return m.EmployeeID()
  28669. case tutorial.FieldIndex:
  28670. return m.Index()
  28671. case tutorial.FieldTitle:
  28672. return m.Title()
  28673. case tutorial.FieldContent:
  28674. return m.Content()
  28675. case tutorial.FieldOrganizationID:
  28676. return m.OrganizationID()
  28677. }
  28678. return nil, false
  28679. }
  28680. // OldField returns the old value of the field from the database. An error is
  28681. // returned if the mutation operation is not UpdateOne, or the query to the
  28682. // database failed.
  28683. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28684. switch name {
  28685. case tutorial.FieldCreatedAt:
  28686. return m.OldCreatedAt(ctx)
  28687. case tutorial.FieldUpdatedAt:
  28688. return m.OldUpdatedAt(ctx)
  28689. case tutorial.FieldDeletedAt:
  28690. return m.OldDeletedAt(ctx)
  28691. case tutorial.FieldEmployeeID:
  28692. return m.OldEmployeeID(ctx)
  28693. case tutorial.FieldIndex:
  28694. return m.OldIndex(ctx)
  28695. case tutorial.FieldTitle:
  28696. return m.OldTitle(ctx)
  28697. case tutorial.FieldContent:
  28698. return m.OldContent(ctx)
  28699. case tutorial.FieldOrganizationID:
  28700. return m.OldOrganizationID(ctx)
  28701. }
  28702. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  28703. }
  28704. // SetField sets the value of a field with the given name. It returns an error if
  28705. // the field is not defined in the schema, or if the type mismatched the field
  28706. // type.
  28707. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  28708. switch name {
  28709. case tutorial.FieldCreatedAt:
  28710. v, ok := value.(time.Time)
  28711. if !ok {
  28712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28713. }
  28714. m.SetCreatedAt(v)
  28715. return nil
  28716. case tutorial.FieldUpdatedAt:
  28717. v, ok := value.(time.Time)
  28718. if !ok {
  28719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28720. }
  28721. m.SetUpdatedAt(v)
  28722. return nil
  28723. case tutorial.FieldDeletedAt:
  28724. v, ok := value.(time.Time)
  28725. if !ok {
  28726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28727. }
  28728. m.SetDeletedAt(v)
  28729. return nil
  28730. case tutorial.FieldEmployeeID:
  28731. v, ok := value.(uint64)
  28732. if !ok {
  28733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28734. }
  28735. m.SetEmployeeID(v)
  28736. return nil
  28737. case tutorial.FieldIndex:
  28738. v, ok := value.(int)
  28739. if !ok {
  28740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28741. }
  28742. m.SetIndex(v)
  28743. return nil
  28744. case tutorial.FieldTitle:
  28745. v, ok := value.(string)
  28746. if !ok {
  28747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28748. }
  28749. m.SetTitle(v)
  28750. return nil
  28751. case tutorial.FieldContent:
  28752. v, ok := value.(string)
  28753. if !ok {
  28754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28755. }
  28756. m.SetContent(v)
  28757. return nil
  28758. case tutorial.FieldOrganizationID:
  28759. v, ok := value.(uint64)
  28760. if !ok {
  28761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28762. }
  28763. m.SetOrganizationID(v)
  28764. return nil
  28765. }
  28766. return fmt.Errorf("unknown Tutorial field %s", name)
  28767. }
  28768. // AddedFields returns all numeric fields that were incremented/decremented during
  28769. // this mutation.
  28770. func (m *TutorialMutation) AddedFields() []string {
  28771. var fields []string
  28772. if m.addindex != nil {
  28773. fields = append(fields, tutorial.FieldIndex)
  28774. }
  28775. if m.addorganization_id != nil {
  28776. fields = append(fields, tutorial.FieldOrganizationID)
  28777. }
  28778. return fields
  28779. }
  28780. // AddedField returns the numeric value that was incremented/decremented on a field
  28781. // with the given name. The second boolean return value indicates that this field
  28782. // was not set, or was not defined in the schema.
  28783. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  28784. switch name {
  28785. case tutorial.FieldIndex:
  28786. return m.AddedIndex()
  28787. case tutorial.FieldOrganizationID:
  28788. return m.AddedOrganizationID()
  28789. }
  28790. return nil, false
  28791. }
  28792. // AddField adds the value to the field with the given name. It returns an error if
  28793. // the field is not defined in the schema, or if the type mismatched the field
  28794. // type.
  28795. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  28796. switch name {
  28797. case tutorial.FieldIndex:
  28798. v, ok := value.(int)
  28799. if !ok {
  28800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28801. }
  28802. m.AddIndex(v)
  28803. return nil
  28804. case tutorial.FieldOrganizationID:
  28805. v, ok := value.(int64)
  28806. if !ok {
  28807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28808. }
  28809. m.AddOrganizationID(v)
  28810. return nil
  28811. }
  28812. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  28813. }
  28814. // ClearedFields returns all nullable fields that were cleared during this
  28815. // mutation.
  28816. func (m *TutorialMutation) ClearedFields() []string {
  28817. var fields []string
  28818. if m.FieldCleared(tutorial.FieldDeletedAt) {
  28819. fields = append(fields, tutorial.FieldDeletedAt)
  28820. }
  28821. return fields
  28822. }
  28823. // FieldCleared returns a boolean indicating if a field with the given name was
  28824. // cleared in this mutation.
  28825. func (m *TutorialMutation) FieldCleared(name string) bool {
  28826. _, ok := m.clearedFields[name]
  28827. return ok
  28828. }
  28829. // ClearField clears the value of the field with the given name. It returns an
  28830. // error if the field is not defined in the schema.
  28831. func (m *TutorialMutation) ClearField(name string) error {
  28832. switch name {
  28833. case tutorial.FieldDeletedAt:
  28834. m.ClearDeletedAt()
  28835. return nil
  28836. }
  28837. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  28838. }
  28839. // ResetField resets all changes in the mutation for the field with the given name.
  28840. // It returns an error if the field is not defined in the schema.
  28841. func (m *TutorialMutation) ResetField(name string) error {
  28842. switch name {
  28843. case tutorial.FieldCreatedAt:
  28844. m.ResetCreatedAt()
  28845. return nil
  28846. case tutorial.FieldUpdatedAt:
  28847. m.ResetUpdatedAt()
  28848. return nil
  28849. case tutorial.FieldDeletedAt:
  28850. m.ResetDeletedAt()
  28851. return nil
  28852. case tutorial.FieldEmployeeID:
  28853. m.ResetEmployeeID()
  28854. return nil
  28855. case tutorial.FieldIndex:
  28856. m.ResetIndex()
  28857. return nil
  28858. case tutorial.FieldTitle:
  28859. m.ResetTitle()
  28860. return nil
  28861. case tutorial.FieldContent:
  28862. m.ResetContent()
  28863. return nil
  28864. case tutorial.FieldOrganizationID:
  28865. m.ResetOrganizationID()
  28866. return nil
  28867. }
  28868. return fmt.Errorf("unknown Tutorial field %s", name)
  28869. }
  28870. // AddedEdges returns all edge names that were set/added in this mutation.
  28871. func (m *TutorialMutation) AddedEdges() []string {
  28872. edges := make([]string, 0, 1)
  28873. if m.employee != nil {
  28874. edges = append(edges, tutorial.EdgeEmployee)
  28875. }
  28876. return edges
  28877. }
  28878. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28879. // name in this mutation.
  28880. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  28881. switch name {
  28882. case tutorial.EdgeEmployee:
  28883. if id := m.employee; id != nil {
  28884. return []ent.Value{*id}
  28885. }
  28886. }
  28887. return nil
  28888. }
  28889. // RemovedEdges returns all edge names that were removed in this mutation.
  28890. func (m *TutorialMutation) RemovedEdges() []string {
  28891. edges := make([]string, 0, 1)
  28892. return edges
  28893. }
  28894. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28895. // the given name in this mutation.
  28896. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  28897. return nil
  28898. }
  28899. // ClearedEdges returns all edge names that were cleared in this mutation.
  28900. func (m *TutorialMutation) ClearedEdges() []string {
  28901. edges := make([]string, 0, 1)
  28902. if m.clearedemployee {
  28903. edges = append(edges, tutorial.EdgeEmployee)
  28904. }
  28905. return edges
  28906. }
  28907. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28908. // was cleared in this mutation.
  28909. func (m *TutorialMutation) EdgeCleared(name string) bool {
  28910. switch name {
  28911. case tutorial.EdgeEmployee:
  28912. return m.clearedemployee
  28913. }
  28914. return false
  28915. }
  28916. // ClearEdge clears the value of the edge with the given name. It returns an error
  28917. // if that edge is not defined in the schema.
  28918. func (m *TutorialMutation) ClearEdge(name string) error {
  28919. switch name {
  28920. case tutorial.EdgeEmployee:
  28921. m.ClearEmployee()
  28922. return nil
  28923. }
  28924. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  28925. }
  28926. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28927. // It returns an error if the edge is not defined in the schema.
  28928. func (m *TutorialMutation) ResetEdge(name string) error {
  28929. switch name {
  28930. case tutorial.EdgeEmployee:
  28931. m.ResetEmployee()
  28932. return nil
  28933. }
  28934. return fmt.Errorf("unknown Tutorial edge %s", name)
  28935. }
  28936. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  28937. type UsageDetailMutation struct {
  28938. config
  28939. op Op
  28940. typ string
  28941. id *uint64
  28942. created_at *time.Time
  28943. updated_at *time.Time
  28944. status *uint8
  28945. addstatus *int8
  28946. _type *int
  28947. add_type *int
  28948. bot_id *string
  28949. receiver_id *string
  28950. app *int
  28951. addapp *int
  28952. session_id *uint64
  28953. addsession_id *int64
  28954. request *string
  28955. response *string
  28956. original_data *custom_types.OriginalData
  28957. total_tokens *uint64
  28958. addtotal_tokens *int64
  28959. prompt_tokens *uint64
  28960. addprompt_tokens *int64
  28961. completion_tokens *uint64
  28962. addcompletion_tokens *int64
  28963. organization_id *uint64
  28964. addorganization_id *int64
  28965. clearedFields map[string]struct{}
  28966. done bool
  28967. oldValue func(context.Context) (*UsageDetail, error)
  28968. predicates []predicate.UsageDetail
  28969. }
  28970. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  28971. // usagedetailOption allows management of the mutation configuration using functional options.
  28972. type usagedetailOption func(*UsageDetailMutation)
  28973. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  28974. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  28975. m := &UsageDetailMutation{
  28976. config: c,
  28977. op: op,
  28978. typ: TypeUsageDetail,
  28979. clearedFields: make(map[string]struct{}),
  28980. }
  28981. for _, opt := range opts {
  28982. opt(m)
  28983. }
  28984. return m
  28985. }
  28986. // withUsageDetailID sets the ID field of the mutation.
  28987. func withUsageDetailID(id uint64) usagedetailOption {
  28988. return func(m *UsageDetailMutation) {
  28989. var (
  28990. err error
  28991. once sync.Once
  28992. value *UsageDetail
  28993. )
  28994. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  28995. once.Do(func() {
  28996. if m.done {
  28997. err = errors.New("querying old values post mutation is not allowed")
  28998. } else {
  28999. value, err = m.Client().UsageDetail.Get(ctx, id)
  29000. }
  29001. })
  29002. return value, err
  29003. }
  29004. m.id = &id
  29005. }
  29006. }
  29007. // withUsageDetail sets the old UsageDetail of the mutation.
  29008. func withUsageDetail(node *UsageDetail) usagedetailOption {
  29009. return func(m *UsageDetailMutation) {
  29010. m.oldValue = func(context.Context) (*UsageDetail, error) {
  29011. return node, nil
  29012. }
  29013. m.id = &node.ID
  29014. }
  29015. }
  29016. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29017. // executed in a transaction (ent.Tx), a transactional client is returned.
  29018. func (m UsageDetailMutation) Client() *Client {
  29019. client := &Client{config: m.config}
  29020. client.init()
  29021. return client
  29022. }
  29023. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29024. // it returns an error otherwise.
  29025. func (m UsageDetailMutation) Tx() (*Tx, error) {
  29026. if _, ok := m.driver.(*txDriver); !ok {
  29027. return nil, errors.New("ent: mutation is not running in a transaction")
  29028. }
  29029. tx := &Tx{config: m.config}
  29030. tx.init()
  29031. return tx, nil
  29032. }
  29033. // SetID sets the value of the id field. Note that this
  29034. // operation is only accepted on creation of UsageDetail entities.
  29035. func (m *UsageDetailMutation) SetID(id uint64) {
  29036. m.id = &id
  29037. }
  29038. // ID returns the ID value in the mutation. Note that the ID is only available
  29039. // if it was provided to the builder or after it was returned from the database.
  29040. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  29041. if m.id == nil {
  29042. return
  29043. }
  29044. return *m.id, true
  29045. }
  29046. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29047. // That means, if the mutation is applied within a transaction with an isolation level such
  29048. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29049. // or updated by the mutation.
  29050. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  29051. switch {
  29052. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29053. id, exists := m.ID()
  29054. if exists {
  29055. return []uint64{id}, nil
  29056. }
  29057. fallthrough
  29058. case m.op.Is(OpUpdate | OpDelete):
  29059. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  29060. default:
  29061. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29062. }
  29063. }
  29064. // SetCreatedAt sets the "created_at" field.
  29065. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  29066. m.created_at = &t
  29067. }
  29068. // CreatedAt returns the value of the "created_at" field in the mutation.
  29069. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  29070. v := m.created_at
  29071. if v == nil {
  29072. return
  29073. }
  29074. return *v, true
  29075. }
  29076. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  29077. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29079. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29080. if !m.op.Is(OpUpdateOne) {
  29081. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29082. }
  29083. if m.id == nil || m.oldValue == nil {
  29084. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29085. }
  29086. oldValue, err := m.oldValue(ctx)
  29087. if err != nil {
  29088. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29089. }
  29090. return oldValue.CreatedAt, nil
  29091. }
  29092. // ResetCreatedAt resets all changes to the "created_at" field.
  29093. func (m *UsageDetailMutation) ResetCreatedAt() {
  29094. m.created_at = nil
  29095. }
  29096. // SetUpdatedAt sets the "updated_at" field.
  29097. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29098. m.updated_at = &t
  29099. }
  29100. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29101. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29102. v := m.updated_at
  29103. if v == nil {
  29104. return
  29105. }
  29106. return *v, true
  29107. }
  29108. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29109. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29111. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29112. if !m.op.Is(OpUpdateOne) {
  29113. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29114. }
  29115. if m.id == nil || m.oldValue == nil {
  29116. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29117. }
  29118. oldValue, err := m.oldValue(ctx)
  29119. if err != nil {
  29120. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29121. }
  29122. return oldValue.UpdatedAt, nil
  29123. }
  29124. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29125. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29126. m.updated_at = nil
  29127. }
  29128. // SetStatus sets the "status" field.
  29129. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29130. m.status = &u
  29131. m.addstatus = nil
  29132. }
  29133. // Status returns the value of the "status" field in the mutation.
  29134. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29135. v := m.status
  29136. if v == nil {
  29137. return
  29138. }
  29139. return *v, true
  29140. }
  29141. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29142. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29144. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29145. if !m.op.Is(OpUpdateOne) {
  29146. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29147. }
  29148. if m.id == nil || m.oldValue == nil {
  29149. return v, errors.New("OldStatus requires an ID field in the mutation")
  29150. }
  29151. oldValue, err := m.oldValue(ctx)
  29152. if err != nil {
  29153. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29154. }
  29155. return oldValue.Status, nil
  29156. }
  29157. // AddStatus adds u to the "status" field.
  29158. func (m *UsageDetailMutation) AddStatus(u int8) {
  29159. if m.addstatus != nil {
  29160. *m.addstatus += u
  29161. } else {
  29162. m.addstatus = &u
  29163. }
  29164. }
  29165. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29166. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29167. v := m.addstatus
  29168. if v == nil {
  29169. return
  29170. }
  29171. return *v, true
  29172. }
  29173. // ClearStatus clears the value of the "status" field.
  29174. func (m *UsageDetailMutation) ClearStatus() {
  29175. m.status = nil
  29176. m.addstatus = nil
  29177. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29178. }
  29179. // StatusCleared returns if the "status" field was cleared in this mutation.
  29180. func (m *UsageDetailMutation) StatusCleared() bool {
  29181. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29182. return ok
  29183. }
  29184. // ResetStatus resets all changes to the "status" field.
  29185. func (m *UsageDetailMutation) ResetStatus() {
  29186. m.status = nil
  29187. m.addstatus = nil
  29188. delete(m.clearedFields, usagedetail.FieldStatus)
  29189. }
  29190. // SetType sets the "type" field.
  29191. func (m *UsageDetailMutation) SetType(i int) {
  29192. m._type = &i
  29193. m.add_type = nil
  29194. }
  29195. // GetType returns the value of the "type" field in the mutation.
  29196. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29197. v := m._type
  29198. if v == nil {
  29199. return
  29200. }
  29201. return *v, true
  29202. }
  29203. // OldType returns the old "type" field's value of the UsageDetail entity.
  29204. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29206. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29207. if !m.op.Is(OpUpdateOne) {
  29208. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29209. }
  29210. if m.id == nil || m.oldValue == nil {
  29211. return v, errors.New("OldType requires an ID field in the mutation")
  29212. }
  29213. oldValue, err := m.oldValue(ctx)
  29214. if err != nil {
  29215. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29216. }
  29217. return oldValue.Type, nil
  29218. }
  29219. // AddType adds i to the "type" field.
  29220. func (m *UsageDetailMutation) AddType(i int) {
  29221. if m.add_type != nil {
  29222. *m.add_type += i
  29223. } else {
  29224. m.add_type = &i
  29225. }
  29226. }
  29227. // AddedType returns the value that was added to the "type" field in this mutation.
  29228. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29229. v := m.add_type
  29230. if v == nil {
  29231. return
  29232. }
  29233. return *v, true
  29234. }
  29235. // ClearType clears the value of the "type" field.
  29236. func (m *UsageDetailMutation) ClearType() {
  29237. m._type = nil
  29238. m.add_type = nil
  29239. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29240. }
  29241. // TypeCleared returns if the "type" field was cleared in this mutation.
  29242. func (m *UsageDetailMutation) TypeCleared() bool {
  29243. _, ok := m.clearedFields[usagedetail.FieldType]
  29244. return ok
  29245. }
  29246. // ResetType resets all changes to the "type" field.
  29247. func (m *UsageDetailMutation) ResetType() {
  29248. m._type = nil
  29249. m.add_type = nil
  29250. delete(m.clearedFields, usagedetail.FieldType)
  29251. }
  29252. // SetBotID sets the "bot_id" field.
  29253. func (m *UsageDetailMutation) SetBotID(s string) {
  29254. m.bot_id = &s
  29255. }
  29256. // BotID returns the value of the "bot_id" field in the mutation.
  29257. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29258. v := m.bot_id
  29259. if v == nil {
  29260. return
  29261. }
  29262. return *v, true
  29263. }
  29264. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  29265. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29267. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  29268. if !m.op.Is(OpUpdateOne) {
  29269. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29270. }
  29271. if m.id == nil || m.oldValue == nil {
  29272. return v, errors.New("OldBotID requires an ID field in the mutation")
  29273. }
  29274. oldValue, err := m.oldValue(ctx)
  29275. if err != nil {
  29276. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29277. }
  29278. return oldValue.BotID, nil
  29279. }
  29280. // ResetBotID resets all changes to the "bot_id" field.
  29281. func (m *UsageDetailMutation) ResetBotID() {
  29282. m.bot_id = nil
  29283. }
  29284. // SetReceiverID sets the "receiver_id" field.
  29285. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29286. m.receiver_id = &s
  29287. }
  29288. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29289. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29290. v := m.receiver_id
  29291. if v == nil {
  29292. return
  29293. }
  29294. return *v, true
  29295. }
  29296. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29297. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29299. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29300. if !m.op.Is(OpUpdateOne) {
  29301. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29302. }
  29303. if m.id == nil || m.oldValue == nil {
  29304. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29305. }
  29306. oldValue, err := m.oldValue(ctx)
  29307. if err != nil {
  29308. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29309. }
  29310. return oldValue.ReceiverID, nil
  29311. }
  29312. // ResetReceiverID resets all changes to the "receiver_id" field.
  29313. func (m *UsageDetailMutation) ResetReceiverID() {
  29314. m.receiver_id = nil
  29315. }
  29316. // SetApp sets the "app" field.
  29317. func (m *UsageDetailMutation) SetApp(i int) {
  29318. m.app = &i
  29319. m.addapp = nil
  29320. }
  29321. // App returns the value of the "app" field in the mutation.
  29322. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29323. v := m.app
  29324. if v == nil {
  29325. return
  29326. }
  29327. return *v, true
  29328. }
  29329. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29330. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29332. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29333. if !m.op.Is(OpUpdateOne) {
  29334. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29335. }
  29336. if m.id == nil || m.oldValue == nil {
  29337. return v, errors.New("OldApp requires an ID field in the mutation")
  29338. }
  29339. oldValue, err := m.oldValue(ctx)
  29340. if err != nil {
  29341. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29342. }
  29343. return oldValue.App, nil
  29344. }
  29345. // AddApp adds i to the "app" field.
  29346. func (m *UsageDetailMutation) AddApp(i int) {
  29347. if m.addapp != nil {
  29348. *m.addapp += i
  29349. } else {
  29350. m.addapp = &i
  29351. }
  29352. }
  29353. // AddedApp returns the value that was added to the "app" field in this mutation.
  29354. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29355. v := m.addapp
  29356. if v == nil {
  29357. return
  29358. }
  29359. return *v, true
  29360. }
  29361. // ClearApp clears the value of the "app" field.
  29362. func (m *UsageDetailMutation) ClearApp() {
  29363. m.app = nil
  29364. m.addapp = nil
  29365. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29366. }
  29367. // AppCleared returns if the "app" field was cleared in this mutation.
  29368. func (m *UsageDetailMutation) AppCleared() bool {
  29369. _, ok := m.clearedFields[usagedetail.FieldApp]
  29370. return ok
  29371. }
  29372. // ResetApp resets all changes to the "app" field.
  29373. func (m *UsageDetailMutation) ResetApp() {
  29374. m.app = nil
  29375. m.addapp = nil
  29376. delete(m.clearedFields, usagedetail.FieldApp)
  29377. }
  29378. // SetSessionID sets the "session_id" field.
  29379. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29380. m.session_id = &u
  29381. m.addsession_id = nil
  29382. }
  29383. // SessionID returns the value of the "session_id" field in the mutation.
  29384. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29385. v := m.session_id
  29386. if v == nil {
  29387. return
  29388. }
  29389. return *v, true
  29390. }
  29391. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29392. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29394. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29395. if !m.op.Is(OpUpdateOne) {
  29396. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29397. }
  29398. if m.id == nil || m.oldValue == nil {
  29399. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29400. }
  29401. oldValue, err := m.oldValue(ctx)
  29402. if err != nil {
  29403. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29404. }
  29405. return oldValue.SessionID, nil
  29406. }
  29407. // AddSessionID adds u to the "session_id" field.
  29408. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29409. if m.addsession_id != nil {
  29410. *m.addsession_id += u
  29411. } else {
  29412. m.addsession_id = &u
  29413. }
  29414. }
  29415. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29416. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29417. v := m.addsession_id
  29418. if v == nil {
  29419. return
  29420. }
  29421. return *v, true
  29422. }
  29423. // ClearSessionID clears the value of the "session_id" field.
  29424. func (m *UsageDetailMutation) ClearSessionID() {
  29425. m.session_id = nil
  29426. m.addsession_id = nil
  29427. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29428. }
  29429. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29430. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29431. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29432. return ok
  29433. }
  29434. // ResetSessionID resets all changes to the "session_id" field.
  29435. func (m *UsageDetailMutation) ResetSessionID() {
  29436. m.session_id = nil
  29437. m.addsession_id = nil
  29438. delete(m.clearedFields, usagedetail.FieldSessionID)
  29439. }
  29440. // SetRequest sets the "request" field.
  29441. func (m *UsageDetailMutation) SetRequest(s string) {
  29442. m.request = &s
  29443. }
  29444. // Request returns the value of the "request" field in the mutation.
  29445. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29446. v := m.request
  29447. if v == nil {
  29448. return
  29449. }
  29450. return *v, true
  29451. }
  29452. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  29453. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29455. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  29456. if !m.op.Is(OpUpdateOne) {
  29457. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29458. }
  29459. if m.id == nil || m.oldValue == nil {
  29460. return v, errors.New("OldRequest requires an ID field in the mutation")
  29461. }
  29462. oldValue, err := m.oldValue(ctx)
  29463. if err != nil {
  29464. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  29465. }
  29466. return oldValue.Request, nil
  29467. }
  29468. // ResetRequest resets all changes to the "request" field.
  29469. func (m *UsageDetailMutation) ResetRequest() {
  29470. m.request = nil
  29471. }
  29472. // SetResponse sets the "response" field.
  29473. func (m *UsageDetailMutation) SetResponse(s string) {
  29474. m.response = &s
  29475. }
  29476. // Response returns the value of the "response" field in the mutation.
  29477. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29478. v := m.response
  29479. if v == nil {
  29480. return
  29481. }
  29482. return *v, true
  29483. }
  29484. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29485. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29487. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29488. if !m.op.Is(OpUpdateOne) {
  29489. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29490. }
  29491. if m.id == nil || m.oldValue == nil {
  29492. return v, errors.New("OldResponse requires an ID field in the mutation")
  29493. }
  29494. oldValue, err := m.oldValue(ctx)
  29495. if err != nil {
  29496. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  29497. }
  29498. return oldValue.Response, nil
  29499. }
  29500. // ResetResponse resets all changes to the "response" field.
  29501. func (m *UsageDetailMutation) ResetResponse() {
  29502. m.response = nil
  29503. }
  29504. // SetOriginalData sets the "original_data" field.
  29505. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29506. m.original_data = &ctd
  29507. }
  29508. // OriginalData returns the value of the "original_data" field in the mutation.
  29509. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29510. v := m.original_data
  29511. if v == nil {
  29512. return
  29513. }
  29514. return *v, true
  29515. }
  29516. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29517. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29519. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29520. if !m.op.Is(OpUpdateOne) {
  29521. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29522. }
  29523. if m.id == nil || m.oldValue == nil {
  29524. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29525. }
  29526. oldValue, err := m.oldValue(ctx)
  29527. if err != nil {
  29528. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29529. }
  29530. return oldValue.OriginalData, nil
  29531. }
  29532. // ResetOriginalData resets all changes to the "original_data" field.
  29533. func (m *UsageDetailMutation) ResetOriginalData() {
  29534. m.original_data = nil
  29535. }
  29536. // SetTotalTokens sets the "total_tokens" field.
  29537. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29538. m.total_tokens = &u
  29539. m.addtotal_tokens = nil
  29540. }
  29541. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29542. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29543. v := m.total_tokens
  29544. if v == nil {
  29545. return
  29546. }
  29547. return *v, true
  29548. }
  29549. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29550. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29552. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29553. if !m.op.Is(OpUpdateOne) {
  29554. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29555. }
  29556. if m.id == nil || m.oldValue == nil {
  29557. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29558. }
  29559. oldValue, err := m.oldValue(ctx)
  29560. if err != nil {
  29561. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29562. }
  29563. return oldValue.TotalTokens, nil
  29564. }
  29565. // AddTotalTokens adds u to the "total_tokens" field.
  29566. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29567. if m.addtotal_tokens != nil {
  29568. *m.addtotal_tokens += u
  29569. } else {
  29570. m.addtotal_tokens = &u
  29571. }
  29572. }
  29573. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29574. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29575. v := m.addtotal_tokens
  29576. if v == nil {
  29577. return
  29578. }
  29579. return *v, true
  29580. }
  29581. // ClearTotalTokens clears the value of the "total_tokens" field.
  29582. func (m *UsageDetailMutation) ClearTotalTokens() {
  29583. m.total_tokens = nil
  29584. m.addtotal_tokens = nil
  29585. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29586. }
  29587. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29588. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29589. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29590. return ok
  29591. }
  29592. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29593. func (m *UsageDetailMutation) ResetTotalTokens() {
  29594. m.total_tokens = nil
  29595. m.addtotal_tokens = nil
  29596. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29597. }
  29598. // SetPromptTokens sets the "prompt_tokens" field.
  29599. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29600. m.prompt_tokens = &u
  29601. m.addprompt_tokens = nil
  29602. }
  29603. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29604. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29605. v := m.prompt_tokens
  29606. if v == nil {
  29607. return
  29608. }
  29609. return *v, true
  29610. }
  29611. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29612. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29614. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29615. if !m.op.Is(OpUpdateOne) {
  29616. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29617. }
  29618. if m.id == nil || m.oldValue == nil {
  29619. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29620. }
  29621. oldValue, err := m.oldValue(ctx)
  29622. if err != nil {
  29623. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29624. }
  29625. return oldValue.PromptTokens, nil
  29626. }
  29627. // AddPromptTokens adds u to the "prompt_tokens" field.
  29628. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29629. if m.addprompt_tokens != nil {
  29630. *m.addprompt_tokens += u
  29631. } else {
  29632. m.addprompt_tokens = &u
  29633. }
  29634. }
  29635. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  29636. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  29637. v := m.addprompt_tokens
  29638. if v == nil {
  29639. return
  29640. }
  29641. return *v, true
  29642. }
  29643. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  29644. func (m *UsageDetailMutation) ClearPromptTokens() {
  29645. m.prompt_tokens = nil
  29646. m.addprompt_tokens = nil
  29647. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  29648. }
  29649. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  29650. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  29651. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  29652. return ok
  29653. }
  29654. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  29655. func (m *UsageDetailMutation) ResetPromptTokens() {
  29656. m.prompt_tokens = nil
  29657. m.addprompt_tokens = nil
  29658. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  29659. }
  29660. // SetCompletionTokens sets the "completion_tokens" field.
  29661. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  29662. m.completion_tokens = &u
  29663. m.addcompletion_tokens = nil
  29664. }
  29665. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  29666. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  29667. v := m.completion_tokens
  29668. if v == nil {
  29669. return
  29670. }
  29671. return *v, true
  29672. }
  29673. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  29674. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29676. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  29677. if !m.op.Is(OpUpdateOne) {
  29678. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  29679. }
  29680. if m.id == nil || m.oldValue == nil {
  29681. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  29682. }
  29683. oldValue, err := m.oldValue(ctx)
  29684. if err != nil {
  29685. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  29686. }
  29687. return oldValue.CompletionTokens, nil
  29688. }
  29689. // AddCompletionTokens adds u to the "completion_tokens" field.
  29690. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  29691. if m.addcompletion_tokens != nil {
  29692. *m.addcompletion_tokens += u
  29693. } else {
  29694. m.addcompletion_tokens = &u
  29695. }
  29696. }
  29697. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  29698. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  29699. v := m.addcompletion_tokens
  29700. if v == nil {
  29701. return
  29702. }
  29703. return *v, true
  29704. }
  29705. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  29706. func (m *UsageDetailMutation) ClearCompletionTokens() {
  29707. m.completion_tokens = nil
  29708. m.addcompletion_tokens = nil
  29709. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  29710. }
  29711. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  29712. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  29713. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  29714. return ok
  29715. }
  29716. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  29717. func (m *UsageDetailMutation) ResetCompletionTokens() {
  29718. m.completion_tokens = nil
  29719. m.addcompletion_tokens = nil
  29720. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  29721. }
  29722. // SetOrganizationID sets the "organization_id" field.
  29723. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  29724. m.organization_id = &u
  29725. m.addorganization_id = nil
  29726. }
  29727. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29728. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  29729. v := m.organization_id
  29730. if v == nil {
  29731. return
  29732. }
  29733. return *v, true
  29734. }
  29735. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  29736. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29738. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29739. if !m.op.Is(OpUpdateOne) {
  29740. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29741. }
  29742. if m.id == nil || m.oldValue == nil {
  29743. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29744. }
  29745. oldValue, err := m.oldValue(ctx)
  29746. if err != nil {
  29747. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29748. }
  29749. return oldValue.OrganizationID, nil
  29750. }
  29751. // AddOrganizationID adds u to the "organization_id" field.
  29752. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  29753. if m.addorganization_id != nil {
  29754. *m.addorganization_id += u
  29755. } else {
  29756. m.addorganization_id = &u
  29757. }
  29758. }
  29759. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29760. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  29761. v := m.addorganization_id
  29762. if v == nil {
  29763. return
  29764. }
  29765. return *v, true
  29766. }
  29767. // ClearOrganizationID clears the value of the "organization_id" field.
  29768. func (m *UsageDetailMutation) ClearOrganizationID() {
  29769. m.organization_id = nil
  29770. m.addorganization_id = nil
  29771. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  29772. }
  29773. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29774. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  29775. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  29776. return ok
  29777. }
  29778. // ResetOrganizationID resets all changes to the "organization_id" field.
  29779. func (m *UsageDetailMutation) ResetOrganizationID() {
  29780. m.organization_id = nil
  29781. m.addorganization_id = nil
  29782. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  29783. }
  29784. // Where appends a list predicates to the UsageDetailMutation builder.
  29785. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  29786. m.predicates = append(m.predicates, ps...)
  29787. }
  29788. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  29789. // users can use type-assertion to append predicates that do not depend on any generated package.
  29790. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  29791. p := make([]predicate.UsageDetail, len(ps))
  29792. for i := range ps {
  29793. p[i] = ps[i]
  29794. }
  29795. m.Where(p...)
  29796. }
  29797. // Op returns the operation name.
  29798. func (m *UsageDetailMutation) Op() Op {
  29799. return m.op
  29800. }
  29801. // SetOp allows setting the mutation operation.
  29802. func (m *UsageDetailMutation) SetOp(op Op) {
  29803. m.op = op
  29804. }
  29805. // Type returns the node type of this mutation (UsageDetail).
  29806. func (m *UsageDetailMutation) Type() string {
  29807. return m.typ
  29808. }
  29809. // Fields returns all fields that were changed during this mutation. Note that in
  29810. // order to get all numeric fields that were incremented/decremented, call
  29811. // AddedFields().
  29812. func (m *UsageDetailMutation) Fields() []string {
  29813. fields := make([]string, 0, 15)
  29814. if m.created_at != nil {
  29815. fields = append(fields, usagedetail.FieldCreatedAt)
  29816. }
  29817. if m.updated_at != nil {
  29818. fields = append(fields, usagedetail.FieldUpdatedAt)
  29819. }
  29820. if m.status != nil {
  29821. fields = append(fields, usagedetail.FieldStatus)
  29822. }
  29823. if m._type != nil {
  29824. fields = append(fields, usagedetail.FieldType)
  29825. }
  29826. if m.bot_id != nil {
  29827. fields = append(fields, usagedetail.FieldBotID)
  29828. }
  29829. if m.receiver_id != nil {
  29830. fields = append(fields, usagedetail.FieldReceiverID)
  29831. }
  29832. if m.app != nil {
  29833. fields = append(fields, usagedetail.FieldApp)
  29834. }
  29835. if m.session_id != nil {
  29836. fields = append(fields, usagedetail.FieldSessionID)
  29837. }
  29838. if m.request != nil {
  29839. fields = append(fields, usagedetail.FieldRequest)
  29840. }
  29841. if m.response != nil {
  29842. fields = append(fields, usagedetail.FieldResponse)
  29843. }
  29844. if m.original_data != nil {
  29845. fields = append(fields, usagedetail.FieldOriginalData)
  29846. }
  29847. if m.total_tokens != nil {
  29848. fields = append(fields, usagedetail.FieldTotalTokens)
  29849. }
  29850. if m.prompt_tokens != nil {
  29851. fields = append(fields, usagedetail.FieldPromptTokens)
  29852. }
  29853. if m.completion_tokens != nil {
  29854. fields = append(fields, usagedetail.FieldCompletionTokens)
  29855. }
  29856. if m.organization_id != nil {
  29857. fields = append(fields, usagedetail.FieldOrganizationID)
  29858. }
  29859. return fields
  29860. }
  29861. // Field returns the value of a field with the given name. The second boolean
  29862. // return value indicates that this field was not set, or was not defined in the
  29863. // schema.
  29864. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  29865. switch name {
  29866. case usagedetail.FieldCreatedAt:
  29867. return m.CreatedAt()
  29868. case usagedetail.FieldUpdatedAt:
  29869. return m.UpdatedAt()
  29870. case usagedetail.FieldStatus:
  29871. return m.Status()
  29872. case usagedetail.FieldType:
  29873. return m.GetType()
  29874. case usagedetail.FieldBotID:
  29875. return m.BotID()
  29876. case usagedetail.FieldReceiverID:
  29877. return m.ReceiverID()
  29878. case usagedetail.FieldApp:
  29879. return m.App()
  29880. case usagedetail.FieldSessionID:
  29881. return m.SessionID()
  29882. case usagedetail.FieldRequest:
  29883. return m.Request()
  29884. case usagedetail.FieldResponse:
  29885. return m.Response()
  29886. case usagedetail.FieldOriginalData:
  29887. return m.OriginalData()
  29888. case usagedetail.FieldTotalTokens:
  29889. return m.TotalTokens()
  29890. case usagedetail.FieldPromptTokens:
  29891. return m.PromptTokens()
  29892. case usagedetail.FieldCompletionTokens:
  29893. return m.CompletionTokens()
  29894. case usagedetail.FieldOrganizationID:
  29895. return m.OrganizationID()
  29896. }
  29897. return nil, false
  29898. }
  29899. // OldField returns the old value of the field from the database. An error is
  29900. // returned if the mutation operation is not UpdateOne, or the query to the
  29901. // database failed.
  29902. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29903. switch name {
  29904. case usagedetail.FieldCreatedAt:
  29905. return m.OldCreatedAt(ctx)
  29906. case usagedetail.FieldUpdatedAt:
  29907. return m.OldUpdatedAt(ctx)
  29908. case usagedetail.FieldStatus:
  29909. return m.OldStatus(ctx)
  29910. case usagedetail.FieldType:
  29911. return m.OldType(ctx)
  29912. case usagedetail.FieldBotID:
  29913. return m.OldBotID(ctx)
  29914. case usagedetail.FieldReceiverID:
  29915. return m.OldReceiverID(ctx)
  29916. case usagedetail.FieldApp:
  29917. return m.OldApp(ctx)
  29918. case usagedetail.FieldSessionID:
  29919. return m.OldSessionID(ctx)
  29920. case usagedetail.FieldRequest:
  29921. return m.OldRequest(ctx)
  29922. case usagedetail.FieldResponse:
  29923. return m.OldResponse(ctx)
  29924. case usagedetail.FieldOriginalData:
  29925. return m.OldOriginalData(ctx)
  29926. case usagedetail.FieldTotalTokens:
  29927. return m.OldTotalTokens(ctx)
  29928. case usagedetail.FieldPromptTokens:
  29929. return m.OldPromptTokens(ctx)
  29930. case usagedetail.FieldCompletionTokens:
  29931. return m.OldCompletionTokens(ctx)
  29932. case usagedetail.FieldOrganizationID:
  29933. return m.OldOrganizationID(ctx)
  29934. }
  29935. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  29936. }
  29937. // SetField sets the value of a field with the given name. It returns an error if
  29938. // the field is not defined in the schema, or if the type mismatched the field
  29939. // type.
  29940. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  29941. switch name {
  29942. case usagedetail.FieldCreatedAt:
  29943. v, ok := value.(time.Time)
  29944. if !ok {
  29945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29946. }
  29947. m.SetCreatedAt(v)
  29948. return nil
  29949. case usagedetail.FieldUpdatedAt:
  29950. v, ok := value.(time.Time)
  29951. if !ok {
  29952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29953. }
  29954. m.SetUpdatedAt(v)
  29955. return nil
  29956. case usagedetail.FieldStatus:
  29957. v, ok := value.(uint8)
  29958. if !ok {
  29959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29960. }
  29961. m.SetStatus(v)
  29962. return nil
  29963. case usagedetail.FieldType:
  29964. v, ok := value.(int)
  29965. if !ok {
  29966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29967. }
  29968. m.SetType(v)
  29969. return nil
  29970. case usagedetail.FieldBotID:
  29971. v, ok := value.(string)
  29972. if !ok {
  29973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29974. }
  29975. m.SetBotID(v)
  29976. return nil
  29977. case usagedetail.FieldReceiverID:
  29978. v, ok := value.(string)
  29979. if !ok {
  29980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29981. }
  29982. m.SetReceiverID(v)
  29983. return nil
  29984. case usagedetail.FieldApp:
  29985. v, ok := value.(int)
  29986. if !ok {
  29987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29988. }
  29989. m.SetApp(v)
  29990. return nil
  29991. case usagedetail.FieldSessionID:
  29992. v, ok := value.(uint64)
  29993. if !ok {
  29994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29995. }
  29996. m.SetSessionID(v)
  29997. return nil
  29998. case usagedetail.FieldRequest:
  29999. v, ok := value.(string)
  30000. if !ok {
  30001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30002. }
  30003. m.SetRequest(v)
  30004. return nil
  30005. case usagedetail.FieldResponse:
  30006. v, ok := value.(string)
  30007. if !ok {
  30008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30009. }
  30010. m.SetResponse(v)
  30011. return nil
  30012. case usagedetail.FieldOriginalData:
  30013. v, ok := value.(custom_types.OriginalData)
  30014. if !ok {
  30015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30016. }
  30017. m.SetOriginalData(v)
  30018. return nil
  30019. case usagedetail.FieldTotalTokens:
  30020. v, ok := value.(uint64)
  30021. if !ok {
  30022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30023. }
  30024. m.SetTotalTokens(v)
  30025. return nil
  30026. case usagedetail.FieldPromptTokens:
  30027. v, ok := value.(uint64)
  30028. if !ok {
  30029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30030. }
  30031. m.SetPromptTokens(v)
  30032. return nil
  30033. case usagedetail.FieldCompletionTokens:
  30034. v, ok := value.(uint64)
  30035. if !ok {
  30036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30037. }
  30038. m.SetCompletionTokens(v)
  30039. return nil
  30040. case usagedetail.FieldOrganizationID:
  30041. v, ok := value.(uint64)
  30042. if !ok {
  30043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30044. }
  30045. m.SetOrganizationID(v)
  30046. return nil
  30047. }
  30048. return fmt.Errorf("unknown UsageDetail field %s", name)
  30049. }
  30050. // AddedFields returns all numeric fields that were incremented/decremented during
  30051. // this mutation.
  30052. func (m *UsageDetailMutation) AddedFields() []string {
  30053. var fields []string
  30054. if m.addstatus != nil {
  30055. fields = append(fields, usagedetail.FieldStatus)
  30056. }
  30057. if m.add_type != nil {
  30058. fields = append(fields, usagedetail.FieldType)
  30059. }
  30060. if m.addapp != nil {
  30061. fields = append(fields, usagedetail.FieldApp)
  30062. }
  30063. if m.addsession_id != nil {
  30064. fields = append(fields, usagedetail.FieldSessionID)
  30065. }
  30066. if m.addtotal_tokens != nil {
  30067. fields = append(fields, usagedetail.FieldTotalTokens)
  30068. }
  30069. if m.addprompt_tokens != nil {
  30070. fields = append(fields, usagedetail.FieldPromptTokens)
  30071. }
  30072. if m.addcompletion_tokens != nil {
  30073. fields = append(fields, usagedetail.FieldCompletionTokens)
  30074. }
  30075. if m.addorganization_id != nil {
  30076. fields = append(fields, usagedetail.FieldOrganizationID)
  30077. }
  30078. return fields
  30079. }
  30080. // AddedField returns the numeric value that was incremented/decremented on a field
  30081. // with the given name. The second boolean return value indicates that this field
  30082. // was not set, or was not defined in the schema.
  30083. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30084. switch name {
  30085. case usagedetail.FieldStatus:
  30086. return m.AddedStatus()
  30087. case usagedetail.FieldType:
  30088. return m.AddedType()
  30089. case usagedetail.FieldApp:
  30090. return m.AddedApp()
  30091. case usagedetail.FieldSessionID:
  30092. return m.AddedSessionID()
  30093. case usagedetail.FieldTotalTokens:
  30094. return m.AddedTotalTokens()
  30095. case usagedetail.FieldPromptTokens:
  30096. return m.AddedPromptTokens()
  30097. case usagedetail.FieldCompletionTokens:
  30098. return m.AddedCompletionTokens()
  30099. case usagedetail.FieldOrganizationID:
  30100. return m.AddedOrganizationID()
  30101. }
  30102. return nil, false
  30103. }
  30104. // AddField adds the value to the field with the given name. It returns an error if
  30105. // the field is not defined in the schema, or if the type mismatched the field
  30106. // type.
  30107. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30108. switch name {
  30109. case usagedetail.FieldStatus:
  30110. v, ok := value.(int8)
  30111. if !ok {
  30112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30113. }
  30114. m.AddStatus(v)
  30115. return nil
  30116. case usagedetail.FieldType:
  30117. v, ok := value.(int)
  30118. if !ok {
  30119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30120. }
  30121. m.AddType(v)
  30122. return nil
  30123. case usagedetail.FieldApp:
  30124. v, ok := value.(int)
  30125. if !ok {
  30126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30127. }
  30128. m.AddApp(v)
  30129. return nil
  30130. case usagedetail.FieldSessionID:
  30131. v, ok := value.(int64)
  30132. if !ok {
  30133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30134. }
  30135. m.AddSessionID(v)
  30136. return nil
  30137. case usagedetail.FieldTotalTokens:
  30138. v, ok := value.(int64)
  30139. if !ok {
  30140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30141. }
  30142. m.AddTotalTokens(v)
  30143. return nil
  30144. case usagedetail.FieldPromptTokens:
  30145. v, ok := value.(int64)
  30146. if !ok {
  30147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30148. }
  30149. m.AddPromptTokens(v)
  30150. return nil
  30151. case usagedetail.FieldCompletionTokens:
  30152. v, ok := value.(int64)
  30153. if !ok {
  30154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30155. }
  30156. m.AddCompletionTokens(v)
  30157. return nil
  30158. case usagedetail.FieldOrganizationID:
  30159. v, ok := value.(int64)
  30160. if !ok {
  30161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30162. }
  30163. m.AddOrganizationID(v)
  30164. return nil
  30165. }
  30166. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30167. }
  30168. // ClearedFields returns all nullable fields that were cleared during this
  30169. // mutation.
  30170. func (m *UsageDetailMutation) ClearedFields() []string {
  30171. var fields []string
  30172. if m.FieldCleared(usagedetail.FieldStatus) {
  30173. fields = append(fields, usagedetail.FieldStatus)
  30174. }
  30175. if m.FieldCleared(usagedetail.FieldType) {
  30176. fields = append(fields, usagedetail.FieldType)
  30177. }
  30178. if m.FieldCleared(usagedetail.FieldApp) {
  30179. fields = append(fields, usagedetail.FieldApp)
  30180. }
  30181. if m.FieldCleared(usagedetail.FieldSessionID) {
  30182. fields = append(fields, usagedetail.FieldSessionID)
  30183. }
  30184. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30185. fields = append(fields, usagedetail.FieldTotalTokens)
  30186. }
  30187. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30188. fields = append(fields, usagedetail.FieldPromptTokens)
  30189. }
  30190. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30191. fields = append(fields, usagedetail.FieldCompletionTokens)
  30192. }
  30193. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30194. fields = append(fields, usagedetail.FieldOrganizationID)
  30195. }
  30196. return fields
  30197. }
  30198. // FieldCleared returns a boolean indicating if a field with the given name was
  30199. // cleared in this mutation.
  30200. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30201. _, ok := m.clearedFields[name]
  30202. return ok
  30203. }
  30204. // ClearField clears the value of the field with the given name. It returns an
  30205. // error if the field is not defined in the schema.
  30206. func (m *UsageDetailMutation) ClearField(name string) error {
  30207. switch name {
  30208. case usagedetail.FieldStatus:
  30209. m.ClearStatus()
  30210. return nil
  30211. case usagedetail.FieldType:
  30212. m.ClearType()
  30213. return nil
  30214. case usagedetail.FieldApp:
  30215. m.ClearApp()
  30216. return nil
  30217. case usagedetail.FieldSessionID:
  30218. m.ClearSessionID()
  30219. return nil
  30220. case usagedetail.FieldTotalTokens:
  30221. m.ClearTotalTokens()
  30222. return nil
  30223. case usagedetail.FieldPromptTokens:
  30224. m.ClearPromptTokens()
  30225. return nil
  30226. case usagedetail.FieldCompletionTokens:
  30227. m.ClearCompletionTokens()
  30228. return nil
  30229. case usagedetail.FieldOrganizationID:
  30230. m.ClearOrganizationID()
  30231. return nil
  30232. }
  30233. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30234. }
  30235. // ResetField resets all changes in the mutation for the field with the given name.
  30236. // It returns an error if the field is not defined in the schema.
  30237. func (m *UsageDetailMutation) ResetField(name string) error {
  30238. switch name {
  30239. case usagedetail.FieldCreatedAt:
  30240. m.ResetCreatedAt()
  30241. return nil
  30242. case usagedetail.FieldUpdatedAt:
  30243. m.ResetUpdatedAt()
  30244. return nil
  30245. case usagedetail.FieldStatus:
  30246. m.ResetStatus()
  30247. return nil
  30248. case usagedetail.FieldType:
  30249. m.ResetType()
  30250. return nil
  30251. case usagedetail.FieldBotID:
  30252. m.ResetBotID()
  30253. return nil
  30254. case usagedetail.FieldReceiverID:
  30255. m.ResetReceiverID()
  30256. return nil
  30257. case usagedetail.FieldApp:
  30258. m.ResetApp()
  30259. return nil
  30260. case usagedetail.FieldSessionID:
  30261. m.ResetSessionID()
  30262. return nil
  30263. case usagedetail.FieldRequest:
  30264. m.ResetRequest()
  30265. return nil
  30266. case usagedetail.FieldResponse:
  30267. m.ResetResponse()
  30268. return nil
  30269. case usagedetail.FieldOriginalData:
  30270. m.ResetOriginalData()
  30271. return nil
  30272. case usagedetail.FieldTotalTokens:
  30273. m.ResetTotalTokens()
  30274. return nil
  30275. case usagedetail.FieldPromptTokens:
  30276. m.ResetPromptTokens()
  30277. return nil
  30278. case usagedetail.FieldCompletionTokens:
  30279. m.ResetCompletionTokens()
  30280. return nil
  30281. case usagedetail.FieldOrganizationID:
  30282. m.ResetOrganizationID()
  30283. return nil
  30284. }
  30285. return fmt.Errorf("unknown UsageDetail field %s", name)
  30286. }
  30287. // AddedEdges returns all edge names that were set/added in this mutation.
  30288. func (m *UsageDetailMutation) AddedEdges() []string {
  30289. edges := make([]string, 0, 0)
  30290. return edges
  30291. }
  30292. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30293. // name in this mutation.
  30294. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30295. return nil
  30296. }
  30297. // RemovedEdges returns all edge names that were removed in this mutation.
  30298. func (m *UsageDetailMutation) RemovedEdges() []string {
  30299. edges := make([]string, 0, 0)
  30300. return edges
  30301. }
  30302. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30303. // the given name in this mutation.
  30304. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30305. return nil
  30306. }
  30307. // ClearedEdges returns all edge names that were cleared in this mutation.
  30308. func (m *UsageDetailMutation) ClearedEdges() []string {
  30309. edges := make([]string, 0, 0)
  30310. return edges
  30311. }
  30312. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30313. // was cleared in this mutation.
  30314. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30315. return false
  30316. }
  30317. // ClearEdge clears the value of the edge with the given name. It returns an error
  30318. // if that edge is not defined in the schema.
  30319. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30320. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30321. }
  30322. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30323. // It returns an error if the edge is not defined in the schema.
  30324. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30325. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30326. }
  30327. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30328. type UsageStatisticDayMutation struct {
  30329. config
  30330. op Op
  30331. typ string
  30332. id *uint64
  30333. created_at *time.Time
  30334. updated_at *time.Time
  30335. status *uint8
  30336. addstatus *int8
  30337. deleted_at *time.Time
  30338. addtime *uint64
  30339. addaddtime *int64
  30340. _type *int
  30341. add_type *int
  30342. bot_id *string
  30343. organization_id *uint64
  30344. addorganization_id *int64
  30345. ai_response *uint64
  30346. addai_response *int64
  30347. sop_run *uint64
  30348. addsop_run *int64
  30349. total_friend *uint64
  30350. addtotal_friend *int64
  30351. total_group *uint64
  30352. addtotal_group *int64
  30353. account_balance *uint64
  30354. addaccount_balance *int64
  30355. consume_token *uint64
  30356. addconsume_token *int64
  30357. active_user *uint64
  30358. addactive_user *int64
  30359. new_user *int64
  30360. addnew_user *int64
  30361. label_dist *[]custom_types.LabelDist
  30362. appendlabel_dist []custom_types.LabelDist
  30363. clearedFields map[string]struct{}
  30364. done bool
  30365. oldValue func(context.Context) (*UsageStatisticDay, error)
  30366. predicates []predicate.UsageStatisticDay
  30367. }
  30368. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30369. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30370. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30371. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30372. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30373. m := &UsageStatisticDayMutation{
  30374. config: c,
  30375. op: op,
  30376. typ: TypeUsageStatisticDay,
  30377. clearedFields: make(map[string]struct{}),
  30378. }
  30379. for _, opt := range opts {
  30380. opt(m)
  30381. }
  30382. return m
  30383. }
  30384. // withUsageStatisticDayID sets the ID field of the mutation.
  30385. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30386. return func(m *UsageStatisticDayMutation) {
  30387. var (
  30388. err error
  30389. once sync.Once
  30390. value *UsageStatisticDay
  30391. )
  30392. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30393. once.Do(func() {
  30394. if m.done {
  30395. err = errors.New("querying old values post mutation is not allowed")
  30396. } else {
  30397. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30398. }
  30399. })
  30400. return value, err
  30401. }
  30402. m.id = &id
  30403. }
  30404. }
  30405. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30406. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30407. return func(m *UsageStatisticDayMutation) {
  30408. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30409. return node, nil
  30410. }
  30411. m.id = &node.ID
  30412. }
  30413. }
  30414. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30415. // executed in a transaction (ent.Tx), a transactional client is returned.
  30416. func (m UsageStatisticDayMutation) Client() *Client {
  30417. client := &Client{config: m.config}
  30418. client.init()
  30419. return client
  30420. }
  30421. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30422. // it returns an error otherwise.
  30423. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30424. if _, ok := m.driver.(*txDriver); !ok {
  30425. return nil, errors.New("ent: mutation is not running in a transaction")
  30426. }
  30427. tx := &Tx{config: m.config}
  30428. tx.init()
  30429. return tx, nil
  30430. }
  30431. // SetID sets the value of the id field. Note that this
  30432. // operation is only accepted on creation of UsageStatisticDay entities.
  30433. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30434. m.id = &id
  30435. }
  30436. // ID returns the ID value in the mutation. Note that the ID is only available
  30437. // if it was provided to the builder or after it was returned from the database.
  30438. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30439. if m.id == nil {
  30440. return
  30441. }
  30442. return *m.id, true
  30443. }
  30444. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30445. // That means, if the mutation is applied within a transaction with an isolation level such
  30446. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30447. // or updated by the mutation.
  30448. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30449. switch {
  30450. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30451. id, exists := m.ID()
  30452. if exists {
  30453. return []uint64{id}, nil
  30454. }
  30455. fallthrough
  30456. case m.op.Is(OpUpdate | OpDelete):
  30457. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30458. default:
  30459. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30460. }
  30461. }
  30462. // SetCreatedAt sets the "created_at" field.
  30463. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30464. m.created_at = &t
  30465. }
  30466. // CreatedAt returns the value of the "created_at" field in the mutation.
  30467. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30468. v := m.created_at
  30469. if v == nil {
  30470. return
  30471. }
  30472. return *v, true
  30473. }
  30474. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30475. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30477. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30478. if !m.op.Is(OpUpdateOne) {
  30479. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30480. }
  30481. if m.id == nil || m.oldValue == nil {
  30482. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30483. }
  30484. oldValue, err := m.oldValue(ctx)
  30485. if err != nil {
  30486. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30487. }
  30488. return oldValue.CreatedAt, nil
  30489. }
  30490. // ResetCreatedAt resets all changes to the "created_at" field.
  30491. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30492. m.created_at = nil
  30493. }
  30494. // SetUpdatedAt sets the "updated_at" field.
  30495. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30496. m.updated_at = &t
  30497. }
  30498. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30499. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30500. v := m.updated_at
  30501. if v == nil {
  30502. return
  30503. }
  30504. return *v, true
  30505. }
  30506. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30507. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30509. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30510. if !m.op.Is(OpUpdateOne) {
  30511. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30512. }
  30513. if m.id == nil || m.oldValue == nil {
  30514. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30515. }
  30516. oldValue, err := m.oldValue(ctx)
  30517. if err != nil {
  30518. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30519. }
  30520. return oldValue.UpdatedAt, nil
  30521. }
  30522. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30523. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30524. m.updated_at = nil
  30525. }
  30526. // SetStatus sets the "status" field.
  30527. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30528. m.status = &u
  30529. m.addstatus = nil
  30530. }
  30531. // Status returns the value of the "status" field in the mutation.
  30532. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30533. v := m.status
  30534. if v == nil {
  30535. return
  30536. }
  30537. return *v, true
  30538. }
  30539. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30540. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30542. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30543. if !m.op.Is(OpUpdateOne) {
  30544. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30545. }
  30546. if m.id == nil || m.oldValue == nil {
  30547. return v, errors.New("OldStatus requires an ID field in the mutation")
  30548. }
  30549. oldValue, err := m.oldValue(ctx)
  30550. if err != nil {
  30551. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30552. }
  30553. return oldValue.Status, nil
  30554. }
  30555. // AddStatus adds u to the "status" field.
  30556. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30557. if m.addstatus != nil {
  30558. *m.addstatus += u
  30559. } else {
  30560. m.addstatus = &u
  30561. }
  30562. }
  30563. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30564. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30565. v := m.addstatus
  30566. if v == nil {
  30567. return
  30568. }
  30569. return *v, true
  30570. }
  30571. // ClearStatus clears the value of the "status" field.
  30572. func (m *UsageStatisticDayMutation) ClearStatus() {
  30573. m.status = nil
  30574. m.addstatus = nil
  30575. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30576. }
  30577. // StatusCleared returns if the "status" field was cleared in this mutation.
  30578. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30579. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30580. return ok
  30581. }
  30582. // ResetStatus resets all changes to the "status" field.
  30583. func (m *UsageStatisticDayMutation) ResetStatus() {
  30584. m.status = nil
  30585. m.addstatus = nil
  30586. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30587. }
  30588. // SetDeletedAt sets the "deleted_at" field.
  30589. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30590. m.deleted_at = &t
  30591. }
  30592. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30593. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30594. v := m.deleted_at
  30595. if v == nil {
  30596. return
  30597. }
  30598. return *v, true
  30599. }
  30600. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30601. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30603. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30604. if !m.op.Is(OpUpdateOne) {
  30605. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30606. }
  30607. if m.id == nil || m.oldValue == nil {
  30608. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30609. }
  30610. oldValue, err := m.oldValue(ctx)
  30611. if err != nil {
  30612. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30613. }
  30614. return oldValue.DeletedAt, nil
  30615. }
  30616. // ClearDeletedAt clears the value of the "deleted_at" field.
  30617. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30618. m.deleted_at = nil
  30619. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30620. }
  30621. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30622. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30623. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30624. return ok
  30625. }
  30626. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30627. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30628. m.deleted_at = nil
  30629. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30630. }
  30631. // SetAddtime sets the "addtime" field.
  30632. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30633. m.addtime = &u
  30634. m.addaddtime = nil
  30635. }
  30636. // Addtime returns the value of the "addtime" field in the mutation.
  30637. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  30638. v := m.addtime
  30639. if v == nil {
  30640. return
  30641. }
  30642. return *v, true
  30643. }
  30644. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  30645. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30647. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30648. if !m.op.Is(OpUpdateOne) {
  30649. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30650. }
  30651. if m.id == nil || m.oldValue == nil {
  30652. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30653. }
  30654. oldValue, err := m.oldValue(ctx)
  30655. if err != nil {
  30656. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30657. }
  30658. return oldValue.Addtime, nil
  30659. }
  30660. // AddAddtime adds u to the "addtime" field.
  30661. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  30662. if m.addaddtime != nil {
  30663. *m.addaddtime += u
  30664. } else {
  30665. m.addaddtime = &u
  30666. }
  30667. }
  30668. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30669. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  30670. v := m.addaddtime
  30671. if v == nil {
  30672. return
  30673. }
  30674. return *v, true
  30675. }
  30676. // ResetAddtime resets all changes to the "addtime" field.
  30677. func (m *UsageStatisticDayMutation) ResetAddtime() {
  30678. m.addtime = nil
  30679. m.addaddtime = nil
  30680. }
  30681. // SetType sets the "type" field.
  30682. func (m *UsageStatisticDayMutation) SetType(i int) {
  30683. m._type = &i
  30684. m.add_type = nil
  30685. }
  30686. // GetType returns the value of the "type" field in the mutation.
  30687. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  30688. v := m._type
  30689. if v == nil {
  30690. return
  30691. }
  30692. return *v, true
  30693. }
  30694. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  30695. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30697. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  30698. if !m.op.Is(OpUpdateOne) {
  30699. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30700. }
  30701. if m.id == nil || m.oldValue == nil {
  30702. return v, errors.New("OldType requires an ID field in the mutation")
  30703. }
  30704. oldValue, err := m.oldValue(ctx)
  30705. if err != nil {
  30706. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30707. }
  30708. return oldValue.Type, nil
  30709. }
  30710. // AddType adds i to the "type" field.
  30711. func (m *UsageStatisticDayMutation) AddType(i int) {
  30712. if m.add_type != nil {
  30713. *m.add_type += i
  30714. } else {
  30715. m.add_type = &i
  30716. }
  30717. }
  30718. // AddedType returns the value that was added to the "type" field in this mutation.
  30719. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  30720. v := m.add_type
  30721. if v == nil {
  30722. return
  30723. }
  30724. return *v, true
  30725. }
  30726. // ResetType resets all changes to the "type" field.
  30727. func (m *UsageStatisticDayMutation) ResetType() {
  30728. m._type = nil
  30729. m.add_type = nil
  30730. }
  30731. // SetBotID sets the "bot_id" field.
  30732. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  30733. m.bot_id = &s
  30734. }
  30735. // BotID returns the value of the "bot_id" field in the mutation.
  30736. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  30737. v := m.bot_id
  30738. if v == nil {
  30739. return
  30740. }
  30741. return *v, true
  30742. }
  30743. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  30744. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30746. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  30747. if !m.op.Is(OpUpdateOne) {
  30748. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30749. }
  30750. if m.id == nil || m.oldValue == nil {
  30751. return v, errors.New("OldBotID requires an ID field in the mutation")
  30752. }
  30753. oldValue, err := m.oldValue(ctx)
  30754. if err != nil {
  30755. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30756. }
  30757. return oldValue.BotID, nil
  30758. }
  30759. // ClearBotID clears the value of the "bot_id" field.
  30760. func (m *UsageStatisticDayMutation) ClearBotID() {
  30761. m.bot_id = nil
  30762. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  30763. }
  30764. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30765. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  30766. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  30767. return ok
  30768. }
  30769. // ResetBotID resets all changes to the "bot_id" field.
  30770. func (m *UsageStatisticDayMutation) ResetBotID() {
  30771. m.bot_id = nil
  30772. delete(m.clearedFields, usagestatisticday.FieldBotID)
  30773. }
  30774. // SetOrganizationID sets the "organization_id" field.
  30775. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  30776. m.organization_id = &u
  30777. m.addorganization_id = nil
  30778. }
  30779. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30780. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  30781. v := m.organization_id
  30782. if v == nil {
  30783. return
  30784. }
  30785. return *v, true
  30786. }
  30787. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  30788. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30790. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30791. if !m.op.Is(OpUpdateOne) {
  30792. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30793. }
  30794. if m.id == nil || m.oldValue == nil {
  30795. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30796. }
  30797. oldValue, err := m.oldValue(ctx)
  30798. if err != nil {
  30799. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30800. }
  30801. return oldValue.OrganizationID, nil
  30802. }
  30803. // AddOrganizationID adds u to the "organization_id" field.
  30804. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  30805. if m.addorganization_id != nil {
  30806. *m.addorganization_id += u
  30807. } else {
  30808. m.addorganization_id = &u
  30809. }
  30810. }
  30811. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30812. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  30813. v := m.addorganization_id
  30814. if v == nil {
  30815. return
  30816. }
  30817. return *v, true
  30818. }
  30819. // ClearOrganizationID clears the value of the "organization_id" field.
  30820. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  30821. m.organization_id = nil
  30822. m.addorganization_id = nil
  30823. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  30824. }
  30825. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30826. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  30827. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  30828. return ok
  30829. }
  30830. // ResetOrganizationID resets all changes to the "organization_id" field.
  30831. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  30832. m.organization_id = nil
  30833. m.addorganization_id = nil
  30834. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  30835. }
  30836. // SetAiResponse sets the "ai_response" field.
  30837. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  30838. m.ai_response = &u
  30839. m.addai_response = nil
  30840. }
  30841. // AiResponse returns the value of the "ai_response" field in the mutation.
  30842. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  30843. v := m.ai_response
  30844. if v == nil {
  30845. return
  30846. }
  30847. return *v, true
  30848. }
  30849. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  30850. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30852. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30853. if !m.op.Is(OpUpdateOne) {
  30854. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30855. }
  30856. if m.id == nil || m.oldValue == nil {
  30857. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30858. }
  30859. oldValue, err := m.oldValue(ctx)
  30860. if err != nil {
  30861. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30862. }
  30863. return oldValue.AiResponse, nil
  30864. }
  30865. // AddAiResponse adds u to the "ai_response" field.
  30866. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  30867. if m.addai_response != nil {
  30868. *m.addai_response += u
  30869. } else {
  30870. m.addai_response = &u
  30871. }
  30872. }
  30873. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30874. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  30875. v := m.addai_response
  30876. if v == nil {
  30877. return
  30878. }
  30879. return *v, true
  30880. }
  30881. // ResetAiResponse resets all changes to the "ai_response" field.
  30882. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  30883. m.ai_response = nil
  30884. m.addai_response = nil
  30885. }
  30886. // SetSopRun sets the "sop_run" field.
  30887. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  30888. m.sop_run = &u
  30889. m.addsop_run = nil
  30890. }
  30891. // SopRun returns the value of the "sop_run" field in the mutation.
  30892. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  30893. v := m.sop_run
  30894. if v == nil {
  30895. return
  30896. }
  30897. return *v, true
  30898. }
  30899. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  30900. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30902. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30903. if !m.op.Is(OpUpdateOne) {
  30904. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30905. }
  30906. if m.id == nil || m.oldValue == nil {
  30907. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30908. }
  30909. oldValue, err := m.oldValue(ctx)
  30910. if err != nil {
  30911. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30912. }
  30913. return oldValue.SopRun, nil
  30914. }
  30915. // AddSopRun adds u to the "sop_run" field.
  30916. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  30917. if m.addsop_run != nil {
  30918. *m.addsop_run += u
  30919. } else {
  30920. m.addsop_run = &u
  30921. }
  30922. }
  30923. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30924. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  30925. v := m.addsop_run
  30926. if v == nil {
  30927. return
  30928. }
  30929. return *v, true
  30930. }
  30931. // ResetSopRun resets all changes to the "sop_run" field.
  30932. func (m *UsageStatisticDayMutation) ResetSopRun() {
  30933. m.sop_run = nil
  30934. m.addsop_run = nil
  30935. }
  30936. // SetTotalFriend sets the "total_friend" field.
  30937. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  30938. m.total_friend = &u
  30939. m.addtotal_friend = nil
  30940. }
  30941. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30942. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  30943. v := m.total_friend
  30944. if v == nil {
  30945. return
  30946. }
  30947. return *v, true
  30948. }
  30949. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  30950. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30952. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30953. if !m.op.Is(OpUpdateOne) {
  30954. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30955. }
  30956. if m.id == nil || m.oldValue == nil {
  30957. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30958. }
  30959. oldValue, err := m.oldValue(ctx)
  30960. if err != nil {
  30961. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30962. }
  30963. return oldValue.TotalFriend, nil
  30964. }
  30965. // AddTotalFriend adds u to the "total_friend" field.
  30966. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  30967. if m.addtotal_friend != nil {
  30968. *m.addtotal_friend += u
  30969. } else {
  30970. m.addtotal_friend = &u
  30971. }
  30972. }
  30973. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30974. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  30975. v := m.addtotal_friend
  30976. if v == nil {
  30977. return
  30978. }
  30979. return *v, true
  30980. }
  30981. // ResetTotalFriend resets all changes to the "total_friend" field.
  30982. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  30983. m.total_friend = nil
  30984. m.addtotal_friend = nil
  30985. }
  30986. // SetTotalGroup sets the "total_group" field.
  30987. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  30988. m.total_group = &u
  30989. m.addtotal_group = nil
  30990. }
  30991. // TotalGroup returns the value of the "total_group" field in the mutation.
  30992. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  30993. v := m.total_group
  30994. if v == nil {
  30995. return
  30996. }
  30997. return *v, true
  30998. }
  30999. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  31000. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31002. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31003. if !m.op.Is(OpUpdateOne) {
  31004. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31005. }
  31006. if m.id == nil || m.oldValue == nil {
  31007. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31008. }
  31009. oldValue, err := m.oldValue(ctx)
  31010. if err != nil {
  31011. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31012. }
  31013. return oldValue.TotalGroup, nil
  31014. }
  31015. // AddTotalGroup adds u to the "total_group" field.
  31016. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  31017. if m.addtotal_group != nil {
  31018. *m.addtotal_group += u
  31019. } else {
  31020. m.addtotal_group = &u
  31021. }
  31022. }
  31023. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31024. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  31025. v := m.addtotal_group
  31026. if v == nil {
  31027. return
  31028. }
  31029. return *v, true
  31030. }
  31031. // ResetTotalGroup resets all changes to the "total_group" field.
  31032. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  31033. m.total_group = nil
  31034. m.addtotal_group = nil
  31035. }
  31036. // SetAccountBalance sets the "account_balance" field.
  31037. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  31038. m.account_balance = &u
  31039. m.addaccount_balance = nil
  31040. }
  31041. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31042. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  31043. v := m.account_balance
  31044. if v == nil {
  31045. return
  31046. }
  31047. return *v, true
  31048. }
  31049. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  31050. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31052. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31053. if !m.op.Is(OpUpdateOne) {
  31054. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31055. }
  31056. if m.id == nil || m.oldValue == nil {
  31057. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31058. }
  31059. oldValue, err := m.oldValue(ctx)
  31060. if err != nil {
  31061. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31062. }
  31063. return oldValue.AccountBalance, nil
  31064. }
  31065. // AddAccountBalance adds u to the "account_balance" field.
  31066. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  31067. if m.addaccount_balance != nil {
  31068. *m.addaccount_balance += u
  31069. } else {
  31070. m.addaccount_balance = &u
  31071. }
  31072. }
  31073. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31074. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  31075. v := m.addaccount_balance
  31076. if v == nil {
  31077. return
  31078. }
  31079. return *v, true
  31080. }
  31081. // ResetAccountBalance resets all changes to the "account_balance" field.
  31082. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31083. m.account_balance = nil
  31084. m.addaccount_balance = nil
  31085. }
  31086. // SetConsumeToken sets the "consume_token" field.
  31087. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31088. m.consume_token = &u
  31089. m.addconsume_token = nil
  31090. }
  31091. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31092. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31093. v := m.consume_token
  31094. if v == nil {
  31095. return
  31096. }
  31097. return *v, true
  31098. }
  31099. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31100. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31102. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31103. if !m.op.Is(OpUpdateOne) {
  31104. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31105. }
  31106. if m.id == nil || m.oldValue == nil {
  31107. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31108. }
  31109. oldValue, err := m.oldValue(ctx)
  31110. if err != nil {
  31111. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31112. }
  31113. return oldValue.ConsumeToken, nil
  31114. }
  31115. // AddConsumeToken adds u to the "consume_token" field.
  31116. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31117. if m.addconsume_token != nil {
  31118. *m.addconsume_token += u
  31119. } else {
  31120. m.addconsume_token = &u
  31121. }
  31122. }
  31123. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31124. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31125. v := m.addconsume_token
  31126. if v == nil {
  31127. return
  31128. }
  31129. return *v, true
  31130. }
  31131. // ResetConsumeToken resets all changes to the "consume_token" field.
  31132. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31133. m.consume_token = nil
  31134. m.addconsume_token = nil
  31135. }
  31136. // SetActiveUser sets the "active_user" field.
  31137. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31138. m.active_user = &u
  31139. m.addactive_user = nil
  31140. }
  31141. // ActiveUser returns the value of the "active_user" field in the mutation.
  31142. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31143. v := m.active_user
  31144. if v == nil {
  31145. return
  31146. }
  31147. return *v, true
  31148. }
  31149. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31150. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31152. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31153. if !m.op.Is(OpUpdateOne) {
  31154. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31155. }
  31156. if m.id == nil || m.oldValue == nil {
  31157. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31158. }
  31159. oldValue, err := m.oldValue(ctx)
  31160. if err != nil {
  31161. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31162. }
  31163. return oldValue.ActiveUser, nil
  31164. }
  31165. // AddActiveUser adds u to the "active_user" field.
  31166. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31167. if m.addactive_user != nil {
  31168. *m.addactive_user += u
  31169. } else {
  31170. m.addactive_user = &u
  31171. }
  31172. }
  31173. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31174. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31175. v := m.addactive_user
  31176. if v == nil {
  31177. return
  31178. }
  31179. return *v, true
  31180. }
  31181. // ResetActiveUser resets all changes to the "active_user" field.
  31182. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31183. m.active_user = nil
  31184. m.addactive_user = nil
  31185. }
  31186. // SetNewUser sets the "new_user" field.
  31187. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31188. m.new_user = &i
  31189. m.addnew_user = nil
  31190. }
  31191. // NewUser returns the value of the "new_user" field in the mutation.
  31192. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31193. v := m.new_user
  31194. if v == nil {
  31195. return
  31196. }
  31197. return *v, true
  31198. }
  31199. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31200. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31202. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31203. if !m.op.Is(OpUpdateOne) {
  31204. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31205. }
  31206. if m.id == nil || m.oldValue == nil {
  31207. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31208. }
  31209. oldValue, err := m.oldValue(ctx)
  31210. if err != nil {
  31211. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31212. }
  31213. return oldValue.NewUser, nil
  31214. }
  31215. // AddNewUser adds i to the "new_user" field.
  31216. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31217. if m.addnew_user != nil {
  31218. *m.addnew_user += i
  31219. } else {
  31220. m.addnew_user = &i
  31221. }
  31222. }
  31223. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31224. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31225. v := m.addnew_user
  31226. if v == nil {
  31227. return
  31228. }
  31229. return *v, true
  31230. }
  31231. // ResetNewUser resets all changes to the "new_user" field.
  31232. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31233. m.new_user = nil
  31234. m.addnew_user = nil
  31235. }
  31236. // SetLabelDist sets the "label_dist" field.
  31237. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31238. m.label_dist = &ctd
  31239. m.appendlabel_dist = nil
  31240. }
  31241. // LabelDist returns the value of the "label_dist" field in the mutation.
  31242. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31243. v := m.label_dist
  31244. if v == nil {
  31245. return
  31246. }
  31247. return *v, true
  31248. }
  31249. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31250. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31252. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31253. if !m.op.Is(OpUpdateOne) {
  31254. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31255. }
  31256. if m.id == nil || m.oldValue == nil {
  31257. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31258. }
  31259. oldValue, err := m.oldValue(ctx)
  31260. if err != nil {
  31261. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31262. }
  31263. return oldValue.LabelDist, nil
  31264. }
  31265. // AppendLabelDist adds ctd to the "label_dist" field.
  31266. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31267. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31268. }
  31269. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31270. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31271. if len(m.appendlabel_dist) == 0 {
  31272. return nil, false
  31273. }
  31274. return m.appendlabel_dist, true
  31275. }
  31276. // ResetLabelDist resets all changes to the "label_dist" field.
  31277. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31278. m.label_dist = nil
  31279. m.appendlabel_dist = nil
  31280. }
  31281. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31282. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31283. m.predicates = append(m.predicates, ps...)
  31284. }
  31285. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31286. // users can use type-assertion to append predicates that do not depend on any generated package.
  31287. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31288. p := make([]predicate.UsageStatisticDay, len(ps))
  31289. for i := range ps {
  31290. p[i] = ps[i]
  31291. }
  31292. m.Where(p...)
  31293. }
  31294. // Op returns the operation name.
  31295. func (m *UsageStatisticDayMutation) Op() Op {
  31296. return m.op
  31297. }
  31298. // SetOp allows setting the mutation operation.
  31299. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31300. m.op = op
  31301. }
  31302. // Type returns the node type of this mutation (UsageStatisticDay).
  31303. func (m *UsageStatisticDayMutation) Type() string {
  31304. return m.typ
  31305. }
  31306. // Fields returns all fields that were changed during this mutation. Note that in
  31307. // order to get all numeric fields that were incremented/decremented, call
  31308. // AddedFields().
  31309. func (m *UsageStatisticDayMutation) Fields() []string {
  31310. fields := make([]string, 0, 17)
  31311. if m.created_at != nil {
  31312. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31313. }
  31314. if m.updated_at != nil {
  31315. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31316. }
  31317. if m.status != nil {
  31318. fields = append(fields, usagestatisticday.FieldStatus)
  31319. }
  31320. if m.deleted_at != nil {
  31321. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31322. }
  31323. if m.addtime != nil {
  31324. fields = append(fields, usagestatisticday.FieldAddtime)
  31325. }
  31326. if m._type != nil {
  31327. fields = append(fields, usagestatisticday.FieldType)
  31328. }
  31329. if m.bot_id != nil {
  31330. fields = append(fields, usagestatisticday.FieldBotID)
  31331. }
  31332. if m.organization_id != nil {
  31333. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31334. }
  31335. if m.ai_response != nil {
  31336. fields = append(fields, usagestatisticday.FieldAiResponse)
  31337. }
  31338. if m.sop_run != nil {
  31339. fields = append(fields, usagestatisticday.FieldSopRun)
  31340. }
  31341. if m.total_friend != nil {
  31342. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31343. }
  31344. if m.total_group != nil {
  31345. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31346. }
  31347. if m.account_balance != nil {
  31348. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31349. }
  31350. if m.consume_token != nil {
  31351. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31352. }
  31353. if m.active_user != nil {
  31354. fields = append(fields, usagestatisticday.FieldActiveUser)
  31355. }
  31356. if m.new_user != nil {
  31357. fields = append(fields, usagestatisticday.FieldNewUser)
  31358. }
  31359. if m.label_dist != nil {
  31360. fields = append(fields, usagestatisticday.FieldLabelDist)
  31361. }
  31362. return fields
  31363. }
  31364. // Field returns the value of a field with the given name. The second boolean
  31365. // return value indicates that this field was not set, or was not defined in the
  31366. // schema.
  31367. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31368. switch name {
  31369. case usagestatisticday.FieldCreatedAt:
  31370. return m.CreatedAt()
  31371. case usagestatisticday.FieldUpdatedAt:
  31372. return m.UpdatedAt()
  31373. case usagestatisticday.FieldStatus:
  31374. return m.Status()
  31375. case usagestatisticday.FieldDeletedAt:
  31376. return m.DeletedAt()
  31377. case usagestatisticday.FieldAddtime:
  31378. return m.Addtime()
  31379. case usagestatisticday.FieldType:
  31380. return m.GetType()
  31381. case usagestatisticday.FieldBotID:
  31382. return m.BotID()
  31383. case usagestatisticday.FieldOrganizationID:
  31384. return m.OrganizationID()
  31385. case usagestatisticday.FieldAiResponse:
  31386. return m.AiResponse()
  31387. case usagestatisticday.FieldSopRun:
  31388. return m.SopRun()
  31389. case usagestatisticday.FieldTotalFriend:
  31390. return m.TotalFriend()
  31391. case usagestatisticday.FieldTotalGroup:
  31392. return m.TotalGroup()
  31393. case usagestatisticday.FieldAccountBalance:
  31394. return m.AccountBalance()
  31395. case usagestatisticday.FieldConsumeToken:
  31396. return m.ConsumeToken()
  31397. case usagestatisticday.FieldActiveUser:
  31398. return m.ActiveUser()
  31399. case usagestatisticday.FieldNewUser:
  31400. return m.NewUser()
  31401. case usagestatisticday.FieldLabelDist:
  31402. return m.LabelDist()
  31403. }
  31404. return nil, false
  31405. }
  31406. // OldField returns the old value of the field from the database. An error is
  31407. // returned if the mutation operation is not UpdateOne, or the query to the
  31408. // database failed.
  31409. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31410. switch name {
  31411. case usagestatisticday.FieldCreatedAt:
  31412. return m.OldCreatedAt(ctx)
  31413. case usagestatisticday.FieldUpdatedAt:
  31414. return m.OldUpdatedAt(ctx)
  31415. case usagestatisticday.FieldStatus:
  31416. return m.OldStatus(ctx)
  31417. case usagestatisticday.FieldDeletedAt:
  31418. return m.OldDeletedAt(ctx)
  31419. case usagestatisticday.FieldAddtime:
  31420. return m.OldAddtime(ctx)
  31421. case usagestatisticday.FieldType:
  31422. return m.OldType(ctx)
  31423. case usagestatisticday.FieldBotID:
  31424. return m.OldBotID(ctx)
  31425. case usagestatisticday.FieldOrganizationID:
  31426. return m.OldOrganizationID(ctx)
  31427. case usagestatisticday.FieldAiResponse:
  31428. return m.OldAiResponse(ctx)
  31429. case usagestatisticday.FieldSopRun:
  31430. return m.OldSopRun(ctx)
  31431. case usagestatisticday.FieldTotalFriend:
  31432. return m.OldTotalFriend(ctx)
  31433. case usagestatisticday.FieldTotalGroup:
  31434. return m.OldTotalGroup(ctx)
  31435. case usagestatisticday.FieldAccountBalance:
  31436. return m.OldAccountBalance(ctx)
  31437. case usagestatisticday.FieldConsumeToken:
  31438. return m.OldConsumeToken(ctx)
  31439. case usagestatisticday.FieldActiveUser:
  31440. return m.OldActiveUser(ctx)
  31441. case usagestatisticday.FieldNewUser:
  31442. return m.OldNewUser(ctx)
  31443. case usagestatisticday.FieldLabelDist:
  31444. return m.OldLabelDist(ctx)
  31445. }
  31446. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31447. }
  31448. // SetField sets the value of a field with the given name. It returns an error if
  31449. // the field is not defined in the schema, or if the type mismatched the field
  31450. // type.
  31451. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31452. switch name {
  31453. case usagestatisticday.FieldCreatedAt:
  31454. v, ok := value.(time.Time)
  31455. if !ok {
  31456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31457. }
  31458. m.SetCreatedAt(v)
  31459. return nil
  31460. case usagestatisticday.FieldUpdatedAt:
  31461. v, ok := value.(time.Time)
  31462. if !ok {
  31463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31464. }
  31465. m.SetUpdatedAt(v)
  31466. return nil
  31467. case usagestatisticday.FieldStatus:
  31468. v, ok := value.(uint8)
  31469. if !ok {
  31470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31471. }
  31472. m.SetStatus(v)
  31473. return nil
  31474. case usagestatisticday.FieldDeletedAt:
  31475. v, ok := value.(time.Time)
  31476. if !ok {
  31477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31478. }
  31479. m.SetDeletedAt(v)
  31480. return nil
  31481. case usagestatisticday.FieldAddtime:
  31482. v, ok := value.(uint64)
  31483. if !ok {
  31484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31485. }
  31486. m.SetAddtime(v)
  31487. return nil
  31488. case usagestatisticday.FieldType:
  31489. v, ok := value.(int)
  31490. if !ok {
  31491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31492. }
  31493. m.SetType(v)
  31494. return nil
  31495. case usagestatisticday.FieldBotID:
  31496. v, ok := value.(string)
  31497. if !ok {
  31498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31499. }
  31500. m.SetBotID(v)
  31501. return nil
  31502. case usagestatisticday.FieldOrganizationID:
  31503. v, ok := value.(uint64)
  31504. if !ok {
  31505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31506. }
  31507. m.SetOrganizationID(v)
  31508. return nil
  31509. case usagestatisticday.FieldAiResponse:
  31510. v, ok := value.(uint64)
  31511. if !ok {
  31512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31513. }
  31514. m.SetAiResponse(v)
  31515. return nil
  31516. case usagestatisticday.FieldSopRun:
  31517. v, ok := value.(uint64)
  31518. if !ok {
  31519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31520. }
  31521. m.SetSopRun(v)
  31522. return nil
  31523. case usagestatisticday.FieldTotalFriend:
  31524. v, ok := value.(uint64)
  31525. if !ok {
  31526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31527. }
  31528. m.SetTotalFriend(v)
  31529. return nil
  31530. case usagestatisticday.FieldTotalGroup:
  31531. v, ok := value.(uint64)
  31532. if !ok {
  31533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31534. }
  31535. m.SetTotalGroup(v)
  31536. return nil
  31537. case usagestatisticday.FieldAccountBalance:
  31538. v, ok := value.(uint64)
  31539. if !ok {
  31540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31541. }
  31542. m.SetAccountBalance(v)
  31543. return nil
  31544. case usagestatisticday.FieldConsumeToken:
  31545. v, ok := value.(uint64)
  31546. if !ok {
  31547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31548. }
  31549. m.SetConsumeToken(v)
  31550. return nil
  31551. case usagestatisticday.FieldActiveUser:
  31552. v, ok := value.(uint64)
  31553. if !ok {
  31554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31555. }
  31556. m.SetActiveUser(v)
  31557. return nil
  31558. case usagestatisticday.FieldNewUser:
  31559. v, ok := value.(int64)
  31560. if !ok {
  31561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31562. }
  31563. m.SetNewUser(v)
  31564. return nil
  31565. case usagestatisticday.FieldLabelDist:
  31566. v, ok := value.([]custom_types.LabelDist)
  31567. if !ok {
  31568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31569. }
  31570. m.SetLabelDist(v)
  31571. return nil
  31572. }
  31573. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31574. }
  31575. // AddedFields returns all numeric fields that were incremented/decremented during
  31576. // this mutation.
  31577. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31578. var fields []string
  31579. if m.addstatus != nil {
  31580. fields = append(fields, usagestatisticday.FieldStatus)
  31581. }
  31582. if m.addaddtime != nil {
  31583. fields = append(fields, usagestatisticday.FieldAddtime)
  31584. }
  31585. if m.add_type != nil {
  31586. fields = append(fields, usagestatisticday.FieldType)
  31587. }
  31588. if m.addorganization_id != nil {
  31589. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31590. }
  31591. if m.addai_response != nil {
  31592. fields = append(fields, usagestatisticday.FieldAiResponse)
  31593. }
  31594. if m.addsop_run != nil {
  31595. fields = append(fields, usagestatisticday.FieldSopRun)
  31596. }
  31597. if m.addtotal_friend != nil {
  31598. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31599. }
  31600. if m.addtotal_group != nil {
  31601. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31602. }
  31603. if m.addaccount_balance != nil {
  31604. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31605. }
  31606. if m.addconsume_token != nil {
  31607. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31608. }
  31609. if m.addactive_user != nil {
  31610. fields = append(fields, usagestatisticday.FieldActiveUser)
  31611. }
  31612. if m.addnew_user != nil {
  31613. fields = append(fields, usagestatisticday.FieldNewUser)
  31614. }
  31615. return fields
  31616. }
  31617. // AddedField returns the numeric value that was incremented/decremented on a field
  31618. // with the given name. The second boolean return value indicates that this field
  31619. // was not set, or was not defined in the schema.
  31620. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31621. switch name {
  31622. case usagestatisticday.FieldStatus:
  31623. return m.AddedStatus()
  31624. case usagestatisticday.FieldAddtime:
  31625. return m.AddedAddtime()
  31626. case usagestatisticday.FieldType:
  31627. return m.AddedType()
  31628. case usagestatisticday.FieldOrganizationID:
  31629. return m.AddedOrganizationID()
  31630. case usagestatisticday.FieldAiResponse:
  31631. return m.AddedAiResponse()
  31632. case usagestatisticday.FieldSopRun:
  31633. return m.AddedSopRun()
  31634. case usagestatisticday.FieldTotalFriend:
  31635. return m.AddedTotalFriend()
  31636. case usagestatisticday.FieldTotalGroup:
  31637. return m.AddedTotalGroup()
  31638. case usagestatisticday.FieldAccountBalance:
  31639. return m.AddedAccountBalance()
  31640. case usagestatisticday.FieldConsumeToken:
  31641. return m.AddedConsumeToken()
  31642. case usagestatisticday.FieldActiveUser:
  31643. return m.AddedActiveUser()
  31644. case usagestatisticday.FieldNewUser:
  31645. return m.AddedNewUser()
  31646. }
  31647. return nil, false
  31648. }
  31649. // AddField adds the value to the field with the given name. It returns an error if
  31650. // the field is not defined in the schema, or if the type mismatched the field
  31651. // type.
  31652. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  31653. switch name {
  31654. case usagestatisticday.FieldStatus:
  31655. v, ok := value.(int8)
  31656. if !ok {
  31657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31658. }
  31659. m.AddStatus(v)
  31660. return nil
  31661. case usagestatisticday.FieldAddtime:
  31662. v, ok := value.(int64)
  31663. if !ok {
  31664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31665. }
  31666. m.AddAddtime(v)
  31667. return nil
  31668. case usagestatisticday.FieldType:
  31669. v, ok := value.(int)
  31670. if !ok {
  31671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31672. }
  31673. m.AddType(v)
  31674. return nil
  31675. case usagestatisticday.FieldOrganizationID:
  31676. v, ok := value.(int64)
  31677. if !ok {
  31678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31679. }
  31680. m.AddOrganizationID(v)
  31681. return nil
  31682. case usagestatisticday.FieldAiResponse:
  31683. v, ok := value.(int64)
  31684. if !ok {
  31685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31686. }
  31687. m.AddAiResponse(v)
  31688. return nil
  31689. case usagestatisticday.FieldSopRun:
  31690. v, ok := value.(int64)
  31691. if !ok {
  31692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31693. }
  31694. m.AddSopRun(v)
  31695. return nil
  31696. case usagestatisticday.FieldTotalFriend:
  31697. v, ok := value.(int64)
  31698. if !ok {
  31699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31700. }
  31701. m.AddTotalFriend(v)
  31702. return nil
  31703. case usagestatisticday.FieldTotalGroup:
  31704. v, ok := value.(int64)
  31705. if !ok {
  31706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31707. }
  31708. m.AddTotalGroup(v)
  31709. return nil
  31710. case usagestatisticday.FieldAccountBalance:
  31711. v, ok := value.(int64)
  31712. if !ok {
  31713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31714. }
  31715. m.AddAccountBalance(v)
  31716. return nil
  31717. case usagestatisticday.FieldConsumeToken:
  31718. v, ok := value.(int64)
  31719. if !ok {
  31720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31721. }
  31722. m.AddConsumeToken(v)
  31723. return nil
  31724. case usagestatisticday.FieldActiveUser:
  31725. v, ok := value.(int64)
  31726. if !ok {
  31727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31728. }
  31729. m.AddActiveUser(v)
  31730. return nil
  31731. case usagestatisticday.FieldNewUser:
  31732. v, ok := value.(int64)
  31733. if !ok {
  31734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31735. }
  31736. m.AddNewUser(v)
  31737. return nil
  31738. }
  31739. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  31740. }
  31741. // ClearedFields returns all nullable fields that were cleared during this
  31742. // mutation.
  31743. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  31744. var fields []string
  31745. if m.FieldCleared(usagestatisticday.FieldStatus) {
  31746. fields = append(fields, usagestatisticday.FieldStatus)
  31747. }
  31748. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  31749. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31750. }
  31751. if m.FieldCleared(usagestatisticday.FieldBotID) {
  31752. fields = append(fields, usagestatisticday.FieldBotID)
  31753. }
  31754. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  31755. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31756. }
  31757. return fields
  31758. }
  31759. // FieldCleared returns a boolean indicating if a field with the given name was
  31760. // cleared in this mutation.
  31761. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  31762. _, ok := m.clearedFields[name]
  31763. return ok
  31764. }
  31765. // ClearField clears the value of the field with the given name. It returns an
  31766. // error if the field is not defined in the schema.
  31767. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  31768. switch name {
  31769. case usagestatisticday.FieldStatus:
  31770. m.ClearStatus()
  31771. return nil
  31772. case usagestatisticday.FieldDeletedAt:
  31773. m.ClearDeletedAt()
  31774. return nil
  31775. case usagestatisticday.FieldBotID:
  31776. m.ClearBotID()
  31777. return nil
  31778. case usagestatisticday.FieldOrganizationID:
  31779. m.ClearOrganizationID()
  31780. return nil
  31781. }
  31782. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  31783. }
  31784. // ResetField resets all changes in the mutation for the field with the given name.
  31785. // It returns an error if the field is not defined in the schema.
  31786. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  31787. switch name {
  31788. case usagestatisticday.FieldCreatedAt:
  31789. m.ResetCreatedAt()
  31790. return nil
  31791. case usagestatisticday.FieldUpdatedAt:
  31792. m.ResetUpdatedAt()
  31793. return nil
  31794. case usagestatisticday.FieldStatus:
  31795. m.ResetStatus()
  31796. return nil
  31797. case usagestatisticday.FieldDeletedAt:
  31798. m.ResetDeletedAt()
  31799. return nil
  31800. case usagestatisticday.FieldAddtime:
  31801. m.ResetAddtime()
  31802. return nil
  31803. case usagestatisticday.FieldType:
  31804. m.ResetType()
  31805. return nil
  31806. case usagestatisticday.FieldBotID:
  31807. m.ResetBotID()
  31808. return nil
  31809. case usagestatisticday.FieldOrganizationID:
  31810. m.ResetOrganizationID()
  31811. return nil
  31812. case usagestatisticday.FieldAiResponse:
  31813. m.ResetAiResponse()
  31814. return nil
  31815. case usagestatisticday.FieldSopRun:
  31816. m.ResetSopRun()
  31817. return nil
  31818. case usagestatisticday.FieldTotalFriend:
  31819. m.ResetTotalFriend()
  31820. return nil
  31821. case usagestatisticday.FieldTotalGroup:
  31822. m.ResetTotalGroup()
  31823. return nil
  31824. case usagestatisticday.FieldAccountBalance:
  31825. m.ResetAccountBalance()
  31826. return nil
  31827. case usagestatisticday.FieldConsumeToken:
  31828. m.ResetConsumeToken()
  31829. return nil
  31830. case usagestatisticday.FieldActiveUser:
  31831. m.ResetActiveUser()
  31832. return nil
  31833. case usagestatisticday.FieldNewUser:
  31834. m.ResetNewUser()
  31835. return nil
  31836. case usagestatisticday.FieldLabelDist:
  31837. m.ResetLabelDist()
  31838. return nil
  31839. }
  31840. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31841. }
  31842. // AddedEdges returns all edge names that were set/added in this mutation.
  31843. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  31844. edges := make([]string, 0, 0)
  31845. return edges
  31846. }
  31847. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31848. // name in this mutation.
  31849. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  31850. return nil
  31851. }
  31852. // RemovedEdges returns all edge names that were removed in this mutation.
  31853. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  31854. edges := make([]string, 0, 0)
  31855. return edges
  31856. }
  31857. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31858. // the given name in this mutation.
  31859. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  31860. return nil
  31861. }
  31862. // ClearedEdges returns all edge names that were cleared in this mutation.
  31863. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  31864. edges := make([]string, 0, 0)
  31865. return edges
  31866. }
  31867. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31868. // was cleared in this mutation.
  31869. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  31870. return false
  31871. }
  31872. // ClearEdge clears the value of the edge with the given name. It returns an error
  31873. // if that edge is not defined in the schema.
  31874. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  31875. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  31876. }
  31877. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31878. // It returns an error if the edge is not defined in the schema.
  31879. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  31880. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  31881. }
  31882. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  31883. type UsageStatisticHourMutation struct {
  31884. config
  31885. op Op
  31886. typ string
  31887. id *uint64
  31888. created_at *time.Time
  31889. updated_at *time.Time
  31890. status *uint8
  31891. addstatus *int8
  31892. deleted_at *time.Time
  31893. addtime *uint64
  31894. addaddtime *int64
  31895. _type *int
  31896. add_type *int
  31897. bot_id *string
  31898. organization_id *uint64
  31899. addorganization_id *int64
  31900. ai_response *uint64
  31901. addai_response *int64
  31902. sop_run *uint64
  31903. addsop_run *int64
  31904. total_friend *uint64
  31905. addtotal_friend *int64
  31906. total_group *uint64
  31907. addtotal_group *int64
  31908. account_balance *uint64
  31909. addaccount_balance *int64
  31910. consume_token *uint64
  31911. addconsume_token *int64
  31912. active_user *uint64
  31913. addactive_user *int64
  31914. new_user *int64
  31915. addnew_user *int64
  31916. label_dist *[]custom_types.LabelDist
  31917. appendlabel_dist []custom_types.LabelDist
  31918. clearedFields map[string]struct{}
  31919. done bool
  31920. oldValue func(context.Context) (*UsageStatisticHour, error)
  31921. predicates []predicate.UsageStatisticHour
  31922. }
  31923. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  31924. // usagestatistichourOption allows management of the mutation configuration using functional options.
  31925. type usagestatistichourOption func(*UsageStatisticHourMutation)
  31926. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  31927. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  31928. m := &UsageStatisticHourMutation{
  31929. config: c,
  31930. op: op,
  31931. typ: TypeUsageStatisticHour,
  31932. clearedFields: make(map[string]struct{}),
  31933. }
  31934. for _, opt := range opts {
  31935. opt(m)
  31936. }
  31937. return m
  31938. }
  31939. // withUsageStatisticHourID sets the ID field of the mutation.
  31940. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  31941. return func(m *UsageStatisticHourMutation) {
  31942. var (
  31943. err error
  31944. once sync.Once
  31945. value *UsageStatisticHour
  31946. )
  31947. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  31948. once.Do(func() {
  31949. if m.done {
  31950. err = errors.New("querying old values post mutation is not allowed")
  31951. } else {
  31952. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  31953. }
  31954. })
  31955. return value, err
  31956. }
  31957. m.id = &id
  31958. }
  31959. }
  31960. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  31961. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  31962. return func(m *UsageStatisticHourMutation) {
  31963. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  31964. return node, nil
  31965. }
  31966. m.id = &node.ID
  31967. }
  31968. }
  31969. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31970. // executed in a transaction (ent.Tx), a transactional client is returned.
  31971. func (m UsageStatisticHourMutation) Client() *Client {
  31972. client := &Client{config: m.config}
  31973. client.init()
  31974. return client
  31975. }
  31976. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31977. // it returns an error otherwise.
  31978. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  31979. if _, ok := m.driver.(*txDriver); !ok {
  31980. return nil, errors.New("ent: mutation is not running in a transaction")
  31981. }
  31982. tx := &Tx{config: m.config}
  31983. tx.init()
  31984. return tx, nil
  31985. }
  31986. // SetID sets the value of the id field. Note that this
  31987. // operation is only accepted on creation of UsageStatisticHour entities.
  31988. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  31989. m.id = &id
  31990. }
  31991. // ID returns the ID value in the mutation. Note that the ID is only available
  31992. // if it was provided to the builder or after it was returned from the database.
  31993. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  31994. if m.id == nil {
  31995. return
  31996. }
  31997. return *m.id, true
  31998. }
  31999. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32000. // That means, if the mutation is applied within a transaction with an isolation level such
  32001. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32002. // or updated by the mutation.
  32003. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  32004. switch {
  32005. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32006. id, exists := m.ID()
  32007. if exists {
  32008. return []uint64{id}, nil
  32009. }
  32010. fallthrough
  32011. case m.op.Is(OpUpdate | OpDelete):
  32012. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  32013. default:
  32014. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32015. }
  32016. }
  32017. // SetCreatedAt sets the "created_at" field.
  32018. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  32019. m.created_at = &t
  32020. }
  32021. // CreatedAt returns the value of the "created_at" field in the mutation.
  32022. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  32023. v := m.created_at
  32024. if v == nil {
  32025. return
  32026. }
  32027. return *v, true
  32028. }
  32029. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  32030. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32032. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32033. if !m.op.Is(OpUpdateOne) {
  32034. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32035. }
  32036. if m.id == nil || m.oldValue == nil {
  32037. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32038. }
  32039. oldValue, err := m.oldValue(ctx)
  32040. if err != nil {
  32041. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32042. }
  32043. return oldValue.CreatedAt, nil
  32044. }
  32045. // ResetCreatedAt resets all changes to the "created_at" field.
  32046. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  32047. m.created_at = nil
  32048. }
  32049. // SetUpdatedAt sets the "updated_at" field.
  32050. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  32051. m.updated_at = &t
  32052. }
  32053. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32054. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  32055. v := m.updated_at
  32056. if v == nil {
  32057. return
  32058. }
  32059. return *v, true
  32060. }
  32061. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  32062. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32064. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32065. if !m.op.Is(OpUpdateOne) {
  32066. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32067. }
  32068. if m.id == nil || m.oldValue == nil {
  32069. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32070. }
  32071. oldValue, err := m.oldValue(ctx)
  32072. if err != nil {
  32073. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32074. }
  32075. return oldValue.UpdatedAt, nil
  32076. }
  32077. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32078. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  32079. m.updated_at = nil
  32080. }
  32081. // SetStatus sets the "status" field.
  32082. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32083. m.status = &u
  32084. m.addstatus = nil
  32085. }
  32086. // Status returns the value of the "status" field in the mutation.
  32087. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32088. v := m.status
  32089. if v == nil {
  32090. return
  32091. }
  32092. return *v, true
  32093. }
  32094. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32095. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32097. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32098. if !m.op.Is(OpUpdateOne) {
  32099. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32100. }
  32101. if m.id == nil || m.oldValue == nil {
  32102. return v, errors.New("OldStatus requires an ID field in the mutation")
  32103. }
  32104. oldValue, err := m.oldValue(ctx)
  32105. if err != nil {
  32106. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32107. }
  32108. return oldValue.Status, nil
  32109. }
  32110. // AddStatus adds u to the "status" field.
  32111. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32112. if m.addstatus != nil {
  32113. *m.addstatus += u
  32114. } else {
  32115. m.addstatus = &u
  32116. }
  32117. }
  32118. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32119. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32120. v := m.addstatus
  32121. if v == nil {
  32122. return
  32123. }
  32124. return *v, true
  32125. }
  32126. // ClearStatus clears the value of the "status" field.
  32127. func (m *UsageStatisticHourMutation) ClearStatus() {
  32128. m.status = nil
  32129. m.addstatus = nil
  32130. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32131. }
  32132. // StatusCleared returns if the "status" field was cleared in this mutation.
  32133. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32134. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32135. return ok
  32136. }
  32137. // ResetStatus resets all changes to the "status" field.
  32138. func (m *UsageStatisticHourMutation) ResetStatus() {
  32139. m.status = nil
  32140. m.addstatus = nil
  32141. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32142. }
  32143. // SetDeletedAt sets the "deleted_at" field.
  32144. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32145. m.deleted_at = &t
  32146. }
  32147. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32148. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32149. v := m.deleted_at
  32150. if v == nil {
  32151. return
  32152. }
  32153. return *v, true
  32154. }
  32155. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32156. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32158. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32159. if !m.op.Is(OpUpdateOne) {
  32160. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32161. }
  32162. if m.id == nil || m.oldValue == nil {
  32163. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32164. }
  32165. oldValue, err := m.oldValue(ctx)
  32166. if err != nil {
  32167. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32168. }
  32169. return oldValue.DeletedAt, nil
  32170. }
  32171. // ClearDeletedAt clears the value of the "deleted_at" field.
  32172. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32173. m.deleted_at = nil
  32174. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32175. }
  32176. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32177. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32178. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32179. return ok
  32180. }
  32181. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32182. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32183. m.deleted_at = nil
  32184. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32185. }
  32186. // SetAddtime sets the "addtime" field.
  32187. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32188. m.addtime = &u
  32189. m.addaddtime = nil
  32190. }
  32191. // Addtime returns the value of the "addtime" field in the mutation.
  32192. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32193. v := m.addtime
  32194. if v == nil {
  32195. return
  32196. }
  32197. return *v, true
  32198. }
  32199. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32200. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32202. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32203. if !m.op.Is(OpUpdateOne) {
  32204. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32205. }
  32206. if m.id == nil || m.oldValue == nil {
  32207. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32208. }
  32209. oldValue, err := m.oldValue(ctx)
  32210. if err != nil {
  32211. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32212. }
  32213. return oldValue.Addtime, nil
  32214. }
  32215. // AddAddtime adds u to the "addtime" field.
  32216. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32217. if m.addaddtime != nil {
  32218. *m.addaddtime += u
  32219. } else {
  32220. m.addaddtime = &u
  32221. }
  32222. }
  32223. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32224. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32225. v := m.addaddtime
  32226. if v == nil {
  32227. return
  32228. }
  32229. return *v, true
  32230. }
  32231. // ResetAddtime resets all changes to the "addtime" field.
  32232. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32233. m.addtime = nil
  32234. m.addaddtime = nil
  32235. }
  32236. // SetType sets the "type" field.
  32237. func (m *UsageStatisticHourMutation) SetType(i int) {
  32238. m._type = &i
  32239. m.add_type = nil
  32240. }
  32241. // GetType returns the value of the "type" field in the mutation.
  32242. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32243. v := m._type
  32244. if v == nil {
  32245. return
  32246. }
  32247. return *v, true
  32248. }
  32249. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32250. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32252. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32253. if !m.op.Is(OpUpdateOne) {
  32254. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32255. }
  32256. if m.id == nil || m.oldValue == nil {
  32257. return v, errors.New("OldType requires an ID field in the mutation")
  32258. }
  32259. oldValue, err := m.oldValue(ctx)
  32260. if err != nil {
  32261. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32262. }
  32263. return oldValue.Type, nil
  32264. }
  32265. // AddType adds i to the "type" field.
  32266. func (m *UsageStatisticHourMutation) AddType(i int) {
  32267. if m.add_type != nil {
  32268. *m.add_type += i
  32269. } else {
  32270. m.add_type = &i
  32271. }
  32272. }
  32273. // AddedType returns the value that was added to the "type" field in this mutation.
  32274. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32275. v := m.add_type
  32276. if v == nil {
  32277. return
  32278. }
  32279. return *v, true
  32280. }
  32281. // ResetType resets all changes to the "type" field.
  32282. func (m *UsageStatisticHourMutation) ResetType() {
  32283. m._type = nil
  32284. m.add_type = nil
  32285. }
  32286. // SetBotID sets the "bot_id" field.
  32287. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32288. m.bot_id = &s
  32289. }
  32290. // BotID returns the value of the "bot_id" field in the mutation.
  32291. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32292. v := m.bot_id
  32293. if v == nil {
  32294. return
  32295. }
  32296. return *v, true
  32297. }
  32298. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32299. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32301. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32302. if !m.op.Is(OpUpdateOne) {
  32303. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32304. }
  32305. if m.id == nil || m.oldValue == nil {
  32306. return v, errors.New("OldBotID requires an ID field in the mutation")
  32307. }
  32308. oldValue, err := m.oldValue(ctx)
  32309. if err != nil {
  32310. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32311. }
  32312. return oldValue.BotID, nil
  32313. }
  32314. // ClearBotID clears the value of the "bot_id" field.
  32315. func (m *UsageStatisticHourMutation) ClearBotID() {
  32316. m.bot_id = nil
  32317. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32318. }
  32319. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32320. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32321. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32322. return ok
  32323. }
  32324. // ResetBotID resets all changes to the "bot_id" field.
  32325. func (m *UsageStatisticHourMutation) ResetBotID() {
  32326. m.bot_id = nil
  32327. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32328. }
  32329. // SetOrganizationID sets the "organization_id" field.
  32330. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32331. m.organization_id = &u
  32332. m.addorganization_id = nil
  32333. }
  32334. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32335. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32336. v := m.organization_id
  32337. if v == nil {
  32338. return
  32339. }
  32340. return *v, true
  32341. }
  32342. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32343. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32345. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32346. if !m.op.Is(OpUpdateOne) {
  32347. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32348. }
  32349. if m.id == nil || m.oldValue == nil {
  32350. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32351. }
  32352. oldValue, err := m.oldValue(ctx)
  32353. if err != nil {
  32354. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32355. }
  32356. return oldValue.OrganizationID, nil
  32357. }
  32358. // AddOrganizationID adds u to the "organization_id" field.
  32359. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32360. if m.addorganization_id != nil {
  32361. *m.addorganization_id += u
  32362. } else {
  32363. m.addorganization_id = &u
  32364. }
  32365. }
  32366. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32367. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32368. v := m.addorganization_id
  32369. if v == nil {
  32370. return
  32371. }
  32372. return *v, true
  32373. }
  32374. // ClearOrganizationID clears the value of the "organization_id" field.
  32375. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32376. m.organization_id = nil
  32377. m.addorganization_id = nil
  32378. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32379. }
  32380. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32381. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32382. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32383. return ok
  32384. }
  32385. // ResetOrganizationID resets all changes to the "organization_id" field.
  32386. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32387. m.organization_id = nil
  32388. m.addorganization_id = nil
  32389. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32390. }
  32391. // SetAiResponse sets the "ai_response" field.
  32392. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32393. m.ai_response = &u
  32394. m.addai_response = nil
  32395. }
  32396. // AiResponse returns the value of the "ai_response" field in the mutation.
  32397. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32398. v := m.ai_response
  32399. if v == nil {
  32400. return
  32401. }
  32402. return *v, true
  32403. }
  32404. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32405. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32407. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32408. if !m.op.Is(OpUpdateOne) {
  32409. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32410. }
  32411. if m.id == nil || m.oldValue == nil {
  32412. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32413. }
  32414. oldValue, err := m.oldValue(ctx)
  32415. if err != nil {
  32416. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32417. }
  32418. return oldValue.AiResponse, nil
  32419. }
  32420. // AddAiResponse adds u to the "ai_response" field.
  32421. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32422. if m.addai_response != nil {
  32423. *m.addai_response += u
  32424. } else {
  32425. m.addai_response = &u
  32426. }
  32427. }
  32428. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32429. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32430. v := m.addai_response
  32431. if v == nil {
  32432. return
  32433. }
  32434. return *v, true
  32435. }
  32436. // ResetAiResponse resets all changes to the "ai_response" field.
  32437. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32438. m.ai_response = nil
  32439. m.addai_response = nil
  32440. }
  32441. // SetSopRun sets the "sop_run" field.
  32442. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32443. m.sop_run = &u
  32444. m.addsop_run = nil
  32445. }
  32446. // SopRun returns the value of the "sop_run" field in the mutation.
  32447. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32448. v := m.sop_run
  32449. if v == nil {
  32450. return
  32451. }
  32452. return *v, true
  32453. }
  32454. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  32455. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32457. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32458. if !m.op.Is(OpUpdateOne) {
  32459. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32460. }
  32461. if m.id == nil || m.oldValue == nil {
  32462. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32463. }
  32464. oldValue, err := m.oldValue(ctx)
  32465. if err != nil {
  32466. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32467. }
  32468. return oldValue.SopRun, nil
  32469. }
  32470. // AddSopRun adds u to the "sop_run" field.
  32471. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32472. if m.addsop_run != nil {
  32473. *m.addsop_run += u
  32474. } else {
  32475. m.addsop_run = &u
  32476. }
  32477. }
  32478. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32479. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32480. v := m.addsop_run
  32481. if v == nil {
  32482. return
  32483. }
  32484. return *v, true
  32485. }
  32486. // ResetSopRun resets all changes to the "sop_run" field.
  32487. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32488. m.sop_run = nil
  32489. m.addsop_run = nil
  32490. }
  32491. // SetTotalFriend sets the "total_friend" field.
  32492. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32493. m.total_friend = &u
  32494. m.addtotal_friend = nil
  32495. }
  32496. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32497. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32498. v := m.total_friend
  32499. if v == nil {
  32500. return
  32501. }
  32502. return *v, true
  32503. }
  32504. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32505. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32507. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32508. if !m.op.Is(OpUpdateOne) {
  32509. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32510. }
  32511. if m.id == nil || m.oldValue == nil {
  32512. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32513. }
  32514. oldValue, err := m.oldValue(ctx)
  32515. if err != nil {
  32516. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32517. }
  32518. return oldValue.TotalFriend, nil
  32519. }
  32520. // AddTotalFriend adds u to the "total_friend" field.
  32521. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32522. if m.addtotal_friend != nil {
  32523. *m.addtotal_friend += u
  32524. } else {
  32525. m.addtotal_friend = &u
  32526. }
  32527. }
  32528. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32529. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32530. v := m.addtotal_friend
  32531. if v == nil {
  32532. return
  32533. }
  32534. return *v, true
  32535. }
  32536. // ResetTotalFriend resets all changes to the "total_friend" field.
  32537. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32538. m.total_friend = nil
  32539. m.addtotal_friend = nil
  32540. }
  32541. // SetTotalGroup sets the "total_group" field.
  32542. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32543. m.total_group = &u
  32544. m.addtotal_group = nil
  32545. }
  32546. // TotalGroup returns the value of the "total_group" field in the mutation.
  32547. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32548. v := m.total_group
  32549. if v == nil {
  32550. return
  32551. }
  32552. return *v, true
  32553. }
  32554. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32555. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32557. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32558. if !m.op.Is(OpUpdateOne) {
  32559. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32560. }
  32561. if m.id == nil || m.oldValue == nil {
  32562. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32563. }
  32564. oldValue, err := m.oldValue(ctx)
  32565. if err != nil {
  32566. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32567. }
  32568. return oldValue.TotalGroup, nil
  32569. }
  32570. // AddTotalGroup adds u to the "total_group" field.
  32571. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32572. if m.addtotal_group != nil {
  32573. *m.addtotal_group += u
  32574. } else {
  32575. m.addtotal_group = &u
  32576. }
  32577. }
  32578. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32579. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32580. v := m.addtotal_group
  32581. if v == nil {
  32582. return
  32583. }
  32584. return *v, true
  32585. }
  32586. // ResetTotalGroup resets all changes to the "total_group" field.
  32587. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32588. m.total_group = nil
  32589. m.addtotal_group = nil
  32590. }
  32591. // SetAccountBalance sets the "account_balance" field.
  32592. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32593. m.account_balance = &u
  32594. m.addaccount_balance = nil
  32595. }
  32596. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32597. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32598. v := m.account_balance
  32599. if v == nil {
  32600. return
  32601. }
  32602. return *v, true
  32603. }
  32604. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32605. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32607. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32608. if !m.op.Is(OpUpdateOne) {
  32609. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32610. }
  32611. if m.id == nil || m.oldValue == nil {
  32612. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32613. }
  32614. oldValue, err := m.oldValue(ctx)
  32615. if err != nil {
  32616. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32617. }
  32618. return oldValue.AccountBalance, nil
  32619. }
  32620. // AddAccountBalance adds u to the "account_balance" field.
  32621. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32622. if m.addaccount_balance != nil {
  32623. *m.addaccount_balance += u
  32624. } else {
  32625. m.addaccount_balance = &u
  32626. }
  32627. }
  32628. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32629. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32630. v := m.addaccount_balance
  32631. if v == nil {
  32632. return
  32633. }
  32634. return *v, true
  32635. }
  32636. // ResetAccountBalance resets all changes to the "account_balance" field.
  32637. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  32638. m.account_balance = nil
  32639. m.addaccount_balance = nil
  32640. }
  32641. // SetConsumeToken sets the "consume_token" field.
  32642. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  32643. m.consume_token = &u
  32644. m.addconsume_token = nil
  32645. }
  32646. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32647. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  32648. v := m.consume_token
  32649. if v == nil {
  32650. return
  32651. }
  32652. return *v, true
  32653. }
  32654. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  32655. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32657. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32658. if !m.op.Is(OpUpdateOne) {
  32659. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32660. }
  32661. if m.id == nil || m.oldValue == nil {
  32662. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32663. }
  32664. oldValue, err := m.oldValue(ctx)
  32665. if err != nil {
  32666. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32667. }
  32668. return oldValue.ConsumeToken, nil
  32669. }
  32670. // AddConsumeToken adds u to the "consume_token" field.
  32671. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  32672. if m.addconsume_token != nil {
  32673. *m.addconsume_token += u
  32674. } else {
  32675. m.addconsume_token = &u
  32676. }
  32677. }
  32678. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32679. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  32680. v := m.addconsume_token
  32681. if v == nil {
  32682. return
  32683. }
  32684. return *v, true
  32685. }
  32686. // ResetConsumeToken resets all changes to the "consume_token" field.
  32687. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  32688. m.consume_token = nil
  32689. m.addconsume_token = nil
  32690. }
  32691. // SetActiveUser sets the "active_user" field.
  32692. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  32693. m.active_user = &u
  32694. m.addactive_user = nil
  32695. }
  32696. // ActiveUser returns the value of the "active_user" field in the mutation.
  32697. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  32698. v := m.active_user
  32699. if v == nil {
  32700. return
  32701. }
  32702. return *v, true
  32703. }
  32704. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  32705. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32707. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32708. if !m.op.Is(OpUpdateOne) {
  32709. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32710. }
  32711. if m.id == nil || m.oldValue == nil {
  32712. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32713. }
  32714. oldValue, err := m.oldValue(ctx)
  32715. if err != nil {
  32716. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32717. }
  32718. return oldValue.ActiveUser, nil
  32719. }
  32720. // AddActiveUser adds u to the "active_user" field.
  32721. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  32722. if m.addactive_user != nil {
  32723. *m.addactive_user += u
  32724. } else {
  32725. m.addactive_user = &u
  32726. }
  32727. }
  32728. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32729. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  32730. v := m.addactive_user
  32731. if v == nil {
  32732. return
  32733. }
  32734. return *v, true
  32735. }
  32736. // ResetActiveUser resets all changes to the "active_user" field.
  32737. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  32738. m.active_user = nil
  32739. m.addactive_user = nil
  32740. }
  32741. // SetNewUser sets the "new_user" field.
  32742. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  32743. m.new_user = &i
  32744. m.addnew_user = nil
  32745. }
  32746. // NewUser returns the value of the "new_user" field in the mutation.
  32747. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  32748. v := m.new_user
  32749. if v == nil {
  32750. return
  32751. }
  32752. return *v, true
  32753. }
  32754. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  32755. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32757. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32758. if !m.op.Is(OpUpdateOne) {
  32759. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32760. }
  32761. if m.id == nil || m.oldValue == nil {
  32762. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32763. }
  32764. oldValue, err := m.oldValue(ctx)
  32765. if err != nil {
  32766. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32767. }
  32768. return oldValue.NewUser, nil
  32769. }
  32770. // AddNewUser adds i to the "new_user" field.
  32771. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  32772. if m.addnew_user != nil {
  32773. *m.addnew_user += i
  32774. } else {
  32775. m.addnew_user = &i
  32776. }
  32777. }
  32778. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32779. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  32780. v := m.addnew_user
  32781. if v == nil {
  32782. return
  32783. }
  32784. return *v, true
  32785. }
  32786. // ResetNewUser resets all changes to the "new_user" field.
  32787. func (m *UsageStatisticHourMutation) ResetNewUser() {
  32788. m.new_user = nil
  32789. m.addnew_user = nil
  32790. }
  32791. // SetLabelDist sets the "label_dist" field.
  32792. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32793. m.label_dist = &ctd
  32794. m.appendlabel_dist = nil
  32795. }
  32796. // LabelDist returns the value of the "label_dist" field in the mutation.
  32797. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32798. v := m.label_dist
  32799. if v == nil {
  32800. return
  32801. }
  32802. return *v, true
  32803. }
  32804. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  32805. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32807. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32808. if !m.op.Is(OpUpdateOne) {
  32809. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32810. }
  32811. if m.id == nil || m.oldValue == nil {
  32812. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32813. }
  32814. oldValue, err := m.oldValue(ctx)
  32815. if err != nil {
  32816. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32817. }
  32818. return oldValue.LabelDist, nil
  32819. }
  32820. // AppendLabelDist adds ctd to the "label_dist" field.
  32821. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32822. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32823. }
  32824. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32825. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32826. if len(m.appendlabel_dist) == 0 {
  32827. return nil, false
  32828. }
  32829. return m.appendlabel_dist, true
  32830. }
  32831. // ResetLabelDist resets all changes to the "label_dist" field.
  32832. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  32833. m.label_dist = nil
  32834. m.appendlabel_dist = nil
  32835. }
  32836. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  32837. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  32838. m.predicates = append(m.predicates, ps...)
  32839. }
  32840. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  32841. // users can use type-assertion to append predicates that do not depend on any generated package.
  32842. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  32843. p := make([]predicate.UsageStatisticHour, len(ps))
  32844. for i := range ps {
  32845. p[i] = ps[i]
  32846. }
  32847. m.Where(p...)
  32848. }
  32849. // Op returns the operation name.
  32850. func (m *UsageStatisticHourMutation) Op() Op {
  32851. return m.op
  32852. }
  32853. // SetOp allows setting the mutation operation.
  32854. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  32855. m.op = op
  32856. }
  32857. // Type returns the node type of this mutation (UsageStatisticHour).
  32858. func (m *UsageStatisticHourMutation) Type() string {
  32859. return m.typ
  32860. }
  32861. // Fields returns all fields that were changed during this mutation. Note that in
  32862. // order to get all numeric fields that were incremented/decremented, call
  32863. // AddedFields().
  32864. func (m *UsageStatisticHourMutation) Fields() []string {
  32865. fields := make([]string, 0, 17)
  32866. if m.created_at != nil {
  32867. fields = append(fields, usagestatistichour.FieldCreatedAt)
  32868. }
  32869. if m.updated_at != nil {
  32870. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  32871. }
  32872. if m.status != nil {
  32873. fields = append(fields, usagestatistichour.FieldStatus)
  32874. }
  32875. if m.deleted_at != nil {
  32876. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32877. }
  32878. if m.addtime != nil {
  32879. fields = append(fields, usagestatistichour.FieldAddtime)
  32880. }
  32881. if m._type != nil {
  32882. fields = append(fields, usagestatistichour.FieldType)
  32883. }
  32884. if m.bot_id != nil {
  32885. fields = append(fields, usagestatistichour.FieldBotID)
  32886. }
  32887. if m.organization_id != nil {
  32888. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32889. }
  32890. if m.ai_response != nil {
  32891. fields = append(fields, usagestatistichour.FieldAiResponse)
  32892. }
  32893. if m.sop_run != nil {
  32894. fields = append(fields, usagestatistichour.FieldSopRun)
  32895. }
  32896. if m.total_friend != nil {
  32897. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32898. }
  32899. if m.total_group != nil {
  32900. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32901. }
  32902. if m.account_balance != nil {
  32903. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32904. }
  32905. if m.consume_token != nil {
  32906. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32907. }
  32908. if m.active_user != nil {
  32909. fields = append(fields, usagestatistichour.FieldActiveUser)
  32910. }
  32911. if m.new_user != nil {
  32912. fields = append(fields, usagestatistichour.FieldNewUser)
  32913. }
  32914. if m.label_dist != nil {
  32915. fields = append(fields, usagestatistichour.FieldLabelDist)
  32916. }
  32917. return fields
  32918. }
  32919. // Field returns the value of a field with the given name. The second boolean
  32920. // return value indicates that this field was not set, or was not defined in the
  32921. // schema.
  32922. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  32923. switch name {
  32924. case usagestatistichour.FieldCreatedAt:
  32925. return m.CreatedAt()
  32926. case usagestatistichour.FieldUpdatedAt:
  32927. return m.UpdatedAt()
  32928. case usagestatistichour.FieldStatus:
  32929. return m.Status()
  32930. case usagestatistichour.FieldDeletedAt:
  32931. return m.DeletedAt()
  32932. case usagestatistichour.FieldAddtime:
  32933. return m.Addtime()
  32934. case usagestatistichour.FieldType:
  32935. return m.GetType()
  32936. case usagestatistichour.FieldBotID:
  32937. return m.BotID()
  32938. case usagestatistichour.FieldOrganizationID:
  32939. return m.OrganizationID()
  32940. case usagestatistichour.FieldAiResponse:
  32941. return m.AiResponse()
  32942. case usagestatistichour.FieldSopRun:
  32943. return m.SopRun()
  32944. case usagestatistichour.FieldTotalFriend:
  32945. return m.TotalFriend()
  32946. case usagestatistichour.FieldTotalGroup:
  32947. return m.TotalGroup()
  32948. case usagestatistichour.FieldAccountBalance:
  32949. return m.AccountBalance()
  32950. case usagestatistichour.FieldConsumeToken:
  32951. return m.ConsumeToken()
  32952. case usagestatistichour.FieldActiveUser:
  32953. return m.ActiveUser()
  32954. case usagestatistichour.FieldNewUser:
  32955. return m.NewUser()
  32956. case usagestatistichour.FieldLabelDist:
  32957. return m.LabelDist()
  32958. }
  32959. return nil, false
  32960. }
  32961. // OldField returns the old value of the field from the database. An error is
  32962. // returned if the mutation operation is not UpdateOne, or the query to the
  32963. // database failed.
  32964. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32965. switch name {
  32966. case usagestatistichour.FieldCreatedAt:
  32967. return m.OldCreatedAt(ctx)
  32968. case usagestatistichour.FieldUpdatedAt:
  32969. return m.OldUpdatedAt(ctx)
  32970. case usagestatistichour.FieldStatus:
  32971. return m.OldStatus(ctx)
  32972. case usagestatistichour.FieldDeletedAt:
  32973. return m.OldDeletedAt(ctx)
  32974. case usagestatistichour.FieldAddtime:
  32975. return m.OldAddtime(ctx)
  32976. case usagestatistichour.FieldType:
  32977. return m.OldType(ctx)
  32978. case usagestatistichour.FieldBotID:
  32979. return m.OldBotID(ctx)
  32980. case usagestatistichour.FieldOrganizationID:
  32981. return m.OldOrganizationID(ctx)
  32982. case usagestatistichour.FieldAiResponse:
  32983. return m.OldAiResponse(ctx)
  32984. case usagestatistichour.FieldSopRun:
  32985. return m.OldSopRun(ctx)
  32986. case usagestatistichour.FieldTotalFriend:
  32987. return m.OldTotalFriend(ctx)
  32988. case usagestatistichour.FieldTotalGroup:
  32989. return m.OldTotalGroup(ctx)
  32990. case usagestatistichour.FieldAccountBalance:
  32991. return m.OldAccountBalance(ctx)
  32992. case usagestatistichour.FieldConsumeToken:
  32993. return m.OldConsumeToken(ctx)
  32994. case usagestatistichour.FieldActiveUser:
  32995. return m.OldActiveUser(ctx)
  32996. case usagestatistichour.FieldNewUser:
  32997. return m.OldNewUser(ctx)
  32998. case usagestatistichour.FieldLabelDist:
  32999. return m.OldLabelDist(ctx)
  33000. }
  33001. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33002. }
  33003. // SetField sets the value of a field with the given name. It returns an error if
  33004. // the field is not defined in the schema, or if the type mismatched the field
  33005. // type.
  33006. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  33007. switch name {
  33008. case usagestatistichour.FieldCreatedAt:
  33009. v, ok := value.(time.Time)
  33010. if !ok {
  33011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33012. }
  33013. m.SetCreatedAt(v)
  33014. return nil
  33015. case usagestatistichour.FieldUpdatedAt:
  33016. v, ok := value.(time.Time)
  33017. if !ok {
  33018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33019. }
  33020. m.SetUpdatedAt(v)
  33021. return nil
  33022. case usagestatistichour.FieldStatus:
  33023. v, ok := value.(uint8)
  33024. if !ok {
  33025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33026. }
  33027. m.SetStatus(v)
  33028. return nil
  33029. case usagestatistichour.FieldDeletedAt:
  33030. v, ok := value.(time.Time)
  33031. if !ok {
  33032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33033. }
  33034. m.SetDeletedAt(v)
  33035. return nil
  33036. case usagestatistichour.FieldAddtime:
  33037. v, ok := value.(uint64)
  33038. if !ok {
  33039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33040. }
  33041. m.SetAddtime(v)
  33042. return nil
  33043. case usagestatistichour.FieldType:
  33044. v, ok := value.(int)
  33045. if !ok {
  33046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33047. }
  33048. m.SetType(v)
  33049. return nil
  33050. case usagestatistichour.FieldBotID:
  33051. v, ok := value.(string)
  33052. if !ok {
  33053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33054. }
  33055. m.SetBotID(v)
  33056. return nil
  33057. case usagestatistichour.FieldOrganizationID:
  33058. v, ok := value.(uint64)
  33059. if !ok {
  33060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33061. }
  33062. m.SetOrganizationID(v)
  33063. return nil
  33064. case usagestatistichour.FieldAiResponse:
  33065. v, ok := value.(uint64)
  33066. if !ok {
  33067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33068. }
  33069. m.SetAiResponse(v)
  33070. return nil
  33071. case usagestatistichour.FieldSopRun:
  33072. v, ok := value.(uint64)
  33073. if !ok {
  33074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33075. }
  33076. m.SetSopRun(v)
  33077. return nil
  33078. case usagestatistichour.FieldTotalFriend:
  33079. v, ok := value.(uint64)
  33080. if !ok {
  33081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33082. }
  33083. m.SetTotalFriend(v)
  33084. return nil
  33085. case usagestatistichour.FieldTotalGroup:
  33086. v, ok := value.(uint64)
  33087. if !ok {
  33088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33089. }
  33090. m.SetTotalGroup(v)
  33091. return nil
  33092. case usagestatistichour.FieldAccountBalance:
  33093. v, ok := value.(uint64)
  33094. if !ok {
  33095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33096. }
  33097. m.SetAccountBalance(v)
  33098. return nil
  33099. case usagestatistichour.FieldConsumeToken:
  33100. v, ok := value.(uint64)
  33101. if !ok {
  33102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33103. }
  33104. m.SetConsumeToken(v)
  33105. return nil
  33106. case usagestatistichour.FieldActiveUser:
  33107. v, ok := value.(uint64)
  33108. if !ok {
  33109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33110. }
  33111. m.SetActiveUser(v)
  33112. return nil
  33113. case usagestatistichour.FieldNewUser:
  33114. v, ok := value.(int64)
  33115. if !ok {
  33116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33117. }
  33118. m.SetNewUser(v)
  33119. return nil
  33120. case usagestatistichour.FieldLabelDist:
  33121. v, ok := value.([]custom_types.LabelDist)
  33122. if !ok {
  33123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33124. }
  33125. m.SetLabelDist(v)
  33126. return nil
  33127. }
  33128. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33129. }
  33130. // AddedFields returns all numeric fields that were incremented/decremented during
  33131. // this mutation.
  33132. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33133. var fields []string
  33134. if m.addstatus != nil {
  33135. fields = append(fields, usagestatistichour.FieldStatus)
  33136. }
  33137. if m.addaddtime != nil {
  33138. fields = append(fields, usagestatistichour.FieldAddtime)
  33139. }
  33140. if m.add_type != nil {
  33141. fields = append(fields, usagestatistichour.FieldType)
  33142. }
  33143. if m.addorganization_id != nil {
  33144. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33145. }
  33146. if m.addai_response != nil {
  33147. fields = append(fields, usagestatistichour.FieldAiResponse)
  33148. }
  33149. if m.addsop_run != nil {
  33150. fields = append(fields, usagestatistichour.FieldSopRun)
  33151. }
  33152. if m.addtotal_friend != nil {
  33153. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33154. }
  33155. if m.addtotal_group != nil {
  33156. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33157. }
  33158. if m.addaccount_balance != nil {
  33159. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33160. }
  33161. if m.addconsume_token != nil {
  33162. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33163. }
  33164. if m.addactive_user != nil {
  33165. fields = append(fields, usagestatistichour.FieldActiveUser)
  33166. }
  33167. if m.addnew_user != nil {
  33168. fields = append(fields, usagestatistichour.FieldNewUser)
  33169. }
  33170. return fields
  33171. }
  33172. // AddedField returns the numeric value that was incremented/decremented on a field
  33173. // with the given name. The second boolean return value indicates that this field
  33174. // was not set, or was not defined in the schema.
  33175. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33176. switch name {
  33177. case usagestatistichour.FieldStatus:
  33178. return m.AddedStatus()
  33179. case usagestatistichour.FieldAddtime:
  33180. return m.AddedAddtime()
  33181. case usagestatistichour.FieldType:
  33182. return m.AddedType()
  33183. case usagestatistichour.FieldOrganizationID:
  33184. return m.AddedOrganizationID()
  33185. case usagestatistichour.FieldAiResponse:
  33186. return m.AddedAiResponse()
  33187. case usagestatistichour.FieldSopRun:
  33188. return m.AddedSopRun()
  33189. case usagestatistichour.FieldTotalFriend:
  33190. return m.AddedTotalFriend()
  33191. case usagestatistichour.FieldTotalGroup:
  33192. return m.AddedTotalGroup()
  33193. case usagestatistichour.FieldAccountBalance:
  33194. return m.AddedAccountBalance()
  33195. case usagestatistichour.FieldConsumeToken:
  33196. return m.AddedConsumeToken()
  33197. case usagestatistichour.FieldActiveUser:
  33198. return m.AddedActiveUser()
  33199. case usagestatistichour.FieldNewUser:
  33200. return m.AddedNewUser()
  33201. }
  33202. return nil, false
  33203. }
  33204. // AddField adds the value to the field with the given name. It returns an error if
  33205. // the field is not defined in the schema, or if the type mismatched the field
  33206. // type.
  33207. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33208. switch name {
  33209. case usagestatistichour.FieldStatus:
  33210. v, ok := value.(int8)
  33211. if !ok {
  33212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33213. }
  33214. m.AddStatus(v)
  33215. return nil
  33216. case usagestatistichour.FieldAddtime:
  33217. v, ok := value.(int64)
  33218. if !ok {
  33219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33220. }
  33221. m.AddAddtime(v)
  33222. return nil
  33223. case usagestatistichour.FieldType:
  33224. v, ok := value.(int)
  33225. if !ok {
  33226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33227. }
  33228. m.AddType(v)
  33229. return nil
  33230. case usagestatistichour.FieldOrganizationID:
  33231. v, ok := value.(int64)
  33232. if !ok {
  33233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33234. }
  33235. m.AddOrganizationID(v)
  33236. return nil
  33237. case usagestatistichour.FieldAiResponse:
  33238. v, ok := value.(int64)
  33239. if !ok {
  33240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33241. }
  33242. m.AddAiResponse(v)
  33243. return nil
  33244. case usagestatistichour.FieldSopRun:
  33245. v, ok := value.(int64)
  33246. if !ok {
  33247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33248. }
  33249. m.AddSopRun(v)
  33250. return nil
  33251. case usagestatistichour.FieldTotalFriend:
  33252. v, ok := value.(int64)
  33253. if !ok {
  33254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33255. }
  33256. m.AddTotalFriend(v)
  33257. return nil
  33258. case usagestatistichour.FieldTotalGroup:
  33259. v, ok := value.(int64)
  33260. if !ok {
  33261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33262. }
  33263. m.AddTotalGroup(v)
  33264. return nil
  33265. case usagestatistichour.FieldAccountBalance:
  33266. v, ok := value.(int64)
  33267. if !ok {
  33268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33269. }
  33270. m.AddAccountBalance(v)
  33271. return nil
  33272. case usagestatistichour.FieldConsumeToken:
  33273. v, ok := value.(int64)
  33274. if !ok {
  33275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33276. }
  33277. m.AddConsumeToken(v)
  33278. return nil
  33279. case usagestatistichour.FieldActiveUser:
  33280. v, ok := value.(int64)
  33281. if !ok {
  33282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33283. }
  33284. m.AddActiveUser(v)
  33285. return nil
  33286. case usagestatistichour.FieldNewUser:
  33287. v, ok := value.(int64)
  33288. if !ok {
  33289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33290. }
  33291. m.AddNewUser(v)
  33292. return nil
  33293. }
  33294. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33295. }
  33296. // ClearedFields returns all nullable fields that were cleared during this
  33297. // mutation.
  33298. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33299. var fields []string
  33300. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33301. fields = append(fields, usagestatistichour.FieldStatus)
  33302. }
  33303. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33304. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33305. }
  33306. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33307. fields = append(fields, usagestatistichour.FieldBotID)
  33308. }
  33309. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33310. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33311. }
  33312. return fields
  33313. }
  33314. // FieldCleared returns a boolean indicating if a field with the given name was
  33315. // cleared in this mutation.
  33316. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33317. _, ok := m.clearedFields[name]
  33318. return ok
  33319. }
  33320. // ClearField clears the value of the field with the given name. It returns an
  33321. // error if the field is not defined in the schema.
  33322. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33323. switch name {
  33324. case usagestatistichour.FieldStatus:
  33325. m.ClearStatus()
  33326. return nil
  33327. case usagestatistichour.FieldDeletedAt:
  33328. m.ClearDeletedAt()
  33329. return nil
  33330. case usagestatistichour.FieldBotID:
  33331. m.ClearBotID()
  33332. return nil
  33333. case usagestatistichour.FieldOrganizationID:
  33334. m.ClearOrganizationID()
  33335. return nil
  33336. }
  33337. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33338. }
  33339. // ResetField resets all changes in the mutation for the field with the given name.
  33340. // It returns an error if the field is not defined in the schema.
  33341. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33342. switch name {
  33343. case usagestatistichour.FieldCreatedAt:
  33344. m.ResetCreatedAt()
  33345. return nil
  33346. case usagestatistichour.FieldUpdatedAt:
  33347. m.ResetUpdatedAt()
  33348. return nil
  33349. case usagestatistichour.FieldStatus:
  33350. m.ResetStatus()
  33351. return nil
  33352. case usagestatistichour.FieldDeletedAt:
  33353. m.ResetDeletedAt()
  33354. return nil
  33355. case usagestatistichour.FieldAddtime:
  33356. m.ResetAddtime()
  33357. return nil
  33358. case usagestatistichour.FieldType:
  33359. m.ResetType()
  33360. return nil
  33361. case usagestatistichour.FieldBotID:
  33362. m.ResetBotID()
  33363. return nil
  33364. case usagestatistichour.FieldOrganizationID:
  33365. m.ResetOrganizationID()
  33366. return nil
  33367. case usagestatistichour.FieldAiResponse:
  33368. m.ResetAiResponse()
  33369. return nil
  33370. case usagestatistichour.FieldSopRun:
  33371. m.ResetSopRun()
  33372. return nil
  33373. case usagestatistichour.FieldTotalFriend:
  33374. m.ResetTotalFriend()
  33375. return nil
  33376. case usagestatistichour.FieldTotalGroup:
  33377. m.ResetTotalGroup()
  33378. return nil
  33379. case usagestatistichour.FieldAccountBalance:
  33380. m.ResetAccountBalance()
  33381. return nil
  33382. case usagestatistichour.FieldConsumeToken:
  33383. m.ResetConsumeToken()
  33384. return nil
  33385. case usagestatistichour.FieldActiveUser:
  33386. m.ResetActiveUser()
  33387. return nil
  33388. case usagestatistichour.FieldNewUser:
  33389. m.ResetNewUser()
  33390. return nil
  33391. case usagestatistichour.FieldLabelDist:
  33392. m.ResetLabelDist()
  33393. return nil
  33394. }
  33395. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33396. }
  33397. // AddedEdges returns all edge names that were set/added in this mutation.
  33398. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33399. edges := make([]string, 0, 0)
  33400. return edges
  33401. }
  33402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33403. // name in this mutation.
  33404. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33405. return nil
  33406. }
  33407. // RemovedEdges returns all edge names that were removed in this mutation.
  33408. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33409. edges := make([]string, 0, 0)
  33410. return edges
  33411. }
  33412. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33413. // the given name in this mutation.
  33414. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33415. return nil
  33416. }
  33417. // ClearedEdges returns all edge names that were cleared in this mutation.
  33418. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33419. edges := make([]string, 0, 0)
  33420. return edges
  33421. }
  33422. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33423. // was cleared in this mutation.
  33424. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33425. return false
  33426. }
  33427. // ClearEdge clears the value of the edge with the given name. It returns an error
  33428. // if that edge is not defined in the schema.
  33429. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33430. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33431. }
  33432. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33433. // It returns an error if the edge is not defined in the schema.
  33434. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33435. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33436. }
  33437. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33438. type UsageStatisticMonthMutation struct {
  33439. config
  33440. op Op
  33441. typ string
  33442. id *uint64
  33443. created_at *time.Time
  33444. updated_at *time.Time
  33445. status *uint8
  33446. addstatus *int8
  33447. deleted_at *time.Time
  33448. addtime *uint64
  33449. addaddtime *int64
  33450. _type *int
  33451. add_type *int
  33452. bot_id *string
  33453. organization_id *uint64
  33454. addorganization_id *int64
  33455. ai_response *uint64
  33456. addai_response *int64
  33457. sop_run *uint64
  33458. addsop_run *int64
  33459. total_friend *uint64
  33460. addtotal_friend *int64
  33461. total_group *uint64
  33462. addtotal_group *int64
  33463. account_balance *uint64
  33464. addaccount_balance *int64
  33465. consume_token *uint64
  33466. addconsume_token *int64
  33467. active_user *uint64
  33468. addactive_user *int64
  33469. new_user *int64
  33470. addnew_user *int64
  33471. label_dist *[]custom_types.LabelDist
  33472. appendlabel_dist []custom_types.LabelDist
  33473. clearedFields map[string]struct{}
  33474. done bool
  33475. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33476. predicates []predicate.UsageStatisticMonth
  33477. }
  33478. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33479. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33480. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33481. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33482. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33483. m := &UsageStatisticMonthMutation{
  33484. config: c,
  33485. op: op,
  33486. typ: TypeUsageStatisticMonth,
  33487. clearedFields: make(map[string]struct{}),
  33488. }
  33489. for _, opt := range opts {
  33490. opt(m)
  33491. }
  33492. return m
  33493. }
  33494. // withUsageStatisticMonthID sets the ID field of the mutation.
  33495. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33496. return func(m *UsageStatisticMonthMutation) {
  33497. var (
  33498. err error
  33499. once sync.Once
  33500. value *UsageStatisticMonth
  33501. )
  33502. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33503. once.Do(func() {
  33504. if m.done {
  33505. err = errors.New("querying old values post mutation is not allowed")
  33506. } else {
  33507. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33508. }
  33509. })
  33510. return value, err
  33511. }
  33512. m.id = &id
  33513. }
  33514. }
  33515. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33516. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33517. return func(m *UsageStatisticMonthMutation) {
  33518. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33519. return node, nil
  33520. }
  33521. m.id = &node.ID
  33522. }
  33523. }
  33524. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33525. // executed in a transaction (ent.Tx), a transactional client is returned.
  33526. func (m UsageStatisticMonthMutation) Client() *Client {
  33527. client := &Client{config: m.config}
  33528. client.init()
  33529. return client
  33530. }
  33531. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33532. // it returns an error otherwise.
  33533. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33534. if _, ok := m.driver.(*txDriver); !ok {
  33535. return nil, errors.New("ent: mutation is not running in a transaction")
  33536. }
  33537. tx := &Tx{config: m.config}
  33538. tx.init()
  33539. return tx, nil
  33540. }
  33541. // SetID sets the value of the id field. Note that this
  33542. // operation is only accepted on creation of UsageStatisticMonth entities.
  33543. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33544. m.id = &id
  33545. }
  33546. // ID returns the ID value in the mutation. Note that the ID is only available
  33547. // if it was provided to the builder or after it was returned from the database.
  33548. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33549. if m.id == nil {
  33550. return
  33551. }
  33552. return *m.id, true
  33553. }
  33554. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33555. // That means, if the mutation is applied within a transaction with an isolation level such
  33556. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33557. // or updated by the mutation.
  33558. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33559. switch {
  33560. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33561. id, exists := m.ID()
  33562. if exists {
  33563. return []uint64{id}, nil
  33564. }
  33565. fallthrough
  33566. case m.op.Is(OpUpdate | OpDelete):
  33567. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33568. default:
  33569. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33570. }
  33571. }
  33572. // SetCreatedAt sets the "created_at" field.
  33573. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33574. m.created_at = &t
  33575. }
  33576. // CreatedAt returns the value of the "created_at" field in the mutation.
  33577. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33578. v := m.created_at
  33579. if v == nil {
  33580. return
  33581. }
  33582. return *v, true
  33583. }
  33584. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33585. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33587. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33588. if !m.op.Is(OpUpdateOne) {
  33589. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33590. }
  33591. if m.id == nil || m.oldValue == nil {
  33592. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33593. }
  33594. oldValue, err := m.oldValue(ctx)
  33595. if err != nil {
  33596. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33597. }
  33598. return oldValue.CreatedAt, nil
  33599. }
  33600. // ResetCreatedAt resets all changes to the "created_at" field.
  33601. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33602. m.created_at = nil
  33603. }
  33604. // SetUpdatedAt sets the "updated_at" field.
  33605. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33606. m.updated_at = &t
  33607. }
  33608. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33609. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33610. v := m.updated_at
  33611. if v == nil {
  33612. return
  33613. }
  33614. return *v, true
  33615. }
  33616. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33617. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33619. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33620. if !m.op.Is(OpUpdateOne) {
  33621. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33622. }
  33623. if m.id == nil || m.oldValue == nil {
  33624. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33625. }
  33626. oldValue, err := m.oldValue(ctx)
  33627. if err != nil {
  33628. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33629. }
  33630. return oldValue.UpdatedAt, nil
  33631. }
  33632. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33633. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33634. m.updated_at = nil
  33635. }
  33636. // SetStatus sets the "status" field.
  33637. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  33638. m.status = &u
  33639. m.addstatus = nil
  33640. }
  33641. // Status returns the value of the "status" field in the mutation.
  33642. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  33643. v := m.status
  33644. if v == nil {
  33645. return
  33646. }
  33647. return *v, true
  33648. }
  33649. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  33650. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33652. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33653. if !m.op.Is(OpUpdateOne) {
  33654. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33655. }
  33656. if m.id == nil || m.oldValue == nil {
  33657. return v, errors.New("OldStatus requires an ID field in the mutation")
  33658. }
  33659. oldValue, err := m.oldValue(ctx)
  33660. if err != nil {
  33661. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33662. }
  33663. return oldValue.Status, nil
  33664. }
  33665. // AddStatus adds u to the "status" field.
  33666. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  33667. if m.addstatus != nil {
  33668. *m.addstatus += u
  33669. } else {
  33670. m.addstatus = &u
  33671. }
  33672. }
  33673. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33674. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  33675. v := m.addstatus
  33676. if v == nil {
  33677. return
  33678. }
  33679. return *v, true
  33680. }
  33681. // ClearStatus clears the value of the "status" field.
  33682. func (m *UsageStatisticMonthMutation) ClearStatus() {
  33683. m.status = nil
  33684. m.addstatus = nil
  33685. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  33686. }
  33687. // StatusCleared returns if the "status" field was cleared in this mutation.
  33688. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  33689. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  33690. return ok
  33691. }
  33692. // ResetStatus resets all changes to the "status" field.
  33693. func (m *UsageStatisticMonthMutation) ResetStatus() {
  33694. m.status = nil
  33695. m.addstatus = nil
  33696. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  33697. }
  33698. // SetDeletedAt sets the "deleted_at" field.
  33699. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  33700. m.deleted_at = &t
  33701. }
  33702. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33703. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  33704. v := m.deleted_at
  33705. if v == nil {
  33706. return
  33707. }
  33708. return *v, true
  33709. }
  33710. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  33711. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33713. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33714. if !m.op.Is(OpUpdateOne) {
  33715. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33716. }
  33717. if m.id == nil || m.oldValue == nil {
  33718. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33719. }
  33720. oldValue, err := m.oldValue(ctx)
  33721. if err != nil {
  33722. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33723. }
  33724. return oldValue.DeletedAt, nil
  33725. }
  33726. // ClearDeletedAt clears the value of the "deleted_at" field.
  33727. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  33728. m.deleted_at = nil
  33729. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  33730. }
  33731. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33732. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  33733. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  33734. return ok
  33735. }
  33736. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33737. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  33738. m.deleted_at = nil
  33739. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  33740. }
  33741. // SetAddtime sets the "addtime" field.
  33742. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  33743. m.addtime = &u
  33744. m.addaddtime = nil
  33745. }
  33746. // Addtime returns the value of the "addtime" field in the mutation.
  33747. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  33748. v := m.addtime
  33749. if v == nil {
  33750. return
  33751. }
  33752. return *v, true
  33753. }
  33754. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  33755. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33757. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33758. if !m.op.Is(OpUpdateOne) {
  33759. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33760. }
  33761. if m.id == nil || m.oldValue == nil {
  33762. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33763. }
  33764. oldValue, err := m.oldValue(ctx)
  33765. if err != nil {
  33766. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33767. }
  33768. return oldValue.Addtime, nil
  33769. }
  33770. // AddAddtime adds u to the "addtime" field.
  33771. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  33772. if m.addaddtime != nil {
  33773. *m.addaddtime += u
  33774. } else {
  33775. m.addaddtime = &u
  33776. }
  33777. }
  33778. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33779. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  33780. v := m.addaddtime
  33781. if v == nil {
  33782. return
  33783. }
  33784. return *v, true
  33785. }
  33786. // ResetAddtime resets all changes to the "addtime" field.
  33787. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  33788. m.addtime = nil
  33789. m.addaddtime = nil
  33790. }
  33791. // SetType sets the "type" field.
  33792. func (m *UsageStatisticMonthMutation) SetType(i int) {
  33793. m._type = &i
  33794. m.add_type = nil
  33795. }
  33796. // GetType returns the value of the "type" field in the mutation.
  33797. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  33798. v := m._type
  33799. if v == nil {
  33800. return
  33801. }
  33802. return *v, true
  33803. }
  33804. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  33805. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33807. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  33808. if !m.op.Is(OpUpdateOne) {
  33809. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33810. }
  33811. if m.id == nil || m.oldValue == nil {
  33812. return v, errors.New("OldType requires an ID field in the mutation")
  33813. }
  33814. oldValue, err := m.oldValue(ctx)
  33815. if err != nil {
  33816. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33817. }
  33818. return oldValue.Type, nil
  33819. }
  33820. // AddType adds i to the "type" field.
  33821. func (m *UsageStatisticMonthMutation) AddType(i int) {
  33822. if m.add_type != nil {
  33823. *m.add_type += i
  33824. } else {
  33825. m.add_type = &i
  33826. }
  33827. }
  33828. // AddedType returns the value that was added to the "type" field in this mutation.
  33829. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  33830. v := m.add_type
  33831. if v == nil {
  33832. return
  33833. }
  33834. return *v, true
  33835. }
  33836. // ResetType resets all changes to the "type" field.
  33837. func (m *UsageStatisticMonthMutation) ResetType() {
  33838. m._type = nil
  33839. m.add_type = nil
  33840. }
  33841. // SetBotID sets the "bot_id" field.
  33842. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  33843. m.bot_id = &s
  33844. }
  33845. // BotID returns the value of the "bot_id" field in the mutation.
  33846. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  33847. v := m.bot_id
  33848. if v == nil {
  33849. return
  33850. }
  33851. return *v, true
  33852. }
  33853. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  33854. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33856. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  33857. if !m.op.Is(OpUpdateOne) {
  33858. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33859. }
  33860. if m.id == nil || m.oldValue == nil {
  33861. return v, errors.New("OldBotID requires an ID field in the mutation")
  33862. }
  33863. oldValue, err := m.oldValue(ctx)
  33864. if err != nil {
  33865. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33866. }
  33867. return oldValue.BotID, nil
  33868. }
  33869. // ClearBotID clears the value of the "bot_id" field.
  33870. func (m *UsageStatisticMonthMutation) ClearBotID() {
  33871. m.bot_id = nil
  33872. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  33873. }
  33874. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33875. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  33876. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  33877. return ok
  33878. }
  33879. // ResetBotID resets all changes to the "bot_id" field.
  33880. func (m *UsageStatisticMonthMutation) ResetBotID() {
  33881. m.bot_id = nil
  33882. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  33883. }
  33884. // SetOrganizationID sets the "organization_id" field.
  33885. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  33886. m.organization_id = &u
  33887. m.addorganization_id = nil
  33888. }
  33889. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33890. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  33891. v := m.organization_id
  33892. if v == nil {
  33893. return
  33894. }
  33895. return *v, true
  33896. }
  33897. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  33898. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33900. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33901. if !m.op.Is(OpUpdateOne) {
  33902. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33903. }
  33904. if m.id == nil || m.oldValue == nil {
  33905. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33906. }
  33907. oldValue, err := m.oldValue(ctx)
  33908. if err != nil {
  33909. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33910. }
  33911. return oldValue.OrganizationID, nil
  33912. }
  33913. // AddOrganizationID adds u to the "organization_id" field.
  33914. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  33915. if m.addorganization_id != nil {
  33916. *m.addorganization_id += u
  33917. } else {
  33918. m.addorganization_id = &u
  33919. }
  33920. }
  33921. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33922. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  33923. v := m.addorganization_id
  33924. if v == nil {
  33925. return
  33926. }
  33927. return *v, true
  33928. }
  33929. // ClearOrganizationID clears the value of the "organization_id" field.
  33930. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  33931. m.organization_id = nil
  33932. m.addorganization_id = nil
  33933. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  33934. }
  33935. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33936. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  33937. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  33938. return ok
  33939. }
  33940. // ResetOrganizationID resets all changes to the "organization_id" field.
  33941. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  33942. m.organization_id = nil
  33943. m.addorganization_id = nil
  33944. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  33945. }
  33946. // SetAiResponse sets the "ai_response" field.
  33947. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  33948. m.ai_response = &u
  33949. m.addai_response = nil
  33950. }
  33951. // AiResponse returns the value of the "ai_response" field in the mutation.
  33952. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  33953. v := m.ai_response
  33954. if v == nil {
  33955. return
  33956. }
  33957. return *v, true
  33958. }
  33959. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  33960. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33962. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33963. if !m.op.Is(OpUpdateOne) {
  33964. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33965. }
  33966. if m.id == nil || m.oldValue == nil {
  33967. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33968. }
  33969. oldValue, err := m.oldValue(ctx)
  33970. if err != nil {
  33971. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33972. }
  33973. return oldValue.AiResponse, nil
  33974. }
  33975. // AddAiResponse adds u to the "ai_response" field.
  33976. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  33977. if m.addai_response != nil {
  33978. *m.addai_response += u
  33979. } else {
  33980. m.addai_response = &u
  33981. }
  33982. }
  33983. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33984. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  33985. v := m.addai_response
  33986. if v == nil {
  33987. return
  33988. }
  33989. return *v, true
  33990. }
  33991. // ResetAiResponse resets all changes to the "ai_response" field.
  33992. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  33993. m.ai_response = nil
  33994. m.addai_response = nil
  33995. }
  33996. // SetSopRun sets the "sop_run" field.
  33997. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  33998. m.sop_run = &u
  33999. m.addsop_run = nil
  34000. }
  34001. // SopRun returns the value of the "sop_run" field in the mutation.
  34002. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  34003. v := m.sop_run
  34004. if v == nil {
  34005. return
  34006. }
  34007. return *v, true
  34008. }
  34009. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  34010. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34012. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34013. if !m.op.Is(OpUpdateOne) {
  34014. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34015. }
  34016. if m.id == nil || m.oldValue == nil {
  34017. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34018. }
  34019. oldValue, err := m.oldValue(ctx)
  34020. if err != nil {
  34021. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34022. }
  34023. return oldValue.SopRun, nil
  34024. }
  34025. // AddSopRun adds u to the "sop_run" field.
  34026. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  34027. if m.addsop_run != nil {
  34028. *m.addsop_run += u
  34029. } else {
  34030. m.addsop_run = &u
  34031. }
  34032. }
  34033. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34034. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  34035. v := m.addsop_run
  34036. if v == nil {
  34037. return
  34038. }
  34039. return *v, true
  34040. }
  34041. // ResetSopRun resets all changes to the "sop_run" field.
  34042. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  34043. m.sop_run = nil
  34044. m.addsop_run = nil
  34045. }
  34046. // SetTotalFriend sets the "total_friend" field.
  34047. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  34048. m.total_friend = &u
  34049. m.addtotal_friend = nil
  34050. }
  34051. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34052. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  34053. v := m.total_friend
  34054. if v == nil {
  34055. return
  34056. }
  34057. return *v, true
  34058. }
  34059. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  34060. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34062. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34063. if !m.op.Is(OpUpdateOne) {
  34064. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34065. }
  34066. if m.id == nil || m.oldValue == nil {
  34067. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34068. }
  34069. oldValue, err := m.oldValue(ctx)
  34070. if err != nil {
  34071. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34072. }
  34073. return oldValue.TotalFriend, nil
  34074. }
  34075. // AddTotalFriend adds u to the "total_friend" field.
  34076. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  34077. if m.addtotal_friend != nil {
  34078. *m.addtotal_friend += u
  34079. } else {
  34080. m.addtotal_friend = &u
  34081. }
  34082. }
  34083. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34084. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34085. v := m.addtotal_friend
  34086. if v == nil {
  34087. return
  34088. }
  34089. return *v, true
  34090. }
  34091. // ResetTotalFriend resets all changes to the "total_friend" field.
  34092. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34093. m.total_friend = nil
  34094. m.addtotal_friend = nil
  34095. }
  34096. // SetTotalGroup sets the "total_group" field.
  34097. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34098. m.total_group = &u
  34099. m.addtotal_group = nil
  34100. }
  34101. // TotalGroup returns the value of the "total_group" field in the mutation.
  34102. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34103. v := m.total_group
  34104. if v == nil {
  34105. return
  34106. }
  34107. return *v, true
  34108. }
  34109. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34110. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34112. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34113. if !m.op.Is(OpUpdateOne) {
  34114. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34115. }
  34116. if m.id == nil || m.oldValue == nil {
  34117. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34118. }
  34119. oldValue, err := m.oldValue(ctx)
  34120. if err != nil {
  34121. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34122. }
  34123. return oldValue.TotalGroup, nil
  34124. }
  34125. // AddTotalGroup adds u to the "total_group" field.
  34126. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34127. if m.addtotal_group != nil {
  34128. *m.addtotal_group += u
  34129. } else {
  34130. m.addtotal_group = &u
  34131. }
  34132. }
  34133. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34134. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34135. v := m.addtotal_group
  34136. if v == nil {
  34137. return
  34138. }
  34139. return *v, true
  34140. }
  34141. // ResetTotalGroup resets all changes to the "total_group" field.
  34142. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34143. m.total_group = nil
  34144. m.addtotal_group = nil
  34145. }
  34146. // SetAccountBalance sets the "account_balance" field.
  34147. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34148. m.account_balance = &u
  34149. m.addaccount_balance = nil
  34150. }
  34151. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34152. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34153. v := m.account_balance
  34154. if v == nil {
  34155. return
  34156. }
  34157. return *v, true
  34158. }
  34159. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34160. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34162. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34163. if !m.op.Is(OpUpdateOne) {
  34164. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34165. }
  34166. if m.id == nil || m.oldValue == nil {
  34167. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34168. }
  34169. oldValue, err := m.oldValue(ctx)
  34170. if err != nil {
  34171. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34172. }
  34173. return oldValue.AccountBalance, nil
  34174. }
  34175. // AddAccountBalance adds u to the "account_balance" field.
  34176. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34177. if m.addaccount_balance != nil {
  34178. *m.addaccount_balance += u
  34179. } else {
  34180. m.addaccount_balance = &u
  34181. }
  34182. }
  34183. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34184. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34185. v := m.addaccount_balance
  34186. if v == nil {
  34187. return
  34188. }
  34189. return *v, true
  34190. }
  34191. // ResetAccountBalance resets all changes to the "account_balance" field.
  34192. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34193. m.account_balance = nil
  34194. m.addaccount_balance = nil
  34195. }
  34196. // SetConsumeToken sets the "consume_token" field.
  34197. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34198. m.consume_token = &u
  34199. m.addconsume_token = nil
  34200. }
  34201. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34202. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34203. v := m.consume_token
  34204. if v == nil {
  34205. return
  34206. }
  34207. return *v, true
  34208. }
  34209. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34210. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34212. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34213. if !m.op.Is(OpUpdateOne) {
  34214. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34215. }
  34216. if m.id == nil || m.oldValue == nil {
  34217. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34218. }
  34219. oldValue, err := m.oldValue(ctx)
  34220. if err != nil {
  34221. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34222. }
  34223. return oldValue.ConsumeToken, nil
  34224. }
  34225. // AddConsumeToken adds u to the "consume_token" field.
  34226. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34227. if m.addconsume_token != nil {
  34228. *m.addconsume_token += u
  34229. } else {
  34230. m.addconsume_token = &u
  34231. }
  34232. }
  34233. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34234. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34235. v := m.addconsume_token
  34236. if v == nil {
  34237. return
  34238. }
  34239. return *v, true
  34240. }
  34241. // ResetConsumeToken resets all changes to the "consume_token" field.
  34242. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34243. m.consume_token = nil
  34244. m.addconsume_token = nil
  34245. }
  34246. // SetActiveUser sets the "active_user" field.
  34247. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34248. m.active_user = &u
  34249. m.addactive_user = nil
  34250. }
  34251. // ActiveUser returns the value of the "active_user" field in the mutation.
  34252. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34253. v := m.active_user
  34254. if v == nil {
  34255. return
  34256. }
  34257. return *v, true
  34258. }
  34259. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34260. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34262. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34263. if !m.op.Is(OpUpdateOne) {
  34264. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34265. }
  34266. if m.id == nil || m.oldValue == nil {
  34267. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34268. }
  34269. oldValue, err := m.oldValue(ctx)
  34270. if err != nil {
  34271. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34272. }
  34273. return oldValue.ActiveUser, nil
  34274. }
  34275. // AddActiveUser adds u to the "active_user" field.
  34276. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34277. if m.addactive_user != nil {
  34278. *m.addactive_user += u
  34279. } else {
  34280. m.addactive_user = &u
  34281. }
  34282. }
  34283. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34284. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34285. v := m.addactive_user
  34286. if v == nil {
  34287. return
  34288. }
  34289. return *v, true
  34290. }
  34291. // ResetActiveUser resets all changes to the "active_user" field.
  34292. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34293. m.active_user = nil
  34294. m.addactive_user = nil
  34295. }
  34296. // SetNewUser sets the "new_user" field.
  34297. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34298. m.new_user = &i
  34299. m.addnew_user = nil
  34300. }
  34301. // NewUser returns the value of the "new_user" field in the mutation.
  34302. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34303. v := m.new_user
  34304. if v == nil {
  34305. return
  34306. }
  34307. return *v, true
  34308. }
  34309. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34310. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34312. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34313. if !m.op.Is(OpUpdateOne) {
  34314. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34315. }
  34316. if m.id == nil || m.oldValue == nil {
  34317. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34318. }
  34319. oldValue, err := m.oldValue(ctx)
  34320. if err != nil {
  34321. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34322. }
  34323. return oldValue.NewUser, nil
  34324. }
  34325. // AddNewUser adds i to the "new_user" field.
  34326. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34327. if m.addnew_user != nil {
  34328. *m.addnew_user += i
  34329. } else {
  34330. m.addnew_user = &i
  34331. }
  34332. }
  34333. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34334. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34335. v := m.addnew_user
  34336. if v == nil {
  34337. return
  34338. }
  34339. return *v, true
  34340. }
  34341. // ResetNewUser resets all changes to the "new_user" field.
  34342. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34343. m.new_user = nil
  34344. m.addnew_user = nil
  34345. }
  34346. // SetLabelDist sets the "label_dist" field.
  34347. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34348. m.label_dist = &ctd
  34349. m.appendlabel_dist = nil
  34350. }
  34351. // LabelDist returns the value of the "label_dist" field in the mutation.
  34352. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34353. v := m.label_dist
  34354. if v == nil {
  34355. return
  34356. }
  34357. return *v, true
  34358. }
  34359. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34360. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34362. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34363. if !m.op.Is(OpUpdateOne) {
  34364. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34365. }
  34366. if m.id == nil || m.oldValue == nil {
  34367. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34368. }
  34369. oldValue, err := m.oldValue(ctx)
  34370. if err != nil {
  34371. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34372. }
  34373. return oldValue.LabelDist, nil
  34374. }
  34375. // AppendLabelDist adds ctd to the "label_dist" field.
  34376. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34377. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34378. }
  34379. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34380. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34381. if len(m.appendlabel_dist) == 0 {
  34382. return nil, false
  34383. }
  34384. return m.appendlabel_dist, true
  34385. }
  34386. // ResetLabelDist resets all changes to the "label_dist" field.
  34387. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34388. m.label_dist = nil
  34389. m.appendlabel_dist = nil
  34390. }
  34391. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34392. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34393. m.predicates = append(m.predicates, ps...)
  34394. }
  34395. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34396. // users can use type-assertion to append predicates that do not depend on any generated package.
  34397. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34398. p := make([]predicate.UsageStatisticMonth, len(ps))
  34399. for i := range ps {
  34400. p[i] = ps[i]
  34401. }
  34402. m.Where(p...)
  34403. }
  34404. // Op returns the operation name.
  34405. func (m *UsageStatisticMonthMutation) Op() Op {
  34406. return m.op
  34407. }
  34408. // SetOp allows setting the mutation operation.
  34409. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34410. m.op = op
  34411. }
  34412. // Type returns the node type of this mutation (UsageStatisticMonth).
  34413. func (m *UsageStatisticMonthMutation) Type() string {
  34414. return m.typ
  34415. }
  34416. // Fields returns all fields that were changed during this mutation. Note that in
  34417. // order to get all numeric fields that were incremented/decremented, call
  34418. // AddedFields().
  34419. func (m *UsageStatisticMonthMutation) Fields() []string {
  34420. fields := make([]string, 0, 17)
  34421. if m.created_at != nil {
  34422. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34423. }
  34424. if m.updated_at != nil {
  34425. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34426. }
  34427. if m.status != nil {
  34428. fields = append(fields, usagestatisticmonth.FieldStatus)
  34429. }
  34430. if m.deleted_at != nil {
  34431. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34432. }
  34433. if m.addtime != nil {
  34434. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34435. }
  34436. if m._type != nil {
  34437. fields = append(fields, usagestatisticmonth.FieldType)
  34438. }
  34439. if m.bot_id != nil {
  34440. fields = append(fields, usagestatisticmonth.FieldBotID)
  34441. }
  34442. if m.organization_id != nil {
  34443. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34444. }
  34445. if m.ai_response != nil {
  34446. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34447. }
  34448. if m.sop_run != nil {
  34449. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34450. }
  34451. if m.total_friend != nil {
  34452. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34453. }
  34454. if m.total_group != nil {
  34455. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34456. }
  34457. if m.account_balance != nil {
  34458. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34459. }
  34460. if m.consume_token != nil {
  34461. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34462. }
  34463. if m.active_user != nil {
  34464. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34465. }
  34466. if m.new_user != nil {
  34467. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34468. }
  34469. if m.label_dist != nil {
  34470. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34471. }
  34472. return fields
  34473. }
  34474. // Field returns the value of a field with the given name. The second boolean
  34475. // return value indicates that this field was not set, or was not defined in the
  34476. // schema.
  34477. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34478. switch name {
  34479. case usagestatisticmonth.FieldCreatedAt:
  34480. return m.CreatedAt()
  34481. case usagestatisticmonth.FieldUpdatedAt:
  34482. return m.UpdatedAt()
  34483. case usagestatisticmonth.FieldStatus:
  34484. return m.Status()
  34485. case usagestatisticmonth.FieldDeletedAt:
  34486. return m.DeletedAt()
  34487. case usagestatisticmonth.FieldAddtime:
  34488. return m.Addtime()
  34489. case usagestatisticmonth.FieldType:
  34490. return m.GetType()
  34491. case usagestatisticmonth.FieldBotID:
  34492. return m.BotID()
  34493. case usagestatisticmonth.FieldOrganizationID:
  34494. return m.OrganizationID()
  34495. case usagestatisticmonth.FieldAiResponse:
  34496. return m.AiResponse()
  34497. case usagestatisticmonth.FieldSopRun:
  34498. return m.SopRun()
  34499. case usagestatisticmonth.FieldTotalFriend:
  34500. return m.TotalFriend()
  34501. case usagestatisticmonth.FieldTotalGroup:
  34502. return m.TotalGroup()
  34503. case usagestatisticmonth.FieldAccountBalance:
  34504. return m.AccountBalance()
  34505. case usagestatisticmonth.FieldConsumeToken:
  34506. return m.ConsumeToken()
  34507. case usagestatisticmonth.FieldActiveUser:
  34508. return m.ActiveUser()
  34509. case usagestatisticmonth.FieldNewUser:
  34510. return m.NewUser()
  34511. case usagestatisticmonth.FieldLabelDist:
  34512. return m.LabelDist()
  34513. }
  34514. return nil, false
  34515. }
  34516. // OldField returns the old value of the field from the database. An error is
  34517. // returned if the mutation operation is not UpdateOne, or the query to the
  34518. // database failed.
  34519. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34520. switch name {
  34521. case usagestatisticmonth.FieldCreatedAt:
  34522. return m.OldCreatedAt(ctx)
  34523. case usagestatisticmonth.FieldUpdatedAt:
  34524. return m.OldUpdatedAt(ctx)
  34525. case usagestatisticmonth.FieldStatus:
  34526. return m.OldStatus(ctx)
  34527. case usagestatisticmonth.FieldDeletedAt:
  34528. return m.OldDeletedAt(ctx)
  34529. case usagestatisticmonth.FieldAddtime:
  34530. return m.OldAddtime(ctx)
  34531. case usagestatisticmonth.FieldType:
  34532. return m.OldType(ctx)
  34533. case usagestatisticmonth.FieldBotID:
  34534. return m.OldBotID(ctx)
  34535. case usagestatisticmonth.FieldOrganizationID:
  34536. return m.OldOrganizationID(ctx)
  34537. case usagestatisticmonth.FieldAiResponse:
  34538. return m.OldAiResponse(ctx)
  34539. case usagestatisticmonth.FieldSopRun:
  34540. return m.OldSopRun(ctx)
  34541. case usagestatisticmonth.FieldTotalFriend:
  34542. return m.OldTotalFriend(ctx)
  34543. case usagestatisticmonth.FieldTotalGroup:
  34544. return m.OldTotalGroup(ctx)
  34545. case usagestatisticmonth.FieldAccountBalance:
  34546. return m.OldAccountBalance(ctx)
  34547. case usagestatisticmonth.FieldConsumeToken:
  34548. return m.OldConsumeToken(ctx)
  34549. case usagestatisticmonth.FieldActiveUser:
  34550. return m.OldActiveUser(ctx)
  34551. case usagestatisticmonth.FieldNewUser:
  34552. return m.OldNewUser(ctx)
  34553. case usagestatisticmonth.FieldLabelDist:
  34554. return m.OldLabelDist(ctx)
  34555. }
  34556. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34557. }
  34558. // SetField sets the value of a field with the given name. It returns an error if
  34559. // the field is not defined in the schema, or if the type mismatched the field
  34560. // type.
  34561. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34562. switch name {
  34563. case usagestatisticmonth.FieldCreatedAt:
  34564. v, ok := value.(time.Time)
  34565. if !ok {
  34566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34567. }
  34568. m.SetCreatedAt(v)
  34569. return nil
  34570. case usagestatisticmonth.FieldUpdatedAt:
  34571. v, ok := value.(time.Time)
  34572. if !ok {
  34573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34574. }
  34575. m.SetUpdatedAt(v)
  34576. return nil
  34577. case usagestatisticmonth.FieldStatus:
  34578. v, ok := value.(uint8)
  34579. if !ok {
  34580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34581. }
  34582. m.SetStatus(v)
  34583. return nil
  34584. case usagestatisticmonth.FieldDeletedAt:
  34585. v, ok := value.(time.Time)
  34586. if !ok {
  34587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34588. }
  34589. m.SetDeletedAt(v)
  34590. return nil
  34591. case usagestatisticmonth.FieldAddtime:
  34592. v, ok := value.(uint64)
  34593. if !ok {
  34594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34595. }
  34596. m.SetAddtime(v)
  34597. return nil
  34598. case usagestatisticmonth.FieldType:
  34599. v, ok := value.(int)
  34600. if !ok {
  34601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34602. }
  34603. m.SetType(v)
  34604. return nil
  34605. case usagestatisticmonth.FieldBotID:
  34606. v, ok := value.(string)
  34607. if !ok {
  34608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34609. }
  34610. m.SetBotID(v)
  34611. return nil
  34612. case usagestatisticmonth.FieldOrganizationID:
  34613. v, ok := value.(uint64)
  34614. if !ok {
  34615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34616. }
  34617. m.SetOrganizationID(v)
  34618. return nil
  34619. case usagestatisticmonth.FieldAiResponse:
  34620. v, ok := value.(uint64)
  34621. if !ok {
  34622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34623. }
  34624. m.SetAiResponse(v)
  34625. return nil
  34626. case usagestatisticmonth.FieldSopRun:
  34627. v, ok := value.(uint64)
  34628. if !ok {
  34629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34630. }
  34631. m.SetSopRun(v)
  34632. return nil
  34633. case usagestatisticmonth.FieldTotalFriend:
  34634. v, ok := value.(uint64)
  34635. if !ok {
  34636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34637. }
  34638. m.SetTotalFriend(v)
  34639. return nil
  34640. case usagestatisticmonth.FieldTotalGroup:
  34641. v, ok := value.(uint64)
  34642. if !ok {
  34643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34644. }
  34645. m.SetTotalGroup(v)
  34646. return nil
  34647. case usagestatisticmonth.FieldAccountBalance:
  34648. v, ok := value.(uint64)
  34649. if !ok {
  34650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34651. }
  34652. m.SetAccountBalance(v)
  34653. return nil
  34654. case usagestatisticmonth.FieldConsumeToken:
  34655. v, ok := value.(uint64)
  34656. if !ok {
  34657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34658. }
  34659. m.SetConsumeToken(v)
  34660. return nil
  34661. case usagestatisticmonth.FieldActiveUser:
  34662. v, ok := value.(uint64)
  34663. if !ok {
  34664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34665. }
  34666. m.SetActiveUser(v)
  34667. return nil
  34668. case usagestatisticmonth.FieldNewUser:
  34669. v, ok := value.(int64)
  34670. if !ok {
  34671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34672. }
  34673. m.SetNewUser(v)
  34674. return nil
  34675. case usagestatisticmonth.FieldLabelDist:
  34676. v, ok := value.([]custom_types.LabelDist)
  34677. if !ok {
  34678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34679. }
  34680. m.SetLabelDist(v)
  34681. return nil
  34682. }
  34683. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34684. }
  34685. // AddedFields returns all numeric fields that were incremented/decremented during
  34686. // this mutation.
  34687. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  34688. var fields []string
  34689. if m.addstatus != nil {
  34690. fields = append(fields, usagestatisticmonth.FieldStatus)
  34691. }
  34692. if m.addaddtime != nil {
  34693. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34694. }
  34695. if m.add_type != nil {
  34696. fields = append(fields, usagestatisticmonth.FieldType)
  34697. }
  34698. if m.addorganization_id != nil {
  34699. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34700. }
  34701. if m.addai_response != nil {
  34702. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34703. }
  34704. if m.addsop_run != nil {
  34705. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34706. }
  34707. if m.addtotal_friend != nil {
  34708. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34709. }
  34710. if m.addtotal_group != nil {
  34711. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34712. }
  34713. if m.addaccount_balance != nil {
  34714. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34715. }
  34716. if m.addconsume_token != nil {
  34717. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34718. }
  34719. if m.addactive_user != nil {
  34720. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34721. }
  34722. if m.addnew_user != nil {
  34723. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34724. }
  34725. return fields
  34726. }
  34727. // AddedField returns the numeric value that was incremented/decremented on a field
  34728. // with the given name. The second boolean return value indicates that this field
  34729. // was not set, or was not defined in the schema.
  34730. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  34731. switch name {
  34732. case usagestatisticmonth.FieldStatus:
  34733. return m.AddedStatus()
  34734. case usagestatisticmonth.FieldAddtime:
  34735. return m.AddedAddtime()
  34736. case usagestatisticmonth.FieldType:
  34737. return m.AddedType()
  34738. case usagestatisticmonth.FieldOrganizationID:
  34739. return m.AddedOrganizationID()
  34740. case usagestatisticmonth.FieldAiResponse:
  34741. return m.AddedAiResponse()
  34742. case usagestatisticmonth.FieldSopRun:
  34743. return m.AddedSopRun()
  34744. case usagestatisticmonth.FieldTotalFriend:
  34745. return m.AddedTotalFriend()
  34746. case usagestatisticmonth.FieldTotalGroup:
  34747. return m.AddedTotalGroup()
  34748. case usagestatisticmonth.FieldAccountBalance:
  34749. return m.AddedAccountBalance()
  34750. case usagestatisticmonth.FieldConsumeToken:
  34751. return m.AddedConsumeToken()
  34752. case usagestatisticmonth.FieldActiveUser:
  34753. return m.AddedActiveUser()
  34754. case usagestatisticmonth.FieldNewUser:
  34755. return m.AddedNewUser()
  34756. }
  34757. return nil, false
  34758. }
  34759. // AddField adds the value to the field with the given name. It returns an error if
  34760. // the field is not defined in the schema, or if the type mismatched the field
  34761. // type.
  34762. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  34763. switch name {
  34764. case usagestatisticmonth.FieldStatus:
  34765. v, ok := value.(int8)
  34766. if !ok {
  34767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34768. }
  34769. m.AddStatus(v)
  34770. return nil
  34771. case usagestatisticmonth.FieldAddtime:
  34772. v, ok := value.(int64)
  34773. if !ok {
  34774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34775. }
  34776. m.AddAddtime(v)
  34777. return nil
  34778. case usagestatisticmonth.FieldType:
  34779. v, ok := value.(int)
  34780. if !ok {
  34781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34782. }
  34783. m.AddType(v)
  34784. return nil
  34785. case usagestatisticmonth.FieldOrganizationID:
  34786. v, ok := value.(int64)
  34787. if !ok {
  34788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34789. }
  34790. m.AddOrganizationID(v)
  34791. return nil
  34792. case usagestatisticmonth.FieldAiResponse:
  34793. v, ok := value.(int64)
  34794. if !ok {
  34795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34796. }
  34797. m.AddAiResponse(v)
  34798. return nil
  34799. case usagestatisticmonth.FieldSopRun:
  34800. v, ok := value.(int64)
  34801. if !ok {
  34802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34803. }
  34804. m.AddSopRun(v)
  34805. return nil
  34806. case usagestatisticmonth.FieldTotalFriend:
  34807. v, ok := value.(int64)
  34808. if !ok {
  34809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34810. }
  34811. m.AddTotalFriend(v)
  34812. return nil
  34813. case usagestatisticmonth.FieldTotalGroup:
  34814. v, ok := value.(int64)
  34815. if !ok {
  34816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34817. }
  34818. m.AddTotalGroup(v)
  34819. return nil
  34820. case usagestatisticmonth.FieldAccountBalance:
  34821. v, ok := value.(int64)
  34822. if !ok {
  34823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34824. }
  34825. m.AddAccountBalance(v)
  34826. return nil
  34827. case usagestatisticmonth.FieldConsumeToken:
  34828. v, ok := value.(int64)
  34829. if !ok {
  34830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34831. }
  34832. m.AddConsumeToken(v)
  34833. return nil
  34834. case usagestatisticmonth.FieldActiveUser:
  34835. v, ok := value.(int64)
  34836. if !ok {
  34837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34838. }
  34839. m.AddActiveUser(v)
  34840. return nil
  34841. case usagestatisticmonth.FieldNewUser:
  34842. v, ok := value.(int64)
  34843. if !ok {
  34844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34845. }
  34846. m.AddNewUser(v)
  34847. return nil
  34848. }
  34849. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  34850. }
  34851. // ClearedFields returns all nullable fields that were cleared during this
  34852. // mutation.
  34853. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  34854. var fields []string
  34855. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  34856. fields = append(fields, usagestatisticmonth.FieldStatus)
  34857. }
  34858. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  34859. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34860. }
  34861. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  34862. fields = append(fields, usagestatisticmonth.FieldBotID)
  34863. }
  34864. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  34865. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34866. }
  34867. return fields
  34868. }
  34869. // FieldCleared returns a boolean indicating if a field with the given name was
  34870. // cleared in this mutation.
  34871. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  34872. _, ok := m.clearedFields[name]
  34873. return ok
  34874. }
  34875. // ClearField clears the value of the field with the given name. It returns an
  34876. // error if the field is not defined in the schema.
  34877. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  34878. switch name {
  34879. case usagestatisticmonth.FieldStatus:
  34880. m.ClearStatus()
  34881. return nil
  34882. case usagestatisticmonth.FieldDeletedAt:
  34883. m.ClearDeletedAt()
  34884. return nil
  34885. case usagestatisticmonth.FieldBotID:
  34886. m.ClearBotID()
  34887. return nil
  34888. case usagestatisticmonth.FieldOrganizationID:
  34889. m.ClearOrganizationID()
  34890. return nil
  34891. }
  34892. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  34893. }
  34894. // ResetField resets all changes in the mutation for the field with the given name.
  34895. // It returns an error if the field is not defined in the schema.
  34896. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  34897. switch name {
  34898. case usagestatisticmonth.FieldCreatedAt:
  34899. m.ResetCreatedAt()
  34900. return nil
  34901. case usagestatisticmonth.FieldUpdatedAt:
  34902. m.ResetUpdatedAt()
  34903. return nil
  34904. case usagestatisticmonth.FieldStatus:
  34905. m.ResetStatus()
  34906. return nil
  34907. case usagestatisticmonth.FieldDeletedAt:
  34908. m.ResetDeletedAt()
  34909. return nil
  34910. case usagestatisticmonth.FieldAddtime:
  34911. m.ResetAddtime()
  34912. return nil
  34913. case usagestatisticmonth.FieldType:
  34914. m.ResetType()
  34915. return nil
  34916. case usagestatisticmonth.FieldBotID:
  34917. m.ResetBotID()
  34918. return nil
  34919. case usagestatisticmonth.FieldOrganizationID:
  34920. m.ResetOrganizationID()
  34921. return nil
  34922. case usagestatisticmonth.FieldAiResponse:
  34923. m.ResetAiResponse()
  34924. return nil
  34925. case usagestatisticmonth.FieldSopRun:
  34926. m.ResetSopRun()
  34927. return nil
  34928. case usagestatisticmonth.FieldTotalFriend:
  34929. m.ResetTotalFriend()
  34930. return nil
  34931. case usagestatisticmonth.FieldTotalGroup:
  34932. m.ResetTotalGroup()
  34933. return nil
  34934. case usagestatisticmonth.FieldAccountBalance:
  34935. m.ResetAccountBalance()
  34936. return nil
  34937. case usagestatisticmonth.FieldConsumeToken:
  34938. m.ResetConsumeToken()
  34939. return nil
  34940. case usagestatisticmonth.FieldActiveUser:
  34941. m.ResetActiveUser()
  34942. return nil
  34943. case usagestatisticmonth.FieldNewUser:
  34944. m.ResetNewUser()
  34945. return nil
  34946. case usagestatisticmonth.FieldLabelDist:
  34947. m.ResetLabelDist()
  34948. return nil
  34949. }
  34950. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34951. }
  34952. // AddedEdges returns all edge names that were set/added in this mutation.
  34953. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  34954. edges := make([]string, 0, 0)
  34955. return edges
  34956. }
  34957. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34958. // name in this mutation.
  34959. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  34960. return nil
  34961. }
  34962. // RemovedEdges returns all edge names that were removed in this mutation.
  34963. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  34964. edges := make([]string, 0, 0)
  34965. return edges
  34966. }
  34967. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34968. // the given name in this mutation.
  34969. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  34970. return nil
  34971. }
  34972. // ClearedEdges returns all edge names that were cleared in this mutation.
  34973. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  34974. edges := make([]string, 0, 0)
  34975. return edges
  34976. }
  34977. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34978. // was cleared in this mutation.
  34979. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  34980. return false
  34981. }
  34982. // ClearEdge clears the value of the edge with the given name. It returns an error
  34983. // if that edge is not defined in the schema.
  34984. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  34985. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  34986. }
  34987. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34988. // It returns an error if the edge is not defined in the schema.
  34989. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  34990. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  34991. }
  34992. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  34993. type UsageTotalMutation struct {
  34994. config
  34995. op Op
  34996. typ string
  34997. id *uint64
  34998. created_at *time.Time
  34999. updated_at *time.Time
  35000. status *uint8
  35001. addstatus *int8
  35002. _type *int
  35003. add_type *int
  35004. bot_id *string
  35005. total_tokens *uint64
  35006. addtotal_tokens *int64
  35007. start_index *uint64
  35008. addstart_index *int64
  35009. end_index *uint64
  35010. addend_index *int64
  35011. organization_id *uint64
  35012. addorganization_id *int64
  35013. clearedFields map[string]struct{}
  35014. done bool
  35015. oldValue func(context.Context) (*UsageTotal, error)
  35016. predicates []predicate.UsageTotal
  35017. }
  35018. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  35019. // usagetotalOption allows management of the mutation configuration using functional options.
  35020. type usagetotalOption func(*UsageTotalMutation)
  35021. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  35022. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  35023. m := &UsageTotalMutation{
  35024. config: c,
  35025. op: op,
  35026. typ: TypeUsageTotal,
  35027. clearedFields: make(map[string]struct{}),
  35028. }
  35029. for _, opt := range opts {
  35030. opt(m)
  35031. }
  35032. return m
  35033. }
  35034. // withUsageTotalID sets the ID field of the mutation.
  35035. func withUsageTotalID(id uint64) usagetotalOption {
  35036. return func(m *UsageTotalMutation) {
  35037. var (
  35038. err error
  35039. once sync.Once
  35040. value *UsageTotal
  35041. )
  35042. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  35043. once.Do(func() {
  35044. if m.done {
  35045. err = errors.New("querying old values post mutation is not allowed")
  35046. } else {
  35047. value, err = m.Client().UsageTotal.Get(ctx, id)
  35048. }
  35049. })
  35050. return value, err
  35051. }
  35052. m.id = &id
  35053. }
  35054. }
  35055. // withUsageTotal sets the old UsageTotal of the mutation.
  35056. func withUsageTotal(node *UsageTotal) usagetotalOption {
  35057. return func(m *UsageTotalMutation) {
  35058. m.oldValue = func(context.Context) (*UsageTotal, error) {
  35059. return node, nil
  35060. }
  35061. m.id = &node.ID
  35062. }
  35063. }
  35064. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35065. // executed in a transaction (ent.Tx), a transactional client is returned.
  35066. func (m UsageTotalMutation) Client() *Client {
  35067. client := &Client{config: m.config}
  35068. client.init()
  35069. return client
  35070. }
  35071. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35072. // it returns an error otherwise.
  35073. func (m UsageTotalMutation) Tx() (*Tx, error) {
  35074. if _, ok := m.driver.(*txDriver); !ok {
  35075. return nil, errors.New("ent: mutation is not running in a transaction")
  35076. }
  35077. tx := &Tx{config: m.config}
  35078. tx.init()
  35079. return tx, nil
  35080. }
  35081. // SetID sets the value of the id field. Note that this
  35082. // operation is only accepted on creation of UsageTotal entities.
  35083. func (m *UsageTotalMutation) SetID(id uint64) {
  35084. m.id = &id
  35085. }
  35086. // ID returns the ID value in the mutation. Note that the ID is only available
  35087. // if it was provided to the builder or after it was returned from the database.
  35088. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35089. if m.id == nil {
  35090. return
  35091. }
  35092. return *m.id, true
  35093. }
  35094. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35095. // That means, if the mutation is applied within a transaction with an isolation level such
  35096. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35097. // or updated by the mutation.
  35098. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35099. switch {
  35100. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35101. id, exists := m.ID()
  35102. if exists {
  35103. return []uint64{id}, nil
  35104. }
  35105. fallthrough
  35106. case m.op.Is(OpUpdate | OpDelete):
  35107. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35108. default:
  35109. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35110. }
  35111. }
  35112. // SetCreatedAt sets the "created_at" field.
  35113. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35114. m.created_at = &t
  35115. }
  35116. // CreatedAt returns the value of the "created_at" field in the mutation.
  35117. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35118. v := m.created_at
  35119. if v == nil {
  35120. return
  35121. }
  35122. return *v, true
  35123. }
  35124. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35125. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35127. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35128. if !m.op.Is(OpUpdateOne) {
  35129. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35130. }
  35131. if m.id == nil || m.oldValue == nil {
  35132. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35133. }
  35134. oldValue, err := m.oldValue(ctx)
  35135. if err != nil {
  35136. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35137. }
  35138. return oldValue.CreatedAt, nil
  35139. }
  35140. // ResetCreatedAt resets all changes to the "created_at" field.
  35141. func (m *UsageTotalMutation) ResetCreatedAt() {
  35142. m.created_at = nil
  35143. }
  35144. // SetUpdatedAt sets the "updated_at" field.
  35145. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35146. m.updated_at = &t
  35147. }
  35148. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35149. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35150. v := m.updated_at
  35151. if v == nil {
  35152. return
  35153. }
  35154. return *v, true
  35155. }
  35156. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35157. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35159. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35160. if !m.op.Is(OpUpdateOne) {
  35161. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35162. }
  35163. if m.id == nil || m.oldValue == nil {
  35164. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35165. }
  35166. oldValue, err := m.oldValue(ctx)
  35167. if err != nil {
  35168. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35169. }
  35170. return oldValue.UpdatedAt, nil
  35171. }
  35172. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35173. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35174. m.updated_at = nil
  35175. }
  35176. // SetStatus sets the "status" field.
  35177. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35178. m.status = &u
  35179. m.addstatus = nil
  35180. }
  35181. // Status returns the value of the "status" field in the mutation.
  35182. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35183. v := m.status
  35184. if v == nil {
  35185. return
  35186. }
  35187. return *v, true
  35188. }
  35189. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35190. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35192. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35193. if !m.op.Is(OpUpdateOne) {
  35194. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35195. }
  35196. if m.id == nil || m.oldValue == nil {
  35197. return v, errors.New("OldStatus requires an ID field in the mutation")
  35198. }
  35199. oldValue, err := m.oldValue(ctx)
  35200. if err != nil {
  35201. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35202. }
  35203. return oldValue.Status, nil
  35204. }
  35205. // AddStatus adds u to the "status" field.
  35206. func (m *UsageTotalMutation) AddStatus(u int8) {
  35207. if m.addstatus != nil {
  35208. *m.addstatus += u
  35209. } else {
  35210. m.addstatus = &u
  35211. }
  35212. }
  35213. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35214. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35215. v := m.addstatus
  35216. if v == nil {
  35217. return
  35218. }
  35219. return *v, true
  35220. }
  35221. // ClearStatus clears the value of the "status" field.
  35222. func (m *UsageTotalMutation) ClearStatus() {
  35223. m.status = nil
  35224. m.addstatus = nil
  35225. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35226. }
  35227. // StatusCleared returns if the "status" field was cleared in this mutation.
  35228. func (m *UsageTotalMutation) StatusCleared() bool {
  35229. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35230. return ok
  35231. }
  35232. // ResetStatus resets all changes to the "status" field.
  35233. func (m *UsageTotalMutation) ResetStatus() {
  35234. m.status = nil
  35235. m.addstatus = nil
  35236. delete(m.clearedFields, usagetotal.FieldStatus)
  35237. }
  35238. // SetType sets the "type" field.
  35239. func (m *UsageTotalMutation) SetType(i int) {
  35240. m._type = &i
  35241. m.add_type = nil
  35242. }
  35243. // GetType returns the value of the "type" field in the mutation.
  35244. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35245. v := m._type
  35246. if v == nil {
  35247. return
  35248. }
  35249. return *v, true
  35250. }
  35251. // OldType returns the old "type" field's value of the UsageTotal entity.
  35252. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35254. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35255. if !m.op.Is(OpUpdateOne) {
  35256. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35257. }
  35258. if m.id == nil || m.oldValue == nil {
  35259. return v, errors.New("OldType requires an ID field in the mutation")
  35260. }
  35261. oldValue, err := m.oldValue(ctx)
  35262. if err != nil {
  35263. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35264. }
  35265. return oldValue.Type, nil
  35266. }
  35267. // AddType adds i to the "type" field.
  35268. func (m *UsageTotalMutation) AddType(i int) {
  35269. if m.add_type != nil {
  35270. *m.add_type += i
  35271. } else {
  35272. m.add_type = &i
  35273. }
  35274. }
  35275. // AddedType returns the value that was added to the "type" field in this mutation.
  35276. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35277. v := m.add_type
  35278. if v == nil {
  35279. return
  35280. }
  35281. return *v, true
  35282. }
  35283. // ClearType clears the value of the "type" field.
  35284. func (m *UsageTotalMutation) ClearType() {
  35285. m._type = nil
  35286. m.add_type = nil
  35287. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35288. }
  35289. // TypeCleared returns if the "type" field was cleared in this mutation.
  35290. func (m *UsageTotalMutation) TypeCleared() bool {
  35291. _, ok := m.clearedFields[usagetotal.FieldType]
  35292. return ok
  35293. }
  35294. // ResetType resets all changes to the "type" field.
  35295. func (m *UsageTotalMutation) ResetType() {
  35296. m._type = nil
  35297. m.add_type = nil
  35298. delete(m.clearedFields, usagetotal.FieldType)
  35299. }
  35300. // SetBotID sets the "bot_id" field.
  35301. func (m *UsageTotalMutation) SetBotID(s string) {
  35302. m.bot_id = &s
  35303. }
  35304. // BotID returns the value of the "bot_id" field in the mutation.
  35305. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35306. v := m.bot_id
  35307. if v == nil {
  35308. return
  35309. }
  35310. return *v, true
  35311. }
  35312. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  35313. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35315. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  35316. if !m.op.Is(OpUpdateOne) {
  35317. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35318. }
  35319. if m.id == nil || m.oldValue == nil {
  35320. return v, errors.New("OldBotID requires an ID field in the mutation")
  35321. }
  35322. oldValue, err := m.oldValue(ctx)
  35323. if err != nil {
  35324. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35325. }
  35326. return oldValue.BotID, nil
  35327. }
  35328. // ResetBotID resets all changes to the "bot_id" field.
  35329. func (m *UsageTotalMutation) ResetBotID() {
  35330. m.bot_id = nil
  35331. }
  35332. // SetTotalTokens sets the "total_tokens" field.
  35333. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35334. m.total_tokens = &u
  35335. m.addtotal_tokens = nil
  35336. }
  35337. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35338. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35339. v := m.total_tokens
  35340. if v == nil {
  35341. return
  35342. }
  35343. return *v, true
  35344. }
  35345. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  35346. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35348. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35349. if !m.op.Is(OpUpdateOne) {
  35350. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35351. }
  35352. if m.id == nil || m.oldValue == nil {
  35353. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35354. }
  35355. oldValue, err := m.oldValue(ctx)
  35356. if err != nil {
  35357. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35358. }
  35359. return oldValue.TotalTokens, nil
  35360. }
  35361. // AddTotalTokens adds u to the "total_tokens" field.
  35362. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35363. if m.addtotal_tokens != nil {
  35364. *m.addtotal_tokens += u
  35365. } else {
  35366. m.addtotal_tokens = &u
  35367. }
  35368. }
  35369. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35370. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35371. v := m.addtotal_tokens
  35372. if v == nil {
  35373. return
  35374. }
  35375. return *v, true
  35376. }
  35377. // ClearTotalTokens clears the value of the "total_tokens" field.
  35378. func (m *UsageTotalMutation) ClearTotalTokens() {
  35379. m.total_tokens = nil
  35380. m.addtotal_tokens = nil
  35381. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35382. }
  35383. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35384. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35385. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35386. return ok
  35387. }
  35388. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35389. func (m *UsageTotalMutation) ResetTotalTokens() {
  35390. m.total_tokens = nil
  35391. m.addtotal_tokens = nil
  35392. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35393. }
  35394. // SetStartIndex sets the "start_index" field.
  35395. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35396. m.start_index = &u
  35397. m.addstart_index = nil
  35398. }
  35399. // StartIndex returns the value of the "start_index" field in the mutation.
  35400. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35401. v := m.start_index
  35402. if v == nil {
  35403. return
  35404. }
  35405. return *v, true
  35406. }
  35407. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  35408. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35410. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35411. if !m.op.Is(OpUpdateOne) {
  35412. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35413. }
  35414. if m.id == nil || m.oldValue == nil {
  35415. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  35416. }
  35417. oldValue, err := m.oldValue(ctx)
  35418. if err != nil {
  35419. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  35420. }
  35421. return oldValue.StartIndex, nil
  35422. }
  35423. // AddStartIndex adds u to the "start_index" field.
  35424. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35425. if m.addstart_index != nil {
  35426. *m.addstart_index += u
  35427. } else {
  35428. m.addstart_index = &u
  35429. }
  35430. }
  35431. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35432. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35433. v := m.addstart_index
  35434. if v == nil {
  35435. return
  35436. }
  35437. return *v, true
  35438. }
  35439. // ClearStartIndex clears the value of the "start_index" field.
  35440. func (m *UsageTotalMutation) ClearStartIndex() {
  35441. m.start_index = nil
  35442. m.addstart_index = nil
  35443. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35444. }
  35445. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35446. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35447. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35448. return ok
  35449. }
  35450. // ResetStartIndex resets all changes to the "start_index" field.
  35451. func (m *UsageTotalMutation) ResetStartIndex() {
  35452. m.start_index = nil
  35453. m.addstart_index = nil
  35454. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35455. }
  35456. // SetEndIndex sets the "end_index" field.
  35457. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35458. m.end_index = &u
  35459. m.addend_index = nil
  35460. }
  35461. // EndIndex returns the value of the "end_index" field in the mutation.
  35462. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35463. v := m.end_index
  35464. if v == nil {
  35465. return
  35466. }
  35467. return *v, true
  35468. }
  35469. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35470. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35472. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35473. if !m.op.Is(OpUpdateOne) {
  35474. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35475. }
  35476. if m.id == nil || m.oldValue == nil {
  35477. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  35478. }
  35479. oldValue, err := m.oldValue(ctx)
  35480. if err != nil {
  35481. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  35482. }
  35483. return oldValue.EndIndex, nil
  35484. }
  35485. // AddEndIndex adds u to the "end_index" field.
  35486. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35487. if m.addend_index != nil {
  35488. *m.addend_index += u
  35489. } else {
  35490. m.addend_index = &u
  35491. }
  35492. }
  35493. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35494. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35495. v := m.addend_index
  35496. if v == nil {
  35497. return
  35498. }
  35499. return *v, true
  35500. }
  35501. // ClearEndIndex clears the value of the "end_index" field.
  35502. func (m *UsageTotalMutation) ClearEndIndex() {
  35503. m.end_index = nil
  35504. m.addend_index = nil
  35505. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35506. }
  35507. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35508. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35509. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35510. return ok
  35511. }
  35512. // ResetEndIndex resets all changes to the "end_index" field.
  35513. func (m *UsageTotalMutation) ResetEndIndex() {
  35514. m.end_index = nil
  35515. m.addend_index = nil
  35516. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35517. }
  35518. // SetOrganizationID sets the "organization_id" field.
  35519. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35520. m.organization_id = &u
  35521. m.addorganization_id = nil
  35522. }
  35523. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35524. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35525. v := m.organization_id
  35526. if v == nil {
  35527. return
  35528. }
  35529. return *v, true
  35530. }
  35531. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35532. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35534. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35535. if !m.op.Is(OpUpdateOne) {
  35536. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35537. }
  35538. if m.id == nil || m.oldValue == nil {
  35539. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35540. }
  35541. oldValue, err := m.oldValue(ctx)
  35542. if err != nil {
  35543. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35544. }
  35545. return oldValue.OrganizationID, nil
  35546. }
  35547. // AddOrganizationID adds u to the "organization_id" field.
  35548. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35549. if m.addorganization_id != nil {
  35550. *m.addorganization_id += u
  35551. } else {
  35552. m.addorganization_id = &u
  35553. }
  35554. }
  35555. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35556. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35557. v := m.addorganization_id
  35558. if v == nil {
  35559. return
  35560. }
  35561. return *v, true
  35562. }
  35563. // ClearOrganizationID clears the value of the "organization_id" field.
  35564. func (m *UsageTotalMutation) ClearOrganizationID() {
  35565. m.organization_id = nil
  35566. m.addorganization_id = nil
  35567. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35568. }
  35569. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35570. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35571. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35572. return ok
  35573. }
  35574. // ResetOrganizationID resets all changes to the "organization_id" field.
  35575. func (m *UsageTotalMutation) ResetOrganizationID() {
  35576. m.organization_id = nil
  35577. m.addorganization_id = nil
  35578. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35579. }
  35580. // Where appends a list predicates to the UsageTotalMutation builder.
  35581. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35582. m.predicates = append(m.predicates, ps...)
  35583. }
  35584. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35585. // users can use type-assertion to append predicates that do not depend on any generated package.
  35586. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35587. p := make([]predicate.UsageTotal, len(ps))
  35588. for i := range ps {
  35589. p[i] = ps[i]
  35590. }
  35591. m.Where(p...)
  35592. }
  35593. // Op returns the operation name.
  35594. func (m *UsageTotalMutation) Op() Op {
  35595. return m.op
  35596. }
  35597. // SetOp allows setting the mutation operation.
  35598. func (m *UsageTotalMutation) SetOp(op Op) {
  35599. m.op = op
  35600. }
  35601. // Type returns the node type of this mutation (UsageTotal).
  35602. func (m *UsageTotalMutation) Type() string {
  35603. return m.typ
  35604. }
  35605. // Fields returns all fields that were changed during this mutation. Note that in
  35606. // order to get all numeric fields that were incremented/decremented, call
  35607. // AddedFields().
  35608. func (m *UsageTotalMutation) Fields() []string {
  35609. fields := make([]string, 0, 9)
  35610. if m.created_at != nil {
  35611. fields = append(fields, usagetotal.FieldCreatedAt)
  35612. }
  35613. if m.updated_at != nil {
  35614. fields = append(fields, usagetotal.FieldUpdatedAt)
  35615. }
  35616. if m.status != nil {
  35617. fields = append(fields, usagetotal.FieldStatus)
  35618. }
  35619. if m._type != nil {
  35620. fields = append(fields, usagetotal.FieldType)
  35621. }
  35622. if m.bot_id != nil {
  35623. fields = append(fields, usagetotal.FieldBotID)
  35624. }
  35625. if m.total_tokens != nil {
  35626. fields = append(fields, usagetotal.FieldTotalTokens)
  35627. }
  35628. if m.start_index != nil {
  35629. fields = append(fields, usagetotal.FieldStartIndex)
  35630. }
  35631. if m.end_index != nil {
  35632. fields = append(fields, usagetotal.FieldEndIndex)
  35633. }
  35634. if m.organization_id != nil {
  35635. fields = append(fields, usagetotal.FieldOrganizationID)
  35636. }
  35637. return fields
  35638. }
  35639. // Field returns the value of a field with the given name. The second boolean
  35640. // return value indicates that this field was not set, or was not defined in the
  35641. // schema.
  35642. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  35643. switch name {
  35644. case usagetotal.FieldCreatedAt:
  35645. return m.CreatedAt()
  35646. case usagetotal.FieldUpdatedAt:
  35647. return m.UpdatedAt()
  35648. case usagetotal.FieldStatus:
  35649. return m.Status()
  35650. case usagetotal.FieldType:
  35651. return m.GetType()
  35652. case usagetotal.FieldBotID:
  35653. return m.BotID()
  35654. case usagetotal.FieldTotalTokens:
  35655. return m.TotalTokens()
  35656. case usagetotal.FieldStartIndex:
  35657. return m.StartIndex()
  35658. case usagetotal.FieldEndIndex:
  35659. return m.EndIndex()
  35660. case usagetotal.FieldOrganizationID:
  35661. return m.OrganizationID()
  35662. }
  35663. return nil, false
  35664. }
  35665. // OldField returns the old value of the field from the database. An error is
  35666. // returned if the mutation operation is not UpdateOne, or the query to the
  35667. // database failed.
  35668. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35669. switch name {
  35670. case usagetotal.FieldCreatedAt:
  35671. return m.OldCreatedAt(ctx)
  35672. case usagetotal.FieldUpdatedAt:
  35673. return m.OldUpdatedAt(ctx)
  35674. case usagetotal.FieldStatus:
  35675. return m.OldStatus(ctx)
  35676. case usagetotal.FieldType:
  35677. return m.OldType(ctx)
  35678. case usagetotal.FieldBotID:
  35679. return m.OldBotID(ctx)
  35680. case usagetotal.FieldTotalTokens:
  35681. return m.OldTotalTokens(ctx)
  35682. case usagetotal.FieldStartIndex:
  35683. return m.OldStartIndex(ctx)
  35684. case usagetotal.FieldEndIndex:
  35685. return m.OldEndIndex(ctx)
  35686. case usagetotal.FieldOrganizationID:
  35687. return m.OldOrganizationID(ctx)
  35688. }
  35689. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  35690. }
  35691. // SetField sets the value of a field with the given name. It returns an error if
  35692. // the field is not defined in the schema, or if the type mismatched the field
  35693. // type.
  35694. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  35695. switch name {
  35696. case usagetotal.FieldCreatedAt:
  35697. v, ok := value.(time.Time)
  35698. if !ok {
  35699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35700. }
  35701. m.SetCreatedAt(v)
  35702. return nil
  35703. case usagetotal.FieldUpdatedAt:
  35704. v, ok := value.(time.Time)
  35705. if !ok {
  35706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35707. }
  35708. m.SetUpdatedAt(v)
  35709. return nil
  35710. case usagetotal.FieldStatus:
  35711. v, ok := value.(uint8)
  35712. if !ok {
  35713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35714. }
  35715. m.SetStatus(v)
  35716. return nil
  35717. case usagetotal.FieldType:
  35718. v, ok := value.(int)
  35719. if !ok {
  35720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35721. }
  35722. m.SetType(v)
  35723. return nil
  35724. case usagetotal.FieldBotID:
  35725. v, ok := value.(string)
  35726. if !ok {
  35727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35728. }
  35729. m.SetBotID(v)
  35730. return nil
  35731. case usagetotal.FieldTotalTokens:
  35732. v, ok := value.(uint64)
  35733. if !ok {
  35734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35735. }
  35736. m.SetTotalTokens(v)
  35737. return nil
  35738. case usagetotal.FieldStartIndex:
  35739. v, ok := value.(uint64)
  35740. if !ok {
  35741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35742. }
  35743. m.SetStartIndex(v)
  35744. return nil
  35745. case usagetotal.FieldEndIndex:
  35746. v, ok := value.(uint64)
  35747. if !ok {
  35748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35749. }
  35750. m.SetEndIndex(v)
  35751. return nil
  35752. case usagetotal.FieldOrganizationID:
  35753. v, ok := value.(uint64)
  35754. if !ok {
  35755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35756. }
  35757. m.SetOrganizationID(v)
  35758. return nil
  35759. }
  35760. return fmt.Errorf("unknown UsageTotal field %s", name)
  35761. }
  35762. // AddedFields returns all numeric fields that were incremented/decremented during
  35763. // this mutation.
  35764. func (m *UsageTotalMutation) AddedFields() []string {
  35765. var fields []string
  35766. if m.addstatus != nil {
  35767. fields = append(fields, usagetotal.FieldStatus)
  35768. }
  35769. if m.add_type != nil {
  35770. fields = append(fields, usagetotal.FieldType)
  35771. }
  35772. if m.addtotal_tokens != nil {
  35773. fields = append(fields, usagetotal.FieldTotalTokens)
  35774. }
  35775. if m.addstart_index != nil {
  35776. fields = append(fields, usagetotal.FieldStartIndex)
  35777. }
  35778. if m.addend_index != nil {
  35779. fields = append(fields, usagetotal.FieldEndIndex)
  35780. }
  35781. if m.addorganization_id != nil {
  35782. fields = append(fields, usagetotal.FieldOrganizationID)
  35783. }
  35784. return fields
  35785. }
  35786. // AddedField returns the numeric value that was incremented/decremented on a field
  35787. // with the given name. The second boolean return value indicates that this field
  35788. // was not set, or was not defined in the schema.
  35789. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  35790. switch name {
  35791. case usagetotal.FieldStatus:
  35792. return m.AddedStatus()
  35793. case usagetotal.FieldType:
  35794. return m.AddedType()
  35795. case usagetotal.FieldTotalTokens:
  35796. return m.AddedTotalTokens()
  35797. case usagetotal.FieldStartIndex:
  35798. return m.AddedStartIndex()
  35799. case usagetotal.FieldEndIndex:
  35800. return m.AddedEndIndex()
  35801. case usagetotal.FieldOrganizationID:
  35802. return m.AddedOrganizationID()
  35803. }
  35804. return nil, false
  35805. }
  35806. // AddField adds the value to the field with the given name. It returns an error if
  35807. // the field is not defined in the schema, or if the type mismatched the field
  35808. // type.
  35809. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  35810. switch name {
  35811. case usagetotal.FieldStatus:
  35812. v, ok := value.(int8)
  35813. if !ok {
  35814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35815. }
  35816. m.AddStatus(v)
  35817. return nil
  35818. case usagetotal.FieldType:
  35819. v, ok := value.(int)
  35820. if !ok {
  35821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35822. }
  35823. m.AddType(v)
  35824. return nil
  35825. case usagetotal.FieldTotalTokens:
  35826. v, ok := value.(int64)
  35827. if !ok {
  35828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35829. }
  35830. m.AddTotalTokens(v)
  35831. return nil
  35832. case usagetotal.FieldStartIndex:
  35833. v, ok := value.(int64)
  35834. if !ok {
  35835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35836. }
  35837. m.AddStartIndex(v)
  35838. return nil
  35839. case usagetotal.FieldEndIndex:
  35840. v, ok := value.(int64)
  35841. if !ok {
  35842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35843. }
  35844. m.AddEndIndex(v)
  35845. return nil
  35846. case usagetotal.FieldOrganizationID:
  35847. v, ok := value.(int64)
  35848. if !ok {
  35849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35850. }
  35851. m.AddOrganizationID(v)
  35852. return nil
  35853. }
  35854. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  35855. }
  35856. // ClearedFields returns all nullable fields that were cleared during this
  35857. // mutation.
  35858. func (m *UsageTotalMutation) ClearedFields() []string {
  35859. var fields []string
  35860. if m.FieldCleared(usagetotal.FieldStatus) {
  35861. fields = append(fields, usagetotal.FieldStatus)
  35862. }
  35863. if m.FieldCleared(usagetotal.FieldType) {
  35864. fields = append(fields, usagetotal.FieldType)
  35865. }
  35866. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  35867. fields = append(fields, usagetotal.FieldTotalTokens)
  35868. }
  35869. if m.FieldCleared(usagetotal.FieldStartIndex) {
  35870. fields = append(fields, usagetotal.FieldStartIndex)
  35871. }
  35872. if m.FieldCleared(usagetotal.FieldEndIndex) {
  35873. fields = append(fields, usagetotal.FieldEndIndex)
  35874. }
  35875. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  35876. fields = append(fields, usagetotal.FieldOrganizationID)
  35877. }
  35878. return fields
  35879. }
  35880. // FieldCleared returns a boolean indicating if a field with the given name was
  35881. // cleared in this mutation.
  35882. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  35883. _, ok := m.clearedFields[name]
  35884. return ok
  35885. }
  35886. // ClearField clears the value of the field with the given name. It returns an
  35887. // error if the field is not defined in the schema.
  35888. func (m *UsageTotalMutation) ClearField(name string) error {
  35889. switch name {
  35890. case usagetotal.FieldStatus:
  35891. m.ClearStatus()
  35892. return nil
  35893. case usagetotal.FieldType:
  35894. m.ClearType()
  35895. return nil
  35896. case usagetotal.FieldTotalTokens:
  35897. m.ClearTotalTokens()
  35898. return nil
  35899. case usagetotal.FieldStartIndex:
  35900. m.ClearStartIndex()
  35901. return nil
  35902. case usagetotal.FieldEndIndex:
  35903. m.ClearEndIndex()
  35904. return nil
  35905. case usagetotal.FieldOrganizationID:
  35906. m.ClearOrganizationID()
  35907. return nil
  35908. }
  35909. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  35910. }
  35911. // ResetField resets all changes in the mutation for the field with the given name.
  35912. // It returns an error if the field is not defined in the schema.
  35913. func (m *UsageTotalMutation) ResetField(name string) error {
  35914. switch name {
  35915. case usagetotal.FieldCreatedAt:
  35916. m.ResetCreatedAt()
  35917. return nil
  35918. case usagetotal.FieldUpdatedAt:
  35919. m.ResetUpdatedAt()
  35920. return nil
  35921. case usagetotal.FieldStatus:
  35922. m.ResetStatus()
  35923. return nil
  35924. case usagetotal.FieldType:
  35925. m.ResetType()
  35926. return nil
  35927. case usagetotal.FieldBotID:
  35928. m.ResetBotID()
  35929. return nil
  35930. case usagetotal.FieldTotalTokens:
  35931. m.ResetTotalTokens()
  35932. return nil
  35933. case usagetotal.FieldStartIndex:
  35934. m.ResetStartIndex()
  35935. return nil
  35936. case usagetotal.FieldEndIndex:
  35937. m.ResetEndIndex()
  35938. return nil
  35939. case usagetotal.FieldOrganizationID:
  35940. m.ResetOrganizationID()
  35941. return nil
  35942. }
  35943. return fmt.Errorf("unknown UsageTotal field %s", name)
  35944. }
  35945. // AddedEdges returns all edge names that were set/added in this mutation.
  35946. func (m *UsageTotalMutation) AddedEdges() []string {
  35947. edges := make([]string, 0, 0)
  35948. return edges
  35949. }
  35950. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35951. // name in this mutation.
  35952. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  35953. return nil
  35954. }
  35955. // RemovedEdges returns all edge names that were removed in this mutation.
  35956. func (m *UsageTotalMutation) RemovedEdges() []string {
  35957. edges := make([]string, 0, 0)
  35958. return edges
  35959. }
  35960. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35961. // the given name in this mutation.
  35962. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  35963. return nil
  35964. }
  35965. // ClearedEdges returns all edge names that were cleared in this mutation.
  35966. func (m *UsageTotalMutation) ClearedEdges() []string {
  35967. edges := make([]string, 0, 0)
  35968. return edges
  35969. }
  35970. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35971. // was cleared in this mutation.
  35972. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  35973. return false
  35974. }
  35975. // ClearEdge clears the value of the edge with the given name. It returns an error
  35976. // if that edge is not defined in the schema.
  35977. func (m *UsageTotalMutation) ClearEdge(name string) error {
  35978. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  35979. }
  35980. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35981. // It returns an error if the edge is not defined in the schema.
  35982. func (m *UsageTotalMutation) ResetEdge(name string) error {
  35983. return fmt.Errorf("unknown UsageTotal edge %s", name)
  35984. }
  35985. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  35986. type WhatsappMutation struct {
  35987. config
  35988. op Op
  35989. typ string
  35990. id *uint64
  35991. created_at *time.Time
  35992. updated_at *time.Time
  35993. status *uint8
  35994. addstatus *int8
  35995. deleted_at *time.Time
  35996. wa_id *string
  35997. wa_name *string
  35998. callback *string
  35999. account *string
  36000. cc *string
  36001. phone *string
  36002. cc_phone *string
  36003. phone_name *string
  36004. phone_status *int8
  36005. addphone_status *int8
  36006. organization_id *uint64
  36007. addorganization_id *int64
  36008. api_base *string
  36009. api_key *string
  36010. allow_list *[]string
  36011. appendallow_list []string
  36012. group_allow_list *[]string
  36013. appendgroup_allow_list []string
  36014. block_list *[]string
  36015. appendblock_list []string
  36016. group_block_list *[]string
  36017. appendgroup_block_list []string
  36018. clearedFields map[string]struct{}
  36019. agent *uint64
  36020. clearedagent bool
  36021. done bool
  36022. oldValue func(context.Context) (*Whatsapp, error)
  36023. predicates []predicate.Whatsapp
  36024. }
  36025. var _ ent.Mutation = (*WhatsappMutation)(nil)
  36026. // whatsappOption allows management of the mutation configuration using functional options.
  36027. type whatsappOption func(*WhatsappMutation)
  36028. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  36029. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  36030. m := &WhatsappMutation{
  36031. config: c,
  36032. op: op,
  36033. typ: TypeWhatsapp,
  36034. clearedFields: make(map[string]struct{}),
  36035. }
  36036. for _, opt := range opts {
  36037. opt(m)
  36038. }
  36039. return m
  36040. }
  36041. // withWhatsappID sets the ID field of the mutation.
  36042. func withWhatsappID(id uint64) whatsappOption {
  36043. return func(m *WhatsappMutation) {
  36044. var (
  36045. err error
  36046. once sync.Once
  36047. value *Whatsapp
  36048. )
  36049. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  36050. once.Do(func() {
  36051. if m.done {
  36052. err = errors.New("querying old values post mutation is not allowed")
  36053. } else {
  36054. value, err = m.Client().Whatsapp.Get(ctx, id)
  36055. }
  36056. })
  36057. return value, err
  36058. }
  36059. m.id = &id
  36060. }
  36061. }
  36062. // withWhatsapp sets the old Whatsapp of the mutation.
  36063. func withWhatsapp(node *Whatsapp) whatsappOption {
  36064. return func(m *WhatsappMutation) {
  36065. m.oldValue = func(context.Context) (*Whatsapp, error) {
  36066. return node, nil
  36067. }
  36068. m.id = &node.ID
  36069. }
  36070. }
  36071. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36072. // executed in a transaction (ent.Tx), a transactional client is returned.
  36073. func (m WhatsappMutation) Client() *Client {
  36074. client := &Client{config: m.config}
  36075. client.init()
  36076. return client
  36077. }
  36078. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36079. // it returns an error otherwise.
  36080. func (m WhatsappMutation) Tx() (*Tx, error) {
  36081. if _, ok := m.driver.(*txDriver); !ok {
  36082. return nil, errors.New("ent: mutation is not running in a transaction")
  36083. }
  36084. tx := &Tx{config: m.config}
  36085. tx.init()
  36086. return tx, nil
  36087. }
  36088. // SetID sets the value of the id field. Note that this
  36089. // operation is only accepted on creation of Whatsapp entities.
  36090. func (m *WhatsappMutation) SetID(id uint64) {
  36091. m.id = &id
  36092. }
  36093. // ID returns the ID value in the mutation. Note that the ID is only available
  36094. // if it was provided to the builder or after it was returned from the database.
  36095. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36096. if m.id == nil {
  36097. return
  36098. }
  36099. return *m.id, true
  36100. }
  36101. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36102. // That means, if the mutation is applied within a transaction with an isolation level such
  36103. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36104. // or updated by the mutation.
  36105. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36106. switch {
  36107. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36108. id, exists := m.ID()
  36109. if exists {
  36110. return []uint64{id}, nil
  36111. }
  36112. fallthrough
  36113. case m.op.Is(OpUpdate | OpDelete):
  36114. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36115. default:
  36116. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36117. }
  36118. }
  36119. // SetCreatedAt sets the "created_at" field.
  36120. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36121. m.created_at = &t
  36122. }
  36123. // CreatedAt returns the value of the "created_at" field in the mutation.
  36124. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36125. v := m.created_at
  36126. if v == nil {
  36127. return
  36128. }
  36129. return *v, true
  36130. }
  36131. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36132. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36134. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36135. if !m.op.Is(OpUpdateOne) {
  36136. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36137. }
  36138. if m.id == nil || m.oldValue == nil {
  36139. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36140. }
  36141. oldValue, err := m.oldValue(ctx)
  36142. if err != nil {
  36143. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36144. }
  36145. return oldValue.CreatedAt, nil
  36146. }
  36147. // ResetCreatedAt resets all changes to the "created_at" field.
  36148. func (m *WhatsappMutation) ResetCreatedAt() {
  36149. m.created_at = nil
  36150. }
  36151. // SetUpdatedAt sets the "updated_at" field.
  36152. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36153. m.updated_at = &t
  36154. }
  36155. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36156. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36157. v := m.updated_at
  36158. if v == nil {
  36159. return
  36160. }
  36161. return *v, true
  36162. }
  36163. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36164. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36166. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36167. if !m.op.Is(OpUpdateOne) {
  36168. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36169. }
  36170. if m.id == nil || m.oldValue == nil {
  36171. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36172. }
  36173. oldValue, err := m.oldValue(ctx)
  36174. if err != nil {
  36175. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36176. }
  36177. return oldValue.UpdatedAt, nil
  36178. }
  36179. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36180. func (m *WhatsappMutation) ResetUpdatedAt() {
  36181. m.updated_at = nil
  36182. }
  36183. // SetStatus sets the "status" field.
  36184. func (m *WhatsappMutation) SetStatus(u uint8) {
  36185. m.status = &u
  36186. m.addstatus = nil
  36187. }
  36188. // Status returns the value of the "status" field in the mutation.
  36189. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36190. v := m.status
  36191. if v == nil {
  36192. return
  36193. }
  36194. return *v, true
  36195. }
  36196. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36197. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36199. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36200. if !m.op.Is(OpUpdateOne) {
  36201. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36202. }
  36203. if m.id == nil || m.oldValue == nil {
  36204. return v, errors.New("OldStatus requires an ID field in the mutation")
  36205. }
  36206. oldValue, err := m.oldValue(ctx)
  36207. if err != nil {
  36208. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36209. }
  36210. return oldValue.Status, nil
  36211. }
  36212. // AddStatus adds u to the "status" field.
  36213. func (m *WhatsappMutation) AddStatus(u int8) {
  36214. if m.addstatus != nil {
  36215. *m.addstatus += u
  36216. } else {
  36217. m.addstatus = &u
  36218. }
  36219. }
  36220. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36221. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36222. v := m.addstatus
  36223. if v == nil {
  36224. return
  36225. }
  36226. return *v, true
  36227. }
  36228. // ClearStatus clears the value of the "status" field.
  36229. func (m *WhatsappMutation) ClearStatus() {
  36230. m.status = nil
  36231. m.addstatus = nil
  36232. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36233. }
  36234. // StatusCleared returns if the "status" field was cleared in this mutation.
  36235. func (m *WhatsappMutation) StatusCleared() bool {
  36236. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36237. return ok
  36238. }
  36239. // ResetStatus resets all changes to the "status" field.
  36240. func (m *WhatsappMutation) ResetStatus() {
  36241. m.status = nil
  36242. m.addstatus = nil
  36243. delete(m.clearedFields, whatsapp.FieldStatus)
  36244. }
  36245. // SetDeletedAt sets the "deleted_at" field.
  36246. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36247. m.deleted_at = &t
  36248. }
  36249. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36250. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36251. v := m.deleted_at
  36252. if v == nil {
  36253. return
  36254. }
  36255. return *v, true
  36256. }
  36257. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36258. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36260. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36261. if !m.op.Is(OpUpdateOne) {
  36262. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36263. }
  36264. if m.id == nil || m.oldValue == nil {
  36265. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36266. }
  36267. oldValue, err := m.oldValue(ctx)
  36268. if err != nil {
  36269. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36270. }
  36271. return oldValue.DeletedAt, nil
  36272. }
  36273. // ClearDeletedAt clears the value of the "deleted_at" field.
  36274. func (m *WhatsappMutation) ClearDeletedAt() {
  36275. m.deleted_at = nil
  36276. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36277. }
  36278. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36279. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36280. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36281. return ok
  36282. }
  36283. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36284. func (m *WhatsappMutation) ResetDeletedAt() {
  36285. m.deleted_at = nil
  36286. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36287. }
  36288. // SetWaID sets the "wa_id" field.
  36289. func (m *WhatsappMutation) SetWaID(s string) {
  36290. m.wa_id = &s
  36291. }
  36292. // WaID returns the value of the "wa_id" field in the mutation.
  36293. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36294. v := m.wa_id
  36295. if v == nil {
  36296. return
  36297. }
  36298. return *v, true
  36299. }
  36300. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36301. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36303. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36304. if !m.op.Is(OpUpdateOne) {
  36305. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36306. }
  36307. if m.id == nil || m.oldValue == nil {
  36308. return v, errors.New("OldWaID requires an ID field in the mutation")
  36309. }
  36310. oldValue, err := m.oldValue(ctx)
  36311. if err != nil {
  36312. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36313. }
  36314. return oldValue.WaID, nil
  36315. }
  36316. // ClearWaID clears the value of the "wa_id" field.
  36317. func (m *WhatsappMutation) ClearWaID() {
  36318. m.wa_id = nil
  36319. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36320. }
  36321. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36322. func (m *WhatsappMutation) WaIDCleared() bool {
  36323. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36324. return ok
  36325. }
  36326. // ResetWaID resets all changes to the "wa_id" field.
  36327. func (m *WhatsappMutation) ResetWaID() {
  36328. m.wa_id = nil
  36329. delete(m.clearedFields, whatsapp.FieldWaID)
  36330. }
  36331. // SetWaName sets the "wa_name" field.
  36332. func (m *WhatsappMutation) SetWaName(s string) {
  36333. m.wa_name = &s
  36334. }
  36335. // WaName returns the value of the "wa_name" field in the mutation.
  36336. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36337. v := m.wa_name
  36338. if v == nil {
  36339. return
  36340. }
  36341. return *v, true
  36342. }
  36343. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36344. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36346. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36347. if !m.op.Is(OpUpdateOne) {
  36348. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36349. }
  36350. if m.id == nil || m.oldValue == nil {
  36351. return v, errors.New("OldWaName requires an ID field in the mutation")
  36352. }
  36353. oldValue, err := m.oldValue(ctx)
  36354. if err != nil {
  36355. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36356. }
  36357. return oldValue.WaName, nil
  36358. }
  36359. // ClearWaName clears the value of the "wa_name" field.
  36360. func (m *WhatsappMutation) ClearWaName() {
  36361. m.wa_name = nil
  36362. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36363. }
  36364. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36365. func (m *WhatsappMutation) WaNameCleared() bool {
  36366. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36367. return ok
  36368. }
  36369. // ResetWaName resets all changes to the "wa_name" field.
  36370. func (m *WhatsappMutation) ResetWaName() {
  36371. m.wa_name = nil
  36372. delete(m.clearedFields, whatsapp.FieldWaName)
  36373. }
  36374. // SetCallback sets the "callback" field.
  36375. func (m *WhatsappMutation) SetCallback(s string) {
  36376. m.callback = &s
  36377. }
  36378. // Callback returns the value of the "callback" field in the mutation.
  36379. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36380. v := m.callback
  36381. if v == nil {
  36382. return
  36383. }
  36384. return *v, true
  36385. }
  36386. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36387. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36389. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36390. if !m.op.Is(OpUpdateOne) {
  36391. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36392. }
  36393. if m.id == nil || m.oldValue == nil {
  36394. return v, errors.New("OldCallback requires an ID field in the mutation")
  36395. }
  36396. oldValue, err := m.oldValue(ctx)
  36397. if err != nil {
  36398. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36399. }
  36400. return oldValue.Callback, nil
  36401. }
  36402. // ClearCallback clears the value of the "callback" field.
  36403. func (m *WhatsappMutation) ClearCallback() {
  36404. m.callback = nil
  36405. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36406. }
  36407. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36408. func (m *WhatsappMutation) CallbackCleared() bool {
  36409. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36410. return ok
  36411. }
  36412. // ResetCallback resets all changes to the "callback" field.
  36413. func (m *WhatsappMutation) ResetCallback() {
  36414. m.callback = nil
  36415. delete(m.clearedFields, whatsapp.FieldCallback)
  36416. }
  36417. // SetAgentID sets the "agent_id" field.
  36418. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36419. m.agent = &u
  36420. }
  36421. // AgentID returns the value of the "agent_id" field in the mutation.
  36422. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36423. v := m.agent
  36424. if v == nil {
  36425. return
  36426. }
  36427. return *v, true
  36428. }
  36429. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36430. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36432. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36433. if !m.op.Is(OpUpdateOne) {
  36434. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36435. }
  36436. if m.id == nil || m.oldValue == nil {
  36437. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36438. }
  36439. oldValue, err := m.oldValue(ctx)
  36440. if err != nil {
  36441. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36442. }
  36443. return oldValue.AgentID, nil
  36444. }
  36445. // ResetAgentID resets all changes to the "agent_id" field.
  36446. func (m *WhatsappMutation) ResetAgentID() {
  36447. m.agent = nil
  36448. }
  36449. // SetAccount sets the "account" field.
  36450. func (m *WhatsappMutation) SetAccount(s string) {
  36451. m.account = &s
  36452. }
  36453. // Account returns the value of the "account" field in the mutation.
  36454. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36455. v := m.account
  36456. if v == nil {
  36457. return
  36458. }
  36459. return *v, true
  36460. }
  36461. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36462. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36464. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36465. if !m.op.Is(OpUpdateOne) {
  36466. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36467. }
  36468. if m.id == nil || m.oldValue == nil {
  36469. return v, errors.New("OldAccount requires an ID field in the mutation")
  36470. }
  36471. oldValue, err := m.oldValue(ctx)
  36472. if err != nil {
  36473. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36474. }
  36475. return oldValue.Account, nil
  36476. }
  36477. // ClearAccount clears the value of the "account" field.
  36478. func (m *WhatsappMutation) ClearAccount() {
  36479. m.account = nil
  36480. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36481. }
  36482. // AccountCleared returns if the "account" field was cleared in this mutation.
  36483. func (m *WhatsappMutation) AccountCleared() bool {
  36484. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36485. return ok
  36486. }
  36487. // ResetAccount resets all changes to the "account" field.
  36488. func (m *WhatsappMutation) ResetAccount() {
  36489. m.account = nil
  36490. delete(m.clearedFields, whatsapp.FieldAccount)
  36491. }
  36492. // SetCc sets the "cc" field.
  36493. func (m *WhatsappMutation) SetCc(s string) {
  36494. m.cc = &s
  36495. }
  36496. // Cc returns the value of the "cc" field in the mutation.
  36497. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36498. v := m.cc
  36499. if v == nil {
  36500. return
  36501. }
  36502. return *v, true
  36503. }
  36504. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36505. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36507. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36508. if !m.op.Is(OpUpdateOne) {
  36509. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36510. }
  36511. if m.id == nil || m.oldValue == nil {
  36512. return v, errors.New("OldCc requires an ID field in the mutation")
  36513. }
  36514. oldValue, err := m.oldValue(ctx)
  36515. if err != nil {
  36516. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36517. }
  36518. return oldValue.Cc, nil
  36519. }
  36520. // ResetCc resets all changes to the "cc" field.
  36521. func (m *WhatsappMutation) ResetCc() {
  36522. m.cc = nil
  36523. }
  36524. // SetPhone sets the "phone" field.
  36525. func (m *WhatsappMutation) SetPhone(s string) {
  36526. m.phone = &s
  36527. }
  36528. // Phone returns the value of the "phone" field in the mutation.
  36529. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36530. v := m.phone
  36531. if v == nil {
  36532. return
  36533. }
  36534. return *v, true
  36535. }
  36536. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36537. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36539. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36540. if !m.op.Is(OpUpdateOne) {
  36541. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36542. }
  36543. if m.id == nil || m.oldValue == nil {
  36544. return v, errors.New("OldPhone requires an ID field in the mutation")
  36545. }
  36546. oldValue, err := m.oldValue(ctx)
  36547. if err != nil {
  36548. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36549. }
  36550. return oldValue.Phone, nil
  36551. }
  36552. // ResetPhone resets all changes to the "phone" field.
  36553. func (m *WhatsappMutation) ResetPhone() {
  36554. m.phone = nil
  36555. }
  36556. // SetCcPhone sets the "cc_phone" field.
  36557. func (m *WhatsappMutation) SetCcPhone(s string) {
  36558. m.cc_phone = &s
  36559. }
  36560. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36561. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36562. v := m.cc_phone
  36563. if v == nil {
  36564. return
  36565. }
  36566. return *v, true
  36567. }
  36568. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36569. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36571. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36572. if !m.op.Is(OpUpdateOne) {
  36573. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36574. }
  36575. if m.id == nil || m.oldValue == nil {
  36576. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36577. }
  36578. oldValue, err := m.oldValue(ctx)
  36579. if err != nil {
  36580. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36581. }
  36582. return oldValue.CcPhone, nil
  36583. }
  36584. // ResetCcPhone resets all changes to the "cc_phone" field.
  36585. func (m *WhatsappMutation) ResetCcPhone() {
  36586. m.cc_phone = nil
  36587. }
  36588. // SetPhoneName sets the "phone_name" field.
  36589. func (m *WhatsappMutation) SetPhoneName(s string) {
  36590. m.phone_name = &s
  36591. }
  36592. // PhoneName returns the value of the "phone_name" field in the mutation.
  36593. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36594. v := m.phone_name
  36595. if v == nil {
  36596. return
  36597. }
  36598. return *v, true
  36599. }
  36600. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36601. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36603. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36604. if !m.op.Is(OpUpdateOne) {
  36605. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36606. }
  36607. if m.id == nil || m.oldValue == nil {
  36608. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36609. }
  36610. oldValue, err := m.oldValue(ctx)
  36611. if err != nil {
  36612. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36613. }
  36614. return oldValue.PhoneName, nil
  36615. }
  36616. // ResetPhoneName resets all changes to the "phone_name" field.
  36617. func (m *WhatsappMutation) ResetPhoneName() {
  36618. m.phone_name = nil
  36619. }
  36620. // SetPhoneStatus sets the "phone_status" field.
  36621. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36622. m.phone_status = &i
  36623. m.addphone_status = nil
  36624. }
  36625. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36626. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36627. v := m.phone_status
  36628. if v == nil {
  36629. return
  36630. }
  36631. return *v, true
  36632. }
  36633. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36634. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36636. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  36637. if !m.op.Is(OpUpdateOne) {
  36638. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  36639. }
  36640. if m.id == nil || m.oldValue == nil {
  36641. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  36642. }
  36643. oldValue, err := m.oldValue(ctx)
  36644. if err != nil {
  36645. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  36646. }
  36647. return oldValue.PhoneStatus, nil
  36648. }
  36649. // AddPhoneStatus adds i to the "phone_status" field.
  36650. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  36651. if m.addphone_status != nil {
  36652. *m.addphone_status += i
  36653. } else {
  36654. m.addphone_status = &i
  36655. }
  36656. }
  36657. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  36658. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  36659. v := m.addphone_status
  36660. if v == nil {
  36661. return
  36662. }
  36663. return *v, true
  36664. }
  36665. // ResetPhoneStatus resets all changes to the "phone_status" field.
  36666. func (m *WhatsappMutation) ResetPhoneStatus() {
  36667. m.phone_status = nil
  36668. m.addphone_status = nil
  36669. }
  36670. // SetOrganizationID sets the "organization_id" field.
  36671. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  36672. m.organization_id = &u
  36673. m.addorganization_id = nil
  36674. }
  36675. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36676. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  36677. v := m.organization_id
  36678. if v == nil {
  36679. return
  36680. }
  36681. return *v, true
  36682. }
  36683. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  36684. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36686. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36687. if !m.op.Is(OpUpdateOne) {
  36688. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36689. }
  36690. if m.id == nil || m.oldValue == nil {
  36691. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36692. }
  36693. oldValue, err := m.oldValue(ctx)
  36694. if err != nil {
  36695. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36696. }
  36697. return oldValue.OrganizationID, nil
  36698. }
  36699. // AddOrganizationID adds u to the "organization_id" field.
  36700. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  36701. if m.addorganization_id != nil {
  36702. *m.addorganization_id += u
  36703. } else {
  36704. m.addorganization_id = &u
  36705. }
  36706. }
  36707. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36708. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  36709. v := m.addorganization_id
  36710. if v == nil {
  36711. return
  36712. }
  36713. return *v, true
  36714. }
  36715. // ClearOrganizationID clears the value of the "organization_id" field.
  36716. func (m *WhatsappMutation) ClearOrganizationID() {
  36717. m.organization_id = nil
  36718. m.addorganization_id = nil
  36719. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  36720. }
  36721. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36722. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  36723. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  36724. return ok
  36725. }
  36726. // ResetOrganizationID resets all changes to the "organization_id" field.
  36727. func (m *WhatsappMutation) ResetOrganizationID() {
  36728. m.organization_id = nil
  36729. m.addorganization_id = nil
  36730. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  36731. }
  36732. // SetAPIBase sets the "api_base" field.
  36733. func (m *WhatsappMutation) SetAPIBase(s string) {
  36734. m.api_base = &s
  36735. }
  36736. // APIBase returns the value of the "api_base" field in the mutation.
  36737. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  36738. v := m.api_base
  36739. if v == nil {
  36740. return
  36741. }
  36742. return *v, true
  36743. }
  36744. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  36745. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36747. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36748. if !m.op.Is(OpUpdateOne) {
  36749. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36750. }
  36751. if m.id == nil || m.oldValue == nil {
  36752. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  36753. }
  36754. oldValue, err := m.oldValue(ctx)
  36755. if err != nil {
  36756. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  36757. }
  36758. return oldValue.APIBase, nil
  36759. }
  36760. // ClearAPIBase clears the value of the "api_base" field.
  36761. func (m *WhatsappMutation) ClearAPIBase() {
  36762. m.api_base = nil
  36763. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  36764. }
  36765. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  36766. func (m *WhatsappMutation) APIBaseCleared() bool {
  36767. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  36768. return ok
  36769. }
  36770. // ResetAPIBase resets all changes to the "api_base" field.
  36771. func (m *WhatsappMutation) ResetAPIBase() {
  36772. m.api_base = nil
  36773. delete(m.clearedFields, whatsapp.FieldAPIBase)
  36774. }
  36775. // SetAPIKey sets the "api_key" field.
  36776. func (m *WhatsappMutation) SetAPIKey(s string) {
  36777. m.api_key = &s
  36778. }
  36779. // APIKey returns the value of the "api_key" field in the mutation.
  36780. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  36781. v := m.api_key
  36782. if v == nil {
  36783. return
  36784. }
  36785. return *v, true
  36786. }
  36787. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  36788. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36790. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  36791. if !m.op.Is(OpUpdateOne) {
  36792. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  36793. }
  36794. if m.id == nil || m.oldValue == nil {
  36795. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  36796. }
  36797. oldValue, err := m.oldValue(ctx)
  36798. if err != nil {
  36799. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  36800. }
  36801. return oldValue.APIKey, nil
  36802. }
  36803. // ClearAPIKey clears the value of the "api_key" field.
  36804. func (m *WhatsappMutation) ClearAPIKey() {
  36805. m.api_key = nil
  36806. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  36807. }
  36808. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  36809. func (m *WhatsappMutation) APIKeyCleared() bool {
  36810. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  36811. return ok
  36812. }
  36813. // ResetAPIKey resets all changes to the "api_key" field.
  36814. func (m *WhatsappMutation) ResetAPIKey() {
  36815. m.api_key = nil
  36816. delete(m.clearedFields, whatsapp.FieldAPIKey)
  36817. }
  36818. // SetAllowList sets the "allow_list" field.
  36819. func (m *WhatsappMutation) SetAllowList(s []string) {
  36820. m.allow_list = &s
  36821. m.appendallow_list = nil
  36822. }
  36823. // AllowList returns the value of the "allow_list" field in the mutation.
  36824. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  36825. v := m.allow_list
  36826. if v == nil {
  36827. return
  36828. }
  36829. return *v, true
  36830. }
  36831. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  36832. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36834. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  36835. if !m.op.Is(OpUpdateOne) {
  36836. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  36837. }
  36838. if m.id == nil || m.oldValue == nil {
  36839. return v, errors.New("OldAllowList requires an ID field in the mutation")
  36840. }
  36841. oldValue, err := m.oldValue(ctx)
  36842. if err != nil {
  36843. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  36844. }
  36845. return oldValue.AllowList, nil
  36846. }
  36847. // AppendAllowList adds s to the "allow_list" field.
  36848. func (m *WhatsappMutation) AppendAllowList(s []string) {
  36849. m.appendallow_list = append(m.appendallow_list, s...)
  36850. }
  36851. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  36852. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  36853. if len(m.appendallow_list) == 0 {
  36854. return nil, false
  36855. }
  36856. return m.appendallow_list, true
  36857. }
  36858. // ClearAllowList clears the value of the "allow_list" field.
  36859. func (m *WhatsappMutation) ClearAllowList() {
  36860. m.allow_list = nil
  36861. m.appendallow_list = nil
  36862. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  36863. }
  36864. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  36865. func (m *WhatsappMutation) AllowListCleared() bool {
  36866. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  36867. return ok
  36868. }
  36869. // ResetAllowList resets all changes to the "allow_list" field.
  36870. func (m *WhatsappMutation) ResetAllowList() {
  36871. m.allow_list = nil
  36872. m.appendallow_list = nil
  36873. delete(m.clearedFields, whatsapp.FieldAllowList)
  36874. }
  36875. // SetGroupAllowList sets the "group_allow_list" field.
  36876. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  36877. m.group_allow_list = &s
  36878. m.appendgroup_allow_list = nil
  36879. }
  36880. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  36881. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  36882. v := m.group_allow_list
  36883. if v == nil {
  36884. return
  36885. }
  36886. return *v, true
  36887. }
  36888. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  36889. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36891. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  36892. if !m.op.Is(OpUpdateOne) {
  36893. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  36894. }
  36895. if m.id == nil || m.oldValue == nil {
  36896. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  36897. }
  36898. oldValue, err := m.oldValue(ctx)
  36899. if err != nil {
  36900. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  36901. }
  36902. return oldValue.GroupAllowList, nil
  36903. }
  36904. // AppendGroupAllowList adds s to the "group_allow_list" field.
  36905. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  36906. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  36907. }
  36908. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  36909. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  36910. if len(m.appendgroup_allow_list) == 0 {
  36911. return nil, false
  36912. }
  36913. return m.appendgroup_allow_list, true
  36914. }
  36915. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  36916. func (m *WhatsappMutation) ClearGroupAllowList() {
  36917. m.group_allow_list = nil
  36918. m.appendgroup_allow_list = nil
  36919. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  36920. }
  36921. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  36922. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  36923. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  36924. return ok
  36925. }
  36926. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  36927. func (m *WhatsappMutation) ResetGroupAllowList() {
  36928. m.group_allow_list = nil
  36929. m.appendgroup_allow_list = nil
  36930. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  36931. }
  36932. // SetBlockList sets the "block_list" field.
  36933. func (m *WhatsappMutation) SetBlockList(s []string) {
  36934. m.block_list = &s
  36935. m.appendblock_list = nil
  36936. }
  36937. // BlockList returns the value of the "block_list" field in the mutation.
  36938. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  36939. v := m.block_list
  36940. if v == nil {
  36941. return
  36942. }
  36943. return *v, true
  36944. }
  36945. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  36946. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36948. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  36949. if !m.op.Is(OpUpdateOne) {
  36950. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  36951. }
  36952. if m.id == nil || m.oldValue == nil {
  36953. return v, errors.New("OldBlockList requires an ID field in the mutation")
  36954. }
  36955. oldValue, err := m.oldValue(ctx)
  36956. if err != nil {
  36957. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  36958. }
  36959. return oldValue.BlockList, nil
  36960. }
  36961. // AppendBlockList adds s to the "block_list" field.
  36962. func (m *WhatsappMutation) AppendBlockList(s []string) {
  36963. m.appendblock_list = append(m.appendblock_list, s...)
  36964. }
  36965. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  36966. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  36967. if len(m.appendblock_list) == 0 {
  36968. return nil, false
  36969. }
  36970. return m.appendblock_list, true
  36971. }
  36972. // ClearBlockList clears the value of the "block_list" field.
  36973. func (m *WhatsappMutation) ClearBlockList() {
  36974. m.block_list = nil
  36975. m.appendblock_list = nil
  36976. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  36977. }
  36978. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  36979. func (m *WhatsappMutation) BlockListCleared() bool {
  36980. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  36981. return ok
  36982. }
  36983. // ResetBlockList resets all changes to the "block_list" field.
  36984. func (m *WhatsappMutation) ResetBlockList() {
  36985. m.block_list = nil
  36986. m.appendblock_list = nil
  36987. delete(m.clearedFields, whatsapp.FieldBlockList)
  36988. }
  36989. // SetGroupBlockList sets the "group_block_list" field.
  36990. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  36991. m.group_block_list = &s
  36992. m.appendgroup_block_list = nil
  36993. }
  36994. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  36995. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  36996. v := m.group_block_list
  36997. if v == nil {
  36998. return
  36999. }
  37000. return *v, true
  37001. }
  37002. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  37003. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37005. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  37006. if !m.op.Is(OpUpdateOne) {
  37007. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  37008. }
  37009. if m.id == nil || m.oldValue == nil {
  37010. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  37011. }
  37012. oldValue, err := m.oldValue(ctx)
  37013. if err != nil {
  37014. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  37015. }
  37016. return oldValue.GroupBlockList, nil
  37017. }
  37018. // AppendGroupBlockList adds s to the "group_block_list" field.
  37019. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  37020. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  37021. }
  37022. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  37023. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  37024. if len(m.appendgroup_block_list) == 0 {
  37025. return nil, false
  37026. }
  37027. return m.appendgroup_block_list, true
  37028. }
  37029. // ClearGroupBlockList clears the value of the "group_block_list" field.
  37030. func (m *WhatsappMutation) ClearGroupBlockList() {
  37031. m.group_block_list = nil
  37032. m.appendgroup_block_list = nil
  37033. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  37034. }
  37035. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  37036. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  37037. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  37038. return ok
  37039. }
  37040. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  37041. func (m *WhatsappMutation) ResetGroupBlockList() {
  37042. m.group_block_list = nil
  37043. m.appendgroup_block_list = nil
  37044. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  37045. }
  37046. // ClearAgent clears the "agent" edge to the Agent entity.
  37047. func (m *WhatsappMutation) ClearAgent() {
  37048. m.clearedagent = true
  37049. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  37050. }
  37051. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  37052. func (m *WhatsappMutation) AgentCleared() bool {
  37053. return m.clearedagent
  37054. }
  37055. // AgentIDs returns the "agent" edge IDs in the mutation.
  37056. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37057. // AgentID instead. It exists only for internal usage by the builders.
  37058. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  37059. if id := m.agent; id != nil {
  37060. ids = append(ids, *id)
  37061. }
  37062. return
  37063. }
  37064. // ResetAgent resets all changes to the "agent" edge.
  37065. func (m *WhatsappMutation) ResetAgent() {
  37066. m.agent = nil
  37067. m.clearedagent = false
  37068. }
  37069. // Where appends a list predicates to the WhatsappMutation builder.
  37070. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  37071. m.predicates = append(m.predicates, ps...)
  37072. }
  37073. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  37074. // users can use type-assertion to append predicates that do not depend on any generated package.
  37075. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  37076. p := make([]predicate.Whatsapp, len(ps))
  37077. for i := range ps {
  37078. p[i] = ps[i]
  37079. }
  37080. m.Where(p...)
  37081. }
  37082. // Op returns the operation name.
  37083. func (m *WhatsappMutation) Op() Op {
  37084. return m.op
  37085. }
  37086. // SetOp allows setting the mutation operation.
  37087. func (m *WhatsappMutation) SetOp(op Op) {
  37088. m.op = op
  37089. }
  37090. // Type returns the node type of this mutation (Whatsapp).
  37091. func (m *WhatsappMutation) Type() string {
  37092. return m.typ
  37093. }
  37094. // Fields returns all fields that were changed during this mutation. Note that in
  37095. // order to get all numeric fields that were incremented/decremented, call
  37096. // AddedFields().
  37097. func (m *WhatsappMutation) Fields() []string {
  37098. fields := make([]string, 0, 21)
  37099. if m.created_at != nil {
  37100. fields = append(fields, whatsapp.FieldCreatedAt)
  37101. }
  37102. if m.updated_at != nil {
  37103. fields = append(fields, whatsapp.FieldUpdatedAt)
  37104. }
  37105. if m.status != nil {
  37106. fields = append(fields, whatsapp.FieldStatus)
  37107. }
  37108. if m.deleted_at != nil {
  37109. fields = append(fields, whatsapp.FieldDeletedAt)
  37110. }
  37111. if m.wa_id != nil {
  37112. fields = append(fields, whatsapp.FieldWaID)
  37113. }
  37114. if m.wa_name != nil {
  37115. fields = append(fields, whatsapp.FieldWaName)
  37116. }
  37117. if m.callback != nil {
  37118. fields = append(fields, whatsapp.FieldCallback)
  37119. }
  37120. if m.agent != nil {
  37121. fields = append(fields, whatsapp.FieldAgentID)
  37122. }
  37123. if m.account != nil {
  37124. fields = append(fields, whatsapp.FieldAccount)
  37125. }
  37126. if m.cc != nil {
  37127. fields = append(fields, whatsapp.FieldCc)
  37128. }
  37129. if m.phone != nil {
  37130. fields = append(fields, whatsapp.FieldPhone)
  37131. }
  37132. if m.cc_phone != nil {
  37133. fields = append(fields, whatsapp.FieldCcPhone)
  37134. }
  37135. if m.phone_name != nil {
  37136. fields = append(fields, whatsapp.FieldPhoneName)
  37137. }
  37138. if m.phone_status != nil {
  37139. fields = append(fields, whatsapp.FieldPhoneStatus)
  37140. }
  37141. if m.organization_id != nil {
  37142. fields = append(fields, whatsapp.FieldOrganizationID)
  37143. }
  37144. if m.api_base != nil {
  37145. fields = append(fields, whatsapp.FieldAPIBase)
  37146. }
  37147. if m.api_key != nil {
  37148. fields = append(fields, whatsapp.FieldAPIKey)
  37149. }
  37150. if m.allow_list != nil {
  37151. fields = append(fields, whatsapp.FieldAllowList)
  37152. }
  37153. if m.group_allow_list != nil {
  37154. fields = append(fields, whatsapp.FieldGroupAllowList)
  37155. }
  37156. if m.block_list != nil {
  37157. fields = append(fields, whatsapp.FieldBlockList)
  37158. }
  37159. if m.group_block_list != nil {
  37160. fields = append(fields, whatsapp.FieldGroupBlockList)
  37161. }
  37162. return fields
  37163. }
  37164. // Field returns the value of a field with the given name. The second boolean
  37165. // return value indicates that this field was not set, or was not defined in the
  37166. // schema.
  37167. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37168. switch name {
  37169. case whatsapp.FieldCreatedAt:
  37170. return m.CreatedAt()
  37171. case whatsapp.FieldUpdatedAt:
  37172. return m.UpdatedAt()
  37173. case whatsapp.FieldStatus:
  37174. return m.Status()
  37175. case whatsapp.FieldDeletedAt:
  37176. return m.DeletedAt()
  37177. case whatsapp.FieldWaID:
  37178. return m.WaID()
  37179. case whatsapp.FieldWaName:
  37180. return m.WaName()
  37181. case whatsapp.FieldCallback:
  37182. return m.Callback()
  37183. case whatsapp.FieldAgentID:
  37184. return m.AgentID()
  37185. case whatsapp.FieldAccount:
  37186. return m.Account()
  37187. case whatsapp.FieldCc:
  37188. return m.Cc()
  37189. case whatsapp.FieldPhone:
  37190. return m.Phone()
  37191. case whatsapp.FieldCcPhone:
  37192. return m.CcPhone()
  37193. case whatsapp.FieldPhoneName:
  37194. return m.PhoneName()
  37195. case whatsapp.FieldPhoneStatus:
  37196. return m.PhoneStatus()
  37197. case whatsapp.FieldOrganizationID:
  37198. return m.OrganizationID()
  37199. case whatsapp.FieldAPIBase:
  37200. return m.APIBase()
  37201. case whatsapp.FieldAPIKey:
  37202. return m.APIKey()
  37203. case whatsapp.FieldAllowList:
  37204. return m.AllowList()
  37205. case whatsapp.FieldGroupAllowList:
  37206. return m.GroupAllowList()
  37207. case whatsapp.FieldBlockList:
  37208. return m.BlockList()
  37209. case whatsapp.FieldGroupBlockList:
  37210. return m.GroupBlockList()
  37211. }
  37212. return nil, false
  37213. }
  37214. // OldField returns the old value of the field from the database. An error is
  37215. // returned if the mutation operation is not UpdateOne, or the query to the
  37216. // database failed.
  37217. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37218. switch name {
  37219. case whatsapp.FieldCreatedAt:
  37220. return m.OldCreatedAt(ctx)
  37221. case whatsapp.FieldUpdatedAt:
  37222. return m.OldUpdatedAt(ctx)
  37223. case whatsapp.FieldStatus:
  37224. return m.OldStatus(ctx)
  37225. case whatsapp.FieldDeletedAt:
  37226. return m.OldDeletedAt(ctx)
  37227. case whatsapp.FieldWaID:
  37228. return m.OldWaID(ctx)
  37229. case whatsapp.FieldWaName:
  37230. return m.OldWaName(ctx)
  37231. case whatsapp.FieldCallback:
  37232. return m.OldCallback(ctx)
  37233. case whatsapp.FieldAgentID:
  37234. return m.OldAgentID(ctx)
  37235. case whatsapp.FieldAccount:
  37236. return m.OldAccount(ctx)
  37237. case whatsapp.FieldCc:
  37238. return m.OldCc(ctx)
  37239. case whatsapp.FieldPhone:
  37240. return m.OldPhone(ctx)
  37241. case whatsapp.FieldCcPhone:
  37242. return m.OldCcPhone(ctx)
  37243. case whatsapp.FieldPhoneName:
  37244. return m.OldPhoneName(ctx)
  37245. case whatsapp.FieldPhoneStatus:
  37246. return m.OldPhoneStatus(ctx)
  37247. case whatsapp.FieldOrganizationID:
  37248. return m.OldOrganizationID(ctx)
  37249. case whatsapp.FieldAPIBase:
  37250. return m.OldAPIBase(ctx)
  37251. case whatsapp.FieldAPIKey:
  37252. return m.OldAPIKey(ctx)
  37253. case whatsapp.FieldAllowList:
  37254. return m.OldAllowList(ctx)
  37255. case whatsapp.FieldGroupAllowList:
  37256. return m.OldGroupAllowList(ctx)
  37257. case whatsapp.FieldBlockList:
  37258. return m.OldBlockList(ctx)
  37259. case whatsapp.FieldGroupBlockList:
  37260. return m.OldGroupBlockList(ctx)
  37261. }
  37262. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37263. }
  37264. // SetField sets the value of a field with the given name. It returns an error if
  37265. // the field is not defined in the schema, or if the type mismatched the field
  37266. // type.
  37267. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37268. switch name {
  37269. case whatsapp.FieldCreatedAt:
  37270. v, ok := value.(time.Time)
  37271. if !ok {
  37272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37273. }
  37274. m.SetCreatedAt(v)
  37275. return nil
  37276. case whatsapp.FieldUpdatedAt:
  37277. v, ok := value.(time.Time)
  37278. if !ok {
  37279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37280. }
  37281. m.SetUpdatedAt(v)
  37282. return nil
  37283. case whatsapp.FieldStatus:
  37284. v, ok := value.(uint8)
  37285. if !ok {
  37286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37287. }
  37288. m.SetStatus(v)
  37289. return nil
  37290. case whatsapp.FieldDeletedAt:
  37291. v, ok := value.(time.Time)
  37292. if !ok {
  37293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37294. }
  37295. m.SetDeletedAt(v)
  37296. return nil
  37297. case whatsapp.FieldWaID:
  37298. v, ok := value.(string)
  37299. if !ok {
  37300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37301. }
  37302. m.SetWaID(v)
  37303. return nil
  37304. case whatsapp.FieldWaName:
  37305. v, ok := value.(string)
  37306. if !ok {
  37307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37308. }
  37309. m.SetWaName(v)
  37310. return nil
  37311. case whatsapp.FieldCallback:
  37312. v, ok := value.(string)
  37313. if !ok {
  37314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37315. }
  37316. m.SetCallback(v)
  37317. return nil
  37318. case whatsapp.FieldAgentID:
  37319. v, ok := value.(uint64)
  37320. if !ok {
  37321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37322. }
  37323. m.SetAgentID(v)
  37324. return nil
  37325. case whatsapp.FieldAccount:
  37326. v, ok := value.(string)
  37327. if !ok {
  37328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37329. }
  37330. m.SetAccount(v)
  37331. return nil
  37332. case whatsapp.FieldCc:
  37333. v, ok := value.(string)
  37334. if !ok {
  37335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37336. }
  37337. m.SetCc(v)
  37338. return nil
  37339. case whatsapp.FieldPhone:
  37340. v, ok := value.(string)
  37341. if !ok {
  37342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37343. }
  37344. m.SetPhone(v)
  37345. return nil
  37346. case whatsapp.FieldCcPhone:
  37347. v, ok := value.(string)
  37348. if !ok {
  37349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37350. }
  37351. m.SetCcPhone(v)
  37352. return nil
  37353. case whatsapp.FieldPhoneName:
  37354. v, ok := value.(string)
  37355. if !ok {
  37356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37357. }
  37358. m.SetPhoneName(v)
  37359. return nil
  37360. case whatsapp.FieldPhoneStatus:
  37361. v, ok := value.(int8)
  37362. if !ok {
  37363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37364. }
  37365. m.SetPhoneStatus(v)
  37366. return nil
  37367. case whatsapp.FieldOrganizationID:
  37368. v, ok := value.(uint64)
  37369. if !ok {
  37370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37371. }
  37372. m.SetOrganizationID(v)
  37373. return nil
  37374. case whatsapp.FieldAPIBase:
  37375. v, ok := value.(string)
  37376. if !ok {
  37377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37378. }
  37379. m.SetAPIBase(v)
  37380. return nil
  37381. case whatsapp.FieldAPIKey:
  37382. v, ok := value.(string)
  37383. if !ok {
  37384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37385. }
  37386. m.SetAPIKey(v)
  37387. return nil
  37388. case whatsapp.FieldAllowList:
  37389. v, ok := value.([]string)
  37390. if !ok {
  37391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37392. }
  37393. m.SetAllowList(v)
  37394. return nil
  37395. case whatsapp.FieldGroupAllowList:
  37396. v, ok := value.([]string)
  37397. if !ok {
  37398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37399. }
  37400. m.SetGroupAllowList(v)
  37401. return nil
  37402. case whatsapp.FieldBlockList:
  37403. v, ok := value.([]string)
  37404. if !ok {
  37405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37406. }
  37407. m.SetBlockList(v)
  37408. return nil
  37409. case whatsapp.FieldGroupBlockList:
  37410. v, ok := value.([]string)
  37411. if !ok {
  37412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37413. }
  37414. m.SetGroupBlockList(v)
  37415. return nil
  37416. }
  37417. return fmt.Errorf("unknown Whatsapp field %s", name)
  37418. }
  37419. // AddedFields returns all numeric fields that were incremented/decremented during
  37420. // this mutation.
  37421. func (m *WhatsappMutation) AddedFields() []string {
  37422. var fields []string
  37423. if m.addstatus != nil {
  37424. fields = append(fields, whatsapp.FieldStatus)
  37425. }
  37426. if m.addphone_status != nil {
  37427. fields = append(fields, whatsapp.FieldPhoneStatus)
  37428. }
  37429. if m.addorganization_id != nil {
  37430. fields = append(fields, whatsapp.FieldOrganizationID)
  37431. }
  37432. return fields
  37433. }
  37434. // AddedField returns the numeric value that was incremented/decremented on a field
  37435. // with the given name. The second boolean return value indicates that this field
  37436. // was not set, or was not defined in the schema.
  37437. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37438. switch name {
  37439. case whatsapp.FieldStatus:
  37440. return m.AddedStatus()
  37441. case whatsapp.FieldPhoneStatus:
  37442. return m.AddedPhoneStatus()
  37443. case whatsapp.FieldOrganizationID:
  37444. return m.AddedOrganizationID()
  37445. }
  37446. return nil, false
  37447. }
  37448. // AddField adds the value to the field with the given name. It returns an error if
  37449. // the field is not defined in the schema, or if the type mismatched the field
  37450. // type.
  37451. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37452. switch name {
  37453. case whatsapp.FieldStatus:
  37454. v, ok := value.(int8)
  37455. if !ok {
  37456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37457. }
  37458. m.AddStatus(v)
  37459. return nil
  37460. case whatsapp.FieldPhoneStatus:
  37461. v, ok := value.(int8)
  37462. if !ok {
  37463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37464. }
  37465. m.AddPhoneStatus(v)
  37466. return nil
  37467. case whatsapp.FieldOrganizationID:
  37468. v, ok := value.(int64)
  37469. if !ok {
  37470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37471. }
  37472. m.AddOrganizationID(v)
  37473. return nil
  37474. }
  37475. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37476. }
  37477. // ClearedFields returns all nullable fields that were cleared during this
  37478. // mutation.
  37479. func (m *WhatsappMutation) ClearedFields() []string {
  37480. var fields []string
  37481. if m.FieldCleared(whatsapp.FieldStatus) {
  37482. fields = append(fields, whatsapp.FieldStatus)
  37483. }
  37484. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37485. fields = append(fields, whatsapp.FieldDeletedAt)
  37486. }
  37487. if m.FieldCleared(whatsapp.FieldWaID) {
  37488. fields = append(fields, whatsapp.FieldWaID)
  37489. }
  37490. if m.FieldCleared(whatsapp.FieldWaName) {
  37491. fields = append(fields, whatsapp.FieldWaName)
  37492. }
  37493. if m.FieldCleared(whatsapp.FieldCallback) {
  37494. fields = append(fields, whatsapp.FieldCallback)
  37495. }
  37496. if m.FieldCleared(whatsapp.FieldAccount) {
  37497. fields = append(fields, whatsapp.FieldAccount)
  37498. }
  37499. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37500. fields = append(fields, whatsapp.FieldOrganizationID)
  37501. }
  37502. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37503. fields = append(fields, whatsapp.FieldAPIBase)
  37504. }
  37505. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37506. fields = append(fields, whatsapp.FieldAPIKey)
  37507. }
  37508. if m.FieldCleared(whatsapp.FieldAllowList) {
  37509. fields = append(fields, whatsapp.FieldAllowList)
  37510. }
  37511. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37512. fields = append(fields, whatsapp.FieldGroupAllowList)
  37513. }
  37514. if m.FieldCleared(whatsapp.FieldBlockList) {
  37515. fields = append(fields, whatsapp.FieldBlockList)
  37516. }
  37517. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37518. fields = append(fields, whatsapp.FieldGroupBlockList)
  37519. }
  37520. return fields
  37521. }
  37522. // FieldCleared returns a boolean indicating if a field with the given name was
  37523. // cleared in this mutation.
  37524. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37525. _, ok := m.clearedFields[name]
  37526. return ok
  37527. }
  37528. // ClearField clears the value of the field with the given name. It returns an
  37529. // error if the field is not defined in the schema.
  37530. func (m *WhatsappMutation) ClearField(name string) error {
  37531. switch name {
  37532. case whatsapp.FieldStatus:
  37533. m.ClearStatus()
  37534. return nil
  37535. case whatsapp.FieldDeletedAt:
  37536. m.ClearDeletedAt()
  37537. return nil
  37538. case whatsapp.FieldWaID:
  37539. m.ClearWaID()
  37540. return nil
  37541. case whatsapp.FieldWaName:
  37542. m.ClearWaName()
  37543. return nil
  37544. case whatsapp.FieldCallback:
  37545. m.ClearCallback()
  37546. return nil
  37547. case whatsapp.FieldAccount:
  37548. m.ClearAccount()
  37549. return nil
  37550. case whatsapp.FieldOrganizationID:
  37551. m.ClearOrganizationID()
  37552. return nil
  37553. case whatsapp.FieldAPIBase:
  37554. m.ClearAPIBase()
  37555. return nil
  37556. case whatsapp.FieldAPIKey:
  37557. m.ClearAPIKey()
  37558. return nil
  37559. case whatsapp.FieldAllowList:
  37560. m.ClearAllowList()
  37561. return nil
  37562. case whatsapp.FieldGroupAllowList:
  37563. m.ClearGroupAllowList()
  37564. return nil
  37565. case whatsapp.FieldBlockList:
  37566. m.ClearBlockList()
  37567. return nil
  37568. case whatsapp.FieldGroupBlockList:
  37569. m.ClearGroupBlockList()
  37570. return nil
  37571. }
  37572. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37573. }
  37574. // ResetField resets all changes in the mutation for the field with the given name.
  37575. // It returns an error if the field is not defined in the schema.
  37576. func (m *WhatsappMutation) ResetField(name string) error {
  37577. switch name {
  37578. case whatsapp.FieldCreatedAt:
  37579. m.ResetCreatedAt()
  37580. return nil
  37581. case whatsapp.FieldUpdatedAt:
  37582. m.ResetUpdatedAt()
  37583. return nil
  37584. case whatsapp.FieldStatus:
  37585. m.ResetStatus()
  37586. return nil
  37587. case whatsapp.FieldDeletedAt:
  37588. m.ResetDeletedAt()
  37589. return nil
  37590. case whatsapp.FieldWaID:
  37591. m.ResetWaID()
  37592. return nil
  37593. case whatsapp.FieldWaName:
  37594. m.ResetWaName()
  37595. return nil
  37596. case whatsapp.FieldCallback:
  37597. m.ResetCallback()
  37598. return nil
  37599. case whatsapp.FieldAgentID:
  37600. m.ResetAgentID()
  37601. return nil
  37602. case whatsapp.FieldAccount:
  37603. m.ResetAccount()
  37604. return nil
  37605. case whatsapp.FieldCc:
  37606. m.ResetCc()
  37607. return nil
  37608. case whatsapp.FieldPhone:
  37609. m.ResetPhone()
  37610. return nil
  37611. case whatsapp.FieldCcPhone:
  37612. m.ResetCcPhone()
  37613. return nil
  37614. case whatsapp.FieldPhoneName:
  37615. m.ResetPhoneName()
  37616. return nil
  37617. case whatsapp.FieldPhoneStatus:
  37618. m.ResetPhoneStatus()
  37619. return nil
  37620. case whatsapp.FieldOrganizationID:
  37621. m.ResetOrganizationID()
  37622. return nil
  37623. case whatsapp.FieldAPIBase:
  37624. m.ResetAPIBase()
  37625. return nil
  37626. case whatsapp.FieldAPIKey:
  37627. m.ResetAPIKey()
  37628. return nil
  37629. case whatsapp.FieldAllowList:
  37630. m.ResetAllowList()
  37631. return nil
  37632. case whatsapp.FieldGroupAllowList:
  37633. m.ResetGroupAllowList()
  37634. return nil
  37635. case whatsapp.FieldBlockList:
  37636. m.ResetBlockList()
  37637. return nil
  37638. case whatsapp.FieldGroupBlockList:
  37639. m.ResetGroupBlockList()
  37640. return nil
  37641. }
  37642. return fmt.Errorf("unknown Whatsapp field %s", name)
  37643. }
  37644. // AddedEdges returns all edge names that were set/added in this mutation.
  37645. func (m *WhatsappMutation) AddedEdges() []string {
  37646. edges := make([]string, 0, 1)
  37647. if m.agent != nil {
  37648. edges = append(edges, whatsapp.EdgeAgent)
  37649. }
  37650. return edges
  37651. }
  37652. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37653. // name in this mutation.
  37654. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  37655. switch name {
  37656. case whatsapp.EdgeAgent:
  37657. if id := m.agent; id != nil {
  37658. return []ent.Value{*id}
  37659. }
  37660. }
  37661. return nil
  37662. }
  37663. // RemovedEdges returns all edge names that were removed in this mutation.
  37664. func (m *WhatsappMutation) RemovedEdges() []string {
  37665. edges := make([]string, 0, 1)
  37666. return edges
  37667. }
  37668. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37669. // the given name in this mutation.
  37670. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  37671. return nil
  37672. }
  37673. // ClearedEdges returns all edge names that were cleared in this mutation.
  37674. func (m *WhatsappMutation) ClearedEdges() []string {
  37675. edges := make([]string, 0, 1)
  37676. if m.clearedagent {
  37677. edges = append(edges, whatsapp.EdgeAgent)
  37678. }
  37679. return edges
  37680. }
  37681. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37682. // was cleared in this mutation.
  37683. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  37684. switch name {
  37685. case whatsapp.EdgeAgent:
  37686. return m.clearedagent
  37687. }
  37688. return false
  37689. }
  37690. // ClearEdge clears the value of the edge with the given name. It returns an error
  37691. // if that edge is not defined in the schema.
  37692. func (m *WhatsappMutation) ClearEdge(name string) error {
  37693. switch name {
  37694. case whatsapp.EdgeAgent:
  37695. m.ClearAgent()
  37696. return nil
  37697. }
  37698. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  37699. }
  37700. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37701. // It returns an error if the edge is not defined in the schema.
  37702. func (m *WhatsappMutation) ResetEdge(name string) error {
  37703. switch name {
  37704. case whatsapp.EdgeAgent:
  37705. m.ResetAgent()
  37706. return nil
  37707. }
  37708. return fmt.Errorf("unknown Whatsapp edge %s", name)
  37709. }
  37710. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  37711. type WhatsappChannelMutation struct {
  37712. config
  37713. op Op
  37714. typ string
  37715. id *uint64
  37716. created_at *time.Time
  37717. updated_at *time.Time
  37718. status *uint8
  37719. addstatus *int8
  37720. deleted_at *time.Time
  37721. ak *string
  37722. sk *string
  37723. wa_id *string
  37724. wa_name *string
  37725. waba_id *uint64
  37726. addwaba_id *int64
  37727. business_id *uint64
  37728. addbusiness_id *int64
  37729. organization_id *uint64
  37730. addorganization_id *int64
  37731. verify_account *string
  37732. clearedFields map[string]struct{}
  37733. done bool
  37734. oldValue func(context.Context) (*WhatsappChannel, error)
  37735. predicates []predicate.WhatsappChannel
  37736. }
  37737. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  37738. // whatsappchannelOption allows management of the mutation configuration using functional options.
  37739. type whatsappchannelOption func(*WhatsappChannelMutation)
  37740. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  37741. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  37742. m := &WhatsappChannelMutation{
  37743. config: c,
  37744. op: op,
  37745. typ: TypeWhatsappChannel,
  37746. clearedFields: make(map[string]struct{}),
  37747. }
  37748. for _, opt := range opts {
  37749. opt(m)
  37750. }
  37751. return m
  37752. }
  37753. // withWhatsappChannelID sets the ID field of the mutation.
  37754. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  37755. return func(m *WhatsappChannelMutation) {
  37756. var (
  37757. err error
  37758. once sync.Once
  37759. value *WhatsappChannel
  37760. )
  37761. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  37762. once.Do(func() {
  37763. if m.done {
  37764. err = errors.New("querying old values post mutation is not allowed")
  37765. } else {
  37766. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  37767. }
  37768. })
  37769. return value, err
  37770. }
  37771. m.id = &id
  37772. }
  37773. }
  37774. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  37775. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  37776. return func(m *WhatsappChannelMutation) {
  37777. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  37778. return node, nil
  37779. }
  37780. m.id = &node.ID
  37781. }
  37782. }
  37783. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37784. // executed in a transaction (ent.Tx), a transactional client is returned.
  37785. func (m WhatsappChannelMutation) Client() *Client {
  37786. client := &Client{config: m.config}
  37787. client.init()
  37788. return client
  37789. }
  37790. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37791. // it returns an error otherwise.
  37792. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  37793. if _, ok := m.driver.(*txDriver); !ok {
  37794. return nil, errors.New("ent: mutation is not running in a transaction")
  37795. }
  37796. tx := &Tx{config: m.config}
  37797. tx.init()
  37798. return tx, nil
  37799. }
  37800. // SetID sets the value of the id field. Note that this
  37801. // operation is only accepted on creation of WhatsappChannel entities.
  37802. func (m *WhatsappChannelMutation) SetID(id uint64) {
  37803. m.id = &id
  37804. }
  37805. // ID returns the ID value in the mutation. Note that the ID is only available
  37806. // if it was provided to the builder or after it was returned from the database.
  37807. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  37808. if m.id == nil {
  37809. return
  37810. }
  37811. return *m.id, true
  37812. }
  37813. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37814. // That means, if the mutation is applied within a transaction with an isolation level such
  37815. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37816. // or updated by the mutation.
  37817. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  37818. switch {
  37819. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37820. id, exists := m.ID()
  37821. if exists {
  37822. return []uint64{id}, nil
  37823. }
  37824. fallthrough
  37825. case m.op.Is(OpUpdate | OpDelete):
  37826. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  37827. default:
  37828. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37829. }
  37830. }
  37831. // SetCreatedAt sets the "created_at" field.
  37832. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  37833. m.created_at = &t
  37834. }
  37835. // CreatedAt returns the value of the "created_at" field in the mutation.
  37836. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  37837. v := m.created_at
  37838. if v == nil {
  37839. return
  37840. }
  37841. return *v, true
  37842. }
  37843. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  37844. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37846. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37847. if !m.op.Is(OpUpdateOne) {
  37848. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37849. }
  37850. if m.id == nil || m.oldValue == nil {
  37851. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37852. }
  37853. oldValue, err := m.oldValue(ctx)
  37854. if err != nil {
  37855. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37856. }
  37857. return oldValue.CreatedAt, nil
  37858. }
  37859. // ResetCreatedAt resets all changes to the "created_at" field.
  37860. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  37861. m.created_at = nil
  37862. }
  37863. // SetUpdatedAt sets the "updated_at" field.
  37864. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  37865. m.updated_at = &t
  37866. }
  37867. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37868. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  37869. v := m.updated_at
  37870. if v == nil {
  37871. return
  37872. }
  37873. return *v, true
  37874. }
  37875. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  37876. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37878. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37879. if !m.op.Is(OpUpdateOne) {
  37880. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37881. }
  37882. if m.id == nil || m.oldValue == nil {
  37883. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37884. }
  37885. oldValue, err := m.oldValue(ctx)
  37886. if err != nil {
  37887. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37888. }
  37889. return oldValue.UpdatedAt, nil
  37890. }
  37891. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37892. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  37893. m.updated_at = nil
  37894. }
  37895. // SetStatus sets the "status" field.
  37896. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  37897. m.status = &u
  37898. m.addstatus = nil
  37899. }
  37900. // Status returns the value of the "status" field in the mutation.
  37901. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  37902. v := m.status
  37903. if v == nil {
  37904. return
  37905. }
  37906. return *v, true
  37907. }
  37908. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  37909. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37911. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37912. if !m.op.Is(OpUpdateOne) {
  37913. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37914. }
  37915. if m.id == nil || m.oldValue == nil {
  37916. return v, errors.New("OldStatus requires an ID field in the mutation")
  37917. }
  37918. oldValue, err := m.oldValue(ctx)
  37919. if err != nil {
  37920. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37921. }
  37922. return oldValue.Status, nil
  37923. }
  37924. // AddStatus adds u to the "status" field.
  37925. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  37926. if m.addstatus != nil {
  37927. *m.addstatus += u
  37928. } else {
  37929. m.addstatus = &u
  37930. }
  37931. }
  37932. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37933. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  37934. v := m.addstatus
  37935. if v == nil {
  37936. return
  37937. }
  37938. return *v, true
  37939. }
  37940. // ClearStatus clears the value of the "status" field.
  37941. func (m *WhatsappChannelMutation) ClearStatus() {
  37942. m.status = nil
  37943. m.addstatus = nil
  37944. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  37945. }
  37946. // StatusCleared returns if the "status" field was cleared in this mutation.
  37947. func (m *WhatsappChannelMutation) StatusCleared() bool {
  37948. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  37949. return ok
  37950. }
  37951. // ResetStatus resets all changes to the "status" field.
  37952. func (m *WhatsappChannelMutation) ResetStatus() {
  37953. m.status = nil
  37954. m.addstatus = nil
  37955. delete(m.clearedFields, whatsappchannel.FieldStatus)
  37956. }
  37957. // SetDeletedAt sets the "deleted_at" field.
  37958. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  37959. m.deleted_at = &t
  37960. }
  37961. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37962. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  37963. v := m.deleted_at
  37964. if v == nil {
  37965. return
  37966. }
  37967. return *v, true
  37968. }
  37969. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  37970. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37972. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37973. if !m.op.Is(OpUpdateOne) {
  37974. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37975. }
  37976. if m.id == nil || m.oldValue == nil {
  37977. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37978. }
  37979. oldValue, err := m.oldValue(ctx)
  37980. if err != nil {
  37981. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37982. }
  37983. return oldValue.DeletedAt, nil
  37984. }
  37985. // ClearDeletedAt clears the value of the "deleted_at" field.
  37986. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  37987. m.deleted_at = nil
  37988. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  37989. }
  37990. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37991. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  37992. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  37993. return ok
  37994. }
  37995. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37996. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  37997. m.deleted_at = nil
  37998. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  37999. }
  38000. // SetAk sets the "ak" field.
  38001. func (m *WhatsappChannelMutation) SetAk(s string) {
  38002. m.ak = &s
  38003. }
  38004. // Ak returns the value of the "ak" field in the mutation.
  38005. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  38006. v := m.ak
  38007. if v == nil {
  38008. return
  38009. }
  38010. return *v, true
  38011. }
  38012. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  38013. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38015. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  38016. if !m.op.Is(OpUpdateOne) {
  38017. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  38018. }
  38019. if m.id == nil || m.oldValue == nil {
  38020. return v, errors.New("OldAk requires an ID field in the mutation")
  38021. }
  38022. oldValue, err := m.oldValue(ctx)
  38023. if err != nil {
  38024. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  38025. }
  38026. return oldValue.Ak, nil
  38027. }
  38028. // ClearAk clears the value of the "ak" field.
  38029. func (m *WhatsappChannelMutation) ClearAk() {
  38030. m.ak = nil
  38031. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  38032. }
  38033. // AkCleared returns if the "ak" field was cleared in this mutation.
  38034. func (m *WhatsappChannelMutation) AkCleared() bool {
  38035. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  38036. return ok
  38037. }
  38038. // ResetAk resets all changes to the "ak" field.
  38039. func (m *WhatsappChannelMutation) ResetAk() {
  38040. m.ak = nil
  38041. delete(m.clearedFields, whatsappchannel.FieldAk)
  38042. }
  38043. // SetSk sets the "sk" field.
  38044. func (m *WhatsappChannelMutation) SetSk(s string) {
  38045. m.sk = &s
  38046. }
  38047. // Sk returns the value of the "sk" field in the mutation.
  38048. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  38049. v := m.sk
  38050. if v == nil {
  38051. return
  38052. }
  38053. return *v, true
  38054. }
  38055. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  38056. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38058. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  38059. if !m.op.Is(OpUpdateOne) {
  38060. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  38061. }
  38062. if m.id == nil || m.oldValue == nil {
  38063. return v, errors.New("OldSk requires an ID field in the mutation")
  38064. }
  38065. oldValue, err := m.oldValue(ctx)
  38066. if err != nil {
  38067. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  38068. }
  38069. return oldValue.Sk, nil
  38070. }
  38071. // ResetSk resets all changes to the "sk" field.
  38072. func (m *WhatsappChannelMutation) ResetSk() {
  38073. m.sk = nil
  38074. }
  38075. // SetWaID sets the "wa_id" field.
  38076. func (m *WhatsappChannelMutation) SetWaID(s string) {
  38077. m.wa_id = &s
  38078. }
  38079. // WaID returns the value of the "wa_id" field in the mutation.
  38080. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38081. v := m.wa_id
  38082. if v == nil {
  38083. return
  38084. }
  38085. return *v, true
  38086. }
  38087. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38088. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38090. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38091. if !m.op.Is(OpUpdateOne) {
  38092. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38093. }
  38094. if m.id == nil || m.oldValue == nil {
  38095. return v, errors.New("OldWaID requires an ID field in the mutation")
  38096. }
  38097. oldValue, err := m.oldValue(ctx)
  38098. if err != nil {
  38099. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38100. }
  38101. return oldValue.WaID, nil
  38102. }
  38103. // ClearWaID clears the value of the "wa_id" field.
  38104. func (m *WhatsappChannelMutation) ClearWaID() {
  38105. m.wa_id = nil
  38106. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38107. }
  38108. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38109. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38110. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38111. return ok
  38112. }
  38113. // ResetWaID resets all changes to the "wa_id" field.
  38114. func (m *WhatsappChannelMutation) ResetWaID() {
  38115. m.wa_id = nil
  38116. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38117. }
  38118. // SetWaName sets the "wa_name" field.
  38119. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38120. m.wa_name = &s
  38121. }
  38122. // WaName returns the value of the "wa_name" field in the mutation.
  38123. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38124. v := m.wa_name
  38125. if v == nil {
  38126. return
  38127. }
  38128. return *v, true
  38129. }
  38130. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38131. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38133. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38134. if !m.op.Is(OpUpdateOne) {
  38135. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38136. }
  38137. if m.id == nil || m.oldValue == nil {
  38138. return v, errors.New("OldWaName requires an ID field in the mutation")
  38139. }
  38140. oldValue, err := m.oldValue(ctx)
  38141. if err != nil {
  38142. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38143. }
  38144. return oldValue.WaName, nil
  38145. }
  38146. // ClearWaName clears the value of the "wa_name" field.
  38147. func (m *WhatsappChannelMutation) ClearWaName() {
  38148. m.wa_name = nil
  38149. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38150. }
  38151. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38152. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38153. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38154. return ok
  38155. }
  38156. // ResetWaName resets all changes to the "wa_name" field.
  38157. func (m *WhatsappChannelMutation) ResetWaName() {
  38158. m.wa_name = nil
  38159. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38160. }
  38161. // SetWabaID sets the "waba_id" field.
  38162. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38163. m.waba_id = &u
  38164. m.addwaba_id = nil
  38165. }
  38166. // WabaID returns the value of the "waba_id" field in the mutation.
  38167. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38168. v := m.waba_id
  38169. if v == nil {
  38170. return
  38171. }
  38172. return *v, true
  38173. }
  38174. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38175. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38177. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38178. if !m.op.Is(OpUpdateOne) {
  38179. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38180. }
  38181. if m.id == nil || m.oldValue == nil {
  38182. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38183. }
  38184. oldValue, err := m.oldValue(ctx)
  38185. if err != nil {
  38186. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38187. }
  38188. return oldValue.WabaID, nil
  38189. }
  38190. // AddWabaID adds u to the "waba_id" field.
  38191. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38192. if m.addwaba_id != nil {
  38193. *m.addwaba_id += u
  38194. } else {
  38195. m.addwaba_id = &u
  38196. }
  38197. }
  38198. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38199. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38200. v := m.addwaba_id
  38201. if v == nil {
  38202. return
  38203. }
  38204. return *v, true
  38205. }
  38206. // ResetWabaID resets all changes to the "waba_id" field.
  38207. func (m *WhatsappChannelMutation) ResetWabaID() {
  38208. m.waba_id = nil
  38209. m.addwaba_id = nil
  38210. }
  38211. // SetBusinessID sets the "business_id" field.
  38212. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38213. m.business_id = &u
  38214. m.addbusiness_id = nil
  38215. }
  38216. // BusinessID returns the value of the "business_id" field in the mutation.
  38217. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38218. v := m.business_id
  38219. if v == nil {
  38220. return
  38221. }
  38222. return *v, true
  38223. }
  38224. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38225. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38227. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38228. if !m.op.Is(OpUpdateOne) {
  38229. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38230. }
  38231. if m.id == nil || m.oldValue == nil {
  38232. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38233. }
  38234. oldValue, err := m.oldValue(ctx)
  38235. if err != nil {
  38236. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38237. }
  38238. return oldValue.BusinessID, nil
  38239. }
  38240. // AddBusinessID adds u to the "business_id" field.
  38241. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38242. if m.addbusiness_id != nil {
  38243. *m.addbusiness_id += u
  38244. } else {
  38245. m.addbusiness_id = &u
  38246. }
  38247. }
  38248. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38249. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38250. v := m.addbusiness_id
  38251. if v == nil {
  38252. return
  38253. }
  38254. return *v, true
  38255. }
  38256. // ResetBusinessID resets all changes to the "business_id" field.
  38257. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38258. m.business_id = nil
  38259. m.addbusiness_id = nil
  38260. }
  38261. // SetOrganizationID sets the "organization_id" field.
  38262. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38263. m.organization_id = &u
  38264. m.addorganization_id = nil
  38265. }
  38266. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38267. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38268. v := m.organization_id
  38269. if v == nil {
  38270. return
  38271. }
  38272. return *v, true
  38273. }
  38274. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38275. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38277. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38278. if !m.op.Is(OpUpdateOne) {
  38279. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38280. }
  38281. if m.id == nil || m.oldValue == nil {
  38282. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38283. }
  38284. oldValue, err := m.oldValue(ctx)
  38285. if err != nil {
  38286. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38287. }
  38288. return oldValue.OrganizationID, nil
  38289. }
  38290. // AddOrganizationID adds u to the "organization_id" field.
  38291. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38292. if m.addorganization_id != nil {
  38293. *m.addorganization_id += u
  38294. } else {
  38295. m.addorganization_id = &u
  38296. }
  38297. }
  38298. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38299. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38300. v := m.addorganization_id
  38301. if v == nil {
  38302. return
  38303. }
  38304. return *v, true
  38305. }
  38306. // ClearOrganizationID clears the value of the "organization_id" field.
  38307. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38308. m.organization_id = nil
  38309. m.addorganization_id = nil
  38310. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38311. }
  38312. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38313. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38314. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38315. return ok
  38316. }
  38317. // ResetOrganizationID resets all changes to the "organization_id" field.
  38318. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38319. m.organization_id = nil
  38320. m.addorganization_id = nil
  38321. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38322. }
  38323. // SetVerifyAccount sets the "verify_account" field.
  38324. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38325. m.verify_account = &s
  38326. }
  38327. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38328. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38329. v := m.verify_account
  38330. if v == nil {
  38331. return
  38332. }
  38333. return *v, true
  38334. }
  38335. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38336. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38338. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38339. if !m.op.Is(OpUpdateOne) {
  38340. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38341. }
  38342. if m.id == nil || m.oldValue == nil {
  38343. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38344. }
  38345. oldValue, err := m.oldValue(ctx)
  38346. if err != nil {
  38347. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38348. }
  38349. return oldValue.VerifyAccount, nil
  38350. }
  38351. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38352. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38353. m.verify_account = nil
  38354. }
  38355. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38356. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38357. m.predicates = append(m.predicates, ps...)
  38358. }
  38359. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38360. // users can use type-assertion to append predicates that do not depend on any generated package.
  38361. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38362. p := make([]predicate.WhatsappChannel, len(ps))
  38363. for i := range ps {
  38364. p[i] = ps[i]
  38365. }
  38366. m.Where(p...)
  38367. }
  38368. // Op returns the operation name.
  38369. func (m *WhatsappChannelMutation) Op() Op {
  38370. return m.op
  38371. }
  38372. // SetOp allows setting the mutation operation.
  38373. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38374. m.op = op
  38375. }
  38376. // Type returns the node type of this mutation (WhatsappChannel).
  38377. func (m *WhatsappChannelMutation) Type() string {
  38378. return m.typ
  38379. }
  38380. // Fields returns all fields that were changed during this mutation. Note that in
  38381. // order to get all numeric fields that were incremented/decremented, call
  38382. // AddedFields().
  38383. func (m *WhatsappChannelMutation) Fields() []string {
  38384. fields := make([]string, 0, 12)
  38385. if m.created_at != nil {
  38386. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38387. }
  38388. if m.updated_at != nil {
  38389. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38390. }
  38391. if m.status != nil {
  38392. fields = append(fields, whatsappchannel.FieldStatus)
  38393. }
  38394. if m.deleted_at != nil {
  38395. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38396. }
  38397. if m.ak != nil {
  38398. fields = append(fields, whatsappchannel.FieldAk)
  38399. }
  38400. if m.sk != nil {
  38401. fields = append(fields, whatsappchannel.FieldSk)
  38402. }
  38403. if m.wa_id != nil {
  38404. fields = append(fields, whatsappchannel.FieldWaID)
  38405. }
  38406. if m.wa_name != nil {
  38407. fields = append(fields, whatsappchannel.FieldWaName)
  38408. }
  38409. if m.waba_id != nil {
  38410. fields = append(fields, whatsappchannel.FieldWabaID)
  38411. }
  38412. if m.business_id != nil {
  38413. fields = append(fields, whatsappchannel.FieldBusinessID)
  38414. }
  38415. if m.organization_id != nil {
  38416. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38417. }
  38418. if m.verify_account != nil {
  38419. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38420. }
  38421. return fields
  38422. }
  38423. // Field returns the value of a field with the given name. The second boolean
  38424. // return value indicates that this field was not set, or was not defined in the
  38425. // schema.
  38426. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38427. switch name {
  38428. case whatsappchannel.FieldCreatedAt:
  38429. return m.CreatedAt()
  38430. case whatsappchannel.FieldUpdatedAt:
  38431. return m.UpdatedAt()
  38432. case whatsappchannel.FieldStatus:
  38433. return m.Status()
  38434. case whatsappchannel.FieldDeletedAt:
  38435. return m.DeletedAt()
  38436. case whatsappchannel.FieldAk:
  38437. return m.Ak()
  38438. case whatsappchannel.FieldSk:
  38439. return m.Sk()
  38440. case whatsappchannel.FieldWaID:
  38441. return m.WaID()
  38442. case whatsappchannel.FieldWaName:
  38443. return m.WaName()
  38444. case whatsappchannel.FieldWabaID:
  38445. return m.WabaID()
  38446. case whatsappchannel.FieldBusinessID:
  38447. return m.BusinessID()
  38448. case whatsappchannel.FieldOrganizationID:
  38449. return m.OrganizationID()
  38450. case whatsappchannel.FieldVerifyAccount:
  38451. return m.VerifyAccount()
  38452. }
  38453. return nil, false
  38454. }
  38455. // OldField returns the old value of the field from the database. An error is
  38456. // returned if the mutation operation is not UpdateOne, or the query to the
  38457. // database failed.
  38458. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38459. switch name {
  38460. case whatsappchannel.FieldCreatedAt:
  38461. return m.OldCreatedAt(ctx)
  38462. case whatsappchannel.FieldUpdatedAt:
  38463. return m.OldUpdatedAt(ctx)
  38464. case whatsappchannel.FieldStatus:
  38465. return m.OldStatus(ctx)
  38466. case whatsappchannel.FieldDeletedAt:
  38467. return m.OldDeletedAt(ctx)
  38468. case whatsappchannel.FieldAk:
  38469. return m.OldAk(ctx)
  38470. case whatsappchannel.FieldSk:
  38471. return m.OldSk(ctx)
  38472. case whatsappchannel.FieldWaID:
  38473. return m.OldWaID(ctx)
  38474. case whatsappchannel.FieldWaName:
  38475. return m.OldWaName(ctx)
  38476. case whatsappchannel.FieldWabaID:
  38477. return m.OldWabaID(ctx)
  38478. case whatsappchannel.FieldBusinessID:
  38479. return m.OldBusinessID(ctx)
  38480. case whatsappchannel.FieldOrganizationID:
  38481. return m.OldOrganizationID(ctx)
  38482. case whatsappchannel.FieldVerifyAccount:
  38483. return m.OldVerifyAccount(ctx)
  38484. }
  38485. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38486. }
  38487. // SetField sets the value of a field with the given name. It returns an error if
  38488. // the field is not defined in the schema, or if the type mismatched the field
  38489. // type.
  38490. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38491. switch name {
  38492. case whatsappchannel.FieldCreatedAt:
  38493. v, ok := value.(time.Time)
  38494. if !ok {
  38495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38496. }
  38497. m.SetCreatedAt(v)
  38498. return nil
  38499. case whatsappchannel.FieldUpdatedAt:
  38500. v, ok := value.(time.Time)
  38501. if !ok {
  38502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38503. }
  38504. m.SetUpdatedAt(v)
  38505. return nil
  38506. case whatsappchannel.FieldStatus:
  38507. v, ok := value.(uint8)
  38508. if !ok {
  38509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38510. }
  38511. m.SetStatus(v)
  38512. return nil
  38513. case whatsappchannel.FieldDeletedAt:
  38514. v, ok := value.(time.Time)
  38515. if !ok {
  38516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38517. }
  38518. m.SetDeletedAt(v)
  38519. return nil
  38520. case whatsappchannel.FieldAk:
  38521. v, ok := value.(string)
  38522. if !ok {
  38523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38524. }
  38525. m.SetAk(v)
  38526. return nil
  38527. case whatsappchannel.FieldSk:
  38528. v, ok := value.(string)
  38529. if !ok {
  38530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38531. }
  38532. m.SetSk(v)
  38533. return nil
  38534. case whatsappchannel.FieldWaID:
  38535. v, ok := value.(string)
  38536. if !ok {
  38537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38538. }
  38539. m.SetWaID(v)
  38540. return nil
  38541. case whatsappchannel.FieldWaName:
  38542. v, ok := value.(string)
  38543. if !ok {
  38544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38545. }
  38546. m.SetWaName(v)
  38547. return nil
  38548. case whatsappchannel.FieldWabaID:
  38549. v, ok := value.(uint64)
  38550. if !ok {
  38551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38552. }
  38553. m.SetWabaID(v)
  38554. return nil
  38555. case whatsappchannel.FieldBusinessID:
  38556. v, ok := value.(uint64)
  38557. if !ok {
  38558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38559. }
  38560. m.SetBusinessID(v)
  38561. return nil
  38562. case whatsappchannel.FieldOrganizationID:
  38563. v, ok := value.(uint64)
  38564. if !ok {
  38565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38566. }
  38567. m.SetOrganizationID(v)
  38568. return nil
  38569. case whatsappchannel.FieldVerifyAccount:
  38570. v, ok := value.(string)
  38571. if !ok {
  38572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38573. }
  38574. m.SetVerifyAccount(v)
  38575. return nil
  38576. }
  38577. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38578. }
  38579. // AddedFields returns all numeric fields that were incremented/decremented during
  38580. // this mutation.
  38581. func (m *WhatsappChannelMutation) AddedFields() []string {
  38582. var fields []string
  38583. if m.addstatus != nil {
  38584. fields = append(fields, whatsappchannel.FieldStatus)
  38585. }
  38586. if m.addwaba_id != nil {
  38587. fields = append(fields, whatsappchannel.FieldWabaID)
  38588. }
  38589. if m.addbusiness_id != nil {
  38590. fields = append(fields, whatsappchannel.FieldBusinessID)
  38591. }
  38592. if m.addorganization_id != nil {
  38593. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38594. }
  38595. return fields
  38596. }
  38597. // AddedField returns the numeric value that was incremented/decremented on a field
  38598. // with the given name. The second boolean return value indicates that this field
  38599. // was not set, or was not defined in the schema.
  38600. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38601. switch name {
  38602. case whatsappchannel.FieldStatus:
  38603. return m.AddedStatus()
  38604. case whatsappchannel.FieldWabaID:
  38605. return m.AddedWabaID()
  38606. case whatsappchannel.FieldBusinessID:
  38607. return m.AddedBusinessID()
  38608. case whatsappchannel.FieldOrganizationID:
  38609. return m.AddedOrganizationID()
  38610. }
  38611. return nil, false
  38612. }
  38613. // AddField adds the value to the field with the given name. It returns an error if
  38614. // the field is not defined in the schema, or if the type mismatched the field
  38615. // type.
  38616. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38617. switch name {
  38618. case whatsappchannel.FieldStatus:
  38619. v, ok := value.(int8)
  38620. if !ok {
  38621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38622. }
  38623. m.AddStatus(v)
  38624. return nil
  38625. case whatsappchannel.FieldWabaID:
  38626. v, ok := value.(int64)
  38627. if !ok {
  38628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38629. }
  38630. m.AddWabaID(v)
  38631. return nil
  38632. case whatsappchannel.FieldBusinessID:
  38633. v, ok := value.(int64)
  38634. if !ok {
  38635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38636. }
  38637. m.AddBusinessID(v)
  38638. return nil
  38639. case whatsappchannel.FieldOrganizationID:
  38640. v, ok := value.(int64)
  38641. if !ok {
  38642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38643. }
  38644. m.AddOrganizationID(v)
  38645. return nil
  38646. }
  38647. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  38648. }
  38649. // ClearedFields returns all nullable fields that were cleared during this
  38650. // mutation.
  38651. func (m *WhatsappChannelMutation) ClearedFields() []string {
  38652. var fields []string
  38653. if m.FieldCleared(whatsappchannel.FieldStatus) {
  38654. fields = append(fields, whatsappchannel.FieldStatus)
  38655. }
  38656. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  38657. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38658. }
  38659. if m.FieldCleared(whatsappchannel.FieldAk) {
  38660. fields = append(fields, whatsappchannel.FieldAk)
  38661. }
  38662. if m.FieldCleared(whatsappchannel.FieldWaID) {
  38663. fields = append(fields, whatsappchannel.FieldWaID)
  38664. }
  38665. if m.FieldCleared(whatsappchannel.FieldWaName) {
  38666. fields = append(fields, whatsappchannel.FieldWaName)
  38667. }
  38668. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  38669. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38670. }
  38671. return fields
  38672. }
  38673. // FieldCleared returns a boolean indicating if a field with the given name was
  38674. // cleared in this mutation.
  38675. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  38676. _, ok := m.clearedFields[name]
  38677. return ok
  38678. }
  38679. // ClearField clears the value of the field with the given name. It returns an
  38680. // error if the field is not defined in the schema.
  38681. func (m *WhatsappChannelMutation) ClearField(name string) error {
  38682. switch name {
  38683. case whatsappchannel.FieldStatus:
  38684. m.ClearStatus()
  38685. return nil
  38686. case whatsappchannel.FieldDeletedAt:
  38687. m.ClearDeletedAt()
  38688. return nil
  38689. case whatsappchannel.FieldAk:
  38690. m.ClearAk()
  38691. return nil
  38692. case whatsappchannel.FieldWaID:
  38693. m.ClearWaID()
  38694. return nil
  38695. case whatsappchannel.FieldWaName:
  38696. m.ClearWaName()
  38697. return nil
  38698. case whatsappchannel.FieldOrganizationID:
  38699. m.ClearOrganizationID()
  38700. return nil
  38701. }
  38702. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  38703. }
  38704. // ResetField resets all changes in the mutation for the field with the given name.
  38705. // It returns an error if the field is not defined in the schema.
  38706. func (m *WhatsappChannelMutation) ResetField(name string) error {
  38707. switch name {
  38708. case whatsappchannel.FieldCreatedAt:
  38709. m.ResetCreatedAt()
  38710. return nil
  38711. case whatsappchannel.FieldUpdatedAt:
  38712. m.ResetUpdatedAt()
  38713. return nil
  38714. case whatsappchannel.FieldStatus:
  38715. m.ResetStatus()
  38716. return nil
  38717. case whatsappchannel.FieldDeletedAt:
  38718. m.ResetDeletedAt()
  38719. return nil
  38720. case whatsappchannel.FieldAk:
  38721. m.ResetAk()
  38722. return nil
  38723. case whatsappchannel.FieldSk:
  38724. m.ResetSk()
  38725. return nil
  38726. case whatsappchannel.FieldWaID:
  38727. m.ResetWaID()
  38728. return nil
  38729. case whatsappchannel.FieldWaName:
  38730. m.ResetWaName()
  38731. return nil
  38732. case whatsappchannel.FieldWabaID:
  38733. m.ResetWabaID()
  38734. return nil
  38735. case whatsappchannel.FieldBusinessID:
  38736. m.ResetBusinessID()
  38737. return nil
  38738. case whatsappchannel.FieldOrganizationID:
  38739. m.ResetOrganizationID()
  38740. return nil
  38741. case whatsappchannel.FieldVerifyAccount:
  38742. m.ResetVerifyAccount()
  38743. return nil
  38744. }
  38745. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38746. }
  38747. // AddedEdges returns all edge names that were set/added in this mutation.
  38748. func (m *WhatsappChannelMutation) AddedEdges() []string {
  38749. edges := make([]string, 0, 0)
  38750. return edges
  38751. }
  38752. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38753. // name in this mutation.
  38754. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  38755. return nil
  38756. }
  38757. // RemovedEdges returns all edge names that were removed in this mutation.
  38758. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  38759. edges := make([]string, 0, 0)
  38760. return edges
  38761. }
  38762. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38763. // the given name in this mutation.
  38764. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  38765. return nil
  38766. }
  38767. // ClearedEdges returns all edge names that were cleared in this mutation.
  38768. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  38769. edges := make([]string, 0, 0)
  38770. return edges
  38771. }
  38772. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38773. // was cleared in this mutation.
  38774. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  38775. return false
  38776. }
  38777. // ClearEdge clears the value of the edge with the given name. It returns an error
  38778. // if that edge is not defined in the schema.
  38779. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  38780. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  38781. }
  38782. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38783. // It returns an error if the edge is not defined in the schema.
  38784. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  38785. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  38786. }
  38787. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  38788. type WorkExperienceMutation struct {
  38789. config
  38790. op Op
  38791. typ string
  38792. id *uint64
  38793. created_at *time.Time
  38794. updated_at *time.Time
  38795. deleted_at *time.Time
  38796. start_date *time.Time
  38797. end_date *time.Time
  38798. company *string
  38799. experience *string
  38800. organization_id *uint64
  38801. addorganization_id *int64
  38802. clearedFields map[string]struct{}
  38803. employee *uint64
  38804. clearedemployee bool
  38805. done bool
  38806. oldValue func(context.Context) (*WorkExperience, error)
  38807. predicates []predicate.WorkExperience
  38808. }
  38809. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  38810. // workexperienceOption allows management of the mutation configuration using functional options.
  38811. type workexperienceOption func(*WorkExperienceMutation)
  38812. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  38813. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  38814. m := &WorkExperienceMutation{
  38815. config: c,
  38816. op: op,
  38817. typ: TypeWorkExperience,
  38818. clearedFields: make(map[string]struct{}),
  38819. }
  38820. for _, opt := range opts {
  38821. opt(m)
  38822. }
  38823. return m
  38824. }
  38825. // withWorkExperienceID sets the ID field of the mutation.
  38826. func withWorkExperienceID(id uint64) workexperienceOption {
  38827. return func(m *WorkExperienceMutation) {
  38828. var (
  38829. err error
  38830. once sync.Once
  38831. value *WorkExperience
  38832. )
  38833. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  38834. once.Do(func() {
  38835. if m.done {
  38836. err = errors.New("querying old values post mutation is not allowed")
  38837. } else {
  38838. value, err = m.Client().WorkExperience.Get(ctx, id)
  38839. }
  38840. })
  38841. return value, err
  38842. }
  38843. m.id = &id
  38844. }
  38845. }
  38846. // withWorkExperience sets the old WorkExperience of the mutation.
  38847. func withWorkExperience(node *WorkExperience) workexperienceOption {
  38848. return func(m *WorkExperienceMutation) {
  38849. m.oldValue = func(context.Context) (*WorkExperience, error) {
  38850. return node, nil
  38851. }
  38852. m.id = &node.ID
  38853. }
  38854. }
  38855. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38856. // executed in a transaction (ent.Tx), a transactional client is returned.
  38857. func (m WorkExperienceMutation) Client() *Client {
  38858. client := &Client{config: m.config}
  38859. client.init()
  38860. return client
  38861. }
  38862. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38863. // it returns an error otherwise.
  38864. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  38865. if _, ok := m.driver.(*txDriver); !ok {
  38866. return nil, errors.New("ent: mutation is not running in a transaction")
  38867. }
  38868. tx := &Tx{config: m.config}
  38869. tx.init()
  38870. return tx, nil
  38871. }
  38872. // SetID sets the value of the id field. Note that this
  38873. // operation is only accepted on creation of WorkExperience entities.
  38874. func (m *WorkExperienceMutation) SetID(id uint64) {
  38875. m.id = &id
  38876. }
  38877. // ID returns the ID value in the mutation. Note that the ID is only available
  38878. // if it was provided to the builder or after it was returned from the database.
  38879. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  38880. if m.id == nil {
  38881. return
  38882. }
  38883. return *m.id, true
  38884. }
  38885. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38886. // That means, if the mutation is applied within a transaction with an isolation level such
  38887. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38888. // or updated by the mutation.
  38889. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  38890. switch {
  38891. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38892. id, exists := m.ID()
  38893. if exists {
  38894. return []uint64{id}, nil
  38895. }
  38896. fallthrough
  38897. case m.op.Is(OpUpdate | OpDelete):
  38898. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  38899. default:
  38900. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38901. }
  38902. }
  38903. // SetCreatedAt sets the "created_at" field.
  38904. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  38905. m.created_at = &t
  38906. }
  38907. // CreatedAt returns the value of the "created_at" field in the mutation.
  38908. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  38909. v := m.created_at
  38910. if v == nil {
  38911. return
  38912. }
  38913. return *v, true
  38914. }
  38915. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  38916. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38918. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38919. if !m.op.Is(OpUpdateOne) {
  38920. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38921. }
  38922. if m.id == nil || m.oldValue == nil {
  38923. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38924. }
  38925. oldValue, err := m.oldValue(ctx)
  38926. if err != nil {
  38927. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38928. }
  38929. return oldValue.CreatedAt, nil
  38930. }
  38931. // ResetCreatedAt resets all changes to the "created_at" field.
  38932. func (m *WorkExperienceMutation) ResetCreatedAt() {
  38933. m.created_at = nil
  38934. }
  38935. // SetUpdatedAt sets the "updated_at" field.
  38936. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  38937. m.updated_at = &t
  38938. }
  38939. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38940. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  38941. v := m.updated_at
  38942. if v == nil {
  38943. return
  38944. }
  38945. return *v, true
  38946. }
  38947. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  38948. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38950. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38951. if !m.op.Is(OpUpdateOne) {
  38952. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38953. }
  38954. if m.id == nil || m.oldValue == nil {
  38955. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38956. }
  38957. oldValue, err := m.oldValue(ctx)
  38958. if err != nil {
  38959. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38960. }
  38961. return oldValue.UpdatedAt, nil
  38962. }
  38963. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38964. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  38965. m.updated_at = nil
  38966. }
  38967. // SetDeletedAt sets the "deleted_at" field.
  38968. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  38969. m.deleted_at = &t
  38970. }
  38971. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38972. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  38973. v := m.deleted_at
  38974. if v == nil {
  38975. return
  38976. }
  38977. return *v, true
  38978. }
  38979. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  38980. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38982. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38983. if !m.op.Is(OpUpdateOne) {
  38984. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38985. }
  38986. if m.id == nil || m.oldValue == nil {
  38987. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38988. }
  38989. oldValue, err := m.oldValue(ctx)
  38990. if err != nil {
  38991. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38992. }
  38993. return oldValue.DeletedAt, nil
  38994. }
  38995. // ClearDeletedAt clears the value of the "deleted_at" field.
  38996. func (m *WorkExperienceMutation) ClearDeletedAt() {
  38997. m.deleted_at = nil
  38998. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  38999. }
  39000. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39001. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  39002. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  39003. return ok
  39004. }
  39005. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39006. func (m *WorkExperienceMutation) ResetDeletedAt() {
  39007. m.deleted_at = nil
  39008. delete(m.clearedFields, workexperience.FieldDeletedAt)
  39009. }
  39010. // SetEmployeeID sets the "employee_id" field.
  39011. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  39012. m.employee = &u
  39013. }
  39014. // EmployeeID returns the value of the "employee_id" field in the mutation.
  39015. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  39016. v := m.employee
  39017. if v == nil {
  39018. return
  39019. }
  39020. return *v, true
  39021. }
  39022. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  39023. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39025. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  39026. if !m.op.Is(OpUpdateOne) {
  39027. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  39028. }
  39029. if m.id == nil || m.oldValue == nil {
  39030. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  39031. }
  39032. oldValue, err := m.oldValue(ctx)
  39033. if err != nil {
  39034. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  39035. }
  39036. return oldValue.EmployeeID, nil
  39037. }
  39038. // ResetEmployeeID resets all changes to the "employee_id" field.
  39039. func (m *WorkExperienceMutation) ResetEmployeeID() {
  39040. m.employee = nil
  39041. }
  39042. // SetStartDate sets the "start_date" field.
  39043. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  39044. m.start_date = &t
  39045. }
  39046. // StartDate returns the value of the "start_date" field in the mutation.
  39047. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  39048. v := m.start_date
  39049. if v == nil {
  39050. return
  39051. }
  39052. return *v, true
  39053. }
  39054. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  39055. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39057. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  39058. if !m.op.Is(OpUpdateOne) {
  39059. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  39060. }
  39061. if m.id == nil || m.oldValue == nil {
  39062. return v, errors.New("OldStartDate requires an ID field in the mutation")
  39063. }
  39064. oldValue, err := m.oldValue(ctx)
  39065. if err != nil {
  39066. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  39067. }
  39068. return oldValue.StartDate, nil
  39069. }
  39070. // ResetStartDate resets all changes to the "start_date" field.
  39071. func (m *WorkExperienceMutation) ResetStartDate() {
  39072. m.start_date = nil
  39073. }
  39074. // SetEndDate sets the "end_date" field.
  39075. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  39076. m.end_date = &t
  39077. }
  39078. // EndDate returns the value of the "end_date" field in the mutation.
  39079. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39080. v := m.end_date
  39081. if v == nil {
  39082. return
  39083. }
  39084. return *v, true
  39085. }
  39086. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39087. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39089. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39090. if !m.op.Is(OpUpdateOne) {
  39091. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39092. }
  39093. if m.id == nil || m.oldValue == nil {
  39094. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39095. }
  39096. oldValue, err := m.oldValue(ctx)
  39097. if err != nil {
  39098. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39099. }
  39100. return oldValue.EndDate, nil
  39101. }
  39102. // ResetEndDate resets all changes to the "end_date" field.
  39103. func (m *WorkExperienceMutation) ResetEndDate() {
  39104. m.end_date = nil
  39105. }
  39106. // SetCompany sets the "company" field.
  39107. func (m *WorkExperienceMutation) SetCompany(s string) {
  39108. m.company = &s
  39109. }
  39110. // Company returns the value of the "company" field in the mutation.
  39111. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39112. v := m.company
  39113. if v == nil {
  39114. return
  39115. }
  39116. return *v, true
  39117. }
  39118. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39119. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39121. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39122. if !m.op.Is(OpUpdateOne) {
  39123. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39124. }
  39125. if m.id == nil || m.oldValue == nil {
  39126. return v, errors.New("OldCompany requires an ID field in the mutation")
  39127. }
  39128. oldValue, err := m.oldValue(ctx)
  39129. if err != nil {
  39130. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39131. }
  39132. return oldValue.Company, nil
  39133. }
  39134. // ResetCompany resets all changes to the "company" field.
  39135. func (m *WorkExperienceMutation) ResetCompany() {
  39136. m.company = nil
  39137. }
  39138. // SetExperience sets the "experience" field.
  39139. func (m *WorkExperienceMutation) SetExperience(s string) {
  39140. m.experience = &s
  39141. }
  39142. // Experience returns the value of the "experience" field in the mutation.
  39143. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39144. v := m.experience
  39145. if v == nil {
  39146. return
  39147. }
  39148. return *v, true
  39149. }
  39150. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39151. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39153. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39154. if !m.op.Is(OpUpdateOne) {
  39155. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39156. }
  39157. if m.id == nil || m.oldValue == nil {
  39158. return v, errors.New("OldExperience requires an ID field in the mutation")
  39159. }
  39160. oldValue, err := m.oldValue(ctx)
  39161. if err != nil {
  39162. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39163. }
  39164. return oldValue.Experience, nil
  39165. }
  39166. // ResetExperience resets all changes to the "experience" field.
  39167. func (m *WorkExperienceMutation) ResetExperience() {
  39168. m.experience = nil
  39169. }
  39170. // SetOrganizationID sets the "organization_id" field.
  39171. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39172. m.organization_id = &u
  39173. m.addorganization_id = nil
  39174. }
  39175. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39176. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39177. v := m.organization_id
  39178. if v == nil {
  39179. return
  39180. }
  39181. return *v, true
  39182. }
  39183. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39184. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39186. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39187. if !m.op.Is(OpUpdateOne) {
  39188. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39189. }
  39190. if m.id == nil || m.oldValue == nil {
  39191. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39192. }
  39193. oldValue, err := m.oldValue(ctx)
  39194. if err != nil {
  39195. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39196. }
  39197. return oldValue.OrganizationID, nil
  39198. }
  39199. // AddOrganizationID adds u to the "organization_id" field.
  39200. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39201. if m.addorganization_id != nil {
  39202. *m.addorganization_id += u
  39203. } else {
  39204. m.addorganization_id = &u
  39205. }
  39206. }
  39207. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39208. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39209. v := m.addorganization_id
  39210. if v == nil {
  39211. return
  39212. }
  39213. return *v, true
  39214. }
  39215. // ResetOrganizationID resets all changes to the "organization_id" field.
  39216. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39217. m.organization_id = nil
  39218. m.addorganization_id = nil
  39219. }
  39220. // ClearEmployee clears the "employee" edge to the Employee entity.
  39221. func (m *WorkExperienceMutation) ClearEmployee() {
  39222. m.clearedemployee = true
  39223. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39224. }
  39225. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39226. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39227. return m.clearedemployee
  39228. }
  39229. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39230. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39231. // EmployeeID instead. It exists only for internal usage by the builders.
  39232. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39233. if id := m.employee; id != nil {
  39234. ids = append(ids, *id)
  39235. }
  39236. return
  39237. }
  39238. // ResetEmployee resets all changes to the "employee" edge.
  39239. func (m *WorkExperienceMutation) ResetEmployee() {
  39240. m.employee = nil
  39241. m.clearedemployee = false
  39242. }
  39243. // Where appends a list predicates to the WorkExperienceMutation builder.
  39244. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39245. m.predicates = append(m.predicates, ps...)
  39246. }
  39247. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39248. // users can use type-assertion to append predicates that do not depend on any generated package.
  39249. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39250. p := make([]predicate.WorkExperience, len(ps))
  39251. for i := range ps {
  39252. p[i] = ps[i]
  39253. }
  39254. m.Where(p...)
  39255. }
  39256. // Op returns the operation name.
  39257. func (m *WorkExperienceMutation) Op() Op {
  39258. return m.op
  39259. }
  39260. // SetOp allows setting the mutation operation.
  39261. func (m *WorkExperienceMutation) SetOp(op Op) {
  39262. m.op = op
  39263. }
  39264. // Type returns the node type of this mutation (WorkExperience).
  39265. func (m *WorkExperienceMutation) Type() string {
  39266. return m.typ
  39267. }
  39268. // Fields returns all fields that were changed during this mutation. Note that in
  39269. // order to get all numeric fields that were incremented/decremented, call
  39270. // AddedFields().
  39271. func (m *WorkExperienceMutation) Fields() []string {
  39272. fields := make([]string, 0, 9)
  39273. if m.created_at != nil {
  39274. fields = append(fields, workexperience.FieldCreatedAt)
  39275. }
  39276. if m.updated_at != nil {
  39277. fields = append(fields, workexperience.FieldUpdatedAt)
  39278. }
  39279. if m.deleted_at != nil {
  39280. fields = append(fields, workexperience.FieldDeletedAt)
  39281. }
  39282. if m.employee != nil {
  39283. fields = append(fields, workexperience.FieldEmployeeID)
  39284. }
  39285. if m.start_date != nil {
  39286. fields = append(fields, workexperience.FieldStartDate)
  39287. }
  39288. if m.end_date != nil {
  39289. fields = append(fields, workexperience.FieldEndDate)
  39290. }
  39291. if m.company != nil {
  39292. fields = append(fields, workexperience.FieldCompany)
  39293. }
  39294. if m.experience != nil {
  39295. fields = append(fields, workexperience.FieldExperience)
  39296. }
  39297. if m.organization_id != nil {
  39298. fields = append(fields, workexperience.FieldOrganizationID)
  39299. }
  39300. return fields
  39301. }
  39302. // Field returns the value of a field with the given name. The second boolean
  39303. // return value indicates that this field was not set, or was not defined in the
  39304. // schema.
  39305. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39306. switch name {
  39307. case workexperience.FieldCreatedAt:
  39308. return m.CreatedAt()
  39309. case workexperience.FieldUpdatedAt:
  39310. return m.UpdatedAt()
  39311. case workexperience.FieldDeletedAt:
  39312. return m.DeletedAt()
  39313. case workexperience.FieldEmployeeID:
  39314. return m.EmployeeID()
  39315. case workexperience.FieldStartDate:
  39316. return m.StartDate()
  39317. case workexperience.FieldEndDate:
  39318. return m.EndDate()
  39319. case workexperience.FieldCompany:
  39320. return m.Company()
  39321. case workexperience.FieldExperience:
  39322. return m.Experience()
  39323. case workexperience.FieldOrganizationID:
  39324. return m.OrganizationID()
  39325. }
  39326. return nil, false
  39327. }
  39328. // OldField returns the old value of the field from the database. An error is
  39329. // returned if the mutation operation is not UpdateOne, or the query to the
  39330. // database failed.
  39331. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39332. switch name {
  39333. case workexperience.FieldCreatedAt:
  39334. return m.OldCreatedAt(ctx)
  39335. case workexperience.FieldUpdatedAt:
  39336. return m.OldUpdatedAt(ctx)
  39337. case workexperience.FieldDeletedAt:
  39338. return m.OldDeletedAt(ctx)
  39339. case workexperience.FieldEmployeeID:
  39340. return m.OldEmployeeID(ctx)
  39341. case workexperience.FieldStartDate:
  39342. return m.OldStartDate(ctx)
  39343. case workexperience.FieldEndDate:
  39344. return m.OldEndDate(ctx)
  39345. case workexperience.FieldCompany:
  39346. return m.OldCompany(ctx)
  39347. case workexperience.FieldExperience:
  39348. return m.OldExperience(ctx)
  39349. case workexperience.FieldOrganizationID:
  39350. return m.OldOrganizationID(ctx)
  39351. }
  39352. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39353. }
  39354. // SetField sets the value of a field with the given name. It returns an error if
  39355. // the field is not defined in the schema, or if the type mismatched the field
  39356. // type.
  39357. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39358. switch name {
  39359. case workexperience.FieldCreatedAt:
  39360. v, ok := value.(time.Time)
  39361. if !ok {
  39362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39363. }
  39364. m.SetCreatedAt(v)
  39365. return nil
  39366. case workexperience.FieldUpdatedAt:
  39367. v, ok := value.(time.Time)
  39368. if !ok {
  39369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39370. }
  39371. m.SetUpdatedAt(v)
  39372. return nil
  39373. case workexperience.FieldDeletedAt:
  39374. v, ok := value.(time.Time)
  39375. if !ok {
  39376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39377. }
  39378. m.SetDeletedAt(v)
  39379. return nil
  39380. case workexperience.FieldEmployeeID:
  39381. v, ok := value.(uint64)
  39382. if !ok {
  39383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39384. }
  39385. m.SetEmployeeID(v)
  39386. return nil
  39387. case workexperience.FieldStartDate:
  39388. v, ok := value.(time.Time)
  39389. if !ok {
  39390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39391. }
  39392. m.SetStartDate(v)
  39393. return nil
  39394. case workexperience.FieldEndDate:
  39395. v, ok := value.(time.Time)
  39396. if !ok {
  39397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39398. }
  39399. m.SetEndDate(v)
  39400. return nil
  39401. case workexperience.FieldCompany:
  39402. v, ok := value.(string)
  39403. if !ok {
  39404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39405. }
  39406. m.SetCompany(v)
  39407. return nil
  39408. case workexperience.FieldExperience:
  39409. v, ok := value.(string)
  39410. if !ok {
  39411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39412. }
  39413. m.SetExperience(v)
  39414. return nil
  39415. case workexperience.FieldOrganizationID:
  39416. v, ok := value.(uint64)
  39417. if !ok {
  39418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39419. }
  39420. m.SetOrganizationID(v)
  39421. return nil
  39422. }
  39423. return fmt.Errorf("unknown WorkExperience field %s", name)
  39424. }
  39425. // AddedFields returns all numeric fields that were incremented/decremented during
  39426. // this mutation.
  39427. func (m *WorkExperienceMutation) AddedFields() []string {
  39428. var fields []string
  39429. if m.addorganization_id != nil {
  39430. fields = append(fields, workexperience.FieldOrganizationID)
  39431. }
  39432. return fields
  39433. }
  39434. // AddedField returns the numeric value that was incremented/decremented on a field
  39435. // with the given name. The second boolean return value indicates that this field
  39436. // was not set, or was not defined in the schema.
  39437. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39438. switch name {
  39439. case workexperience.FieldOrganizationID:
  39440. return m.AddedOrganizationID()
  39441. }
  39442. return nil, false
  39443. }
  39444. // AddField adds the value to the field with the given name. It returns an error if
  39445. // the field is not defined in the schema, or if the type mismatched the field
  39446. // type.
  39447. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39448. switch name {
  39449. case workexperience.FieldOrganizationID:
  39450. v, ok := value.(int64)
  39451. if !ok {
  39452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39453. }
  39454. m.AddOrganizationID(v)
  39455. return nil
  39456. }
  39457. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39458. }
  39459. // ClearedFields returns all nullable fields that were cleared during this
  39460. // mutation.
  39461. func (m *WorkExperienceMutation) ClearedFields() []string {
  39462. var fields []string
  39463. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39464. fields = append(fields, workexperience.FieldDeletedAt)
  39465. }
  39466. return fields
  39467. }
  39468. // FieldCleared returns a boolean indicating if a field with the given name was
  39469. // cleared in this mutation.
  39470. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39471. _, ok := m.clearedFields[name]
  39472. return ok
  39473. }
  39474. // ClearField clears the value of the field with the given name. It returns an
  39475. // error if the field is not defined in the schema.
  39476. func (m *WorkExperienceMutation) ClearField(name string) error {
  39477. switch name {
  39478. case workexperience.FieldDeletedAt:
  39479. m.ClearDeletedAt()
  39480. return nil
  39481. }
  39482. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39483. }
  39484. // ResetField resets all changes in the mutation for the field with the given name.
  39485. // It returns an error if the field is not defined in the schema.
  39486. func (m *WorkExperienceMutation) ResetField(name string) error {
  39487. switch name {
  39488. case workexperience.FieldCreatedAt:
  39489. m.ResetCreatedAt()
  39490. return nil
  39491. case workexperience.FieldUpdatedAt:
  39492. m.ResetUpdatedAt()
  39493. return nil
  39494. case workexperience.FieldDeletedAt:
  39495. m.ResetDeletedAt()
  39496. return nil
  39497. case workexperience.FieldEmployeeID:
  39498. m.ResetEmployeeID()
  39499. return nil
  39500. case workexperience.FieldStartDate:
  39501. m.ResetStartDate()
  39502. return nil
  39503. case workexperience.FieldEndDate:
  39504. m.ResetEndDate()
  39505. return nil
  39506. case workexperience.FieldCompany:
  39507. m.ResetCompany()
  39508. return nil
  39509. case workexperience.FieldExperience:
  39510. m.ResetExperience()
  39511. return nil
  39512. case workexperience.FieldOrganizationID:
  39513. m.ResetOrganizationID()
  39514. return nil
  39515. }
  39516. return fmt.Errorf("unknown WorkExperience field %s", name)
  39517. }
  39518. // AddedEdges returns all edge names that were set/added in this mutation.
  39519. func (m *WorkExperienceMutation) AddedEdges() []string {
  39520. edges := make([]string, 0, 1)
  39521. if m.employee != nil {
  39522. edges = append(edges, workexperience.EdgeEmployee)
  39523. }
  39524. return edges
  39525. }
  39526. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39527. // name in this mutation.
  39528. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39529. switch name {
  39530. case workexperience.EdgeEmployee:
  39531. if id := m.employee; id != nil {
  39532. return []ent.Value{*id}
  39533. }
  39534. }
  39535. return nil
  39536. }
  39537. // RemovedEdges returns all edge names that were removed in this mutation.
  39538. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39539. edges := make([]string, 0, 1)
  39540. return edges
  39541. }
  39542. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39543. // the given name in this mutation.
  39544. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39545. return nil
  39546. }
  39547. // ClearedEdges returns all edge names that were cleared in this mutation.
  39548. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39549. edges := make([]string, 0, 1)
  39550. if m.clearedemployee {
  39551. edges = append(edges, workexperience.EdgeEmployee)
  39552. }
  39553. return edges
  39554. }
  39555. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39556. // was cleared in this mutation.
  39557. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39558. switch name {
  39559. case workexperience.EdgeEmployee:
  39560. return m.clearedemployee
  39561. }
  39562. return false
  39563. }
  39564. // ClearEdge clears the value of the edge with the given name. It returns an error
  39565. // if that edge is not defined in the schema.
  39566. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39567. switch name {
  39568. case workexperience.EdgeEmployee:
  39569. m.ClearEmployee()
  39570. return nil
  39571. }
  39572. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39573. }
  39574. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39575. // It returns an error if the edge is not defined in the schema.
  39576. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39577. switch name {
  39578. case workexperience.EdgeEmployee:
  39579. m.ResetEmployee()
  39580. return nil
  39581. }
  39582. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39583. }
  39584. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39585. type WpChatroomMutation struct {
  39586. config
  39587. op Op
  39588. typ string
  39589. id *uint64
  39590. created_at *time.Time
  39591. updated_at *time.Time
  39592. status *uint8
  39593. addstatus *int8
  39594. wx_wxid *string
  39595. chatroom_id *string
  39596. nickname *string
  39597. owner *string
  39598. avatar *string
  39599. member_list *[]string
  39600. appendmember_list []string
  39601. clearedFields map[string]struct{}
  39602. done bool
  39603. oldValue func(context.Context) (*WpChatroom, error)
  39604. predicates []predicate.WpChatroom
  39605. }
  39606. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39607. // wpchatroomOption allows management of the mutation configuration using functional options.
  39608. type wpchatroomOption func(*WpChatroomMutation)
  39609. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39610. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39611. m := &WpChatroomMutation{
  39612. config: c,
  39613. op: op,
  39614. typ: TypeWpChatroom,
  39615. clearedFields: make(map[string]struct{}),
  39616. }
  39617. for _, opt := range opts {
  39618. opt(m)
  39619. }
  39620. return m
  39621. }
  39622. // withWpChatroomID sets the ID field of the mutation.
  39623. func withWpChatroomID(id uint64) wpchatroomOption {
  39624. return func(m *WpChatroomMutation) {
  39625. var (
  39626. err error
  39627. once sync.Once
  39628. value *WpChatroom
  39629. )
  39630. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39631. once.Do(func() {
  39632. if m.done {
  39633. err = errors.New("querying old values post mutation is not allowed")
  39634. } else {
  39635. value, err = m.Client().WpChatroom.Get(ctx, id)
  39636. }
  39637. })
  39638. return value, err
  39639. }
  39640. m.id = &id
  39641. }
  39642. }
  39643. // withWpChatroom sets the old WpChatroom of the mutation.
  39644. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  39645. return func(m *WpChatroomMutation) {
  39646. m.oldValue = func(context.Context) (*WpChatroom, error) {
  39647. return node, nil
  39648. }
  39649. m.id = &node.ID
  39650. }
  39651. }
  39652. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39653. // executed in a transaction (ent.Tx), a transactional client is returned.
  39654. func (m WpChatroomMutation) Client() *Client {
  39655. client := &Client{config: m.config}
  39656. client.init()
  39657. return client
  39658. }
  39659. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39660. // it returns an error otherwise.
  39661. func (m WpChatroomMutation) Tx() (*Tx, error) {
  39662. if _, ok := m.driver.(*txDriver); !ok {
  39663. return nil, errors.New("ent: mutation is not running in a transaction")
  39664. }
  39665. tx := &Tx{config: m.config}
  39666. tx.init()
  39667. return tx, nil
  39668. }
  39669. // SetID sets the value of the id field. Note that this
  39670. // operation is only accepted on creation of WpChatroom entities.
  39671. func (m *WpChatroomMutation) SetID(id uint64) {
  39672. m.id = &id
  39673. }
  39674. // ID returns the ID value in the mutation. Note that the ID is only available
  39675. // if it was provided to the builder or after it was returned from the database.
  39676. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  39677. if m.id == nil {
  39678. return
  39679. }
  39680. return *m.id, true
  39681. }
  39682. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39683. // That means, if the mutation is applied within a transaction with an isolation level such
  39684. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39685. // or updated by the mutation.
  39686. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  39687. switch {
  39688. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39689. id, exists := m.ID()
  39690. if exists {
  39691. return []uint64{id}, nil
  39692. }
  39693. fallthrough
  39694. case m.op.Is(OpUpdate | OpDelete):
  39695. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  39696. default:
  39697. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39698. }
  39699. }
  39700. // SetCreatedAt sets the "created_at" field.
  39701. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  39702. m.created_at = &t
  39703. }
  39704. // CreatedAt returns the value of the "created_at" field in the mutation.
  39705. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  39706. v := m.created_at
  39707. if v == nil {
  39708. return
  39709. }
  39710. return *v, true
  39711. }
  39712. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  39713. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39715. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39716. if !m.op.Is(OpUpdateOne) {
  39717. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39718. }
  39719. if m.id == nil || m.oldValue == nil {
  39720. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39721. }
  39722. oldValue, err := m.oldValue(ctx)
  39723. if err != nil {
  39724. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39725. }
  39726. return oldValue.CreatedAt, nil
  39727. }
  39728. // ResetCreatedAt resets all changes to the "created_at" field.
  39729. func (m *WpChatroomMutation) ResetCreatedAt() {
  39730. m.created_at = nil
  39731. }
  39732. // SetUpdatedAt sets the "updated_at" field.
  39733. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  39734. m.updated_at = &t
  39735. }
  39736. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39737. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  39738. v := m.updated_at
  39739. if v == nil {
  39740. return
  39741. }
  39742. return *v, true
  39743. }
  39744. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  39745. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39747. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39748. if !m.op.Is(OpUpdateOne) {
  39749. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39750. }
  39751. if m.id == nil || m.oldValue == nil {
  39752. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39753. }
  39754. oldValue, err := m.oldValue(ctx)
  39755. if err != nil {
  39756. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39757. }
  39758. return oldValue.UpdatedAt, nil
  39759. }
  39760. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39761. func (m *WpChatroomMutation) ResetUpdatedAt() {
  39762. m.updated_at = nil
  39763. }
  39764. // SetStatus sets the "status" field.
  39765. func (m *WpChatroomMutation) SetStatus(u uint8) {
  39766. m.status = &u
  39767. m.addstatus = nil
  39768. }
  39769. // Status returns the value of the "status" field in the mutation.
  39770. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  39771. v := m.status
  39772. if v == nil {
  39773. return
  39774. }
  39775. return *v, true
  39776. }
  39777. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  39778. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39780. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39781. if !m.op.Is(OpUpdateOne) {
  39782. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39783. }
  39784. if m.id == nil || m.oldValue == nil {
  39785. return v, errors.New("OldStatus requires an ID field in the mutation")
  39786. }
  39787. oldValue, err := m.oldValue(ctx)
  39788. if err != nil {
  39789. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39790. }
  39791. return oldValue.Status, nil
  39792. }
  39793. // AddStatus adds u to the "status" field.
  39794. func (m *WpChatroomMutation) AddStatus(u int8) {
  39795. if m.addstatus != nil {
  39796. *m.addstatus += u
  39797. } else {
  39798. m.addstatus = &u
  39799. }
  39800. }
  39801. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39802. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  39803. v := m.addstatus
  39804. if v == nil {
  39805. return
  39806. }
  39807. return *v, true
  39808. }
  39809. // ClearStatus clears the value of the "status" field.
  39810. func (m *WpChatroomMutation) ClearStatus() {
  39811. m.status = nil
  39812. m.addstatus = nil
  39813. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  39814. }
  39815. // StatusCleared returns if the "status" field was cleared in this mutation.
  39816. func (m *WpChatroomMutation) StatusCleared() bool {
  39817. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  39818. return ok
  39819. }
  39820. // ResetStatus resets all changes to the "status" field.
  39821. func (m *WpChatroomMutation) ResetStatus() {
  39822. m.status = nil
  39823. m.addstatus = nil
  39824. delete(m.clearedFields, wpchatroom.FieldStatus)
  39825. }
  39826. // SetWxWxid sets the "wx_wxid" field.
  39827. func (m *WpChatroomMutation) SetWxWxid(s string) {
  39828. m.wx_wxid = &s
  39829. }
  39830. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39831. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  39832. v := m.wx_wxid
  39833. if v == nil {
  39834. return
  39835. }
  39836. return *v, true
  39837. }
  39838. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  39839. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39841. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39842. if !m.op.Is(OpUpdateOne) {
  39843. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39844. }
  39845. if m.id == nil || m.oldValue == nil {
  39846. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39847. }
  39848. oldValue, err := m.oldValue(ctx)
  39849. if err != nil {
  39850. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39851. }
  39852. return oldValue.WxWxid, nil
  39853. }
  39854. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39855. func (m *WpChatroomMutation) ResetWxWxid() {
  39856. m.wx_wxid = nil
  39857. }
  39858. // SetChatroomID sets the "chatroom_id" field.
  39859. func (m *WpChatroomMutation) SetChatroomID(s string) {
  39860. m.chatroom_id = &s
  39861. }
  39862. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  39863. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  39864. v := m.chatroom_id
  39865. if v == nil {
  39866. return
  39867. }
  39868. return *v, true
  39869. }
  39870. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  39871. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39873. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  39874. if !m.op.Is(OpUpdateOne) {
  39875. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  39876. }
  39877. if m.id == nil || m.oldValue == nil {
  39878. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  39879. }
  39880. oldValue, err := m.oldValue(ctx)
  39881. if err != nil {
  39882. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  39883. }
  39884. return oldValue.ChatroomID, nil
  39885. }
  39886. // ResetChatroomID resets all changes to the "chatroom_id" field.
  39887. func (m *WpChatroomMutation) ResetChatroomID() {
  39888. m.chatroom_id = nil
  39889. }
  39890. // SetNickname sets the "nickname" field.
  39891. func (m *WpChatroomMutation) SetNickname(s string) {
  39892. m.nickname = &s
  39893. }
  39894. // Nickname returns the value of the "nickname" field in the mutation.
  39895. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  39896. v := m.nickname
  39897. if v == nil {
  39898. return
  39899. }
  39900. return *v, true
  39901. }
  39902. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  39903. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39905. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  39906. if !m.op.Is(OpUpdateOne) {
  39907. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39908. }
  39909. if m.id == nil || m.oldValue == nil {
  39910. return v, errors.New("OldNickname requires an ID field in the mutation")
  39911. }
  39912. oldValue, err := m.oldValue(ctx)
  39913. if err != nil {
  39914. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39915. }
  39916. return oldValue.Nickname, nil
  39917. }
  39918. // ResetNickname resets all changes to the "nickname" field.
  39919. func (m *WpChatroomMutation) ResetNickname() {
  39920. m.nickname = nil
  39921. }
  39922. // SetOwner sets the "owner" field.
  39923. func (m *WpChatroomMutation) SetOwner(s string) {
  39924. m.owner = &s
  39925. }
  39926. // Owner returns the value of the "owner" field in the mutation.
  39927. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  39928. v := m.owner
  39929. if v == nil {
  39930. return
  39931. }
  39932. return *v, true
  39933. }
  39934. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  39935. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39937. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  39938. if !m.op.Is(OpUpdateOne) {
  39939. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  39940. }
  39941. if m.id == nil || m.oldValue == nil {
  39942. return v, errors.New("OldOwner requires an ID field in the mutation")
  39943. }
  39944. oldValue, err := m.oldValue(ctx)
  39945. if err != nil {
  39946. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  39947. }
  39948. return oldValue.Owner, nil
  39949. }
  39950. // ResetOwner resets all changes to the "owner" field.
  39951. func (m *WpChatroomMutation) ResetOwner() {
  39952. m.owner = nil
  39953. }
  39954. // SetAvatar sets the "avatar" field.
  39955. func (m *WpChatroomMutation) SetAvatar(s string) {
  39956. m.avatar = &s
  39957. }
  39958. // Avatar returns the value of the "avatar" field in the mutation.
  39959. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  39960. v := m.avatar
  39961. if v == nil {
  39962. return
  39963. }
  39964. return *v, true
  39965. }
  39966. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  39967. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39969. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39970. if !m.op.Is(OpUpdateOne) {
  39971. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39972. }
  39973. if m.id == nil || m.oldValue == nil {
  39974. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39975. }
  39976. oldValue, err := m.oldValue(ctx)
  39977. if err != nil {
  39978. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39979. }
  39980. return oldValue.Avatar, nil
  39981. }
  39982. // ResetAvatar resets all changes to the "avatar" field.
  39983. func (m *WpChatroomMutation) ResetAvatar() {
  39984. m.avatar = nil
  39985. }
  39986. // SetMemberList sets the "member_list" field.
  39987. func (m *WpChatroomMutation) SetMemberList(s []string) {
  39988. m.member_list = &s
  39989. m.appendmember_list = nil
  39990. }
  39991. // MemberList returns the value of the "member_list" field in the mutation.
  39992. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  39993. v := m.member_list
  39994. if v == nil {
  39995. return
  39996. }
  39997. return *v, true
  39998. }
  39999. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  40000. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40002. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  40003. if !m.op.Is(OpUpdateOne) {
  40004. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  40005. }
  40006. if m.id == nil || m.oldValue == nil {
  40007. return v, errors.New("OldMemberList requires an ID field in the mutation")
  40008. }
  40009. oldValue, err := m.oldValue(ctx)
  40010. if err != nil {
  40011. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  40012. }
  40013. return oldValue.MemberList, nil
  40014. }
  40015. // AppendMemberList adds s to the "member_list" field.
  40016. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  40017. m.appendmember_list = append(m.appendmember_list, s...)
  40018. }
  40019. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  40020. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  40021. if len(m.appendmember_list) == 0 {
  40022. return nil, false
  40023. }
  40024. return m.appendmember_list, true
  40025. }
  40026. // ResetMemberList resets all changes to the "member_list" field.
  40027. func (m *WpChatroomMutation) ResetMemberList() {
  40028. m.member_list = nil
  40029. m.appendmember_list = nil
  40030. }
  40031. // Where appends a list predicates to the WpChatroomMutation builder.
  40032. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  40033. m.predicates = append(m.predicates, ps...)
  40034. }
  40035. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  40036. // users can use type-assertion to append predicates that do not depend on any generated package.
  40037. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  40038. p := make([]predicate.WpChatroom, len(ps))
  40039. for i := range ps {
  40040. p[i] = ps[i]
  40041. }
  40042. m.Where(p...)
  40043. }
  40044. // Op returns the operation name.
  40045. func (m *WpChatroomMutation) Op() Op {
  40046. return m.op
  40047. }
  40048. // SetOp allows setting the mutation operation.
  40049. func (m *WpChatroomMutation) SetOp(op Op) {
  40050. m.op = op
  40051. }
  40052. // Type returns the node type of this mutation (WpChatroom).
  40053. func (m *WpChatroomMutation) Type() string {
  40054. return m.typ
  40055. }
  40056. // Fields returns all fields that were changed during this mutation. Note that in
  40057. // order to get all numeric fields that were incremented/decremented, call
  40058. // AddedFields().
  40059. func (m *WpChatroomMutation) Fields() []string {
  40060. fields := make([]string, 0, 9)
  40061. if m.created_at != nil {
  40062. fields = append(fields, wpchatroom.FieldCreatedAt)
  40063. }
  40064. if m.updated_at != nil {
  40065. fields = append(fields, wpchatroom.FieldUpdatedAt)
  40066. }
  40067. if m.status != nil {
  40068. fields = append(fields, wpchatroom.FieldStatus)
  40069. }
  40070. if m.wx_wxid != nil {
  40071. fields = append(fields, wpchatroom.FieldWxWxid)
  40072. }
  40073. if m.chatroom_id != nil {
  40074. fields = append(fields, wpchatroom.FieldChatroomID)
  40075. }
  40076. if m.nickname != nil {
  40077. fields = append(fields, wpchatroom.FieldNickname)
  40078. }
  40079. if m.owner != nil {
  40080. fields = append(fields, wpchatroom.FieldOwner)
  40081. }
  40082. if m.avatar != nil {
  40083. fields = append(fields, wpchatroom.FieldAvatar)
  40084. }
  40085. if m.member_list != nil {
  40086. fields = append(fields, wpchatroom.FieldMemberList)
  40087. }
  40088. return fields
  40089. }
  40090. // Field returns the value of a field with the given name. The second boolean
  40091. // return value indicates that this field was not set, or was not defined in the
  40092. // schema.
  40093. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40094. switch name {
  40095. case wpchatroom.FieldCreatedAt:
  40096. return m.CreatedAt()
  40097. case wpchatroom.FieldUpdatedAt:
  40098. return m.UpdatedAt()
  40099. case wpchatroom.FieldStatus:
  40100. return m.Status()
  40101. case wpchatroom.FieldWxWxid:
  40102. return m.WxWxid()
  40103. case wpchatroom.FieldChatroomID:
  40104. return m.ChatroomID()
  40105. case wpchatroom.FieldNickname:
  40106. return m.Nickname()
  40107. case wpchatroom.FieldOwner:
  40108. return m.Owner()
  40109. case wpchatroom.FieldAvatar:
  40110. return m.Avatar()
  40111. case wpchatroom.FieldMemberList:
  40112. return m.MemberList()
  40113. }
  40114. return nil, false
  40115. }
  40116. // OldField returns the old value of the field from the database. An error is
  40117. // returned if the mutation operation is not UpdateOne, or the query to the
  40118. // database failed.
  40119. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40120. switch name {
  40121. case wpchatroom.FieldCreatedAt:
  40122. return m.OldCreatedAt(ctx)
  40123. case wpchatroom.FieldUpdatedAt:
  40124. return m.OldUpdatedAt(ctx)
  40125. case wpchatroom.FieldStatus:
  40126. return m.OldStatus(ctx)
  40127. case wpchatroom.FieldWxWxid:
  40128. return m.OldWxWxid(ctx)
  40129. case wpchatroom.FieldChatroomID:
  40130. return m.OldChatroomID(ctx)
  40131. case wpchatroom.FieldNickname:
  40132. return m.OldNickname(ctx)
  40133. case wpchatroom.FieldOwner:
  40134. return m.OldOwner(ctx)
  40135. case wpchatroom.FieldAvatar:
  40136. return m.OldAvatar(ctx)
  40137. case wpchatroom.FieldMemberList:
  40138. return m.OldMemberList(ctx)
  40139. }
  40140. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40141. }
  40142. // SetField sets the value of a field with the given name. It returns an error if
  40143. // the field is not defined in the schema, or if the type mismatched the field
  40144. // type.
  40145. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40146. switch name {
  40147. case wpchatroom.FieldCreatedAt:
  40148. v, ok := value.(time.Time)
  40149. if !ok {
  40150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40151. }
  40152. m.SetCreatedAt(v)
  40153. return nil
  40154. case wpchatroom.FieldUpdatedAt:
  40155. v, ok := value.(time.Time)
  40156. if !ok {
  40157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40158. }
  40159. m.SetUpdatedAt(v)
  40160. return nil
  40161. case wpchatroom.FieldStatus:
  40162. v, ok := value.(uint8)
  40163. if !ok {
  40164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40165. }
  40166. m.SetStatus(v)
  40167. return nil
  40168. case wpchatroom.FieldWxWxid:
  40169. v, ok := value.(string)
  40170. if !ok {
  40171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40172. }
  40173. m.SetWxWxid(v)
  40174. return nil
  40175. case wpchatroom.FieldChatroomID:
  40176. v, ok := value.(string)
  40177. if !ok {
  40178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40179. }
  40180. m.SetChatroomID(v)
  40181. return nil
  40182. case wpchatroom.FieldNickname:
  40183. v, ok := value.(string)
  40184. if !ok {
  40185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40186. }
  40187. m.SetNickname(v)
  40188. return nil
  40189. case wpchatroom.FieldOwner:
  40190. v, ok := value.(string)
  40191. if !ok {
  40192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40193. }
  40194. m.SetOwner(v)
  40195. return nil
  40196. case wpchatroom.FieldAvatar:
  40197. v, ok := value.(string)
  40198. if !ok {
  40199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40200. }
  40201. m.SetAvatar(v)
  40202. return nil
  40203. case wpchatroom.FieldMemberList:
  40204. v, ok := value.([]string)
  40205. if !ok {
  40206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40207. }
  40208. m.SetMemberList(v)
  40209. return nil
  40210. }
  40211. return fmt.Errorf("unknown WpChatroom field %s", name)
  40212. }
  40213. // AddedFields returns all numeric fields that were incremented/decremented during
  40214. // this mutation.
  40215. func (m *WpChatroomMutation) AddedFields() []string {
  40216. var fields []string
  40217. if m.addstatus != nil {
  40218. fields = append(fields, wpchatroom.FieldStatus)
  40219. }
  40220. return fields
  40221. }
  40222. // AddedField returns the numeric value that was incremented/decremented on a field
  40223. // with the given name. The second boolean return value indicates that this field
  40224. // was not set, or was not defined in the schema.
  40225. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40226. switch name {
  40227. case wpchatroom.FieldStatus:
  40228. return m.AddedStatus()
  40229. }
  40230. return nil, false
  40231. }
  40232. // AddField adds the value to the field with the given name. It returns an error if
  40233. // the field is not defined in the schema, or if the type mismatched the field
  40234. // type.
  40235. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40236. switch name {
  40237. case wpchatroom.FieldStatus:
  40238. v, ok := value.(int8)
  40239. if !ok {
  40240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40241. }
  40242. m.AddStatus(v)
  40243. return nil
  40244. }
  40245. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40246. }
  40247. // ClearedFields returns all nullable fields that were cleared during this
  40248. // mutation.
  40249. func (m *WpChatroomMutation) ClearedFields() []string {
  40250. var fields []string
  40251. if m.FieldCleared(wpchatroom.FieldStatus) {
  40252. fields = append(fields, wpchatroom.FieldStatus)
  40253. }
  40254. return fields
  40255. }
  40256. // FieldCleared returns a boolean indicating if a field with the given name was
  40257. // cleared in this mutation.
  40258. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40259. _, ok := m.clearedFields[name]
  40260. return ok
  40261. }
  40262. // ClearField clears the value of the field with the given name. It returns an
  40263. // error if the field is not defined in the schema.
  40264. func (m *WpChatroomMutation) ClearField(name string) error {
  40265. switch name {
  40266. case wpchatroom.FieldStatus:
  40267. m.ClearStatus()
  40268. return nil
  40269. }
  40270. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40271. }
  40272. // ResetField resets all changes in the mutation for the field with the given name.
  40273. // It returns an error if the field is not defined in the schema.
  40274. func (m *WpChatroomMutation) ResetField(name string) error {
  40275. switch name {
  40276. case wpchatroom.FieldCreatedAt:
  40277. m.ResetCreatedAt()
  40278. return nil
  40279. case wpchatroom.FieldUpdatedAt:
  40280. m.ResetUpdatedAt()
  40281. return nil
  40282. case wpchatroom.FieldStatus:
  40283. m.ResetStatus()
  40284. return nil
  40285. case wpchatroom.FieldWxWxid:
  40286. m.ResetWxWxid()
  40287. return nil
  40288. case wpchatroom.FieldChatroomID:
  40289. m.ResetChatroomID()
  40290. return nil
  40291. case wpchatroom.FieldNickname:
  40292. m.ResetNickname()
  40293. return nil
  40294. case wpchatroom.FieldOwner:
  40295. m.ResetOwner()
  40296. return nil
  40297. case wpchatroom.FieldAvatar:
  40298. m.ResetAvatar()
  40299. return nil
  40300. case wpchatroom.FieldMemberList:
  40301. m.ResetMemberList()
  40302. return nil
  40303. }
  40304. return fmt.Errorf("unknown WpChatroom field %s", name)
  40305. }
  40306. // AddedEdges returns all edge names that were set/added in this mutation.
  40307. func (m *WpChatroomMutation) AddedEdges() []string {
  40308. edges := make([]string, 0, 0)
  40309. return edges
  40310. }
  40311. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40312. // name in this mutation.
  40313. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40314. return nil
  40315. }
  40316. // RemovedEdges returns all edge names that were removed in this mutation.
  40317. func (m *WpChatroomMutation) RemovedEdges() []string {
  40318. edges := make([]string, 0, 0)
  40319. return edges
  40320. }
  40321. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40322. // the given name in this mutation.
  40323. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40324. return nil
  40325. }
  40326. // ClearedEdges returns all edge names that were cleared in this mutation.
  40327. func (m *WpChatroomMutation) ClearedEdges() []string {
  40328. edges := make([]string, 0, 0)
  40329. return edges
  40330. }
  40331. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40332. // was cleared in this mutation.
  40333. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40334. return false
  40335. }
  40336. // ClearEdge clears the value of the edge with the given name. It returns an error
  40337. // if that edge is not defined in the schema.
  40338. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40339. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40340. }
  40341. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40342. // It returns an error if the edge is not defined in the schema.
  40343. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40344. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40345. }
  40346. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40347. type WpChatroomMemberMutation struct {
  40348. config
  40349. op Op
  40350. typ string
  40351. id *uint64
  40352. created_at *time.Time
  40353. updated_at *time.Time
  40354. status *uint8
  40355. addstatus *int8
  40356. wx_wxid *string
  40357. wxid *string
  40358. nickname *string
  40359. avatar *string
  40360. clearedFields map[string]struct{}
  40361. done bool
  40362. oldValue func(context.Context) (*WpChatroomMember, error)
  40363. predicates []predicate.WpChatroomMember
  40364. }
  40365. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40366. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40367. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40368. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40369. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40370. m := &WpChatroomMemberMutation{
  40371. config: c,
  40372. op: op,
  40373. typ: TypeWpChatroomMember,
  40374. clearedFields: make(map[string]struct{}),
  40375. }
  40376. for _, opt := range opts {
  40377. opt(m)
  40378. }
  40379. return m
  40380. }
  40381. // withWpChatroomMemberID sets the ID field of the mutation.
  40382. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40383. return func(m *WpChatroomMemberMutation) {
  40384. var (
  40385. err error
  40386. once sync.Once
  40387. value *WpChatroomMember
  40388. )
  40389. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40390. once.Do(func() {
  40391. if m.done {
  40392. err = errors.New("querying old values post mutation is not allowed")
  40393. } else {
  40394. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40395. }
  40396. })
  40397. return value, err
  40398. }
  40399. m.id = &id
  40400. }
  40401. }
  40402. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40403. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40404. return func(m *WpChatroomMemberMutation) {
  40405. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40406. return node, nil
  40407. }
  40408. m.id = &node.ID
  40409. }
  40410. }
  40411. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40412. // executed in a transaction (ent.Tx), a transactional client is returned.
  40413. func (m WpChatroomMemberMutation) Client() *Client {
  40414. client := &Client{config: m.config}
  40415. client.init()
  40416. return client
  40417. }
  40418. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40419. // it returns an error otherwise.
  40420. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40421. if _, ok := m.driver.(*txDriver); !ok {
  40422. return nil, errors.New("ent: mutation is not running in a transaction")
  40423. }
  40424. tx := &Tx{config: m.config}
  40425. tx.init()
  40426. return tx, nil
  40427. }
  40428. // SetID sets the value of the id field. Note that this
  40429. // operation is only accepted on creation of WpChatroomMember entities.
  40430. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40431. m.id = &id
  40432. }
  40433. // ID returns the ID value in the mutation. Note that the ID is only available
  40434. // if it was provided to the builder or after it was returned from the database.
  40435. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40436. if m.id == nil {
  40437. return
  40438. }
  40439. return *m.id, true
  40440. }
  40441. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40442. // That means, if the mutation is applied within a transaction with an isolation level such
  40443. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40444. // or updated by the mutation.
  40445. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40446. switch {
  40447. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40448. id, exists := m.ID()
  40449. if exists {
  40450. return []uint64{id}, nil
  40451. }
  40452. fallthrough
  40453. case m.op.Is(OpUpdate | OpDelete):
  40454. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40455. default:
  40456. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40457. }
  40458. }
  40459. // SetCreatedAt sets the "created_at" field.
  40460. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40461. m.created_at = &t
  40462. }
  40463. // CreatedAt returns the value of the "created_at" field in the mutation.
  40464. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40465. v := m.created_at
  40466. if v == nil {
  40467. return
  40468. }
  40469. return *v, true
  40470. }
  40471. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40472. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40474. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40475. if !m.op.Is(OpUpdateOne) {
  40476. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40477. }
  40478. if m.id == nil || m.oldValue == nil {
  40479. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40480. }
  40481. oldValue, err := m.oldValue(ctx)
  40482. if err != nil {
  40483. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40484. }
  40485. return oldValue.CreatedAt, nil
  40486. }
  40487. // ResetCreatedAt resets all changes to the "created_at" field.
  40488. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40489. m.created_at = nil
  40490. }
  40491. // SetUpdatedAt sets the "updated_at" field.
  40492. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40493. m.updated_at = &t
  40494. }
  40495. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40496. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40497. v := m.updated_at
  40498. if v == nil {
  40499. return
  40500. }
  40501. return *v, true
  40502. }
  40503. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40504. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40506. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40507. if !m.op.Is(OpUpdateOne) {
  40508. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40509. }
  40510. if m.id == nil || m.oldValue == nil {
  40511. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40512. }
  40513. oldValue, err := m.oldValue(ctx)
  40514. if err != nil {
  40515. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40516. }
  40517. return oldValue.UpdatedAt, nil
  40518. }
  40519. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40520. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40521. m.updated_at = nil
  40522. }
  40523. // SetStatus sets the "status" field.
  40524. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40525. m.status = &u
  40526. m.addstatus = nil
  40527. }
  40528. // Status returns the value of the "status" field in the mutation.
  40529. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40530. v := m.status
  40531. if v == nil {
  40532. return
  40533. }
  40534. return *v, true
  40535. }
  40536. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40537. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40539. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40540. if !m.op.Is(OpUpdateOne) {
  40541. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40542. }
  40543. if m.id == nil || m.oldValue == nil {
  40544. return v, errors.New("OldStatus requires an ID field in the mutation")
  40545. }
  40546. oldValue, err := m.oldValue(ctx)
  40547. if err != nil {
  40548. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40549. }
  40550. return oldValue.Status, nil
  40551. }
  40552. // AddStatus adds u to the "status" field.
  40553. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40554. if m.addstatus != nil {
  40555. *m.addstatus += u
  40556. } else {
  40557. m.addstatus = &u
  40558. }
  40559. }
  40560. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40561. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40562. v := m.addstatus
  40563. if v == nil {
  40564. return
  40565. }
  40566. return *v, true
  40567. }
  40568. // ClearStatus clears the value of the "status" field.
  40569. func (m *WpChatroomMemberMutation) ClearStatus() {
  40570. m.status = nil
  40571. m.addstatus = nil
  40572. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40573. }
  40574. // StatusCleared returns if the "status" field was cleared in this mutation.
  40575. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40576. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40577. return ok
  40578. }
  40579. // ResetStatus resets all changes to the "status" field.
  40580. func (m *WpChatroomMemberMutation) ResetStatus() {
  40581. m.status = nil
  40582. m.addstatus = nil
  40583. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40584. }
  40585. // SetWxWxid sets the "wx_wxid" field.
  40586. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40587. m.wx_wxid = &s
  40588. }
  40589. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40590. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40591. v := m.wx_wxid
  40592. if v == nil {
  40593. return
  40594. }
  40595. return *v, true
  40596. }
  40597. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40598. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40600. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40601. if !m.op.Is(OpUpdateOne) {
  40602. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40603. }
  40604. if m.id == nil || m.oldValue == nil {
  40605. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40606. }
  40607. oldValue, err := m.oldValue(ctx)
  40608. if err != nil {
  40609. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40610. }
  40611. return oldValue.WxWxid, nil
  40612. }
  40613. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40614. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40615. m.wx_wxid = nil
  40616. }
  40617. // SetWxid sets the "wxid" field.
  40618. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40619. m.wxid = &s
  40620. }
  40621. // Wxid returns the value of the "wxid" field in the mutation.
  40622. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40623. v := m.wxid
  40624. if v == nil {
  40625. return
  40626. }
  40627. return *v, true
  40628. }
  40629. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40630. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40632. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40633. if !m.op.Is(OpUpdateOne) {
  40634. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40635. }
  40636. if m.id == nil || m.oldValue == nil {
  40637. return v, errors.New("OldWxid requires an ID field in the mutation")
  40638. }
  40639. oldValue, err := m.oldValue(ctx)
  40640. if err != nil {
  40641. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40642. }
  40643. return oldValue.Wxid, nil
  40644. }
  40645. // ResetWxid resets all changes to the "wxid" field.
  40646. func (m *WpChatroomMemberMutation) ResetWxid() {
  40647. m.wxid = nil
  40648. }
  40649. // SetNickname sets the "nickname" field.
  40650. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  40651. m.nickname = &s
  40652. }
  40653. // Nickname returns the value of the "nickname" field in the mutation.
  40654. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  40655. v := m.nickname
  40656. if v == nil {
  40657. return
  40658. }
  40659. return *v, true
  40660. }
  40661. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  40662. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40664. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  40665. if !m.op.Is(OpUpdateOne) {
  40666. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40667. }
  40668. if m.id == nil || m.oldValue == nil {
  40669. return v, errors.New("OldNickname requires an ID field in the mutation")
  40670. }
  40671. oldValue, err := m.oldValue(ctx)
  40672. if err != nil {
  40673. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40674. }
  40675. return oldValue.Nickname, nil
  40676. }
  40677. // ResetNickname resets all changes to the "nickname" field.
  40678. func (m *WpChatroomMemberMutation) ResetNickname() {
  40679. m.nickname = nil
  40680. }
  40681. // SetAvatar sets the "avatar" field.
  40682. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  40683. m.avatar = &s
  40684. }
  40685. // Avatar returns the value of the "avatar" field in the mutation.
  40686. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  40687. v := m.avatar
  40688. if v == nil {
  40689. return
  40690. }
  40691. return *v, true
  40692. }
  40693. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  40694. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40696. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40697. if !m.op.Is(OpUpdateOne) {
  40698. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40699. }
  40700. if m.id == nil || m.oldValue == nil {
  40701. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40702. }
  40703. oldValue, err := m.oldValue(ctx)
  40704. if err != nil {
  40705. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40706. }
  40707. return oldValue.Avatar, nil
  40708. }
  40709. // ResetAvatar resets all changes to the "avatar" field.
  40710. func (m *WpChatroomMemberMutation) ResetAvatar() {
  40711. m.avatar = nil
  40712. }
  40713. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  40714. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  40715. m.predicates = append(m.predicates, ps...)
  40716. }
  40717. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  40718. // users can use type-assertion to append predicates that do not depend on any generated package.
  40719. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  40720. p := make([]predicate.WpChatroomMember, len(ps))
  40721. for i := range ps {
  40722. p[i] = ps[i]
  40723. }
  40724. m.Where(p...)
  40725. }
  40726. // Op returns the operation name.
  40727. func (m *WpChatroomMemberMutation) Op() Op {
  40728. return m.op
  40729. }
  40730. // SetOp allows setting the mutation operation.
  40731. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  40732. m.op = op
  40733. }
  40734. // Type returns the node type of this mutation (WpChatroomMember).
  40735. func (m *WpChatroomMemberMutation) Type() string {
  40736. return m.typ
  40737. }
  40738. // Fields returns all fields that were changed during this mutation. Note that in
  40739. // order to get all numeric fields that were incremented/decremented, call
  40740. // AddedFields().
  40741. func (m *WpChatroomMemberMutation) Fields() []string {
  40742. fields := make([]string, 0, 7)
  40743. if m.created_at != nil {
  40744. fields = append(fields, wpchatroommember.FieldCreatedAt)
  40745. }
  40746. if m.updated_at != nil {
  40747. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  40748. }
  40749. if m.status != nil {
  40750. fields = append(fields, wpchatroommember.FieldStatus)
  40751. }
  40752. if m.wx_wxid != nil {
  40753. fields = append(fields, wpchatroommember.FieldWxWxid)
  40754. }
  40755. if m.wxid != nil {
  40756. fields = append(fields, wpchatroommember.FieldWxid)
  40757. }
  40758. if m.nickname != nil {
  40759. fields = append(fields, wpchatroommember.FieldNickname)
  40760. }
  40761. if m.avatar != nil {
  40762. fields = append(fields, wpchatroommember.FieldAvatar)
  40763. }
  40764. return fields
  40765. }
  40766. // Field returns the value of a field with the given name. The second boolean
  40767. // return value indicates that this field was not set, or was not defined in the
  40768. // schema.
  40769. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  40770. switch name {
  40771. case wpchatroommember.FieldCreatedAt:
  40772. return m.CreatedAt()
  40773. case wpchatroommember.FieldUpdatedAt:
  40774. return m.UpdatedAt()
  40775. case wpchatroommember.FieldStatus:
  40776. return m.Status()
  40777. case wpchatroommember.FieldWxWxid:
  40778. return m.WxWxid()
  40779. case wpchatroommember.FieldWxid:
  40780. return m.Wxid()
  40781. case wpchatroommember.FieldNickname:
  40782. return m.Nickname()
  40783. case wpchatroommember.FieldAvatar:
  40784. return m.Avatar()
  40785. }
  40786. return nil, false
  40787. }
  40788. // OldField returns the old value of the field from the database. An error is
  40789. // returned if the mutation operation is not UpdateOne, or the query to the
  40790. // database failed.
  40791. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40792. switch name {
  40793. case wpchatroommember.FieldCreatedAt:
  40794. return m.OldCreatedAt(ctx)
  40795. case wpchatroommember.FieldUpdatedAt:
  40796. return m.OldUpdatedAt(ctx)
  40797. case wpchatroommember.FieldStatus:
  40798. return m.OldStatus(ctx)
  40799. case wpchatroommember.FieldWxWxid:
  40800. return m.OldWxWxid(ctx)
  40801. case wpchatroommember.FieldWxid:
  40802. return m.OldWxid(ctx)
  40803. case wpchatroommember.FieldNickname:
  40804. return m.OldNickname(ctx)
  40805. case wpchatroommember.FieldAvatar:
  40806. return m.OldAvatar(ctx)
  40807. }
  40808. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  40809. }
  40810. // SetField sets the value of a field with the given name. It returns an error if
  40811. // the field is not defined in the schema, or if the type mismatched the field
  40812. // type.
  40813. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  40814. switch name {
  40815. case wpchatroommember.FieldCreatedAt:
  40816. v, ok := value.(time.Time)
  40817. if !ok {
  40818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40819. }
  40820. m.SetCreatedAt(v)
  40821. return nil
  40822. case wpchatroommember.FieldUpdatedAt:
  40823. v, ok := value.(time.Time)
  40824. if !ok {
  40825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40826. }
  40827. m.SetUpdatedAt(v)
  40828. return nil
  40829. case wpchatroommember.FieldStatus:
  40830. v, ok := value.(uint8)
  40831. if !ok {
  40832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40833. }
  40834. m.SetStatus(v)
  40835. return nil
  40836. case wpchatroommember.FieldWxWxid:
  40837. v, ok := value.(string)
  40838. if !ok {
  40839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40840. }
  40841. m.SetWxWxid(v)
  40842. return nil
  40843. case wpchatroommember.FieldWxid:
  40844. v, ok := value.(string)
  40845. if !ok {
  40846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40847. }
  40848. m.SetWxid(v)
  40849. return nil
  40850. case wpchatroommember.FieldNickname:
  40851. v, ok := value.(string)
  40852. if !ok {
  40853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40854. }
  40855. m.SetNickname(v)
  40856. return nil
  40857. case wpchatroommember.FieldAvatar:
  40858. v, ok := value.(string)
  40859. if !ok {
  40860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40861. }
  40862. m.SetAvatar(v)
  40863. return nil
  40864. }
  40865. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40866. }
  40867. // AddedFields returns all numeric fields that were incremented/decremented during
  40868. // this mutation.
  40869. func (m *WpChatroomMemberMutation) AddedFields() []string {
  40870. var fields []string
  40871. if m.addstatus != nil {
  40872. fields = append(fields, wpchatroommember.FieldStatus)
  40873. }
  40874. return fields
  40875. }
  40876. // AddedField returns the numeric value that was incremented/decremented on a field
  40877. // with the given name. The second boolean return value indicates that this field
  40878. // was not set, or was not defined in the schema.
  40879. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  40880. switch name {
  40881. case wpchatroommember.FieldStatus:
  40882. return m.AddedStatus()
  40883. }
  40884. return nil, false
  40885. }
  40886. // AddField adds the value to the field with the given name. It returns an error if
  40887. // the field is not defined in the schema, or if the type mismatched the field
  40888. // type.
  40889. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  40890. switch name {
  40891. case wpchatroommember.FieldStatus:
  40892. v, ok := value.(int8)
  40893. if !ok {
  40894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40895. }
  40896. m.AddStatus(v)
  40897. return nil
  40898. }
  40899. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  40900. }
  40901. // ClearedFields returns all nullable fields that were cleared during this
  40902. // mutation.
  40903. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  40904. var fields []string
  40905. if m.FieldCleared(wpchatroommember.FieldStatus) {
  40906. fields = append(fields, wpchatroommember.FieldStatus)
  40907. }
  40908. return fields
  40909. }
  40910. // FieldCleared returns a boolean indicating if a field with the given name was
  40911. // cleared in this mutation.
  40912. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  40913. _, ok := m.clearedFields[name]
  40914. return ok
  40915. }
  40916. // ClearField clears the value of the field with the given name. It returns an
  40917. // error if the field is not defined in the schema.
  40918. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  40919. switch name {
  40920. case wpchatroommember.FieldStatus:
  40921. m.ClearStatus()
  40922. return nil
  40923. }
  40924. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  40925. }
  40926. // ResetField resets all changes in the mutation for the field with the given name.
  40927. // It returns an error if the field is not defined in the schema.
  40928. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  40929. switch name {
  40930. case wpchatroommember.FieldCreatedAt:
  40931. m.ResetCreatedAt()
  40932. return nil
  40933. case wpchatroommember.FieldUpdatedAt:
  40934. m.ResetUpdatedAt()
  40935. return nil
  40936. case wpchatroommember.FieldStatus:
  40937. m.ResetStatus()
  40938. return nil
  40939. case wpchatroommember.FieldWxWxid:
  40940. m.ResetWxWxid()
  40941. return nil
  40942. case wpchatroommember.FieldWxid:
  40943. m.ResetWxid()
  40944. return nil
  40945. case wpchatroommember.FieldNickname:
  40946. m.ResetNickname()
  40947. return nil
  40948. case wpchatroommember.FieldAvatar:
  40949. m.ResetAvatar()
  40950. return nil
  40951. }
  40952. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40953. }
  40954. // AddedEdges returns all edge names that were set/added in this mutation.
  40955. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  40956. edges := make([]string, 0, 0)
  40957. return edges
  40958. }
  40959. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40960. // name in this mutation.
  40961. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  40962. return nil
  40963. }
  40964. // RemovedEdges returns all edge names that were removed in this mutation.
  40965. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  40966. edges := make([]string, 0, 0)
  40967. return edges
  40968. }
  40969. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40970. // the given name in this mutation.
  40971. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  40972. return nil
  40973. }
  40974. // ClearedEdges returns all edge names that were cleared in this mutation.
  40975. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  40976. edges := make([]string, 0, 0)
  40977. return edges
  40978. }
  40979. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40980. // was cleared in this mutation.
  40981. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  40982. return false
  40983. }
  40984. // ClearEdge clears the value of the edge with the given name. It returns an error
  40985. // if that edge is not defined in the schema.
  40986. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  40987. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  40988. }
  40989. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40990. // It returns an error if the edge is not defined in the schema.
  40991. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  40992. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  40993. }
  40994. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  40995. type WxMutation struct {
  40996. config
  40997. op Op
  40998. typ string
  40999. id *uint64
  41000. created_at *time.Time
  41001. updated_at *time.Time
  41002. status *uint8
  41003. addstatus *int8
  41004. deleted_at *time.Time
  41005. port *string
  41006. process_id *string
  41007. callback *string
  41008. wxid *string
  41009. account *string
  41010. nickname *string
  41011. tel *string
  41012. head_big *string
  41013. organization_id *uint64
  41014. addorganization_id *int64
  41015. api_base *string
  41016. api_key *string
  41017. allow_list *[]string
  41018. appendallow_list []string
  41019. group_allow_list *[]string
  41020. appendgroup_allow_list []string
  41021. block_list *[]string
  41022. appendblock_list []string
  41023. group_block_list *[]string
  41024. appendgroup_block_list []string
  41025. ctype *uint64
  41026. addctype *int64
  41027. clearedFields map[string]struct{}
  41028. server *uint64
  41029. clearedserver bool
  41030. agent *uint64
  41031. clearedagent bool
  41032. done bool
  41033. oldValue func(context.Context) (*Wx, error)
  41034. predicates []predicate.Wx
  41035. }
  41036. var _ ent.Mutation = (*WxMutation)(nil)
  41037. // wxOption allows management of the mutation configuration using functional options.
  41038. type wxOption func(*WxMutation)
  41039. // newWxMutation creates new mutation for the Wx entity.
  41040. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  41041. m := &WxMutation{
  41042. config: c,
  41043. op: op,
  41044. typ: TypeWx,
  41045. clearedFields: make(map[string]struct{}),
  41046. }
  41047. for _, opt := range opts {
  41048. opt(m)
  41049. }
  41050. return m
  41051. }
  41052. // withWxID sets the ID field of the mutation.
  41053. func withWxID(id uint64) wxOption {
  41054. return func(m *WxMutation) {
  41055. var (
  41056. err error
  41057. once sync.Once
  41058. value *Wx
  41059. )
  41060. m.oldValue = func(ctx context.Context) (*Wx, error) {
  41061. once.Do(func() {
  41062. if m.done {
  41063. err = errors.New("querying old values post mutation is not allowed")
  41064. } else {
  41065. value, err = m.Client().Wx.Get(ctx, id)
  41066. }
  41067. })
  41068. return value, err
  41069. }
  41070. m.id = &id
  41071. }
  41072. }
  41073. // withWx sets the old Wx of the mutation.
  41074. func withWx(node *Wx) wxOption {
  41075. return func(m *WxMutation) {
  41076. m.oldValue = func(context.Context) (*Wx, error) {
  41077. return node, nil
  41078. }
  41079. m.id = &node.ID
  41080. }
  41081. }
  41082. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41083. // executed in a transaction (ent.Tx), a transactional client is returned.
  41084. func (m WxMutation) Client() *Client {
  41085. client := &Client{config: m.config}
  41086. client.init()
  41087. return client
  41088. }
  41089. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41090. // it returns an error otherwise.
  41091. func (m WxMutation) Tx() (*Tx, error) {
  41092. if _, ok := m.driver.(*txDriver); !ok {
  41093. return nil, errors.New("ent: mutation is not running in a transaction")
  41094. }
  41095. tx := &Tx{config: m.config}
  41096. tx.init()
  41097. return tx, nil
  41098. }
  41099. // SetID sets the value of the id field. Note that this
  41100. // operation is only accepted on creation of Wx entities.
  41101. func (m *WxMutation) SetID(id uint64) {
  41102. m.id = &id
  41103. }
  41104. // ID returns the ID value in the mutation. Note that the ID is only available
  41105. // if it was provided to the builder or after it was returned from the database.
  41106. func (m *WxMutation) ID() (id uint64, exists bool) {
  41107. if m.id == nil {
  41108. return
  41109. }
  41110. return *m.id, true
  41111. }
  41112. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41113. // That means, if the mutation is applied within a transaction with an isolation level such
  41114. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41115. // or updated by the mutation.
  41116. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41117. switch {
  41118. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41119. id, exists := m.ID()
  41120. if exists {
  41121. return []uint64{id}, nil
  41122. }
  41123. fallthrough
  41124. case m.op.Is(OpUpdate | OpDelete):
  41125. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41126. default:
  41127. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41128. }
  41129. }
  41130. // SetCreatedAt sets the "created_at" field.
  41131. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41132. m.created_at = &t
  41133. }
  41134. // CreatedAt returns the value of the "created_at" field in the mutation.
  41135. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41136. v := m.created_at
  41137. if v == nil {
  41138. return
  41139. }
  41140. return *v, true
  41141. }
  41142. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41143. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41145. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41146. if !m.op.Is(OpUpdateOne) {
  41147. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41148. }
  41149. if m.id == nil || m.oldValue == nil {
  41150. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41151. }
  41152. oldValue, err := m.oldValue(ctx)
  41153. if err != nil {
  41154. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41155. }
  41156. return oldValue.CreatedAt, nil
  41157. }
  41158. // ResetCreatedAt resets all changes to the "created_at" field.
  41159. func (m *WxMutation) ResetCreatedAt() {
  41160. m.created_at = nil
  41161. }
  41162. // SetUpdatedAt sets the "updated_at" field.
  41163. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41164. m.updated_at = &t
  41165. }
  41166. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41167. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41168. v := m.updated_at
  41169. if v == nil {
  41170. return
  41171. }
  41172. return *v, true
  41173. }
  41174. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41175. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41177. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41178. if !m.op.Is(OpUpdateOne) {
  41179. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41180. }
  41181. if m.id == nil || m.oldValue == nil {
  41182. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41183. }
  41184. oldValue, err := m.oldValue(ctx)
  41185. if err != nil {
  41186. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41187. }
  41188. return oldValue.UpdatedAt, nil
  41189. }
  41190. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41191. func (m *WxMutation) ResetUpdatedAt() {
  41192. m.updated_at = nil
  41193. }
  41194. // SetStatus sets the "status" field.
  41195. func (m *WxMutation) SetStatus(u uint8) {
  41196. m.status = &u
  41197. m.addstatus = nil
  41198. }
  41199. // Status returns the value of the "status" field in the mutation.
  41200. func (m *WxMutation) Status() (r uint8, exists bool) {
  41201. v := m.status
  41202. if v == nil {
  41203. return
  41204. }
  41205. return *v, true
  41206. }
  41207. // OldStatus returns the old "status" field's value of the Wx entity.
  41208. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41210. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41211. if !m.op.Is(OpUpdateOne) {
  41212. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41213. }
  41214. if m.id == nil || m.oldValue == nil {
  41215. return v, errors.New("OldStatus requires an ID field in the mutation")
  41216. }
  41217. oldValue, err := m.oldValue(ctx)
  41218. if err != nil {
  41219. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41220. }
  41221. return oldValue.Status, nil
  41222. }
  41223. // AddStatus adds u to the "status" field.
  41224. func (m *WxMutation) AddStatus(u int8) {
  41225. if m.addstatus != nil {
  41226. *m.addstatus += u
  41227. } else {
  41228. m.addstatus = &u
  41229. }
  41230. }
  41231. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41232. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41233. v := m.addstatus
  41234. if v == nil {
  41235. return
  41236. }
  41237. return *v, true
  41238. }
  41239. // ClearStatus clears the value of the "status" field.
  41240. func (m *WxMutation) ClearStatus() {
  41241. m.status = nil
  41242. m.addstatus = nil
  41243. m.clearedFields[wx.FieldStatus] = struct{}{}
  41244. }
  41245. // StatusCleared returns if the "status" field was cleared in this mutation.
  41246. func (m *WxMutation) StatusCleared() bool {
  41247. _, ok := m.clearedFields[wx.FieldStatus]
  41248. return ok
  41249. }
  41250. // ResetStatus resets all changes to the "status" field.
  41251. func (m *WxMutation) ResetStatus() {
  41252. m.status = nil
  41253. m.addstatus = nil
  41254. delete(m.clearedFields, wx.FieldStatus)
  41255. }
  41256. // SetDeletedAt sets the "deleted_at" field.
  41257. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41258. m.deleted_at = &t
  41259. }
  41260. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41261. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41262. v := m.deleted_at
  41263. if v == nil {
  41264. return
  41265. }
  41266. return *v, true
  41267. }
  41268. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41269. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41271. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41272. if !m.op.Is(OpUpdateOne) {
  41273. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41274. }
  41275. if m.id == nil || m.oldValue == nil {
  41276. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41277. }
  41278. oldValue, err := m.oldValue(ctx)
  41279. if err != nil {
  41280. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41281. }
  41282. return oldValue.DeletedAt, nil
  41283. }
  41284. // ClearDeletedAt clears the value of the "deleted_at" field.
  41285. func (m *WxMutation) ClearDeletedAt() {
  41286. m.deleted_at = nil
  41287. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41288. }
  41289. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41290. func (m *WxMutation) DeletedAtCleared() bool {
  41291. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41292. return ok
  41293. }
  41294. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41295. func (m *WxMutation) ResetDeletedAt() {
  41296. m.deleted_at = nil
  41297. delete(m.clearedFields, wx.FieldDeletedAt)
  41298. }
  41299. // SetServerID sets the "server_id" field.
  41300. func (m *WxMutation) SetServerID(u uint64) {
  41301. m.server = &u
  41302. }
  41303. // ServerID returns the value of the "server_id" field in the mutation.
  41304. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41305. v := m.server
  41306. if v == nil {
  41307. return
  41308. }
  41309. return *v, true
  41310. }
  41311. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41312. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41314. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41315. if !m.op.Is(OpUpdateOne) {
  41316. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41317. }
  41318. if m.id == nil || m.oldValue == nil {
  41319. return v, errors.New("OldServerID requires an ID field in the mutation")
  41320. }
  41321. oldValue, err := m.oldValue(ctx)
  41322. if err != nil {
  41323. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41324. }
  41325. return oldValue.ServerID, nil
  41326. }
  41327. // ClearServerID clears the value of the "server_id" field.
  41328. func (m *WxMutation) ClearServerID() {
  41329. m.server = nil
  41330. m.clearedFields[wx.FieldServerID] = struct{}{}
  41331. }
  41332. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41333. func (m *WxMutation) ServerIDCleared() bool {
  41334. _, ok := m.clearedFields[wx.FieldServerID]
  41335. return ok
  41336. }
  41337. // ResetServerID resets all changes to the "server_id" field.
  41338. func (m *WxMutation) ResetServerID() {
  41339. m.server = nil
  41340. delete(m.clearedFields, wx.FieldServerID)
  41341. }
  41342. // SetPort sets the "port" field.
  41343. func (m *WxMutation) SetPort(s string) {
  41344. m.port = &s
  41345. }
  41346. // Port returns the value of the "port" field in the mutation.
  41347. func (m *WxMutation) Port() (r string, exists bool) {
  41348. v := m.port
  41349. if v == nil {
  41350. return
  41351. }
  41352. return *v, true
  41353. }
  41354. // OldPort returns the old "port" field's value of the Wx entity.
  41355. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41357. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41358. if !m.op.Is(OpUpdateOne) {
  41359. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41360. }
  41361. if m.id == nil || m.oldValue == nil {
  41362. return v, errors.New("OldPort requires an ID field in the mutation")
  41363. }
  41364. oldValue, err := m.oldValue(ctx)
  41365. if err != nil {
  41366. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41367. }
  41368. return oldValue.Port, nil
  41369. }
  41370. // ResetPort resets all changes to the "port" field.
  41371. func (m *WxMutation) ResetPort() {
  41372. m.port = nil
  41373. }
  41374. // SetProcessID sets the "process_id" field.
  41375. func (m *WxMutation) SetProcessID(s string) {
  41376. m.process_id = &s
  41377. }
  41378. // ProcessID returns the value of the "process_id" field in the mutation.
  41379. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41380. v := m.process_id
  41381. if v == nil {
  41382. return
  41383. }
  41384. return *v, true
  41385. }
  41386. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41387. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41389. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41390. if !m.op.Is(OpUpdateOne) {
  41391. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41392. }
  41393. if m.id == nil || m.oldValue == nil {
  41394. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41395. }
  41396. oldValue, err := m.oldValue(ctx)
  41397. if err != nil {
  41398. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41399. }
  41400. return oldValue.ProcessID, nil
  41401. }
  41402. // ResetProcessID resets all changes to the "process_id" field.
  41403. func (m *WxMutation) ResetProcessID() {
  41404. m.process_id = nil
  41405. }
  41406. // SetCallback sets the "callback" field.
  41407. func (m *WxMutation) SetCallback(s string) {
  41408. m.callback = &s
  41409. }
  41410. // Callback returns the value of the "callback" field in the mutation.
  41411. func (m *WxMutation) Callback() (r string, exists bool) {
  41412. v := m.callback
  41413. if v == nil {
  41414. return
  41415. }
  41416. return *v, true
  41417. }
  41418. // OldCallback returns the old "callback" field's value of the Wx entity.
  41419. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41421. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41422. if !m.op.Is(OpUpdateOne) {
  41423. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41424. }
  41425. if m.id == nil || m.oldValue == nil {
  41426. return v, errors.New("OldCallback requires an ID field in the mutation")
  41427. }
  41428. oldValue, err := m.oldValue(ctx)
  41429. if err != nil {
  41430. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41431. }
  41432. return oldValue.Callback, nil
  41433. }
  41434. // ResetCallback resets all changes to the "callback" field.
  41435. func (m *WxMutation) ResetCallback() {
  41436. m.callback = nil
  41437. }
  41438. // SetWxid sets the "wxid" field.
  41439. func (m *WxMutation) SetWxid(s string) {
  41440. m.wxid = &s
  41441. }
  41442. // Wxid returns the value of the "wxid" field in the mutation.
  41443. func (m *WxMutation) Wxid() (r string, exists bool) {
  41444. v := m.wxid
  41445. if v == nil {
  41446. return
  41447. }
  41448. return *v, true
  41449. }
  41450. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41451. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41453. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41454. if !m.op.Is(OpUpdateOne) {
  41455. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41456. }
  41457. if m.id == nil || m.oldValue == nil {
  41458. return v, errors.New("OldWxid requires an ID field in the mutation")
  41459. }
  41460. oldValue, err := m.oldValue(ctx)
  41461. if err != nil {
  41462. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41463. }
  41464. return oldValue.Wxid, nil
  41465. }
  41466. // ResetWxid resets all changes to the "wxid" field.
  41467. func (m *WxMutation) ResetWxid() {
  41468. m.wxid = nil
  41469. }
  41470. // SetAccount sets the "account" field.
  41471. func (m *WxMutation) SetAccount(s string) {
  41472. m.account = &s
  41473. }
  41474. // Account returns the value of the "account" field in the mutation.
  41475. func (m *WxMutation) Account() (r string, exists bool) {
  41476. v := m.account
  41477. if v == nil {
  41478. return
  41479. }
  41480. return *v, true
  41481. }
  41482. // OldAccount returns the old "account" field's value of the Wx entity.
  41483. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41485. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41486. if !m.op.Is(OpUpdateOne) {
  41487. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41488. }
  41489. if m.id == nil || m.oldValue == nil {
  41490. return v, errors.New("OldAccount requires an ID field in the mutation")
  41491. }
  41492. oldValue, err := m.oldValue(ctx)
  41493. if err != nil {
  41494. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41495. }
  41496. return oldValue.Account, nil
  41497. }
  41498. // ResetAccount resets all changes to the "account" field.
  41499. func (m *WxMutation) ResetAccount() {
  41500. m.account = nil
  41501. }
  41502. // SetNickname sets the "nickname" field.
  41503. func (m *WxMutation) SetNickname(s string) {
  41504. m.nickname = &s
  41505. }
  41506. // Nickname returns the value of the "nickname" field in the mutation.
  41507. func (m *WxMutation) Nickname() (r string, exists bool) {
  41508. v := m.nickname
  41509. if v == nil {
  41510. return
  41511. }
  41512. return *v, true
  41513. }
  41514. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41515. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41517. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41518. if !m.op.Is(OpUpdateOne) {
  41519. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41520. }
  41521. if m.id == nil || m.oldValue == nil {
  41522. return v, errors.New("OldNickname requires an ID field in the mutation")
  41523. }
  41524. oldValue, err := m.oldValue(ctx)
  41525. if err != nil {
  41526. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41527. }
  41528. return oldValue.Nickname, nil
  41529. }
  41530. // ResetNickname resets all changes to the "nickname" field.
  41531. func (m *WxMutation) ResetNickname() {
  41532. m.nickname = nil
  41533. }
  41534. // SetTel sets the "tel" field.
  41535. func (m *WxMutation) SetTel(s string) {
  41536. m.tel = &s
  41537. }
  41538. // Tel returns the value of the "tel" field in the mutation.
  41539. func (m *WxMutation) Tel() (r string, exists bool) {
  41540. v := m.tel
  41541. if v == nil {
  41542. return
  41543. }
  41544. return *v, true
  41545. }
  41546. // OldTel returns the old "tel" field's value of the Wx entity.
  41547. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41549. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41550. if !m.op.Is(OpUpdateOne) {
  41551. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41552. }
  41553. if m.id == nil || m.oldValue == nil {
  41554. return v, errors.New("OldTel requires an ID field in the mutation")
  41555. }
  41556. oldValue, err := m.oldValue(ctx)
  41557. if err != nil {
  41558. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41559. }
  41560. return oldValue.Tel, nil
  41561. }
  41562. // ResetTel resets all changes to the "tel" field.
  41563. func (m *WxMutation) ResetTel() {
  41564. m.tel = nil
  41565. }
  41566. // SetHeadBig sets the "head_big" field.
  41567. func (m *WxMutation) SetHeadBig(s string) {
  41568. m.head_big = &s
  41569. }
  41570. // HeadBig returns the value of the "head_big" field in the mutation.
  41571. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41572. v := m.head_big
  41573. if v == nil {
  41574. return
  41575. }
  41576. return *v, true
  41577. }
  41578. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41579. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41581. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41582. if !m.op.Is(OpUpdateOne) {
  41583. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41584. }
  41585. if m.id == nil || m.oldValue == nil {
  41586. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41587. }
  41588. oldValue, err := m.oldValue(ctx)
  41589. if err != nil {
  41590. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41591. }
  41592. return oldValue.HeadBig, nil
  41593. }
  41594. // ResetHeadBig resets all changes to the "head_big" field.
  41595. func (m *WxMutation) ResetHeadBig() {
  41596. m.head_big = nil
  41597. }
  41598. // SetOrganizationID sets the "organization_id" field.
  41599. func (m *WxMutation) SetOrganizationID(u uint64) {
  41600. m.organization_id = &u
  41601. m.addorganization_id = nil
  41602. }
  41603. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41604. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41605. v := m.organization_id
  41606. if v == nil {
  41607. return
  41608. }
  41609. return *v, true
  41610. }
  41611. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41612. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41614. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41615. if !m.op.Is(OpUpdateOne) {
  41616. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41617. }
  41618. if m.id == nil || m.oldValue == nil {
  41619. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41620. }
  41621. oldValue, err := m.oldValue(ctx)
  41622. if err != nil {
  41623. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41624. }
  41625. return oldValue.OrganizationID, nil
  41626. }
  41627. // AddOrganizationID adds u to the "organization_id" field.
  41628. func (m *WxMutation) AddOrganizationID(u int64) {
  41629. if m.addorganization_id != nil {
  41630. *m.addorganization_id += u
  41631. } else {
  41632. m.addorganization_id = &u
  41633. }
  41634. }
  41635. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41636. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  41637. v := m.addorganization_id
  41638. if v == nil {
  41639. return
  41640. }
  41641. return *v, true
  41642. }
  41643. // ClearOrganizationID clears the value of the "organization_id" field.
  41644. func (m *WxMutation) ClearOrganizationID() {
  41645. m.organization_id = nil
  41646. m.addorganization_id = nil
  41647. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  41648. }
  41649. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41650. func (m *WxMutation) OrganizationIDCleared() bool {
  41651. _, ok := m.clearedFields[wx.FieldOrganizationID]
  41652. return ok
  41653. }
  41654. // ResetOrganizationID resets all changes to the "organization_id" field.
  41655. func (m *WxMutation) ResetOrganizationID() {
  41656. m.organization_id = nil
  41657. m.addorganization_id = nil
  41658. delete(m.clearedFields, wx.FieldOrganizationID)
  41659. }
  41660. // SetAgentID sets the "agent_id" field.
  41661. func (m *WxMutation) SetAgentID(u uint64) {
  41662. m.agent = &u
  41663. }
  41664. // AgentID returns the value of the "agent_id" field in the mutation.
  41665. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  41666. v := m.agent
  41667. if v == nil {
  41668. return
  41669. }
  41670. return *v, true
  41671. }
  41672. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  41673. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41675. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41676. if !m.op.Is(OpUpdateOne) {
  41677. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41678. }
  41679. if m.id == nil || m.oldValue == nil {
  41680. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41681. }
  41682. oldValue, err := m.oldValue(ctx)
  41683. if err != nil {
  41684. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41685. }
  41686. return oldValue.AgentID, nil
  41687. }
  41688. // ResetAgentID resets all changes to the "agent_id" field.
  41689. func (m *WxMutation) ResetAgentID() {
  41690. m.agent = nil
  41691. }
  41692. // SetAPIBase sets the "api_base" field.
  41693. func (m *WxMutation) SetAPIBase(s string) {
  41694. m.api_base = &s
  41695. }
  41696. // APIBase returns the value of the "api_base" field in the mutation.
  41697. func (m *WxMutation) APIBase() (r string, exists bool) {
  41698. v := m.api_base
  41699. if v == nil {
  41700. return
  41701. }
  41702. return *v, true
  41703. }
  41704. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  41705. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41707. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41708. if !m.op.Is(OpUpdateOne) {
  41709. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41710. }
  41711. if m.id == nil || m.oldValue == nil {
  41712. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41713. }
  41714. oldValue, err := m.oldValue(ctx)
  41715. if err != nil {
  41716. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41717. }
  41718. return oldValue.APIBase, nil
  41719. }
  41720. // ClearAPIBase clears the value of the "api_base" field.
  41721. func (m *WxMutation) ClearAPIBase() {
  41722. m.api_base = nil
  41723. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  41724. }
  41725. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41726. func (m *WxMutation) APIBaseCleared() bool {
  41727. _, ok := m.clearedFields[wx.FieldAPIBase]
  41728. return ok
  41729. }
  41730. // ResetAPIBase resets all changes to the "api_base" field.
  41731. func (m *WxMutation) ResetAPIBase() {
  41732. m.api_base = nil
  41733. delete(m.clearedFields, wx.FieldAPIBase)
  41734. }
  41735. // SetAPIKey sets the "api_key" field.
  41736. func (m *WxMutation) SetAPIKey(s string) {
  41737. m.api_key = &s
  41738. }
  41739. // APIKey returns the value of the "api_key" field in the mutation.
  41740. func (m *WxMutation) APIKey() (r string, exists bool) {
  41741. v := m.api_key
  41742. if v == nil {
  41743. return
  41744. }
  41745. return *v, true
  41746. }
  41747. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  41748. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41750. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41751. if !m.op.Is(OpUpdateOne) {
  41752. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41753. }
  41754. if m.id == nil || m.oldValue == nil {
  41755. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41756. }
  41757. oldValue, err := m.oldValue(ctx)
  41758. if err != nil {
  41759. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41760. }
  41761. return oldValue.APIKey, nil
  41762. }
  41763. // ClearAPIKey clears the value of the "api_key" field.
  41764. func (m *WxMutation) ClearAPIKey() {
  41765. m.api_key = nil
  41766. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  41767. }
  41768. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41769. func (m *WxMutation) APIKeyCleared() bool {
  41770. _, ok := m.clearedFields[wx.FieldAPIKey]
  41771. return ok
  41772. }
  41773. // ResetAPIKey resets all changes to the "api_key" field.
  41774. func (m *WxMutation) ResetAPIKey() {
  41775. m.api_key = nil
  41776. delete(m.clearedFields, wx.FieldAPIKey)
  41777. }
  41778. // SetAllowList sets the "allow_list" field.
  41779. func (m *WxMutation) SetAllowList(s []string) {
  41780. m.allow_list = &s
  41781. m.appendallow_list = nil
  41782. }
  41783. // AllowList returns the value of the "allow_list" field in the mutation.
  41784. func (m *WxMutation) AllowList() (r []string, exists bool) {
  41785. v := m.allow_list
  41786. if v == nil {
  41787. return
  41788. }
  41789. return *v, true
  41790. }
  41791. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  41792. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41794. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41795. if !m.op.Is(OpUpdateOne) {
  41796. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41797. }
  41798. if m.id == nil || m.oldValue == nil {
  41799. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41800. }
  41801. oldValue, err := m.oldValue(ctx)
  41802. if err != nil {
  41803. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41804. }
  41805. return oldValue.AllowList, nil
  41806. }
  41807. // AppendAllowList adds s to the "allow_list" field.
  41808. func (m *WxMutation) AppendAllowList(s []string) {
  41809. m.appendallow_list = append(m.appendallow_list, s...)
  41810. }
  41811. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41812. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  41813. if len(m.appendallow_list) == 0 {
  41814. return nil, false
  41815. }
  41816. return m.appendallow_list, true
  41817. }
  41818. // ResetAllowList resets all changes to the "allow_list" field.
  41819. func (m *WxMutation) ResetAllowList() {
  41820. m.allow_list = nil
  41821. m.appendallow_list = nil
  41822. }
  41823. // SetGroupAllowList sets the "group_allow_list" field.
  41824. func (m *WxMutation) SetGroupAllowList(s []string) {
  41825. m.group_allow_list = &s
  41826. m.appendgroup_allow_list = nil
  41827. }
  41828. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41829. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  41830. v := m.group_allow_list
  41831. if v == nil {
  41832. return
  41833. }
  41834. return *v, true
  41835. }
  41836. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  41837. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41839. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41840. if !m.op.Is(OpUpdateOne) {
  41841. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41842. }
  41843. if m.id == nil || m.oldValue == nil {
  41844. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41845. }
  41846. oldValue, err := m.oldValue(ctx)
  41847. if err != nil {
  41848. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41849. }
  41850. return oldValue.GroupAllowList, nil
  41851. }
  41852. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41853. func (m *WxMutation) AppendGroupAllowList(s []string) {
  41854. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41855. }
  41856. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41857. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  41858. if len(m.appendgroup_allow_list) == 0 {
  41859. return nil, false
  41860. }
  41861. return m.appendgroup_allow_list, true
  41862. }
  41863. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41864. func (m *WxMutation) ResetGroupAllowList() {
  41865. m.group_allow_list = nil
  41866. m.appendgroup_allow_list = nil
  41867. }
  41868. // SetBlockList sets the "block_list" field.
  41869. func (m *WxMutation) SetBlockList(s []string) {
  41870. m.block_list = &s
  41871. m.appendblock_list = nil
  41872. }
  41873. // BlockList returns the value of the "block_list" field in the mutation.
  41874. func (m *WxMutation) BlockList() (r []string, exists bool) {
  41875. v := m.block_list
  41876. if v == nil {
  41877. return
  41878. }
  41879. return *v, true
  41880. }
  41881. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  41882. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41884. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41885. if !m.op.Is(OpUpdateOne) {
  41886. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41887. }
  41888. if m.id == nil || m.oldValue == nil {
  41889. return v, errors.New("OldBlockList requires an ID field in the mutation")
  41890. }
  41891. oldValue, err := m.oldValue(ctx)
  41892. if err != nil {
  41893. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  41894. }
  41895. return oldValue.BlockList, nil
  41896. }
  41897. // AppendBlockList adds s to the "block_list" field.
  41898. func (m *WxMutation) AppendBlockList(s []string) {
  41899. m.appendblock_list = append(m.appendblock_list, s...)
  41900. }
  41901. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41902. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  41903. if len(m.appendblock_list) == 0 {
  41904. return nil, false
  41905. }
  41906. return m.appendblock_list, true
  41907. }
  41908. // ResetBlockList resets all changes to the "block_list" field.
  41909. func (m *WxMutation) ResetBlockList() {
  41910. m.block_list = nil
  41911. m.appendblock_list = nil
  41912. }
  41913. // SetGroupBlockList sets the "group_block_list" field.
  41914. func (m *WxMutation) SetGroupBlockList(s []string) {
  41915. m.group_block_list = &s
  41916. m.appendgroup_block_list = nil
  41917. }
  41918. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41919. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  41920. v := m.group_block_list
  41921. if v == nil {
  41922. return
  41923. }
  41924. return *v, true
  41925. }
  41926. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  41927. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41929. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  41930. if !m.op.Is(OpUpdateOne) {
  41931. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  41932. }
  41933. if m.id == nil || m.oldValue == nil {
  41934. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  41935. }
  41936. oldValue, err := m.oldValue(ctx)
  41937. if err != nil {
  41938. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  41939. }
  41940. return oldValue.GroupBlockList, nil
  41941. }
  41942. // AppendGroupBlockList adds s to the "group_block_list" field.
  41943. func (m *WxMutation) AppendGroupBlockList(s []string) {
  41944. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  41945. }
  41946. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  41947. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  41948. if len(m.appendgroup_block_list) == 0 {
  41949. return nil, false
  41950. }
  41951. return m.appendgroup_block_list, true
  41952. }
  41953. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  41954. func (m *WxMutation) ResetGroupBlockList() {
  41955. m.group_block_list = nil
  41956. m.appendgroup_block_list = nil
  41957. }
  41958. // SetCtype sets the "ctype" field.
  41959. func (m *WxMutation) SetCtype(u uint64) {
  41960. m.ctype = &u
  41961. m.addctype = nil
  41962. }
  41963. // Ctype returns the value of the "ctype" field in the mutation.
  41964. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  41965. v := m.ctype
  41966. if v == nil {
  41967. return
  41968. }
  41969. return *v, true
  41970. }
  41971. // OldCtype returns the old "ctype" field's value of the Wx entity.
  41972. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41974. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  41975. if !m.op.Is(OpUpdateOne) {
  41976. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  41977. }
  41978. if m.id == nil || m.oldValue == nil {
  41979. return v, errors.New("OldCtype requires an ID field in the mutation")
  41980. }
  41981. oldValue, err := m.oldValue(ctx)
  41982. if err != nil {
  41983. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  41984. }
  41985. return oldValue.Ctype, nil
  41986. }
  41987. // AddCtype adds u to the "ctype" field.
  41988. func (m *WxMutation) AddCtype(u int64) {
  41989. if m.addctype != nil {
  41990. *m.addctype += u
  41991. } else {
  41992. m.addctype = &u
  41993. }
  41994. }
  41995. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  41996. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  41997. v := m.addctype
  41998. if v == nil {
  41999. return
  42000. }
  42001. return *v, true
  42002. }
  42003. // ClearCtype clears the value of the "ctype" field.
  42004. func (m *WxMutation) ClearCtype() {
  42005. m.ctype = nil
  42006. m.addctype = nil
  42007. m.clearedFields[wx.FieldCtype] = struct{}{}
  42008. }
  42009. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  42010. func (m *WxMutation) CtypeCleared() bool {
  42011. _, ok := m.clearedFields[wx.FieldCtype]
  42012. return ok
  42013. }
  42014. // ResetCtype resets all changes to the "ctype" field.
  42015. func (m *WxMutation) ResetCtype() {
  42016. m.ctype = nil
  42017. m.addctype = nil
  42018. delete(m.clearedFields, wx.FieldCtype)
  42019. }
  42020. // ClearServer clears the "server" edge to the Server entity.
  42021. func (m *WxMutation) ClearServer() {
  42022. m.clearedserver = true
  42023. m.clearedFields[wx.FieldServerID] = struct{}{}
  42024. }
  42025. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  42026. func (m *WxMutation) ServerCleared() bool {
  42027. return m.ServerIDCleared() || m.clearedserver
  42028. }
  42029. // ServerIDs returns the "server" edge IDs in the mutation.
  42030. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42031. // ServerID instead. It exists only for internal usage by the builders.
  42032. func (m *WxMutation) ServerIDs() (ids []uint64) {
  42033. if id := m.server; id != nil {
  42034. ids = append(ids, *id)
  42035. }
  42036. return
  42037. }
  42038. // ResetServer resets all changes to the "server" edge.
  42039. func (m *WxMutation) ResetServer() {
  42040. m.server = nil
  42041. m.clearedserver = false
  42042. }
  42043. // ClearAgent clears the "agent" edge to the Agent entity.
  42044. func (m *WxMutation) ClearAgent() {
  42045. m.clearedagent = true
  42046. m.clearedFields[wx.FieldAgentID] = struct{}{}
  42047. }
  42048. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42049. func (m *WxMutation) AgentCleared() bool {
  42050. return m.clearedagent
  42051. }
  42052. // AgentIDs returns the "agent" edge IDs in the mutation.
  42053. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42054. // AgentID instead. It exists only for internal usage by the builders.
  42055. func (m *WxMutation) AgentIDs() (ids []uint64) {
  42056. if id := m.agent; id != nil {
  42057. ids = append(ids, *id)
  42058. }
  42059. return
  42060. }
  42061. // ResetAgent resets all changes to the "agent" edge.
  42062. func (m *WxMutation) ResetAgent() {
  42063. m.agent = nil
  42064. m.clearedagent = false
  42065. }
  42066. // Where appends a list predicates to the WxMutation builder.
  42067. func (m *WxMutation) Where(ps ...predicate.Wx) {
  42068. m.predicates = append(m.predicates, ps...)
  42069. }
  42070. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  42071. // users can use type-assertion to append predicates that do not depend on any generated package.
  42072. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  42073. p := make([]predicate.Wx, len(ps))
  42074. for i := range ps {
  42075. p[i] = ps[i]
  42076. }
  42077. m.Where(p...)
  42078. }
  42079. // Op returns the operation name.
  42080. func (m *WxMutation) Op() Op {
  42081. return m.op
  42082. }
  42083. // SetOp allows setting the mutation operation.
  42084. func (m *WxMutation) SetOp(op Op) {
  42085. m.op = op
  42086. }
  42087. // Type returns the node type of this mutation (Wx).
  42088. func (m *WxMutation) Type() string {
  42089. return m.typ
  42090. }
  42091. // Fields returns all fields that were changed during this mutation. Note that in
  42092. // order to get all numeric fields that were incremented/decremented, call
  42093. // AddedFields().
  42094. func (m *WxMutation) Fields() []string {
  42095. fields := make([]string, 0, 22)
  42096. if m.created_at != nil {
  42097. fields = append(fields, wx.FieldCreatedAt)
  42098. }
  42099. if m.updated_at != nil {
  42100. fields = append(fields, wx.FieldUpdatedAt)
  42101. }
  42102. if m.status != nil {
  42103. fields = append(fields, wx.FieldStatus)
  42104. }
  42105. if m.deleted_at != nil {
  42106. fields = append(fields, wx.FieldDeletedAt)
  42107. }
  42108. if m.server != nil {
  42109. fields = append(fields, wx.FieldServerID)
  42110. }
  42111. if m.port != nil {
  42112. fields = append(fields, wx.FieldPort)
  42113. }
  42114. if m.process_id != nil {
  42115. fields = append(fields, wx.FieldProcessID)
  42116. }
  42117. if m.callback != nil {
  42118. fields = append(fields, wx.FieldCallback)
  42119. }
  42120. if m.wxid != nil {
  42121. fields = append(fields, wx.FieldWxid)
  42122. }
  42123. if m.account != nil {
  42124. fields = append(fields, wx.FieldAccount)
  42125. }
  42126. if m.nickname != nil {
  42127. fields = append(fields, wx.FieldNickname)
  42128. }
  42129. if m.tel != nil {
  42130. fields = append(fields, wx.FieldTel)
  42131. }
  42132. if m.head_big != nil {
  42133. fields = append(fields, wx.FieldHeadBig)
  42134. }
  42135. if m.organization_id != nil {
  42136. fields = append(fields, wx.FieldOrganizationID)
  42137. }
  42138. if m.agent != nil {
  42139. fields = append(fields, wx.FieldAgentID)
  42140. }
  42141. if m.api_base != nil {
  42142. fields = append(fields, wx.FieldAPIBase)
  42143. }
  42144. if m.api_key != nil {
  42145. fields = append(fields, wx.FieldAPIKey)
  42146. }
  42147. if m.allow_list != nil {
  42148. fields = append(fields, wx.FieldAllowList)
  42149. }
  42150. if m.group_allow_list != nil {
  42151. fields = append(fields, wx.FieldGroupAllowList)
  42152. }
  42153. if m.block_list != nil {
  42154. fields = append(fields, wx.FieldBlockList)
  42155. }
  42156. if m.group_block_list != nil {
  42157. fields = append(fields, wx.FieldGroupBlockList)
  42158. }
  42159. if m.ctype != nil {
  42160. fields = append(fields, wx.FieldCtype)
  42161. }
  42162. return fields
  42163. }
  42164. // Field returns the value of a field with the given name. The second boolean
  42165. // return value indicates that this field was not set, or was not defined in the
  42166. // schema.
  42167. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42168. switch name {
  42169. case wx.FieldCreatedAt:
  42170. return m.CreatedAt()
  42171. case wx.FieldUpdatedAt:
  42172. return m.UpdatedAt()
  42173. case wx.FieldStatus:
  42174. return m.Status()
  42175. case wx.FieldDeletedAt:
  42176. return m.DeletedAt()
  42177. case wx.FieldServerID:
  42178. return m.ServerID()
  42179. case wx.FieldPort:
  42180. return m.Port()
  42181. case wx.FieldProcessID:
  42182. return m.ProcessID()
  42183. case wx.FieldCallback:
  42184. return m.Callback()
  42185. case wx.FieldWxid:
  42186. return m.Wxid()
  42187. case wx.FieldAccount:
  42188. return m.Account()
  42189. case wx.FieldNickname:
  42190. return m.Nickname()
  42191. case wx.FieldTel:
  42192. return m.Tel()
  42193. case wx.FieldHeadBig:
  42194. return m.HeadBig()
  42195. case wx.FieldOrganizationID:
  42196. return m.OrganizationID()
  42197. case wx.FieldAgentID:
  42198. return m.AgentID()
  42199. case wx.FieldAPIBase:
  42200. return m.APIBase()
  42201. case wx.FieldAPIKey:
  42202. return m.APIKey()
  42203. case wx.FieldAllowList:
  42204. return m.AllowList()
  42205. case wx.FieldGroupAllowList:
  42206. return m.GroupAllowList()
  42207. case wx.FieldBlockList:
  42208. return m.BlockList()
  42209. case wx.FieldGroupBlockList:
  42210. return m.GroupBlockList()
  42211. case wx.FieldCtype:
  42212. return m.Ctype()
  42213. }
  42214. return nil, false
  42215. }
  42216. // OldField returns the old value of the field from the database. An error is
  42217. // returned if the mutation operation is not UpdateOne, or the query to the
  42218. // database failed.
  42219. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42220. switch name {
  42221. case wx.FieldCreatedAt:
  42222. return m.OldCreatedAt(ctx)
  42223. case wx.FieldUpdatedAt:
  42224. return m.OldUpdatedAt(ctx)
  42225. case wx.FieldStatus:
  42226. return m.OldStatus(ctx)
  42227. case wx.FieldDeletedAt:
  42228. return m.OldDeletedAt(ctx)
  42229. case wx.FieldServerID:
  42230. return m.OldServerID(ctx)
  42231. case wx.FieldPort:
  42232. return m.OldPort(ctx)
  42233. case wx.FieldProcessID:
  42234. return m.OldProcessID(ctx)
  42235. case wx.FieldCallback:
  42236. return m.OldCallback(ctx)
  42237. case wx.FieldWxid:
  42238. return m.OldWxid(ctx)
  42239. case wx.FieldAccount:
  42240. return m.OldAccount(ctx)
  42241. case wx.FieldNickname:
  42242. return m.OldNickname(ctx)
  42243. case wx.FieldTel:
  42244. return m.OldTel(ctx)
  42245. case wx.FieldHeadBig:
  42246. return m.OldHeadBig(ctx)
  42247. case wx.FieldOrganizationID:
  42248. return m.OldOrganizationID(ctx)
  42249. case wx.FieldAgentID:
  42250. return m.OldAgentID(ctx)
  42251. case wx.FieldAPIBase:
  42252. return m.OldAPIBase(ctx)
  42253. case wx.FieldAPIKey:
  42254. return m.OldAPIKey(ctx)
  42255. case wx.FieldAllowList:
  42256. return m.OldAllowList(ctx)
  42257. case wx.FieldGroupAllowList:
  42258. return m.OldGroupAllowList(ctx)
  42259. case wx.FieldBlockList:
  42260. return m.OldBlockList(ctx)
  42261. case wx.FieldGroupBlockList:
  42262. return m.OldGroupBlockList(ctx)
  42263. case wx.FieldCtype:
  42264. return m.OldCtype(ctx)
  42265. }
  42266. return nil, fmt.Errorf("unknown Wx field %s", name)
  42267. }
  42268. // SetField sets the value of a field with the given name. It returns an error if
  42269. // the field is not defined in the schema, or if the type mismatched the field
  42270. // type.
  42271. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42272. switch name {
  42273. case wx.FieldCreatedAt:
  42274. v, ok := value.(time.Time)
  42275. if !ok {
  42276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42277. }
  42278. m.SetCreatedAt(v)
  42279. return nil
  42280. case wx.FieldUpdatedAt:
  42281. v, ok := value.(time.Time)
  42282. if !ok {
  42283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42284. }
  42285. m.SetUpdatedAt(v)
  42286. return nil
  42287. case wx.FieldStatus:
  42288. v, ok := value.(uint8)
  42289. if !ok {
  42290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42291. }
  42292. m.SetStatus(v)
  42293. return nil
  42294. case wx.FieldDeletedAt:
  42295. v, ok := value.(time.Time)
  42296. if !ok {
  42297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42298. }
  42299. m.SetDeletedAt(v)
  42300. return nil
  42301. case wx.FieldServerID:
  42302. v, ok := value.(uint64)
  42303. if !ok {
  42304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42305. }
  42306. m.SetServerID(v)
  42307. return nil
  42308. case wx.FieldPort:
  42309. v, ok := value.(string)
  42310. if !ok {
  42311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42312. }
  42313. m.SetPort(v)
  42314. return nil
  42315. case wx.FieldProcessID:
  42316. v, ok := value.(string)
  42317. if !ok {
  42318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42319. }
  42320. m.SetProcessID(v)
  42321. return nil
  42322. case wx.FieldCallback:
  42323. v, ok := value.(string)
  42324. if !ok {
  42325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42326. }
  42327. m.SetCallback(v)
  42328. return nil
  42329. case wx.FieldWxid:
  42330. v, ok := value.(string)
  42331. if !ok {
  42332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42333. }
  42334. m.SetWxid(v)
  42335. return nil
  42336. case wx.FieldAccount:
  42337. v, ok := value.(string)
  42338. if !ok {
  42339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42340. }
  42341. m.SetAccount(v)
  42342. return nil
  42343. case wx.FieldNickname:
  42344. v, ok := value.(string)
  42345. if !ok {
  42346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42347. }
  42348. m.SetNickname(v)
  42349. return nil
  42350. case wx.FieldTel:
  42351. v, ok := value.(string)
  42352. if !ok {
  42353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42354. }
  42355. m.SetTel(v)
  42356. return nil
  42357. case wx.FieldHeadBig:
  42358. v, ok := value.(string)
  42359. if !ok {
  42360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42361. }
  42362. m.SetHeadBig(v)
  42363. return nil
  42364. case wx.FieldOrganizationID:
  42365. v, ok := value.(uint64)
  42366. if !ok {
  42367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42368. }
  42369. m.SetOrganizationID(v)
  42370. return nil
  42371. case wx.FieldAgentID:
  42372. v, ok := value.(uint64)
  42373. if !ok {
  42374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42375. }
  42376. m.SetAgentID(v)
  42377. return nil
  42378. case wx.FieldAPIBase:
  42379. v, ok := value.(string)
  42380. if !ok {
  42381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42382. }
  42383. m.SetAPIBase(v)
  42384. return nil
  42385. case wx.FieldAPIKey:
  42386. v, ok := value.(string)
  42387. if !ok {
  42388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42389. }
  42390. m.SetAPIKey(v)
  42391. return nil
  42392. case wx.FieldAllowList:
  42393. v, ok := value.([]string)
  42394. if !ok {
  42395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42396. }
  42397. m.SetAllowList(v)
  42398. return nil
  42399. case wx.FieldGroupAllowList:
  42400. v, ok := value.([]string)
  42401. if !ok {
  42402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42403. }
  42404. m.SetGroupAllowList(v)
  42405. return nil
  42406. case wx.FieldBlockList:
  42407. v, ok := value.([]string)
  42408. if !ok {
  42409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42410. }
  42411. m.SetBlockList(v)
  42412. return nil
  42413. case wx.FieldGroupBlockList:
  42414. v, ok := value.([]string)
  42415. if !ok {
  42416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42417. }
  42418. m.SetGroupBlockList(v)
  42419. return nil
  42420. case wx.FieldCtype:
  42421. v, ok := value.(uint64)
  42422. if !ok {
  42423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42424. }
  42425. m.SetCtype(v)
  42426. return nil
  42427. }
  42428. return fmt.Errorf("unknown Wx field %s", name)
  42429. }
  42430. // AddedFields returns all numeric fields that were incremented/decremented during
  42431. // this mutation.
  42432. func (m *WxMutation) AddedFields() []string {
  42433. var fields []string
  42434. if m.addstatus != nil {
  42435. fields = append(fields, wx.FieldStatus)
  42436. }
  42437. if m.addorganization_id != nil {
  42438. fields = append(fields, wx.FieldOrganizationID)
  42439. }
  42440. if m.addctype != nil {
  42441. fields = append(fields, wx.FieldCtype)
  42442. }
  42443. return fields
  42444. }
  42445. // AddedField returns the numeric value that was incremented/decremented on a field
  42446. // with the given name. The second boolean return value indicates that this field
  42447. // was not set, or was not defined in the schema.
  42448. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42449. switch name {
  42450. case wx.FieldStatus:
  42451. return m.AddedStatus()
  42452. case wx.FieldOrganizationID:
  42453. return m.AddedOrganizationID()
  42454. case wx.FieldCtype:
  42455. return m.AddedCtype()
  42456. }
  42457. return nil, false
  42458. }
  42459. // AddField adds the value to the field with the given name. It returns an error if
  42460. // the field is not defined in the schema, or if the type mismatched the field
  42461. // type.
  42462. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42463. switch name {
  42464. case wx.FieldStatus:
  42465. v, ok := value.(int8)
  42466. if !ok {
  42467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42468. }
  42469. m.AddStatus(v)
  42470. return nil
  42471. case wx.FieldOrganizationID:
  42472. v, ok := value.(int64)
  42473. if !ok {
  42474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42475. }
  42476. m.AddOrganizationID(v)
  42477. return nil
  42478. case wx.FieldCtype:
  42479. v, ok := value.(int64)
  42480. if !ok {
  42481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42482. }
  42483. m.AddCtype(v)
  42484. return nil
  42485. }
  42486. return fmt.Errorf("unknown Wx numeric field %s", name)
  42487. }
  42488. // ClearedFields returns all nullable fields that were cleared during this
  42489. // mutation.
  42490. func (m *WxMutation) ClearedFields() []string {
  42491. var fields []string
  42492. if m.FieldCleared(wx.FieldStatus) {
  42493. fields = append(fields, wx.FieldStatus)
  42494. }
  42495. if m.FieldCleared(wx.FieldDeletedAt) {
  42496. fields = append(fields, wx.FieldDeletedAt)
  42497. }
  42498. if m.FieldCleared(wx.FieldServerID) {
  42499. fields = append(fields, wx.FieldServerID)
  42500. }
  42501. if m.FieldCleared(wx.FieldOrganizationID) {
  42502. fields = append(fields, wx.FieldOrganizationID)
  42503. }
  42504. if m.FieldCleared(wx.FieldAPIBase) {
  42505. fields = append(fields, wx.FieldAPIBase)
  42506. }
  42507. if m.FieldCleared(wx.FieldAPIKey) {
  42508. fields = append(fields, wx.FieldAPIKey)
  42509. }
  42510. if m.FieldCleared(wx.FieldCtype) {
  42511. fields = append(fields, wx.FieldCtype)
  42512. }
  42513. return fields
  42514. }
  42515. // FieldCleared returns a boolean indicating if a field with the given name was
  42516. // cleared in this mutation.
  42517. func (m *WxMutation) FieldCleared(name string) bool {
  42518. _, ok := m.clearedFields[name]
  42519. return ok
  42520. }
  42521. // ClearField clears the value of the field with the given name. It returns an
  42522. // error if the field is not defined in the schema.
  42523. func (m *WxMutation) ClearField(name string) error {
  42524. switch name {
  42525. case wx.FieldStatus:
  42526. m.ClearStatus()
  42527. return nil
  42528. case wx.FieldDeletedAt:
  42529. m.ClearDeletedAt()
  42530. return nil
  42531. case wx.FieldServerID:
  42532. m.ClearServerID()
  42533. return nil
  42534. case wx.FieldOrganizationID:
  42535. m.ClearOrganizationID()
  42536. return nil
  42537. case wx.FieldAPIBase:
  42538. m.ClearAPIBase()
  42539. return nil
  42540. case wx.FieldAPIKey:
  42541. m.ClearAPIKey()
  42542. return nil
  42543. case wx.FieldCtype:
  42544. m.ClearCtype()
  42545. return nil
  42546. }
  42547. return fmt.Errorf("unknown Wx nullable field %s", name)
  42548. }
  42549. // ResetField resets all changes in the mutation for the field with the given name.
  42550. // It returns an error if the field is not defined in the schema.
  42551. func (m *WxMutation) ResetField(name string) error {
  42552. switch name {
  42553. case wx.FieldCreatedAt:
  42554. m.ResetCreatedAt()
  42555. return nil
  42556. case wx.FieldUpdatedAt:
  42557. m.ResetUpdatedAt()
  42558. return nil
  42559. case wx.FieldStatus:
  42560. m.ResetStatus()
  42561. return nil
  42562. case wx.FieldDeletedAt:
  42563. m.ResetDeletedAt()
  42564. return nil
  42565. case wx.FieldServerID:
  42566. m.ResetServerID()
  42567. return nil
  42568. case wx.FieldPort:
  42569. m.ResetPort()
  42570. return nil
  42571. case wx.FieldProcessID:
  42572. m.ResetProcessID()
  42573. return nil
  42574. case wx.FieldCallback:
  42575. m.ResetCallback()
  42576. return nil
  42577. case wx.FieldWxid:
  42578. m.ResetWxid()
  42579. return nil
  42580. case wx.FieldAccount:
  42581. m.ResetAccount()
  42582. return nil
  42583. case wx.FieldNickname:
  42584. m.ResetNickname()
  42585. return nil
  42586. case wx.FieldTel:
  42587. m.ResetTel()
  42588. return nil
  42589. case wx.FieldHeadBig:
  42590. m.ResetHeadBig()
  42591. return nil
  42592. case wx.FieldOrganizationID:
  42593. m.ResetOrganizationID()
  42594. return nil
  42595. case wx.FieldAgentID:
  42596. m.ResetAgentID()
  42597. return nil
  42598. case wx.FieldAPIBase:
  42599. m.ResetAPIBase()
  42600. return nil
  42601. case wx.FieldAPIKey:
  42602. m.ResetAPIKey()
  42603. return nil
  42604. case wx.FieldAllowList:
  42605. m.ResetAllowList()
  42606. return nil
  42607. case wx.FieldGroupAllowList:
  42608. m.ResetGroupAllowList()
  42609. return nil
  42610. case wx.FieldBlockList:
  42611. m.ResetBlockList()
  42612. return nil
  42613. case wx.FieldGroupBlockList:
  42614. m.ResetGroupBlockList()
  42615. return nil
  42616. case wx.FieldCtype:
  42617. m.ResetCtype()
  42618. return nil
  42619. }
  42620. return fmt.Errorf("unknown Wx field %s", name)
  42621. }
  42622. // AddedEdges returns all edge names that were set/added in this mutation.
  42623. func (m *WxMutation) AddedEdges() []string {
  42624. edges := make([]string, 0, 2)
  42625. if m.server != nil {
  42626. edges = append(edges, wx.EdgeServer)
  42627. }
  42628. if m.agent != nil {
  42629. edges = append(edges, wx.EdgeAgent)
  42630. }
  42631. return edges
  42632. }
  42633. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42634. // name in this mutation.
  42635. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  42636. switch name {
  42637. case wx.EdgeServer:
  42638. if id := m.server; id != nil {
  42639. return []ent.Value{*id}
  42640. }
  42641. case wx.EdgeAgent:
  42642. if id := m.agent; id != nil {
  42643. return []ent.Value{*id}
  42644. }
  42645. }
  42646. return nil
  42647. }
  42648. // RemovedEdges returns all edge names that were removed in this mutation.
  42649. func (m *WxMutation) RemovedEdges() []string {
  42650. edges := make([]string, 0, 2)
  42651. return edges
  42652. }
  42653. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42654. // the given name in this mutation.
  42655. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  42656. return nil
  42657. }
  42658. // ClearedEdges returns all edge names that were cleared in this mutation.
  42659. func (m *WxMutation) ClearedEdges() []string {
  42660. edges := make([]string, 0, 2)
  42661. if m.clearedserver {
  42662. edges = append(edges, wx.EdgeServer)
  42663. }
  42664. if m.clearedagent {
  42665. edges = append(edges, wx.EdgeAgent)
  42666. }
  42667. return edges
  42668. }
  42669. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42670. // was cleared in this mutation.
  42671. func (m *WxMutation) EdgeCleared(name string) bool {
  42672. switch name {
  42673. case wx.EdgeServer:
  42674. return m.clearedserver
  42675. case wx.EdgeAgent:
  42676. return m.clearedagent
  42677. }
  42678. return false
  42679. }
  42680. // ClearEdge clears the value of the edge with the given name. It returns an error
  42681. // if that edge is not defined in the schema.
  42682. func (m *WxMutation) ClearEdge(name string) error {
  42683. switch name {
  42684. case wx.EdgeServer:
  42685. m.ClearServer()
  42686. return nil
  42687. case wx.EdgeAgent:
  42688. m.ClearAgent()
  42689. return nil
  42690. }
  42691. return fmt.Errorf("unknown Wx unique edge %s", name)
  42692. }
  42693. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42694. // It returns an error if the edge is not defined in the schema.
  42695. func (m *WxMutation) ResetEdge(name string) error {
  42696. switch name {
  42697. case wx.EdgeServer:
  42698. m.ResetServer()
  42699. return nil
  42700. case wx.EdgeAgent:
  42701. m.ResetAgent()
  42702. return nil
  42703. }
  42704. return fmt.Errorf("unknown Wx edge %s", name)
  42705. }
  42706. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  42707. type WxCardMutation struct {
  42708. config
  42709. op Op
  42710. typ string
  42711. id *uint64
  42712. created_at *time.Time
  42713. updated_at *time.Time
  42714. deleted_at *time.Time
  42715. user_id *uint64
  42716. adduser_id *int64
  42717. wx_user_id *uint64
  42718. addwx_user_id *int64
  42719. avatar *string
  42720. logo *string
  42721. name *string
  42722. company *string
  42723. address *string
  42724. phone *string
  42725. official_account *string
  42726. wechat_account *string
  42727. email *string
  42728. api_base *string
  42729. api_key *string
  42730. ai_info *string
  42731. intro *string
  42732. clearedFields map[string]struct{}
  42733. done bool
  42734. oldValue func(context.Context) (*WxCard, error)
  42735. predicates []predicate.WxCard
  42736. }
  42737. var _ ent.Mutation = (*WxCardMutation)(nil)
  42738. // wxcardOption allows management of the mutation configuration using functional options.
  42739. type wxcardOption func(*WxCardMutation)
  42740. // newWxCardMutation creates new mutation for the WxCard entity.
  42741. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  42742. m := &WxCardMutation{
  42743. config: c,
  42744. op: op,
  42745. typ: TypeWxCard,
  42746. clearedFields: make(map[string]struct{}),
  42747. }
  42748. for _, opt := range opts {
  42749. opt(m)
  42750. }
  42751. return m
  42752. }
  42753. // withWxCardID sets the ID field of the mutation.
  42754. func withWxCardID(id uint64) wxcardOption {
  42755. return func(m *WxCardMutation) {
  42756. var (
  42757. err error
  42758. once sync.Once
  42759. value *WxCard
  42760. )
  42761. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  42762. once.Do(func() {
  42763. if m.done {
  42764. err = errors.New("querying old values post mutation is not allowed")
  42765. } else {
  42766. value, err = m.Client().WxCard.Get(ctx, id)
  42767. }
  42768. })
  42769. return value, err
  42770. }
  42771. m.id = &id
  42772. }
  42773. }
  42774. // withWxCard sets the old WxCard of the mutation.
  42775. func withWxCard(node *WxCard) wxcardOption {
  42776. return func(m *WxCardMutation) {
  42777. m.oldValue = func(context.Context) (*WxCard, error) {
  42778. return node, nil
  42779. }
  42780. m.id = &node.ID
  42781. }
  42782. }
  42783. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42784. // executed in a transaction (ent.Tx), a transactional client is returned.
  42785. func (m WxCardMutation) Client() *Client {
  42786. client := &Client{config: m.config}
  42787. client.init()
  42788. return client
  42789. }
  42790. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42791. // it returns an error otherwise.
  42792. func (m WxCardMutation) Tx() (*Tx, error) {
  42793. if _, ok := m.driver.(*txDriver); !ok {
  42794. return nil, errors.New("ent: mutation is not running in a transaction")
  42795. }
  42796. tx := &Tx{config: m.config}
  42797. tx.init()
  42798. return tx, nil
  42799. }
  42800. // SetID sets the value of the id field. Note that this
  42801. // operation is only accepted on creation of WxCard entities.
  42802. func (m *WxCardMutation) SetID(id uint64) {
  42803. m.id = &id
  42804. }
  42805. // ID returns the ID value in the mutation. Note that the ID is only available
  42806. // if it was provided to the builder or after it was returned from the database.
  42807. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  42808. if m.id == nil {
  42809. return
  42810. }
  42811. return *m.id, true
  42812. }
  42813. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42814. // That means, if the mutation is applied within a transaction with an isolation level such
  42815. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42816. // or updated by the mutation.
  42817. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  42818. switch {
  42819. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42820. id, exists := m.ID()
  42821. if exists {
  42822. return []uint64{id}, nil
  42823. }
  42824. fallthrough
  42825. case m.op.Is(OpUpdate | OpDelete):
  42826. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  42827. default:
  42828. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42829. }
  42830. }
  42831. // SetCreatedAt sets the "created_at" field.
  42832. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  42833. m.created_at = &t
  42834. }
  42835. // CreatedAt returns the value of the "created_at" field in the mutation.
  42836. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  42837. v := m.created_at
  42838. if v == nil {
  42839. return
  42840. }
  42841. return *v, true
  42842. }
  42843. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  42844. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42846. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42847. if !m.op.Is(OpUpdateOne) {
  42848. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42849. }
  42850. if m.id == nil || m.oldValue == nil {
  42851. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42852. }
  42853. oldValue, err := m.oldValue(ctx)
  42854. if err != nil {
  42855. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42856. }
  42857. return oldValue.CreatedAt, nil
  42858. }
  42859. // ResetCreatedAt resets all changes to the "created_at" field.
  42860. func (m *WxCardMutation) ResetCreatedAt() {
  42861. m.created_at = nil
  42862. }
  42863. // SetUpdatedAt sets the "updated_at" field.
  42864. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  42865. m.updated_at = &t
  42866. }
  42867. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42868. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  42869. v := m.updated_at
  42870. if v == nil {
  42871. return
  42872. }
  42873. return *v, true
  42874. }
  42875. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  42876. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42878. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42879. if !m.op.Is(OpUpdateOne) {
  42880. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42881. }
  42882. if m.id == nil || m.oldValue == nil {
  42883. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42884. }
  42885. oldValue, err := m.oldValue(ctx)
  42886. if err != nil {
  42887. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42888. }
  42889. return oldValue.UpdatedAt, nil
  42890. }
  42891. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42892. func (m *WxCardMutation) ResetUpdatedAt() {
  42893. m.updated_at = nil
  42894. }
  42895. // SetDeletedAt sets the "deleted_at" field.
  42896. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  42897. m.deleted_at = &t
  42898. }
  42899. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42900. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  42901. v := m.deleted_at
  42902. if v == nil {
  42903. return
  42904. }
  42905. return *v, true
  42906. }
  42907. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  42908. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42910. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42911. if !m.op.Is(OpUpdateOne) {
  42912. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42913. }
  42914. if m.id == nil || m.oldValue == nil {
  42915. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42916. }
  42917. oldValue, err := m.oldValue(ctx)
  42918. if err != nil {
  42919. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42920. }
  42921. return oldValue.DeletedAt, nil
  42922. }
  42923. // ClearDeletedAt clears the value of the "deleted_at" field.
  42924. func (m *WxCardMutation) ClearDeletedAt() {
  42925. m.deleted_at = nil
  42926. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  42927. }
  42928. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42929. func (m *WxCardMutation) DeletedAtCleared() bool {
  42930. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  42931. return ok
  42932. }
  42933. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42934. func (m *WxCardMutation) ResetDeletedAt() {
  42935. m.deleted_at = nil
  42936. delete(m.clearedFields, wxcard.FieldDeletedAt)
  42937. }
  42938. // SetUserID sets the "user_id" field.
  42939. func (m *WxCardMutation) SetUserID(u uint64) {
  42940. m.user_id = &u
  42941. m.adduser_id = nil
  42942. }
  42943. // UserID returns the value of the "user_id" field in the mutation.
  42944. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  42945. v := m.user_id
  42946. if v == nil {
  42947. return
  42948. }
  42949. return *v, true
  42950. }
  42951. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  42952. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42954. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42955. if !m.op.Is(OpUpdateOne) {
  42956. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42957. }
  42958. if m.id == nil || m.oldValue == nil {
  42959. return v, errors.New("OldUserID requires an ID field in the mutation")
  42960. }
  42961. oldValue, err := m.oldValue(ctx)
  42962. if err != nil {
  42963. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42964. }
  42965. return oldValue.UserID, nil
  42966. }
  42967. // AddUserID adds u to the "user_id" field.
  42968. func (m *WxCardMutation) AddUserID(u int64) {
  42969. if m.adduser_id != nil {
  42970. *m.adduser_id += u
  42971. } else {
  42972. m.adduser_id = &u
  42973. }
  42974. }
  42975. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42976. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  42977. v := m.adduser_id
  42978. if v == nil {
  42979. return
  42980. }
  42981. return *v, true
  42982. }
  42983. // ClearUserID clears the value of the "user_id" field.
  42984. func (m *WxCardMutation) ClearUserID() {
  42985. m.user_id = nil
  42986. m.adduser_id = nil
  42987. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  42988. }
  42989. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42990. func (m *WxCardMutation) UserIDCleared() bool {
  42991. _, ok := m.clearedFields[wxcard.FieldUserID]
  42992. return ok
  42993. }
  42994. // ResetUserID resets all changes to the "user_id" field.
  42995. func (m *WxCardMutation) ResetUserID() {
  42996. m.user_id = nil
  42997. m.adduser_id = nil
  42998. delete(m.clearedFields, wxcard.FieldUserID)
  42999. }
  43000. // SetWxUserID sets the "wx_user_id" field.
  43001. func (m *WxCardMutation) SetWxUserID(u uint64) {
  43002. m.wx_user_id = &u
  43003. m.addwx_user_id = nil
  43004. }
  43005. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  43006. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  43007. v := m.wx_user_id
  43008. if v == nil {
  43009. return
  43010. }
  43011. return *v, true
  43012. }
  43013. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  43014. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43016. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  43017. if !m.op.Is(OpUpdateOne) {
  43018. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  43019. }
  43020. if m.id == nil || m.oldValue == nil {
  43021. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  43022. }
  43023. oldValue, err := m.oldValue(ctx)
  43024. if err != nil {
  43025. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  43026. }
  43027. return oldValue.WxUserID, nil
  43028. }
  43029. // AddWxUserID adds u to the "wx_user_id" field.
  43030. func (m *WxCardMutation) AddWxUserID(u int64) {
  43031. if m.addwx_user_id != nil {
  43032. *m.addwx_user_id += u
  43033. } else {
  43034. m.addwx_user_id = &u
  43035. }
  43036. }
  43037. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  43038. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  43039. v := m.addwx_user_id
  43040. if v == nil {
  43041. return
  43042. }
  43043. return *v, true
  43044. }
  43045. // ClearWxUserID clears the value of the "wx_user_id" field.
  43046. func (m *WxCardMutation) ClearWxUserID() {
  43047. m.wx_user_id = nil
  43048. m.addwx_user_id = nil
  43049. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  43050. }
  43051. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  43052. func (m *WxCardMutation) WxUserIDCleared() bool {
  43053. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  43054. return ok
  43055. }
  43056. // ResetWxUserID resets all changes to the "wx_user_id" field.
  43057. func (m *WxCardMutation) ResetWxUserID() {
  43058. m.wx_user_id = nil
  43059. m.addwx_user_id = nil
  43060. delete(m.clearedFields, wxcard.FieldWxUserID)
  43061. }
  43062. // SetAvatar sets the "avatar" field.
  43063. func (m *WxCardMutation) SetAvatar(s string) {
  43064. m.avatar = &s
  43065. }
  43066. // Avatar returns the value of the "avatar" field in the mutation.
  43067. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  43068. v := m.avatar
  43069. if v == nil {
  43070. return
  43071. }
  43072. return *v, true
  43073. }
  43074. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  43075. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43077. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43078. if !m.op.Is(OpUpdateOne) {
  43079. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43080. }
  43081. if m.id == nil || m.oldValue == nil {
  43082. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43083. }
  43084. oldValue, err := m.oldValue(ctx)
  43085. if err != nil {
  43086. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43087. }
  43088. return oldValue.Avatar, nil
  43089. }
  43090. // ResetAvatar resets all changes to the "avatar" field.
  43091. func (m *WxCardMutation) ResetAvatar() {
  43092. m.avatar = nil
  43093. }
  43094. // SetLogo sets the "logo" field.
  43095. func (m *WxCardMutation) SetLogo(s string) {
  43096. m.logo = &s
  43097. }
  43098. // Logo returns the value of the "logo" field in the mutation.
  43099. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43100. v := m.logo
  43101. if v == nil {
  43102. return
  43103. }
  43104. return *v, true
  43105. }
  43106. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43107. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43109. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43110. if !m.op.Is(OpUpdateOne) {
  43111. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43112. }
  43113. if m.id == nil || m.oldValue == nil {
  43114. return v, errors.New("OldLogo requires an ID field in the mutation")
  43115. }
  43116. oldValue, err := m.oldValue(ctx)
  43117. if err != nil {
  43118. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43119. }
  43120. return oldValue.Logo, nil
  43121. }
  43122. // ResetLogo resets all changes to the "logo" field.
  43123. func (m *WxCardMutation) ResetLogo() {
  43124. m.logo = nil
  43125. }
  43126. // SetName sets the "name" field.
  43127. func (m *WxCardMutation) SetName(s string) {
  43128. m.name = &s
  43129. }
  43130. // Name returns the value of the "name" field in the mutation.
  43131. func (m *WxCardMutation) Name() (r string, exists bool) {
  43132. v := m.name
  43133. if v == nil {
  43134. return
  43135. }
  43136. return *v, true
  43137. }
  43138. // OldName returns the old "name" field's value of the WxCard entity.
  43139. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43141. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43142. if !m.op.Is(OpUpdateOne) {
  43143. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43144. }
  43145. if m.id == nil || m.oldValue == nil {
  43146. return v, errors.New("OldName requires an ID field in the mutation")
  43147. }
  43148. oldValue, err := m.oldValue(ctx)
  43149. if err != nil {
  43150. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43151. }
  43152. return oldValue.Name, nil
  43153. }
  43154. // ResetName resets all changes to the "name" field.
  43155. func (m *WxCardMutation) ResetName() {
  43156. m.name = nil
  43157. }
  43158. // SetCompany sets the "company" field.
  43159. func (m *WxCardMutation) SetCompany(s string) {
  43160. m.company = &s
  43161. }
  43162. // Company returns the value of the "company" field in the mutation.
  43163. func (m *WxCardMutation) Company() (r string, exists bool) {
  43164. v := m.company
  43165. if v == nil {
  43166. return
  43167. }
  43168. return *v, true
  43169. }
  43170. // OldCompany returns the old "company" field's value of the WxCard entity.
  43171. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43173. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43174. if !m.op.Is(OpUpdateOne) {
  43175. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43176. }
  43177. if m.id == nil || m.oldValue == nil {
  43178. return v, errors.New("OldCompany requires an ID field in the mutation")
  43179. }
  43180. oldValue, err := m.oldValue(ctx)
  43181. if err != nil {
  43182. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43183. }
  43184. return oldValue.Company, nil
  43185. }
  43186. // ResetCompany resets all changes to the "company" field.
  43187. func (m *WxCardMutation) ResetCompany() {
  43188. m.company = nil
  43189. }
  43190. // SetAddress sets the "address" field.
  43191. func (m *WxCardMutation) SetAddress(s string) {
  43192. m.address = &s
  43193. }
  43194. // Address returns the value of the "address" field in the mutation.
  43195. func (m *WxCardMutation) Address() (r string, exists bool) {
  43196. v := m.address
  43197. if v == nil {
  43198. return
  43199. }
  43200. return *v, true
  43201. }
  43202. // OldAddress returns the old "address" field's value of the WxCard entity.
  43203. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43205. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43206. if !m.op.Is(OpUpdateOne) {
  43207. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43208. }
  43209. if m.id == nil || m.oldValue == nil {
  43210. return v, errors.New("OldAddress requires an ID field in the mutation")
  43211. }
  43212. oldValue, err := m.oldValue(ctx)
  43213. if err != nil {
  43214. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43215. }
  43216. return oldValue.Address, nil
  43217. }
  43218. // ResetAddress resets all changes to the "address" field.
  43219. func (m *WxCardMutation) ResetAddress() {
  43220. m.address = nil
  43221. }
  43222. // SetPhone sets the "phone" field.
  43223. func (m *WxCardMutation) SetPhone(s string) {
  43224. m.phone = &s
  43225. }
  43226. // Phone returns the value of the "phone" field in the mutation.
  43227. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43228. v := m.phone
  43229. if v == nil {
  43230. return
  43231. }
  43232. return *v, true
  43233. }
  43234. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43235. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43237. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43238. if !m.op.Is(OpUpdateOne) {
  43239. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43240. }
  43241. if m.id == nil || m.oldValue == nil {
  43242. return v, errors.New("OldPhone requires an ID field in the mutation")
  43243. }
  43244. oldValue, err := m.oldValue(ctx)
  43245. if err != nil {
  43246. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43247. }
  43248. return oldValue.Phone, nil
  43249. }
  43250. // ResetPhone resets all changes to the "phone" field.
  43251. func (m *WxCardMutation) ResetPhone() {
  43252. m.phone = nil
  43253. }
  43254. // SetOfficialAccount sets the "official_account" field.
  43255. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43256. m.official_account = &s
  43257. }
  43258. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43259. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43260. v := m.official_account
  43261. if v == nil {
  43262. return
  43263. }
  43264. return *v, true
  43265. }
  43266. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43267. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43269. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43270. if !m.op.Is(OpUpdateOne) {
  43271. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43272. }
  43273. if m.id == nil || m.oldValue == nil {
  43274. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43275. }
  43276. oldValue, err := m.oldValue(ctx)
  43277. if err != nil {
  43278. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43279. }
  43280. return oldValue.OfficialAccount, nil
  43281. }
  43282. // ResetOfficialAccount resets all changes to the "official_account" field.
  43283. func (m *WxCardMutation) ResetOfficialAccount() {
  43284. m.official_account = nil
  43285. }
  43286. // SetWechatAccount sets the "wechat_account" field.
  43287. func (m *WxCardMutation) SetWechatAccount(s string) {
  43288. m.wechat_account = &s
  43289. }
  43290. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43291. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43292. v := m.wechat_account
  43293. if v == nil {
  43294. return
  43295. }
  43296. return *v, true
  43297. }
  43298. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43299. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43301. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43302. if !m.op.Is(OpUpdateOne) {
  43303. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43304. }
  43305. if m.id == nil || m.oldValue == nil {
  43306. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43307. }
  43308. oldValue, err := m.oldValue(ctx)
  43309. if err != nil {
  43310. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43311. }
  43312. return oldValue.WechatAccount, nil
  43313. }
  43314. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43315. func (m *WxCardMutation) ResetWechatAccount() {
  43316. m.wechat_account = nil
  43317. }
  43318. // SetEmail sets the "email" field.
  43319. func (m *WxCardMutation) SetEmail(s string) {
  43320. m.email = &s
  43321. }
  43322. // Email returns the value of the "email" field in the mutation.
  43323. func (m *WxCardMutation) Email() (r string, exists bool) {
  43324. v := m.email
  43325. if v == nil {
  43326. return
  43327. }
  43328. return *v, true
  43329. }
  43330. // OldEmail returns the old "email" field's value of the WxCard entity.
  43331. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43333. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43334. if !m.op.Is(OpUpdateOne) {
  43335. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43336. }
  43337. if m.id == nil || m.oldValue == nil {
  43338. return v, errors.New("OldEmail requires an ID field in the mutation")
  43339. }
  43340. oldValue, err := m.oldValue(ctx)
  43341. if err != nil {
  43342. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43343. }
  43344. return oldValue.Email, nil
  43345. }
  43346. // ClearEmail clears the value of the "email" field.
  43347. func (m *WxCardMutation) ClearEmail() {
  43348. m.email = nil
  43349. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43350. }
  43351. // EmailCleared returns if the "email" field was cleared in this mutation.
  43352. func (m *WxCardMutation) EmailCleared() bool {
  43353. _, ok := m.clearedFields[wxcard.FieldEmail]
  43354. return ok
  43355. }
  43356. // ResetEmail resets all changes to the "email" field.
  43357. func (m *WxCardMutation) ResetEmail() {
  43358. m.email = nil
  43359. delete(m.clearedFields, wxcard.FieldEmail)
  43360. }
  43361. // SetAPIBase sets the "api_base" field.
  43362. func (m *WxCardMutation) SetAPIBase(s string) {
  43363. m.api_base = &s
  43364. }
  43365. // APIBase returns the value of the "api_base" field in the mutation.
  43366. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43367. v := m.api_base
  43368. if v == nil {
  43369. return
  43370. }
  43371. return *v, true
  43372. }
  43373. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43374. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43376. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43377. if !m.op.Is(OpUpdateOne) {
  43378. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43379. }
  43380. if m.id == nil || m.oldValue == nil {
  43381. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43382. }
  43383. oldValue, err := m.oldValue(ctx)
  43384. if err != nil {
  43385. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43386. }
  43387. return oldValue.APIBase, nil
  43388. }
  43389. // ClearAPIBase clears the value of the "api_base" field.
  43390. func (m *WxCardMutation) ClearAPIBase() {
  43391. m.api_base = nil
  43392. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43393. }
  43394. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43395. func (m *WxCardMutation) APIBaseCleared() bool {
  43396. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43397. return ok
  43398. }
  43399. // ResetAPIBase resets all changes to the "api_base" field.
  43400. func (m *WxCardMutation) ResetAPIBase() {
  43401. m.api_base = nil
  43402. delete(m.clearedFields, wxcard.FieldAPIBase)
  43403. }
  43404. // SetAPIKey sets the "api_key" field.
  43405. func (m *WxCardMutation) SetAPIKey(s string) {
  43406. m.api_key = &s
  43407. }
  43408. // APIKey returns the value of the "api_key" field in the mutation.
  43409. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43410. v := m.api_key
  43411. if v == nil {
  43412. return
  43413. }
  43414. return *v, true
  43415. }
  43416. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43417. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43419. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43420. if !m.op.Is(OpUpdateOne) {
  43421. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43422. }
  43423. if m.id == nil || m.oldValue == nil {
  43424. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43425. }
  43426. oldValue, err := m.oldValue(ctx)
  43427. if err != nil {
  43428. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43429. }
  43430. return oldValue.APIKey, nil
  43431. }
  43432. // ClearAPIKey clears the value of the "api_key" field.
  43433. func (m *WxCardMutation) ClearAPIKey() {
  43434. m.api_key = nil
  43435. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43436. }
  43437. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43438. func (m *WxCardMutation) APIKeyCleared() bool {
  43439. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43440. return ok
  43441. }
  43442. // ResetAPIKey resets all changes to the "api_key" field.
  43443. func (m *WxCardMutation) ResetAPIKey() {
  43444. m.api_key = nil
  43445. delete(m.clearedFields, wxcard.FieldAPIKey)
  43446. }
  43447. // SetAiInfo sets the "ai_info" field.
  43448. func (m *WxCardMutation) SetAiInfo(s string) {
  43449. m.ai_info = &s
  43450. }
  43451. // AiInfo returns the value of the "ai_info" field in the mutation.
  43452. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43453. v := m.ai_info
  43454. if v == nil {
  43455. return
  43456. }
  43457. return *v, true
  43458. }
  43459. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43460. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43462. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43463. if !m.op.Is(OpUpdateOne) {
  43464. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43465. }
  43466. if m.id == nil || m.oldValue == nil {
  43467. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43468. }
  43469. oldValue, err := m.oldValue(ctx)
  43470. if err != nil {
  43471. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43472. }
  43473. return oldValue.AiInfo, nil
  43474. }
  43475. // ClearAiInfo clears the value of the "ai_info" field.
  43476. func (m *WxCardMutation) ClearAiInfo() {
  43477. m.ai_info = nil
  43478. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43479. }
  43480. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43481. func (m *WxCardMutation) AiInfoCleared() bool {
  43482. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43483. return ok
  43484. }
  43485. // ResetAiInfo resets all changes to the "ai_info" field.
  43486. func (m *WxCardMutation) ResetAiInfo() {
  43487. m.ai_info = nil
  43488. delete(m.clearedFields, wxcard.FieldAiInfo)
  43489. }
  43490. // SetIntro sets the "intro" field.
  43491. func (m *WxCardMutation) SetIntro(s string) {
  43492. m.intro = &s
  43493. }
  43494. // Intro returns the value of the "intro" field in the mutation.
  43495. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43496. v := m.intro
  43497. if v == nil {
  43498. return
  43499. }
  43500. return *v, true
  43501. }
  43502. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43503. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43505. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43506. if !m.op.Is(OpUpdateOne) {
  43507. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43508. }
  43509. if m.id == nil || m.oldValue == nil {
  43510. return v, errors.New("OldIntro requires an ID field in the mutation")
  43511. }
  43512. oldValue, err := m.oldValue(ctx)
  43513. if err != nil {
  43514. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43515. }
  43516. return oldValue.Intro, nil
  43517. }
  43518. // ClearIntro clears the value of the "intro" field.
  43519. func (m *WxCardMutation) ClearIntro() {
  43520. m.intro = nil
  43521. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43522. }
  43523. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43524. func (m *WxCardMutation) IntroCleared() bool {
  43525. _, ok := m.clearedFields[wxcard.FieldIntro]
  43526. return ok
  43527. }
  43528. // ResetIntro resets all changes to the "intro" field.
  43529. func (m *WxCardMutation) ResetIntro() {
  43530. m.intro = nil
  43531. delete(m.clearedFields, wxcard.FieldIntro)
  43532. }
  43533. // Where appends a list predicates to the WxCardMutation builder.
  43534. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43535. m.predicates = append(m.predicates, ps...)
  43536. }
  43537. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43538. // users can use type-assertion to append predicates that do not depend on any generated package.
  43539. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43540. p := make([]predicate.WxCard, len(ps))
  43541. for i := range ps {
  43542. p[i] = ps[i]
  43543. }
  43544. m.Where(p...)
  43545. }
  43546. // Op returns the operation name.
  43547. func (m *WxCardMutation) Op() Op {
  43548. return m.op
  43549. }
  43550. // SetOp allows setting the mutation operation.
  43551. func (m *WxCardMutation) SetOp(op Op) {
  43552. m.op = op
  43553. }
  43554. // Type returns the node type of this mutation (WxCard).
  43555. func (m *WxCardMutation) Type() string {
  43556. return m.typ
  43557. }
  43558. // Fields returns all fields that were changed during this mutation. Note that in
  43559. // order to get all numeric fields that were incremented/decremented, call
  43560. // AddedFields().
  43561. func (m *WxCardMutation) Fields() []string {
  43562. fields := make([]string, 0, 18)
  43563. if m.created_at != nil {
  43564. fields = append(fields, wxcard.FieldCreatedAt)
  43565. }
  43566. if m.updated_at != nil {
  43567. fields = append(fields, wxcard.FieldUpdatedAt)
  43568. }
  43569. if m.deleted_at != nil {
  43570. fields = append(fields, wxcard.FieldDeletedAt)
  43571. }
  43572. if m.user_id != nil {
  43573. fields = append(fields, wxcard.FieldUserID)
  43574. }
  43575. if m.wx_user_id != nil {
  43576. fields = append(fields, wxcard.FieldWxUserID)
  43577. }
  43578. if m.avatar != nil {
  43579. fields = append(fields, wxcard.FieldAvatar)
  43580. }
  43581. if m.logo != nil {
  43582. fields = append(fields, wxcard.FieldLogo)
  43583. }
  43584. if m.name != nil {
  43585. fields = append(fields, wxcard.FieldName)
  43586. }
  43587. if m.company != nil {
  43588. fields = append(fields, wxcard.FieldCompany)
  43589. }
  43590. if m.address != nil {
  43591. fields = append(fields, wxcard.FieldAddress)
  43592. }
  43593. if m.phone != nil {
  43594. fields = append(fields, wxcard.FieldPhone)
  43595. }
  43596. if m.official_account != nil {
  43597. fields = append(fields, wxcard.FieldOfficialAccount)
  43598. }
  43599. if m.wechat_account != nil {
  43600. fields = append(fields, wxcard.FieldWechatAccount)
  43601. }
  43602. if m.email != nil {
  43603. fields = append(fields, wxcard.FieldEmail)
  43604. }
  43605. if m.api_base != nil {
  43606. fields = append(fields, wxcard.FieldAPIBase)
  43607. }
  43608. if m.api_key != nil {
  43609. fields = append(fields, wxcard.FieldAPIKey)
  43610. }
  43611. if m.ai_info != nil {
  43612. fields = append(fields, wxcard.FieldAiInfo)
  43613. }
  43614. if m.intro != nil {
  43615. fields = append(fields, wxcard.FieldIntro)
  43616. }
  43617. return fields
  43618. }
  43619. // Field returns the value of a field with the given name. The second boolean
  43620. // return value indicates that this field was not set, or was not defined in the
  43621. // schema.
  43622. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43623. switch name {
  43624. case wxcard.FieldCreatedAt:
  43625. return m.CreatedAt()
  43626. case wxcard.FieldUpdatedAt:
  43627. return m.UpdatedAt()
  43628. case wxcard.FieldDeletedAt:
  43629. return m.DeletedAt()
  43630. case wxcard.FieldUserID:
  43631. return m.UserID()
  43632. case wxcard.FieldWxUserID:
  43633. return m.WxUserID()
  43634. case wxcard.FieldAvatar:
  43635. return m.Avatar()
  43636. case wxcard.FieldLogo:
  43637. return m.Logo()
  43638. case wxcard.FieldName:
  43639. return m.Name()
  43640. case wxcard.FieldCompany:
  43641. return m.Company()
  43642. case wxcard.FieldAddress:
  43643. return m.Address()
  43644. case wxcard.FieldPhone:
  43645. return m.Phone()
  43646. case wxcard.FieldOfficialAccount:
  43647. return m.OfficialAccount()
  43648. case wxcard.FieldWechatAccount:
  43649. return m.WechatAccount()
  43650. case wxcard.FieldEmail:
  43651. return m.Email()
  43652. case wxcard.FieldAPIBase:
  43653. return m.APIBase()
  43654. case wxcard.FieldAPIKey:
  43655. return m.APIKey()
  43656. case wxcard.FieldAiInfo:
  43657. return m.AiInfo()
  43658. case wxcard.FieldIntro:
  43659. return m.Intro()
  43660. }
  43661. return nil, false
  43662. }
  43663. // OldField returns the old value of the field from the database. An error is
  43664. // returned if the mutation operation is not UpdateOne, or the query to the
  43665. // database failed.
  43666. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43667. switch name {
  43668. case wxcard.FieldCreatedAt:
  43669. return m.OldCreatedAt(ctx)
  43670. case wxcard.FieldUpdatedAt:
  43671. return m.OldUpdatedAt(ctx)
  43672. case wxcard.FieldDeletedAt:
  43673. return m.OldDeletedAt(ctx)
  43674. case wxcard.FieldUserID:
  43675. return m.OldUserID(ctx)
  43676. case wxcard.FieldWxUserID:
  43677. return m.OldWxUserID(ctx)
  43678. case wxcard.FieldAvatar:
  43679. return m.OldAvatar(ctx)
  43680. case wxcard.FieldLogo:
  43681. return m.OldLogo(ctx)
  43682. case wxcard.FieldName:
  43683. return m.OldName(ctx)
  43684. case wxcard.FieldCompany:
  43685. return m.OldCompany(ctx)
  43686. case wxcard.FieldAddress:
  43687. return m.OldAddress(ctx)
  43688. case wxcard.FieldPhone:
  43689. return m.OldPhone(ctx)
  43690. case wxcard.FieldOfficialAccount:
  43691. return m.OldOfficialAccount(ctx)
  43692. case wxcard.FieldWechatAccount:
  43693. return m.OldWechatAccount(ctx)
  43694. case wxcard.FieldEmail:
  43695. return m.OldEmail(ctx)
  43696. case wxcard.FieldAPIBase:
  43697. return m.OldAPIBase(ctx)
  43698. case wxcard.FieldAPIKey:
  43699. return m.OldAPIKey(ctx)
  43700. case wxcard.FieldAiInfo:
  43701. return m.OldAiInfo(ctx)
  43702. case wxcard.FieldIntro:
  43703. return m.OldIntro(ctx)
  43704. }
  43705. return nil, fmt.Errorf("unknown WxCard field %s", name)
  43706. }
  43707. // SetField sets the value of a field with the given name. It returns an error if
  43708. // the field is not defined in the schema, or if the type mismatched the field
  43709. // type.
  43710. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  43711. switch name {
  43712. case wxcard.FieldCreatedAt:
  43713. v, ok := value.(time.Time)
  43714. if !ok {
  43715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43716. }
  43717. m.SetCreatedAt(v)
  43718. return nil
  43719. case wxcard.FieldUpdatedAt:
  43720. v, ok := value.(time.Time)
  43721. if !ok {
  43722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43723. }
  43724. m.SetUpdatedAt(v)
  43725. return nil
  43726. case wxcard.FieldDeletedAt:
  43727. v, ok := value.(time.Time)
  43728. if !ok {
  43729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43730. }
  43731. m.SetDeletedAt(v)
  43732. return nil
  43733. case wxcard.FieldUserID:
  43734. v, ok := value.(uint64)
  43735. if !ok {
  43736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43737. }
  43738. m.SetUserID(v)
  43739. return nil
  43740. case wxcard.FieldWxUserID:
  43741. v, ok := value.(uint64)
  43742. if !ok {
  43743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43744. }
  43745. m.SetWxUserID(v)
  43746. return nil
  43747. case wxcard.FieldAvatar:
  43748. v, ok := value.(string)
  43749. if !ok {
  43750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43751. }
  43752. m.SetAvatar(v)
  43753. return nil
  43754. case wxcard.FieldLogo:
  43755. v, ok := value.(string)
  43756. if !ok {
  43757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43758. }
  43759. m.SetLogo(v)
  43760. return nil
  43761. case wxcard.FieldName:
  43762. v, ok := value.(string)
  43763. if !ok {
  43764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43765. }
  43766. m.SetName(v)
  43767. return nil
  43768. case wxcard.FieldCompany:
  43769. v, ok := value.(string)
  43770. if !ok {
  43771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43772. }
  43773. m.SetCompany(v)
  43774. return nil
  43775. case wxcard.FieldAddress:
  43776. v, ok := value.(string)
  43777. if !ok {
  43778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43779. }
  43780. m.SetAddress(v)
  43781. return nil
  43782. case wxcard.FieldPhone:
  43783. v, ok := value.(string)
  43784. if !ok {
  43785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43786. }
  43787. m.SetPhone(v)
  43788. return nil
  43789. case wxcard.FieldOfficialAccount:
  43790. v, ok := value.(string)
  43791. if !ok {
  43792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43793. }
  43794. m.SetOfficialAccount(v)
  43795. return nil
  43796. case wxcard.FieldWechatAccount:
  43797. v, ok := value.(string)
  43798. if !ok {
  43799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43800. }
  43801. m.SetWechatAccount(v)
  43802. return nil
  43803. case wxcard.FieldEmail:
  43804. v, ok := value.(string)
  43805. if !ok {
  43806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43807. }
  43808. m.SetEmail(v)
  43809. return nil
  43810. case wxcard.FieldAPIBase:
  43811. v, ok := value.(string)
  43812. if !ok {
  43813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43814. }
  43815. m.SetAPIBase(v)
  43816. return nil
  43817. case wxcard.FieldAPIKey:
  43818. v, ok := value.(string)
  43819. if !ok {
  43820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43821. }
  43822. m.SetAPIKey(v)
  43823. return nil
  43824. case wxcard.FieldAiInfo:
  43825. v, ok := value.(string)
  43826. if !ok {
  43827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43828. }
  43829. m.SetAiInfo(v)
  43830. return nil
  43831. case wxcard.FieldIntro:
  43832. v, ok := value.(string)
  43833. if !ok {
  43834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43835. }
  43836. m.SetIntro(v)
  43837. return nil
  43838. }
  43839. return fmt.Errorf("unknown WxCard field %s", name)
  43840. }
  43841. // AddedFields returns all numeric fields that were incremented/decremented during
  43842. // this mutation.
  43843. func (m *WxCardMutation) AddedFields() []string {
  43844. var fields []string
  43845. if m.adduser_id != nil {
  43846. fields = append(fields, wxcard.FieldUserID)
  43847. }
  43848. if m.addwx_user_id != nil {
  43849. fields = append(fields, wxcard.FieldWxUserID)
  43850. }
  43851. return fields
  43852. }
  43853. // AddedField returns the numeric value that was incremented/decremented on a field
  43854. // with the given name. The second boolean return value indicates that this field
  43855. // was not set, or was not defined in the schema.
  43856. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  43857. switch name {
  43858. case wxcard.FieldUserID:
  43859. return m.AddedUserID()
  43860. case wxcard.FieldWxUserID:
  43861. return m.AddedWxUserID()
  43862. }
  43863. return nil, false
  43864. }
  43865. // AddField adds the value to the field with the given name. It returns an error if
  43866. // the field is not defined in the schema, or if the type mismatched the field
  43867. // type.
  43868. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  43869. switch name {
  43870. case wxcard.FieldUserID:
  43871. v, ok := value.(int64)
  43872. if !ok {
  43873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43874. }
  43875. m.AddUserID(v)
  43876. return nil
  43877. case wxcard.FieldWxUserID:
  43878. v, ok := value.(int64)
  43879. if !ok {
  43880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43881. }
  43882. m.AddWxUserID(v)
  43883. return nil
  43884. }
  43885. return fmt.Errorf("unknown WxCard numeric field %s", name)
  43886. }
  43887. // ClearedFields returns all nullable fields that were cleared during this
  43888. // mutation.
  43889. func (m *WxCardMutation) ClearedFields() []string {
  43890. var fields []string
  43891. if m.FieldCleared(wxcard.FieldDeletedAt) {
  43892. fields = append(fields, wxcard.FieldDeletedAt)
  43893. }
  43894. if m.FieldCleared(wxcard.FieldUserID) {
  43895. fields = append(fields, wxcard.FieldUserID)
  43896. }
  43897. if m.FieldCleared(wxcard.FieldWxUserID) {
  43898. fields = append(fields, wxcard.FieldWxUserID)
  43899. }
  43900. if m.FieldCleared(wxcard.FieldEmail) {
  43901. fields = append(fields, wxcard.FieldEmail)
  43902. }
  43903. if m.FieldCleared(wxcard.FieldAPIBase) {
  43904. fields = append(fields, wxcard.FieldAPIBase)
  43905. }
  43906. if m.FieldCleared(wxcard.FieldAPIKey) {
  43907. fields = append(fields, wxcard.FieldAPIKey)
  43908. }
  43909. if m.FieldCleared(wxcard.FieldAiInfo) {
  43910. fields = append(fields, wxcard.FieldAiInfo)
  43911. }
  43912. if m.FieldCleared(wxcard.FieldIntro) {
  43913. fields = append(fields, wxcard.FieldIntro)
  43914. }
  43915. return fields
  43916. }
  43917. // FieldCleared returns a boolean indicating if a field with the given name was
  43918. // cleared in this mutation.
  43919. func (m *WxCardMutation) FieldCleared(name string) bool {
  43920. _, ok := m.clearedFields[name]
  43921. return ok
  43922. }
  43923. // ClearField clears the value of the field with the given name. It returns an
  43924. // error if the field is not defined in the schema.
  43925. func (m *WxCardMutation) ClearField(name string) error {
  43926. switch name {
  43927. case wxcard.FieldDeletedAt:
  43928. m.ClearDeletedAt()
  43929. return nil
  43930. case wxcard.FieldUserID:
  43931. m.ClearUserID()
  43932. return nil
  43933. case wxcard.FieldWxUserID:
  43934. m.ClearWxUserID()
  43935. return nil
  43936. case wxcard.FieldEmail:
  43937. m.ClearEmail()
  43938. return nil
  43939. case wxcard.FieldAPIBase:
  43940. m.ClearAPIBase()
  43941. return nil
  43942. case wxcard.FieldAPIKey:
  43943. m.ClearAPIKey()
  43944. return nil
  43945. case wxcard.FieldAiInfo:
  43946. m.ClearAiInfo()
  43947. return nil
  43948. case wxcard.FieldIntro:
  43949. m.ClearIntro()
  43950. return nil
  43951. }
  43952. return fmt.Errorf("unknown WxCard nullable field %s", name)
  43953. }
  43954. // ResetField resets all changes in the mutation for the field with the given name.
  43955. // It returns an error if the field is not defined in the schema.
  43956. func (m *WxCardMutation) ResetField(name string) error {
  43957. switch name {
  43958. case wxcard.FieldCreatedAt:
  43959. m.ResetCreatedAt()
  43960. return nil
  43961. case wxcard.FieldUpdatedAt:
  43962. m.ResetUpdatedAt()
  43963. return nil
  43964. case wxcard.FieldDeletedAt:
  43965. m.ResetDeletedAt()
  43966. return nil
  43967. case wxcard.FieldUserID:
  43968. m.ResetUserID()
  43969. return nil
  43970. case wxcard.FieldWxUserID:
  43971. m.ResetWxUserID()
  43972. return nil
  43973. case wxcard.FieldAvatar:
  43974. m.ResetAvatar()
  43975. return nil
  43976. case wxcard.FieldLogo:
  43977. m.ResetLogo()
  43978. return nil
  43979. case wxcard.FieldName:
  43980. m.ResetName()
  43981. return nil
  43982. case wxcard.FieldCompany:
  43983. m.ResetCompany()
  43984. return nil
  43985. case wxcard.FieldAddress:
  43986. m.ResetAddress()
  43987. return nil
  43988. case wxcard.FieldPhone:
  43989. m.ResetPhone()
  43990. return nil
  43991. case wxcard.FieldOfficialAccount:
  43992. m.ResetOfficialAccount()
  43993. return nil
  43994. case wxcard.FieldWechatAccount:
  43995. m.ResetWechatAccount()
  43996. return nil
  43997. case wxcard.FieldEmail:
  43998. m.ResetEmail()
  43999. return nil
  44000. case wxcard.FieldAPIBase:
  44001. m.ResetAPIBase()
  44002. return nil
  44003. case wxcard.FieldAPIKey:
  44004. m.ResetAPIKey()
  44005. return nil
  44006. case wxcard.FieldAiInfo:
  44007. m.ResetAiInfo()
  44008. return nil
  44009. case wxcard.FieldIntro:
  44010. m.ResetIntro()
  44011. return nil
  44012. }
  44013. return fmt.Errorf("unknown WxCard field %s", name)
  44014. }
  44015. // AddedEdges returns all edge names that were set/added in this mutation.
  44016. func (m *WxCardMutation) AddedEdges() []string {
  44017. edges := make([]string, 0, 0)
  44018. return edges
  44019. }
  44020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44021. // name in this mutation.
  44022. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  44023. return nil
  44024. }
  44025. // RemovedEdges returns all edge names that were removed in this mutation.
  44026. func (m *WxCardMutation) RemovedEdges() []string {
  44027. edges := make([]string, 0, 0)
  44028. return edges
  44029. }
  44030. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44031. // the given name in this mutation.
  44032. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  44033. return nil
  44034. }
  44035. // ClearedEdges returns all edge names that were cleared in this mutation.
  44036. func (m *WxCardMutation) ClearedEdges() []string {
  44037. edges := make([]string, 0, 0)
  44038. return edges
  44039. }
  44040. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44041. // was cleared in this mutation.
  44042. func (m *WxCardMutation) EdgeCleared(name string) bool {
  44043. return false
  44044. }
  44045. // ClearEdge clears the value of the edge with the given name. It returns an error
  44046. // if that edge is not defined in the schema.
  44047. func (m *WxCardMutation) ClearEdge(name string) error {
  44048. return fmt.Errorf("unknown WxCard unique edge %s", name)
  44049. }
  44050. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44051. // It returns an error if the edge is not defined in the schema.
  44052. func (m *WxCardMutation) ResetEdge(name string) error {
  44053. return fmt.Errorf("unknown WxCard edge %s", name)
  44054. }
  44055. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  44056. type WxCardUserMutation struct {
  44057. config
  44058. op Op
  44059. typ string
  44060. id *uint64
  44061. created_at *time.Time
  44062. updated_at *time.Time
  44063. deleted_at *time.Time
  44064. wxid *string
  44065. account *string
  44066. avatar *string
  44067. nickname *string
  44068. remark *string
  44069. phone *string
  44070. open_id *string
  44071. union_id *string
  44072. session_key *string
  44073. is_vip *int
  44074. addis_vip *int
  44075. clearedFields map[string]struct{}
  44076. done bool
  44077. oldValue func(context.Context) (*WxCardUser, error)
  44078. predicates []predicate.WxCardUser
  44079. }
  44080. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44081. // wxcarduserOption allows management of the mutation configuration using functional options.
  44082. type wxcarduserOption func(*WxCardUserMutation)
  44083. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44084. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44085. m := &WxCardUserMutation{
  44086. config: c,
  44087. op: op,
  44088. typ: TypeWxCardUser,
  44089. clearedFields: make(map[string]struct{}),
  44090. }
  44091. for _, opt := range opts {
  44092. opt(m)
  44093. }
  44094. return m
  44095. }
  44096. // withWxCardUserID sets the ID field of the mutation.
  44097. func withWxCardUserID(id uint64) wxcarduserOption {
  44098. return func(m *WxCardUserMutation) {
  44099. var (
  44100. err error
  44101. once sync.Once
  44102. value *WxCardUser
  44103. )
  44104. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44105. once.Do(func() {
  44106. if m.done {
  44107. err = errors.New("querying old values post mutation is not allowed")
  44108. } else {
  44109. value, err = m.Client().WxCardUser.Get(ctx, id)
  44110. }
  44111. })
  44112. return value, err
  44113. }
  44114. m.id = &id
  44115. }
  44116. }
  44117. // withWxCardUser sets the old WxCardUser of the mutation.
  44118. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44119. return func(m *WxCardUserMutation) {
  44120. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44121. return node, nil
  44122. }
  44123. m.id = &node.ID
  44124. }
  44125. }
  44126. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44127. // executed in a transaction (ent.Tx), a transactional client is returned.
  44128. func (m WxCardUserMutation) Client() *Client {
  44129. client := &Client{config: m.config}
  44130. client.init()
  44131. return client
  44132. }
  44133. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44134. // it returns an error otherwise.
  44135. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44136. if _, ok := m.driver.(*txDriver); !ok {
  44137. return nil, errors.New("ent: mutation is not running in a transaction")
  44138. }
  44139. tx := &Tx{config: m.config}
  44140. tx.init()
  44141. return tx, nil
  44142. }
  44143. // SetID sets the value of the id field. Note that this
  44144. // operation is only accepted on creation of WxCardUser entities.
  44145. func (m *WxCardUserMutation) SetID(id uint64) {
  44146. m.id = &id
  44147. }
  44148. // ID returns the ID value in the mutation. Note that the ID is only available
  44149. // if it was provided to the builder or after it was returned from the database.
  44150. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44151. if m.id == nil {
  44152. return
  44153. }
  44154. return *m.id, true
  44155. }
  44156. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44157. // That means, if the mutation is applied within a transaction with an isolation level such
  44158. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44159. // or updated by the mutation.
  44160. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44161. switch {
  44162. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44163. id, exists := m.ID()
  44164. if exists {
  44165. return []uint64{id}, nil
  44166. }
  44167. fallthrough
  44168. case m.op.Is(OpUpdate | OpDelete):
  44169. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44170. default:
  44171. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44172. }
  44173. }
  44174. // SetCreatedAt sets the "created_at" field.
  44175. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44176. m.created_at = &t
  44177. }
  44178. // CreatedAt returns the value of the "created_at" field in the mutation.
  44179. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44180. v := m.created_at
  44181. if v == nil {
  44182. return
  44183. }
  44184. return *v, true
  44185. }
  44186. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44187. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44189. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44190. if !m.op.Is(OpUpdateOne) {
  44191. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44192. }
  44193. if m.id == nil || m.oldValue == nil {
  44194. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44195. }
  44196. oldValue, err := m.oldValue(ctx)
  44197. if err != nil {
  44198. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44199. }
  44200. return oldValue.CreatedAt, nil
  44201. }
  44202. // ResetCreatedAt resets all changes to the "created_at" field.
  44203. func (m *WxCardUserMutation) ResetCreatedAt() {
  44204. m.created_at = nil
  44205. }
  44206. // SetUpdatedAt sets the "updated_at" field.
  44207. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44208. m.updated_at = &t
  44209. }
  44210. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44211. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44212. v := m.updated_at
  44213. if v == nil {
  44214. return
  44215. }
  44216. return *v, true
  44217. }
  44218. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44219. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44221. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44222. if !m.op.Is(OpUpdateOne) {
  44223. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44224. }
  44225. if m.id == nil || m.oldValue == nil {
  44226. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44227. }
  44228. oldValue, err := m.oldValue(ctx)
  44229. if err != nil {
  44230. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44231. }
  44232. return oldValue.UpdatedAt, nil
  44233. }
  44234. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44235. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44236. m.updated_at = nil
  44237. }
  44238. // SetDeletedAt sets the "deleted_at" field.
  44239. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44240. m.deleted_at = &t
  44241. }
  44242. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44243. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44244. v := m.deleted_at
  44245. if v == nil {
  44246. return
  44247. }
  44248. return *v, true
  44249. }
  44250. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44251. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44253. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44254. if !m.op.Is(OpUpdateOne) {
  44255. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44256. }
  44257. if m.id == nil || m.oldValue == nil {
  44258. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44259. }
  44260. oldValue, err := m.oldValue(ctx)
  44261. if err != nil {
  44262. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44263. }
  44264. return oldValue.DeletedAt, nil
  44265. }
  44266. // ClearDeletedAt clears the value of the "deleted_at" field.
  44267. func (m *WxCardUserMutation) ClearDeletedAt() {
  44268. m.deleted_at = nil
  44269. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44270. }
  44271. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44272. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44273. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44274. return ok
  44275. }
  44276. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44277. func (m *WxCardUserMutation) ResetDeletedAt() {
  44278. m.deleted_at = nil
  44279. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44280. }
  44281. // SetWxid sets the "wxid" field.
  44282. func (m *WxCardUserMutation) SetWxid(s string) {
  44283. m.wxid = &s
  44284. }
  44285. // Wxid returns the value of the "wxid" field in the mutation.
  44286. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44287. v := m.wxid
  44288. if v == nil {
  44289. return
  44290. }
  44291. return *v, true
  44292. }
  44293. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44294. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44296. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44297. if !m.op.Is(OpUpdateOne) {
  44298. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44299. }
  44300. if m.id == nil || m.oldValue == nil {
  44301. return v, errors.New("OldWxid requires an ID field in the mutation")
  44302. }
  44303. oldValue, err := m.oldValue(ctx)
  44304. if err != nil {
  44305. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44306. }
  44307. return oldValue.Wxid, nil
  44308. }
  44309. // ResetWxid resets all changes to the "wxid" field.
  44310. func (m *WxCardUserMutation) ResetWxid() {
  44311. m.wxid = nil
  44312. }
  44313. // SetAccount sets the "account" field.
  44314. func (m *WxCardUserMutation) SetAccount(s string) {
  44315. m.account = &s
  44316. }
  44317. // Account returns the value of the "account" field in the mutation.
  44318. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44319. v := m.account
  44320. if v == nil {
  44321. return
  44322. }
  44323. return *v, true
  44324. }
  44325. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44326. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44328. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44329. if !m.op.Is(OpUpdateOne) {
  44330. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44331. }
  44332. if m.id == nil || m.oldValue == nil {
  44333. return v, errors.New("OldAccount requires an ID field in the mutation")
  44334. }
  44335. oldValue, err := m.oldValue(ctx)
  44336. if err != nil {
  44337. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44338. }
  44339. return oldValue.Account, nil
  44340. }
  44341. // ResetAccount resets all changes to the "account" field.
  44342. func (m *WxCardUserMutation) ResetAccount() {
  44343. m.account = nil
  44344. }
  44345. // SetAvatar sets the "avatar" field.
  44346. func (m *WxCardUserMutation) SetAvatar(s string) {
  44347. m.avatar = &s
  44348. }
  44349. // Avatar returns the value of the "avatar" field in the mutation.
  44350. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44351. v := m.avatar
  44352. if v == nil {
  44353. return
  44354. }
  44355. return *v, true
  44356. }
  44357. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44358. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44360. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44361. if !m.op.Is(OpUpdateOne) {
  44362. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44363. }
  44364. if m.id == nil || m.oldValue == nil {
  44365. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44366. }
  44367. oldValue, err := m.oldValue(ctx)
  44368. if err != nil {
  44369. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44370. }
  44371. return oldValue.Avatar, nil
  44372. }
  44373. // ResetAvatar resets all changes to the "avatar" field.
  44374. func (m *WxCardUserMutation) ResetAvatar() {
  44375. m.avatar = nil
  44376. }
  44377. // SetNickname sets the "nickname" field.
  44378. func (m *WxCardUserMutation) SetNickname(s string) {
  44379. m.nickname = &s
  44380. }
  44381. // Nickname returns the value of the "nickname" field in the mutation.
  44382. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44383. v := m.nickname
  44384. if v == nil {
  44385. return
  44386. }
  44387. return *v, true
  44388. }
  44389. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44390. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44392. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44393. if !m.op.Is(OpUpdateOne) {
  44394. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44395. }
  44396. if m.id == nil || m.oldValue == nil {
  44397. return v, errors.New("OldNickname requires an ID field in the mutation")
  44398. }
  44399. oldValue, err := m.oldValue(ctx)
  44400. if err != nil {
  44401. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44402. }
  44403. return oldValue.Nickname, nil
  44404. }
  44405. // ResetNickname resets all changes to the "nickname" field.
  44406. func (m *WxCardUserMutation) ResetNickname() {
  44407. m.nickname = nil
  44408. }
  44409. // SetRemark sets the "remark" field.
  44410. func (m *WxCardUserMutation) SetRemark(s string) {
  44411. m.remark = &s
  44412. }
  44413. // Remark returns the value of the "remark" field in the mutation.
  44414. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44415. v := m.remark
  44416. if v == nil {
  44417. return
  44418. }
  44419. return *v, true
  44420. }
  44421. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44422. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44424. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44425. if !m.op.Is(OpUpdateOne) {
  44426. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44427. }
  44428. if m.id == nil || m.oldValue == nil {
  44429. return v, errors.New("OldRemark requires an ID field in the mutation")
  44430. }
  44431. oldValue, err := m.oldValue(ctx)
  44432. if err != nil {
  44433. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44434. }
  44435. return oldValue.Remark, nil
  44436. }
  44437. // ResetRemark resets all changes to the "remark" field.
  44438. func (m *WxCardUserMutation) ResetRemark() {
  44439. m.remark = nil
  44440. }
  44441. // SetPhone sets the "phone" field.
  44442. func (m *WxCardUserMutation) SetPhone(s string) {
  44443. m.phone = &s
  44444. }
  44445. // Phone returns the value of the "phone" field in the mutation.
  44446. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44447. v := m.phone
  44448. if v == nil {
  44449. return
  44450. }
  44451. return *v, true
  44452. }
  44453. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44454. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44456. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44457. if !m.op.Is(OpUpdateOne) {
  44458. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44459. }
  44460. if m.id == nil || m.oldValue == nil {
  44461. return v, errors.New("OldPhone requires an ID field in the mutation")
  44462. }
  44463. oldValue, err := m.oldValue(ctx)
  44464. if err != nil {
  44465. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44466. }
  44467. return oldValue.Phone, nil
  44468. }
  44469. // ResetPhone resets all changes to the "phone" field.
  44470. func (m *WxCardUserMutation) ResetPhone() {
  44471. m.phone = nil
  44472. }
  44473. // SetOpenID sets the "open_id" field.
  44474. func (m *WxCardUserMutation) SetOpenID(s string) {
  44475. m.open_id = &s
  44476. }
  44477. // OpenID returns the value of the "open_id" field in the mutation.
  44478. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44479. v := m.open_id
  44480. if v == nil {
  44481. return
  44482. }
  44483. return *v, true
  44484. }
  44485. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44486. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44488. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44489. if !m.op.Is(OpUpdateOne) {
  44490. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44491. }
  44492. if m.id == nil || m.oldValue == nil {
  44493. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44494. }
  44495. oldValue, err := m.oldValue(ctx)
  44496. if err != nil {
  44497. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44498. }
  44499. return oldValue.OpenID, nil
  44500. }
  44501. // ResetOpenID resets all changes to the "open_id" field.
  44502. func (m *WxCardUserMutation) ResetOpenID() {
  44503. m.open_id = nil
  44504. }
  44505. // SetUnionID sets the "union_id" field.
  44506. func (m *WxCardUserMutation) SetUnionID(s string) {
  44507. m.union_id = &s
  44508. }
  44509. // UnionID returns the value of the "union_id" field in the mutation.
  44510. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44511. v := m.union_id
  44512. if v == nil {
  44513. return
  44514. }
  44515. return *v, true
  44516. }
  44517. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44518. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44520. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44521. if !m.op.Is(OpUpdateOne) {
  44522. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44523. }
  44524. if m.id == nil || m.oldValue == nil {
  44525. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44526. }
  44527. oldValue, err := m.oldValue(ctx)
  44528. if err != nil {
  44529. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44530. }
  44531. return oldValue.UnionID, nil
  44532. }
  44533. // ResetUnionID resets all changes to the "union_id" field.
  44534. func (m *WxCardUserMutation) ResetUnionID() {
  44535. m.union_id = nil
  44536. }
  44537. // SetSessionKey sets the "session_key" field.
  44538. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44539. m.session_key = &s
  44540. }
  44541. // SessionKey returns the value of the "session_key" field in the mutation.
  44542. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44543. v := m.session_key
  44544. if v == nil {
  44545. return
  44546. }
  44547. return *v, true
  44548. }
  44549. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44550. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44552. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44553. if !m.op.Is(OpUpdateOne) {
  44554. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44555. }
  44556. if m.id == nil || m.oldValue == nil {
  44557. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44558. }
  44559. oldValue, err := m.oldValue(ctx)
  44560. if err != nil {
  44561. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44562. }
  44563. return oldValue.SessionKey, nil
  44564. }
  44565. // ResetSessionKey resets all changes to the "session_key" field.
  44566. func (m *WxCardUserMutation) ResetSessionKey() {
  44567. m.session_key = nil
  44568. }
  44569. // SetIsVip sets the "is_vip" field.
  44570. func (m *WxCardUserMutation) SetIsVip(i int) {
  44571. m.is_vip = &i
  44572. m.addis_vip = nil
  44573. }
  44574. // IsVip returns the value of the "is_vip" field in the mutation.
  44575. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44576. v := m.is_vip
  44577. if v == nil {
  44578. return
  44579. }
  44580. return *v, true
  44581. }
  44582. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44583. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44585. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44586. if !m.op.Is(OpUpdateOne) {
  44587. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44588. }
  44589. if m.id == nil || m.oldValue == nil {
  44590. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44591. }
  44592. oldValue, err := m.oldValue(ctx)
  44593. if err != nil {
  44594. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44595. }
  44596. return oldValue.IsVip, nil
  44597. }
  44598. // AddIsVip adds i to the "is_vip" field.
  44599. func (m *WxCardUserMutation) AddIsVip(i int) {
  44600. if m.addis_vip != nil {
  44601. *m.addis_vip += i
  44602. } else {
  44603. m.addis_vip = &i
  44604. }
  44605. }
  44606. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44607. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44608. v := m.addis_vip
  44609. if v == nil {
  44610. return
  44611. }
  44612. return *v, true
  44613. }
  44614. // ResetIsVip resets all changes to the "is_vip" field.
  44615. func (m *WxCardUserMutation) ResetIsVip() {
  44616. m.is_vip = nil
  44617. m.addis_vip = nil
  44618. }
  44619. // Where appends a list predicates to the WxCardUserMutation builder.
  44620. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44621. m.predicates = append(m.predicates, ps...)
  44622. }
  44623. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44624. // users can use type-assertion to append predicates that do not depend on any generated package.
  44625. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44626. p := make([]predicate.WxCardUser, len(ps))
  44627. for i := range ps {
  44628. p[i] = ps[i]
  44629. }
  44630. m.Where(p...)
  44631. }
  44632. // Op returns the operation name.
  44633. func (m *WxCardUserMutation) Op() Op {
  44634. return m.op
  44635. }
  44636. // SetOp allows setting the mutation operation.
  44637. func (m *WxCardUserMutation) SetOp(op Op) {
  44638. m.op = op
  44639. }
  44640. // Type returns the node type of this mutation (WxCardUser).
  44641. func (m *WxCardUserMutation) Type() string {
  44642. return m.typ
  44643. }
  44644. // Fields returns all fields that were changed during this mutation. Note that in
  44645. // order to get all numeric fields that were incremented/decremented, call
  44646. // AddedFields().
  44647. func (m *WxCardUserMutation) Fields() []string {
  44648. fields := make([]string, 0, 13)
  44649. if m.created_at != nil {
  44650. fields = append(fields, wxcarduser.FieldCreatedAt)
  44651. }
  44652. if m.updated_at != nil {
  44653. fields = append(fields, wxcarduser.FieldUpdatedAt)
  44654. }
  44655. if m.deleted_at != nil {
  44656. fields = append(fields, wxcarduser.FieldDeletedAt)
  44657. }
  44658. if m.wxid != nil {
  44659. fields = append(fields, wxcarduser.FieldWxid)
  44660. }
  44661. if m.account != nil {
  44662. fields = append(fields, wxcarduser.FieldAccount)
  44663. }
  44664. if m.avatar != nil {
  44665. fields = append(fields, wxcarduser.FieldAvatar)
  44666. }
  44667. if m.nickname != nil {
  44668. fields = append(fields, wxcarduser.FieldNickname)
  44669. }
  44670. if m.remark != nil {
  44671. fields = append(fields, wxcarduser.FieldRemark)
  44672. }
  44673. if m.phone != nil {
  44674. fields = append(fields, wxcarduser.FieldPhone)
  44675. }
  44676. if m.open_id != nil {
  44677. fields = append(fields, wxcarduser.FieldOpenID)
  44678. }
  44679. if m.union_id != nil {
  44680. fields = append(fields, wxcarduser.FieldUnionID)
  44681. }
  44682. if m.session_key != nil {
  44683. fields = append(fields, wxcarduser.FieldSessionKey)
  44684. }
  44685. if m.is_vip != nil {
  44686. fields = append(fields, wxcarduser.FieldIsVip)
  44687. }
  44688. return fields
  44689. }
  44690. // Field returns the value of a field with the given name. The second boolean
  44691. // return value indicates that this field was not set, or was not defined in the
  44692. // schema.
  44693. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  44694. switch name {
  44695. case wxcarduser.FieldCreatedAt:
  44696. return m.CreatedAt()
  44697. case wxcarduser.FieldUpdatedAt:
  44698. return m.UpdatedAt()
  44699. case wxcarduser.FieldDeletedAt:
  44700. return m.DeletedAt()
  44701. case wxcarduser.FieldWxid:
  44702. return m.Wxid()
  44703. case wxcarduser.FieldAccount:
  44704. return m.Account()
  44705. case wxcarduser.FieldAvatar:
  44706. return m.Avatar()
  44707. case wxcarduser.FieldNickname:
  44708. return m.Nickname()
  44709. case wxcarduser.FieldRemark:
  44710. return m.Remark()
  44711. case wxcarduser.FieldPhone:
  44712. return m.Phone()
  44713. case wxcarduser.FieldOpenID:
  44714. return m.OpenID()
  44715. case wxcarduser.FieldUnionID:
  44716. return m.UnionID()
  44717. case wxcarduser.FieldSessionKey:
  44718. return m.SessionKey()
  44719. case wxcarduser.FieldIsVip:
  44720. return m.IsVip()
  44721. }
  44722. return nil, false
  44723. }
  44724. // OldField returns the old value of the field from the database. An error is
  44725. // returned if the mutation operation is not UpdateOne, or the query to the
  44726. // database failed.
  44727. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44728. switch name {
  44729. case wxcarduser.FieldCreatedAt:
  44730. return m.OldCreatedAt(ctx)
  44731. case wxcarduser.FieldUpdatedAt:
  44732. return m.OldUpdatedAt(ctx)
  44733. case wxcarduser.FieldDeletedAt:
  44734. return m.OldDeletedAt(ctx)
  44735. case wxcarduser.FieldWxid:
  44736. return m.OldWxid(ctx)
  44737. case wxcarduser.FieldAccount:
  44738. return m.OldAccount(ctx)
  44739. case wxcarduser.FieldAvatar:
  44740. return m.OldAvatar(ctx)
  44741. case wxcarduser.FieldNickname:
  44742. return m.OldNickname(ctx)
  44743. case wxcarduser.FieldRemark:
  44744. return m.OldRemark(ctx)
  44745. case wxcarduser.FieldPhone:
  44746. return m.OldPhone(ctx)
  44747. case wxcarduser.FieldOpenID:
  44748. return m.OldOpenID(ctx)
  44749. case wxcarduser.FieldUnionID:
  44750. return m.OldUnionID(ctx)
  44751. case wxcarduser.FieldSessionKey:
  44752. return m.OldSessionKey(ctx)
  44753. case wxcarduser.FieldIsVip:
  44754. return m.OldIsVip(ctx)
  44755. }
  44756. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  44757. }
  44758. // SetField sets the value of a field with the given name. It returns an error if
  44759. // the field is not defined in the schema, or if the type mismatched the field
  44760. // type.
  44761. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  44762. switch name {
  44763. case wxcarduser.FieldCreatedAt:
  44764. v, ok := value.(time.Time)
  44765. if !ok {
  44766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44767. }
  44768. m.SetCreatedAt(v)
  44769. return nil
  44770. case wxcarduser.FieldUpdatedAt:
  44771. v, ok := value.(time.Time)
  44772. if !ok {
  44773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44774. }
  44775. m.SetUpdatedAt(v)
  44776. return nil
  44777. case wxcarduser.FieldDeletedAt:
  44778. v, ok := value.(time.Time)
  44779. if !ok {
  44780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44781. }
  44782. m.SetDeletedAt(v)
  44783. return nil
  44784. case wxcarduser.FieldWxid:
  44785. v, ok := value.(string)
  44786. if !ok {
  44787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44788. }
  44789. m.SetWxid(v)
  44790. return nil
  44791. case wxcarduser.FieldAccount:
  44792. v, ok := value.(string)
  44793. if !ok {
  44794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44795. }
  44796. m.SetAccount(v)
  44797. return nil
  44798. case wxcarduser.FieldAvatar:
  44799. v, ok := value.(string)
  44800. if !ok {
  44801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44802. }
  44803. m.SetAvatar(v)
  44804. return nil
  44805. case wxcarduser.FieldNickname:
  44806. v, ok := value.(string)
  44807. if !ok {
  44808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44809. }
  44810. m.SetNickname(v)
  44811. return nil
  44812. case wxcarduser.FieldRemark:
  44813. v, ok := value.(string)
  44814. if !ok {
  44815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44816. }
  44817. m.SetRemark(v)
  44818. return nil
  44819. case wxcarduser.FieldPhone:
  44820. v, ok := value.(string)
  44821. if !ok {
  44822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44823. }
  44824. m.SetPhone(v)
  44825. return nil
  44826. case wxcarduser.FieldOpenID:
  44827. v, ok := value.(string)
  44828. if !ok {
  44829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44830. }
  44831. m.SetOpenID(v)
  44832. return nil
  44833. case wxcarduser.FieldUnionID:
  44834. v, ok := value.(string)
  44835. if !ok {
  44836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44837. }
  44838. m.SetUnionID(v)
  44839. return nil
  44840. case wxcarduser.FieldSessionKey:
  44841. v, ok := value.(string)
  44842. if !ok {
  44843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44844. }
  44845. m.SetSessionKey(v)
  44846. return nil
  44847. case wxcarduser.FieldIsVip:
  44848. v, ok := value.(int)
  44849. if !ok {
  44850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44851. }
  44852. m.SetIsVip(v)
  44853. return nil
  44854. }
  44855. return fmt.Errorf("unknown WxCardUser field %s", name)
  44856. }
  44857. // AddedFields returns all numeric fields that were incremented/decremented during
  44858. // this mutation.
  44859. func (m *WxCardUserMutation) AddedFields() []string {
  44860. var fields []string
  44861. if m.addis_vip != nil {
  44862. fields = append(fields, wxcarduser.FieldIsVip)
  44863. }
  44864. return fields
  44865. }
  44866. // AddedField returns the numeric value that was incremented/decremented on a field
  44867. // with the given name. The second boolean return value indicates that this field
  44868. // was not set, or was not defined in the schema.
  44869. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  44870. switch name {
  44871. case wxcarduser.FieldIsVip:
  44872. return m.AddedIsVip()
  44873. }
  44874. return nil, false
  44875. }
  44876. // AddField adds the value to the field with the given name. It returns an error if
  44877. // the field is not defined in the schema, or if the type mismatched the field
  44878. // type.
  44879. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  44880. switch name {
  44881. case wxcarduser.FieldIsVip:
  44882. v, ok := value.(int)
  44883. if !ok {
  44884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44885. }
  44886. m.AddIsVip(v)
  44887. return nil
  44888. }
  44889. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  44890. }
  44891. // ClearedFields returns all nullable fields that were cleared during this
  44892. // mutation.
  44893. func (m *WxCardUserMutation) ClearedFields() []string {
  44894. var fields []string
  44895. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  44896. fields = append(fields, wxcarduser.FieldDeletedAt)
  44897. }
  44898. return fields
  44899. }
  44900. // FieldCleared returns a boolean indicating if a field with the given name was
  44901. // cleared in this mutation.
  44902. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  44903. _, ok := m.clearedFields[name]
  44904. return ok
  44905. }
  44906. // ClearField clears the value of the field with the given name. It returns an
  44907. // error if the field is not defined in the schema.
  44908. func (m *WxCardUserMutation) ClearField(name string) error {
  44909. switch name {
  44910. case wxcarduser.FieldDeletedAt:
  44911. m.ClearDeletedAt()
  44912. return nil
  44913. }
  44914. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  44915. }
  44916. // ResetField resets all changes in the mutation for the field with the given name.
  44917. // It returns an error if the field is not defined in the schema.
  44918. func (m *WxCardUserMutation) ResetField(name string) error {
  44919. switch name {
  44920. case wxcarduser.FieldCreatedAt:
  44921. m.ResetCreatedAt()
  44922. return nil
  44923. case wxcarduser.FieldUpdatedAt:
  44924. m.ResetUpdatedAt()
  44925. return nil
  44926. case wxcarduser.FieldDeletedAt:
  44927. m.ResetDeletedAt()
  44928. return nil
  44929. case wxcarduser.FieldWxid:
  44930. m.ResetWxid()
  44931. return nil
  44932. case wxcarduser.FieldAccount:
  44933. m.ResetAccount()
  44934. return nil
  44935. case wxcarduser.FieldAvatar:
  44936. m.ResetAvatar()
  44937. return nil
  44938. case wxcarduser.FieldNickname:
  44939. m.ResetNickname()
  44940. return nil
  44941. case wxcarduser.FieldRemark:
  44942. m.ResetRemark()
  44943. return nil
  44944. case wxcarduser.FieldPhone:
  44945. m.ResetPhone()
  44946. return nil
  44947. case wxcarduser.FieldOpenID:
  44948. m.ResetOpenID()
  44949. return nil
  44950. case wxcarduser.FieldUnionID:
  44951. m.ResetUnionID()
  44952. return nil
  44953. case wxcarduser.FieldSessionKey:
  44954. m.ResetSessionKey()
  44955. return nil
  44956. case wxcarduser.FieldIsVip:
  44957. m.ResetIsVip()
  44958. return nil
  44959. }
  44960. return fmt.Errorf("unknown WxCardUser field %s", name)
  44961. }
  44962. // AddedEdges returns all edge names that were set/added in this mutation.
  44963. func (m *WxCardUserMutation) AddedEdges() []string {
  44964. edges := make([]string, 0, 0)
  44965. return edges
  44966. }
  44967. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44968. // name in this mutation.
  44969. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  44970. return nil
  44971. }
  44972. // RemovedEdges returns all edge names that were removed in this mutation.
  44973. func (m *WxCardUserMutation) RemovedEdges() []string {
  44974. edges := make([]string, 0, 0)
  44975. return edges
  44976. }
  44977. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44978. // the given name in this mutation.
  44979. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  44980. return nil
  44981. }
  44982. // ClearedEdges returns all edge names that were cleared in this mutation.
  44983. func (m *WxCardUserMutation) ClearedEdges() []string {
  44984. edges := make([]string, 0, 0)
  44985. return edges
  44986. }
  44987. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44988. // was cleared in this mutation.
  44989. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  44990. return false
  44991. }
  44992. // ClearEdge clears the value of the edge with the given name. It returns an error
  44993. // if that edge is not defined in the schema.
  44994. func (m *WxCardUserMutation) ClearEdge(name string) error {
  44995. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  44996. }
  44997. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44998. // It returns an error if the edge is not defined in the schema.
  44999. func (m *WxCardUserMutation) ResetEdge(name string) error {
  45000. return fmt.Errorf("unknown WxCardUser edge %s", name)
  45001. }
  45002. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  45003. type WxCardVisitMutation struct {
  45004. config
  45005. op Op
  45006. typ string
  45007. id *uint64
  45008. created_at *time.Time
  45009. updated_at *time.Time
  45010. deleted_at *time.Time
  45011. user_id *uint64
  45012. adduser_id *int64
  45013. bot_id *uint64
  45014. addbot_id *int64
  45015. bot_type *uint8
  45016. addbot_type *int8
  45017. clearedFields map[string]struct{}
  45018. done bool
  45019. oldValue func(context.Context) (*WxCardVisit, error)
  45020. predicates []predicate.WxCardVisit
  45021. }
  45022. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  45023. // wxcardvisitOption allows management of the mutation configuration using functional options.
  45024. type wxcardvisitOption func(*WxCardVisitMutation)
  45025. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  45026. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  45027. m := &WxCardVisitMutation{
  45028. config: c,
  45029. op: op,
  45030. typ: TypeWxCardVisit,
  45031. clearedFields: make(map[string]struct{}),
  45032. }
  45033. for _, opt := range opts {
  45034. opt(m)
  45035. }
  45036. return m
  45037. }
  45038. // withWxCardVisitID sets the ID field of the mutation.
  45039. func withWxCardVisitID(id uint64) wxcardvisitOption {
  45040. return func(m *WxCardVisitMutation) {
  45041. var (
  45042. err error
  45043. once sync.Once
  45044. value *WxCardVisit
  45045. )
  45046. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  45047. once.Do(func() {
  45048. if m.done {
  45049. err = errors.New("querying old values post mutation is not allowed")
  45050. } else {
  45051. value, err = m.Client().WxCardVisit.Get(ctx, id)
  45052. }
  45053. })
  45054. return value, err
  45055. }
  45056. m.id = &id
  45057. }
  45058. }
  45059. // withWxCardVisit sets the old WxCardVisit of the mutation.
  45060. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  45061. return func(m *WxCardVisitMutation) {
  45062. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  45063. return node, nil
  45064. }
  45065. m.id = &node.ID
  45066. }
  45067. }
  45068. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45069. // executed in a transaction (ent.Tx), a transactional client is returned.
  45070. func (m WxCardVisitMutation) Client() *Client {
  45071. client := &Client{config: m.config}
  45072. client.init()
  45073. return client
  45074. }
  45075. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45076. // it returns an error otherwise.
  45077. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  45078. if _, ok := m.driver.(*txDriver); !ok {
  45079. return nil, errors.New("ent: mutation is not running in a transaction")
  45080. }
  45081. tx := &Tx{config: m.config}
  45082. tx.init()
  45083. return tx, nil
  45084. }
  45085. // SetID sets the value of the id field. Note that this
  45086. // operation is only accepted on creation of WxCardVisit entities.
  45087. func (m *WxCardVisitMutation) SetID(id uint64) {
  45088. m.id = &id
  45089. }
  45090. // ID returns the ID value in the mutation. Note that the ID is only available
  45091. // if it was provided to the builder or after it was returned from the database.
  45092. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45093. if m.id == nil {
  45094. return
  45095. }
  45096. return *m.id, true
  45097. }
  45098. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45099. // That means, if the mutation is applied within a transaction with an isolation level such
  45100. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45101. // or updated by the mutation.
  45102. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45103. switch {
  45104. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45105. id, exists := m.ID()
  45106. if exists {
  45107. return []uint64{id}, nil
  45108. }
  45109. fallthrough
  45110. case m.op.Is(OpUpdate | OpDelete):
  45111. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45112. default:
  45113. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45114. }
  45115. }
  45116. // SetCreatedAt sets the "created_at" field.
  45117. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45118. m.created_at = &t
  45119. }
  45120. // CreatedAt returns the value of the "created_at" field in the mutation.
  45121. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45122. v := m.created_at
  45123. if v == nil {
  45124. return
  45125. }
  45126. return *v, true
  45127. }
  45128. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45129. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45131. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45132. if !m.op.Is(OpUpdateOne) {
  45133. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45134. }
  45135. if m.id == nil || m.oldValue == nil {
  45136. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45137. }
  45138. oldValue, err := m.oldValue(ctx)
  45139. if err != nil {
  45140. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45141. }
  45142. return oldValue.CreatedAt, nil
  45143. }
  45144. // ResetCreatedAt resets all changes to the "created_at" field.
  45145. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45146. m.created_at = nil
  45147. }
  45148. // SetUpdatedAt sets the "updated_at" field.
  45149. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45150. m.updated_at = &t
  45151. }
  45152. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45153. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45154. v := m.updated_at
  45155. if v == nil {
  45156. return
  45157. }
  45158. return *v, true
  45159. }
  45160. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45161. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45163. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45164. if !m.op.Is(OpUpdateOne) {
  45165. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45166. }
  45167. if m.id == nil || m.oldValue == nil {
  45168. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45169. }
  45170. oldValue, err := m.oldValue(ctx)
  45171. if err != nil {
  45172. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45173. }
  45174. return oldValue.UpdatedAt, nil
  45175. }
  45176. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45177. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45178. m.updated_at = nil
  45179. }
  45180. // SetDeletedAt sets the "deleted_at" field.
  45181. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45182. m.deleted_at = &t
  45183. }
  45184. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45185. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45186. v := m.deleted_at
  45187. if v == nil {
  45188. return
  45189. }
  45190. return *v, true
  45191. }
  45192. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45193. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45195. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45196. if !m.op.Is(OpUpdateOne) {
  45197. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45198. }
  45199. if m.id == nil || m.oldValue == nil {
  45200. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45201. }
  45202. oldValue, err := m.oldValue(ctx)
  45203. if err != nil {
  45204. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45205. }
  45206. return oldValue.DeletedAt, nil
  45207. }
  45208. // ClearDeletedAt clears the value of the "deleted_at" field.
  45209. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45210. m.deleted_at = nil
  45211. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45212. }
  45213. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45214. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45215. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45216. return ok
  45217. }
  45218. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45219. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45220. m.deleted_at = nil
  45221. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45222. }
  45223. // SetUserID sets the "user_id" field.
  45224. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45225. m.user_id = &u
  45226. m.adduser_id = nil
  45227. }
  45228. // UserID returns the value of the "user_id" field in the mutation.
  45229. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45230. v := m.user_id
  45231. if v == nil {
  45232. return
  45233. }
  45234. return *v, true
  45235. }
  45236. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45237. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45239. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45240. if !m.op.Is(OpUpdateOne) {
  45241. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45242. }
  45243. if m.id == nil || m.oldValue == nil {
  45244. return v, errors.New("OldUserID requires an ID field in the mutation")
  45245. }
  45246. oldValue, err := m.oldValue(ctx)
  45247. if err != nil {
  45248. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45249. }
  45250. return oldValue.UserID, nil
  45251. }
  45252. // AddUserID adds u to the "user_id" field.
  45253. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45254. if m.adduser_id != nil {
  45255. *m.adduser_id += u
  45256. } else {
  45257. m.adduser_id = &u
  45258. }
  45259. }
  45260. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45261. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45262. v := m.adduser_id
  45263. if v == nil {
  45264. return
  45265. }
  45266. return *v, true
  45267. }
  45268. // ClearUserID clears the value of the "user_id" field.
  45269. func (m *WxCardVisitMutation) ClearUserID() {
  45270. m.user_id = nil
  45271. m.adduser_id = nil
  45272. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45273. }
  45274. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45275. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45276. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45277. return ok
  45278. }
  45279. // ResetUserID resets all changes to the "user_id" field.
  45280. func (m *WxCardVisitMutation) ResetUserID() {
  45281. m.user_id = nil
  45282. m.adduser_id = nil
  45283. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45284. }
  45285. // SetBotID sets the "bot_id" field.
  45286. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45287. m.bot_id = &u
  45288. m.addbot_id = nil
  45289. }
  45290. // BotID returns the value of the "bot_id" field in the mutation.
  45291. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45292. v := m.bot_id
  45293. if v == nil {
  45294. return
  45295. }
  45296. return *v, true
  45297. }
  45298. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45299. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45301. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45302. if !m.op.Is(OpUpdateOne) {
  45303. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45304. }
  45305. if m.id == nil || m.oldValue == nil {
  45306. return v, errors.New("OldBotID requires an ID field in the mutation")
  45307. }
  45308. oldValue, err := m.oldValue(ctx)
  45309. if err != nil {
  45310. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45311. }
  45312. return oldValue.BotID, nil
  45313. }
  45314. // AddBotID adds u to the "bot_id" field.
  45315. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45316. if m.addbot_id != nil {
  45317. *m.addbot_id += u
  45318. } else {
  45319. m.addbot_id = &u
  45320. }
  45321. }
  45322. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45323. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45324. v := m.addbot_id
  45325. if v == nil {
  45326. return
  45327. }
  45328. return *v, true
  45329. }
  45330. // ResetBotID resets all changes to the "bot_id" field.
  45331. func (m *WxCardVisitMutation) ResetBotID() {
  45332. m.bot_id = nil
  45333. m.addbot_id = nil
  45334. }
  45335. // SetBotType sets the "bot_type" field.
  45336. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45337. m.bot_type = &u
  45338. m.addbot_type = nil
  45339. }
  45340. // BotType returns the value of the "bot_type" field in the mutation.
  45341. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45342. v := m.bot_type
  45343. if v == nil {
  45344. return
  45345. }
  45346. return *v, true
  45347. }
  45348. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  45349. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45351. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  45352. if !m.op.Is(OpUpdateOne) {
  45353. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45354. }
  45355. if m.id == nil || m.oldValue == nil {
  45356. return v, errors.New("OldBotType requires an ID field in the mutation")
  45357. }
  45358. oldValue, err := m.oldValue(ctx)
  45359. if err != nil {
  45360. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  45361. }
  45362. return oldValue.BotType, nil
  45363. }
  45364. // AddBotType adds u to the "bot_type" field.
  45365. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45366. if m.addbot_type != nil {
  45367. *m.addbot_type += u
  45368. } else {
  45369. m.addbot_type = &u
  45370. }
  45371. }
  45372. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45373. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45374. v := m.addbot_type
  45375. if v == nil {
  45376. return
  45377. }
  45378. return *v, true
  45379. }
  45380. // ResetBotType resets all changes to the "bot_type" field.
  45381. func (m *WxCardVisitMutation) ResetBotType() {
  45382. m.bot_type = nil
  45383. m.addbot_type = nil
  45384. }
  45385. // Where appends a list predicates to the WxCardVisitMutation builder.
  45386. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45387. m.predicates = append(m.predicates, ps...)
  45388. }
  45389. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45390. // users can use type-assertion to append predicates that do not depend on any generated package.
  45391. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45392. p := make([]predicate.WxCardVisit, len(ps))
  45393. for i := range ps {
  45394. p[i] = ps[i]
  45395. }
  45396. m.Where(p...)
  45397. }
  45398. // Op returns the operation name.
  45399. func (m *WxCardVisitMutation) Op() Op {
  45400. return m.op
  45401. }
  45402. // SetOp allows setting the mutation operation.
  45403. func (m *WxCardVisitMutation) SetOp(op Op) {
  45404. m.op = op
  45405. }
  45406. // Type returns the node type of this mutation (WxCardVisit).
  45407. func (m *WxCardVisitMutation) Type() string {
  45408. return m.typ
  45409. }
  45410. // Fields returns all fields that were changed during this mutation. Note that in
  45411. // order to get all numeric fields that were incremented/decremented, call
  45412. // AddedFields().
  45413. func (m *WxCardVisitMutation) Fields() []string {
  45414. fields := make([]string, 0, 6)
  45415. if m.created_at != nil {
  45416. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45417. }
  45418. if m.updated_at != nil {
  45419. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45420. }
  45421. if m.deleted_at != nil {
  45422. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45423. }
  45424. if m.user_id != nil {
  45425. fields = append(fields, wxcardvisit.FieldUserID)
  45426. }
  45427. if m.bot_id != nil {
  45428. fields = append(fields, wxcardvisit.FieldBotID)
  45429. }
  45430. if m.bot_type != nil {
  45431. fields = append(fields, wxcardvisit.FieldBotType)
  45432. }
  45433. return fields
  45434. }
  45435. // Field returns the value of a field with the given name. The second boolean
  45436. // return value indicates that this field was not set, or was not defined in the
  45437. // schema.
  45438. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45439. switch name {
  45440. case wxcardvisit.FieldCreatedAt:
  45441. return m.CreatedAt()
  45442. case wxcardvisit.FieldUpdatedAt:
  45443. return m.UpdatedAt()
  45444. case wxcardvisit.FieldDeletedAt:
  45445. return m.DeletedAt()
  45446. case wxcardvisit.FieldUserID:
  45447. return m.UserID()
  45448. case wxcardvisit.FieldBotID:
  45449. return m.BotID()
  45450. case wxcardvisit.FieldBotType:
  45451. return m.BotType()
  45452. }
  45453. return nil, false
  45454. }
  45455. // OldField returns the old value of the field from the database. An error is
  45456. // returned if the mutation operation is not UpdateOne, or the query to the
  45457. // database failed.
  45458. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45459. switch name {
  45460. case wxcardvisit.FieldCreatedAt:
  45461. return m.OldCreatedAt(ctx)
  45462. case wxcardvisit.FieldUpdatedAt:
  45463. return m.OldUpdatedAt(ctx)
  45464. case wxcardvisit.FieldDeletedAt:
  45465. return m.OldDeletedAt(ctx)
  45466. case wxcardvisit.FieldUserID:
  45467. return m.OldUserID(ctx)
  45468. case wxcardvisit.FieldBotID:
  45469. return m.OldBotID(ctx)
  45470. case wxcardvisit.FieldBotType:
  45471. return m.OldBotType(ctx)
  45472. }
  45473. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45474. }
  45475. // SetField sets the value of a field with the given name. It returns an error if
  45476. // the field is not defined in the schema, or if the type mismatched the field
  45477. // type.
  45478. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45479. switch name {
  45480. case wxcardvisit.FieldCreatedAt:
  45481. v, ok := value.(time.Time)
  45482. if !ok {
  45483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45484. }
  45485. m.SetCreatedAt(v)
  45486. return nil
  45487. case wxcardvisit.FieldUpdatedAt:
  45488. v, ok := value.(time.Time)
  45489. if !ok {
  45490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45491. }
  45492. m.SetUpdatedAt(v)
  45493. return nil
  45494. case wxcardvisit.FieldDeletedAt:
  45495. v, ok := value.(time.Time)
  45496. if !ok {
  45497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45498. }
  45499. m.SetDeletedAt(v)
  45500. return nil
  45501. case wxcardvisit.FieldUserID:
  45502. v, ok := value.(uint64)
  45503. if !ok {
  45504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45505. }
  45506. m.SetUserID(v)
  45507. return nil
  45508. case wxcardvisit.FieldBotID:
  45509. v, ok := value.(uint64)
  45510. if !ok {
  45511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45512. }
  45513. m.SetBotID(v)
  45514. return nil
  45515. case wxcardvisit.FieldBotType:
  45516. v, ok := value.(uint8)
  45517. if !ok {
  45518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45519. }
  45520. m.SetBotType(v)
  45521. return nil
  45522. }
  45523. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45524. }
  45525. // AddedFields returns all numeric fields that were incremented/decremented during
  45526. // this mutation.
  45527. func (m *WxCardVisitMutation) AddedFields() []string {
  45528. var fields []string
  45529. if m.adduser_id != nil {
  45530. fields = append(fields, wxcardvisit.FieldUserID)
  45531. }
  45532. if m.addbot_id != nil {
  45533. fields = append(fields, wxcardvisit.FieldBotID)
  45534. }
  45535. if m.addbot_type != nil {
  45536. fields = append(fields, wxcardvisit.FieldBotType)
  45537. }
  45538. return fields
  45539. }
  45540. // AddedField returns the numeric value that was incremented/decremented on a field
  45541. // with the given name. The second boolean return value indicates that this field
  45542. // was not set, or was not defined in the schema.
  45543. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45544. switch name {
  45545. case wxcardvisit.FieldUserID:
  45546. return m.AddedUserID()
  45547. case wxcardvisit.FieldBotID:
  45548. return m.AddedBotID()
  45549. case wxcardvisit.FieldBotType:
  45550. return m.AddedBotType()
  45551. }
  45552. return nil, false
  45553. }
  45554. // AddField adds the value to the field with the given name. It returns an error if
  45555. // the field is not defined in the schema, or if the type mismatched the field
  45556. // type.
  45557. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45558. switch name {
  45559. case wxcardvisit.FieldUserID:
  45560. v, ok := value.(int64)
  45561. if !ok {
  45562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45563. }
  45564. m.AddUserID(v)
  45565. return nil
  45566. case wxcardvisit.FieldBotID:
  45567. v, ok := value.(int64)
  45568. if !ok {
  45569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45570. }
  45571. m.AddBotID(v)
  45572. return nil
  45573. case wxcardvisit.FieldBotType:
  45574. v, ok := value.(int8)
  45575. if !ok {
  45576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45577. }
  45578. m.AddBotType(v)
  45579. return nil
  45580. }
  45581. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45582. }
  45583. // ClearedFields returns all nullable fields that were cleared during this
  45584. // mutation.
  45585. func (m *WxCardVisitMutation) ClearedFields() []string {
  45586. var fields []string
  45587. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45588. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45589. }
  45590. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45591. fields = append(fields, wxcardvisit.FieldUserID)
  45592. }
  45593. return fields
  45594. }
  45595. // FieldCleared returns a boolean indicating if a field with the given name was
  45596. // cleared in this mutation.
  45597. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45598. _, ok := m.clearedFields[name]
  45599. return ok
  45600. }
  45601. // ClearField clears the value of the field with the given name. It returns an
  45602. // error if the field is not defined in the schema.
  45603. func (m *WxCardVisitMutation) ClearField(name string) error {
  45604. switch name {
  45605. case wxcardvisit.FieldDeletedAt:
  45606. m.ClearDeletedAt()
  45607. return nil
  45608. case wxcardvisit.FieldUserID:
  45609. m.ClearUserID()
  45610. return nil
  45611. }
  45612. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45613. }
  45614. // ResetField resets all changes in the mutation for the field with the given name.
  45615. // It returns an error if the field is not defined in the schema.
  45616. func (m *WxCardVisitMutation) ResetField(name string) error {
  45617. switch name {
  45618. case wxcardvisit.FieldCreatedAt:
  45619. m.ResetCreatedAt()
  45620. return nil
  45621. case wxcardvisit.FieldUpdatedAt:
  45622. m.ResetUpdatedAt()
  45623. return nil
  45624. case wxcardvisit.FieldDeletedAt:
  45625. m.ResetDeletedAt()
  45626. return nil
  45627. case wxcardvisit.FieldUserID:
  45628. m.ResetUserID()
  45629. return nil
  45630. case wxcardvisit.FieldBotID:
  45631. m.ResetBotID()
  45632. return nil
  45633. case wxcardvisit.FieldBotType:
  45634. m.ResetBotType()
  45635. return nil
  45636. }
  45637. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45638. }
  45639. // AddedEdges returns all edge names that were set/added in this mutation.
  45640. func (m *WxCardVisitMutation) AddedEdges() []string {
  45641. edges := make([]string, 0, 0)
  45642. return edges
  45643. }
  45644. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45645. // name in this mutation.
  45646. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  45647. return nil
  45648. }
  45649. // RemovedEdges returns all edge names that were removed in this mutation.
  45650. func (m *WxCardVisitMutation) RemovedEdges() []string {
  45651. edges := make([]string, 0, 0)
  45652. return edges
  45653. }
  45654. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45655. // the given name in this mutation.
  45656. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  45657. return nil
  45658. }
  45659. // ClearedEdges returns all edge names that were cleared in this mutation.
  45660. func (m *WxCardVisitMutation) ClearedEdges() []string {
  45661. edges := make([]string, 0, 0)
  45662. return edges
  45663. }
  45664. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45665. // was cleared in this mutation.
  45666. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  45667. return false
  45668. }
  45669. // ClearEdge clears the value of the edge with the given name. It returns an error
  45670. // if that edge is not defined in the schema.
  45671. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  45672. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  45673. }
  45674. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45675. // It returns an error if the edge is not defined in the schema.
  45676. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  45677. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  45678. }
  45679. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  45680. type XunjiMutation struct {
  45681. config
  45682. op Op
  45683. typ string
  45684. id *uint64
  45685. created_at *time.Time
  45686. updated_at *time.Time
  45687. status *uint8
  45688. addstatus *int8
  45689. deleted_at *time.Time
  45690. app_key *string
  45691. app_secret *string
  45692. token *string
  45693. encoding_key *string
  45694. agent_id *uint64
  45695. addagent_id *int64
  45696. organization_id *uint64
  45697. addorganization_id *int64
  45698. clearedFields map[string]struct{}
  45699. done bool
  45700. oldValue func(context.Context) (*Xunji, error)
  45701. predicates []predicate.Xunji
  45702. }
  45703. var _ ent.Mutation = (*XunjiMutation)(nil)
  45704. // xunjiOption allows management of the mutation configuration using functional options.
  45705. type xunjiOption func(*XunjiMutation)
  45706. // newXunjiMutation creates new mutation for the Xunji entity.
  45707. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  45708. m := &XunjiMutation{
  45709. config: c,
  45710. op: op,
  45711. typ: TypeXunji,
  45712. clearedFields: make(map[string]struct{}),
  45713. }
  45714. for _, opt := range opts {
  45715. opt(m)
  45716. }
  45717. return m
  45718. }
  45719. // withXunjiID sets the ID field of the mutation.
  45720. func withXunjiID(id uint64) xunjiOption {
  45721. return func(m *XunjiMutation) {
  45722. var (
  45723. err error
  45724. once sync.Once
  45725. value *Xunji
  45726. )
  45727. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  45728. once.Do(func() {
  45729. if m.done {
  45730. err = errors.New("querying old values post mutation is not allowed")
  45731. } else {
  45732. value, err = m.Client().Xunji.Get(ctx, id)
  45733. }
  45734. })
  45735. return value, err
  45736. }
  45737. m.id = &id
  45738. }
  45739. }
  45740. // withXunji sets the old Xunji of the mutation.
  45741. func withXunji(node *Xunji) xunjiOption {
  45742. return func(m *XunjiMutation) {
  45743. m.oldValue = func(context.Context) (*Xunji, error) {
  45744. return node, nil
  45745. }
  45746. m.id = &node.ID
  45747. }
  45748. }
  45749. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45750. // executed in a transaction (ent.Tx), a transactional client is returned.
  45751. func (m XunjiMutation) Client() *Client {
  45752. client := &Client{config: m.config}
  45753. client.init()
  45754. return client
  45755. }
  45756. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45757. // it returns an error otherwise.
  45758. func (m XunjiMutation) Tx() (*Tx, error) {
  45759. if _, ok := m.driver.(*txDriver); !ok {
  45760. return nil, errors.New("ent: mutation is not running in a transaction")
  45761. }
  45762. tx := &Tx{config: m.config}
  45763. tx.init()
  45764. return tx, nil
  45765. }
  45766. // SetID sets the value of the id field. Note that this
  45767. // operation is only accepted on creation of Xunji entities.
  45768. func (m *XunjiMutation) SetID(id uint64) {
  45769. m.id = &id
  45770. }
  45771. // ID returns the ID value in the mutation. Note that the ID is only available
  45772. // if it was provided to the builder or after it was returned from the database.
  45773. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  45774. if m.id == nil {
  45775. return
  45776. }
  45777. return *m.id, true
  45778. }
  45779. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45780. // That means, if the mutation is applied within a transaction with an isolation level such
  45781. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45782. // or updated by the mutation.
  45783. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  45784. switch {
  45785. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45786. id, exists := m.ID()
  45787. if exists {
  45788. return []uint64{id}, nil
  45789. }
  45790. fallthrough
  45791. case m.op.Is(OpUpdate | OpDelete):
  45792. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  45793. default:
  45794. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45795. }
  45796. }
  45797. // SetCreatedAt sets the "created_at" field.
  45798. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  45799. m.created_at = &t
  45800. }
  45801. // CreatedAt returns the value of the "created_at" field in the mutation.
  45802. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  45803. v := m.created_at
  45804. if v == nil {
  45805. return
  45806. }
  45807. return *v, true
  45808. }
  45809. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  45810. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45812. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45813. if !m.op.Is(OpUpdateOne) {
  45814. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45815. }
  45816. if m.id == nil || m.oldValue == nil {
  45817. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45818. }
  45819. oldValue, err := m.oldValue(ctx)
  45820. if err != nil {
  45821. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45822. }
  45823. return oldValue.CreatedAt, nil
  45824. }
  45825. // ResetCreatedAt resets all changes to the "created_at" field.
  45826. func (m *XunjiMutation) ResetCreatedAt() {
  45827. m.created_at = nil
  45828. }
  45829. // SetUpdatedAt sets the "updated_at" field.
  45830. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  45831. m.updated_at = &t
  45832. }
  45833. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45834. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  45835. v := m.updated_at
  45836. if v == nil {
  45837. return
  45838. }
  45839. return *v, true
  45840. }
  45841. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  45842. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45844. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45845. if !m.op.Is(OpUpdateOne) {
  45846. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45847. }
  45848. if m.id == nil || m.oldValue == nil {
  45849. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45850. }
  45851. oldValue, err := m.oldValue(ctx)
  45852. if err != nil {
  45853. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45854. }
  45855. return oldValue.UpdatedAt, nil
  45856. }
  45857. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45858. func (m *XunjiMutation) ResetUpdatedAt() {
  45859. m.updated_at = nil
  45860. }
  45861. // SetStatus sets the "status" field.
  45862. func (m *XunjiMutation) SetStatus(u uint8) {
  45863. m.status = &u
  45864. m.addstatus = nil
  45865. }
  45866. // Status returns the value of the "status" field in the mutation.
  45867. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  45868. v := m.status
  45869. if v == nil {
  45870. return
  45871. }
  45872. return *v, true
  45873. }
  45874. // OldStatus returns the old "status" field's value of the Xunji entity.
  45875. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45877. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45878. if !m.op.Is(OpUpdateOne) {
  45879. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45880. }
  45881. if m.id == nil || m.oldValue == nil {
  45882. return v, errors.New("OldStatus requires an ID field in the mutation")
  45883. }
  45884. oldValue, err := m.oldValue(ctx)
  45885. if err != nil {
  45886. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45887. }
  45888. return oldValue.Status, nil
  45889. }
  45890. // AddStatus adds u to the "status" field.
  45891. func (m *XunjiMutation) AddStatus(u int8) {
  45892. if m.addstatus != nil {
  45893. *m.addstatus += u
  45894. } else {
  45895. m.addstatus = &u
  45896. }
  45897. }
  45898. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45899. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  45900. v := m.addstatus
  45901. if v == nil {
  45902. return
  45903. }
  45904. return *v, true
  45905. }
  45906. // ClearStatus clears the value of the "status" field.
  45907. func (m *XunjiMutation) ClearStatus() {
  45908. m.status = nil
  45909. m.addstatus = nil
  45910. m.clearedFields[xunji.FieldStatus] = struct{}{}
  45911. }
  45912. // StatusCleared returns if the "status" field was cleared in this mutation.
  45913. func (m *XunjiMutation) StatusCleared() bool {
  45914. _, ok := m.clearedFields[xunji.FieldStatus]
  45915. return ok
  45916. }
  45917. // ResetStatus resets all changes to the "status" field.
  45918. func (m *XunjiMutation) ResetStatus() {
  45919. m.status = nil
  45920. m.addstatus = nil
  45921. delete(m.clearedFields, xunji.FieldStatus)
  45922. }
  45923. // SetDeletedAt sets the "deleted_at" field.
  45924. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  45925. m.deleted_at = &t
  45926. }
  45927. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45928. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  45929. v := m.deleted_at
  45930. if v == nil {
  45931. return
  45932. }
  45933. return *v, true
  45934. }
  45935. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  45936. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45938. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45939. if !m.op.Is(OpUpdateOne) {
  45940. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45941. }
  45942. if m.id == nil || m.oldValue == nil {
  45943. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45944. }
  45945. oldValue, err := m.oldValue(ctx)
  45946. if err != nil {
  45947. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45948. }
  45949. return oldValue.DeletedAt, nil
  45950. }
  45951. // ClearDeletedAt clears the value of the "deleted_at" field.
  45952. func (m *XunjiMutation) ClearDeletedAt() {
  45953. m.deleted_at = nil
  45954. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  45955. }
  45956. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45957. func (m *XunjiMutation) DeletedAtCleared() bool {
  45958. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  45959. return ok
  45960. }
  45961. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45962. func (m *XunjiMutation) ResetDeletedAt() {
  45963. m.deleted_at = nil
  45964. delete(m.clearedFields, xunji.FieldDeletedAt)
  45965. }
  45966. // SetAppKey sets the "app_key" field.
  45967. func (m *XunjiMutation) SetAppKey(s string) {
  45968. m.app_key = &s
  45969. }
  45970. // AppKey returns the value of the "app_key" field in the mutation.
  45971. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  45972. v := m.app_key
  45973. if v == nil {
  45974. return
  45975. }
  45976. return *v, true
  45977. }
  45978. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  45979. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45981. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  45982. if !m.op.Is(OpUpdateOne) {
  45983. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  45984. }
  45985. if m.id == nil || m.oldValue == nil {
  45986. return v, errors.New("OldAppKey requires an ID field in the mutation")
  45987. }
  45988. oldValue, err := m.oldValue(ctx)
  45989. if err != nil {
  45990. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  45991. }
  45992. return oldValue.AppKey, nil
  45993. }
  45994. // ResetAppKey resets all changes to the "app_key" field.
  45995. func (m *XunjiMutation) ResetAppKey() {
  45996. m.app_key = nil
  45997. }
  45998. // SetAppSecret sets the "app_secret" field.
  45999. func (m *XunjiMutation) SetAppSecret(s string) {
  46000. m.app_secret = &s
  46001. }
  46002. // AppSecret returns the value of the "app_secret" field in the mutation.
  46003. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  46004. v := m.app_secret
  46005. if v == nil {
  46006. return
  46007. }
  46008. return *v, true
  46009. }
  46010. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  46011. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46013. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  46014. if !m.op.Is(OpUpdateOne) {
  46015. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  46016. }
  46017. if m.id == nil || m.oldValue == nil {
  46018. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  46019. }
  46020. oldValue, err := m.oldValue(ctx)
  46021. if err != nil {
  46022. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  46023. }
  46024. return oldValue.AppSecret, nil
  46025. }
  46026. // ResetAppSecret resets all changes to the "app_secret" field.
  46027. func (m *XunjiMutation) ResetAppSecret() {
  46028. m.app_secret = nil
  46029. }
  46030. // SetToken sets the "token" field.
  46031. func (m *XunjiMutation) SetToken(s string) {
  46032. m.token = &s
  46033. }
  46034. // Token returns the value of the "token" field in the mutation.
  46035. func (m *XunjiMutation) Token() (r string, exists bool) {
  46036. v := m.token
  46037. if v == nil {
  46038. return
  46039. }
  46040. return *v, true
  46041. }
  46042. // OldToken returns the old "token" field's value of the Xunji entity.
  46043. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46045. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  46046. if !m.op.Is(OpUpdateOne) {
  46047. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  46048. }
  46049. if m.id == nil || m.oldValue == nil {
  46050. return v, errors.New("OldToken requires an ID field in the mutation")
  46051. }
  46052. oldValue, err := m.oldValue(ctx)
  46053. if err != nil {
  46054. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  46055. }
  46056. return oldValue.Token, nil
  46057. }
  46058. // ResetToken resets all changes to the "token" field.
  46059. func (m *XunjiMutation) ResetToken() {
  46060. m.token = nil
  46061. }
  46062. // SetEncodingKey sets the "encoding_key" field.
  46063. func (m *XunjiMutation) SetEncodingKey(s string) {
  46064. m.encoding_key = &s
  46065. }
  46066. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  46067. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  46068. v := m.encoding_key
  46069. if v == nil {
  46070. return
  46071. }
  46072. return *v, true
  46073. }
  46074. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  46075. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46077. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  46078. if !m.op.Is(OpUpdateOne) {
  46079. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  46080. }
  46081. if m.id == nil || m.oldValue == nil {
  46082. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  46083. }
  46084. oldValue, err := m.oldValue(ctx)
  46085. if err != nil {
  46086. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  46087. }
  46088. return oldValue.EncodingKey, nil
  46089. }
  46090. // ResetEncodingKey resets all changes to the "encoding_key" field.
  46091. func (m *XunjiMutation) ResetEncodingKey() {
  46092. m.encoding_key = nil
  46093. }
  46094. // SetAgentID sets the "agent_id" field.
  46095. func (m *XunjiMutation) SetAgentID(u uint64) {
  46096. m.agent_id = &u
  46097. m.addagent_id = nil
  46098. }
  46099. // AgentID returns the value of the "agent_id" field in the mutation.
  46100. func (m *XunjiMutation) AgentID() (r uint64, exists bool) {
  46101. v := m.agent_id
  46102. if v == nil {
  46103. return
  46104. }
  46105. return *v, true
  46106. }
  46107. // OldAgentID returns the old "agent_id" field's value of the Xunji entity.
  46108. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46110. func (m *XunjiMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46111. if !m.op.Is(OpUpdateOne) {
  46112. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46113. }
  46114. if m.id == nil || m.oldValue == nil {
  46115. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46116. }
  46117. oldValue, err := m.oldValue(ctx)
  46118. if err != nil {
  46119. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46120. }
  46121. return oldValue.AgentID, nil
  46122. }
  46123. // AddAgentID adds u to the "agent_id" field.
  46124. func (m *XunjiMutation) AddAgentID(u int64) {
  46125. if m.addagent_id != nil {
  46126. *m.addagent_id += u
  46127. } else {
  46128. m.addagent_id = &u
  46129. }
  46130. }
  46131. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  46132. func (m *XunjiMutation) AddedAgentID() (r int64, exists bool) {
  46133. v := m.addagent_id
  46134. if v == nil {
  46135. return
  46136. }
  46137. return *v, true
  46138. }
  46139. // ResetAgentID resets all changes to the "agent_id" field.
  46140. func (m *XunjiMutation) ResetAgentID() {
  46141. m.agent_id = nil
  46142. m.addagent_id = nil
  46143. }
  46144. // SetOrganizationID sets the "organization_id" field.
  46145. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  46146. m.organization_id = &u
  46147. m.addorganization_id = nil
  46148. }
  46149. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46150. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  46151. v := m.organization_id
  46152. if v == nil {
  46153. return
  46154. }
  46155. return *v, true
  46156. }
  46157. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  46158. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46160. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46161. if !m.op.Is(OpUpdateOne) {
  46162. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46163. }
  46164. if m.id == nil || m.oldValue == nil {
  46165. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46166. }
  46167. oldValue, err := m.oldValue(ctx)
  46168. if err != nil {
  46169. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46170. }
  46171. return oldValue.OrganizationID, nil
  46172. }
  46173. // AddOrganizationID adds u to the "organization_id" field.
  46174. func (m *XunjiMutation) AddOrganizationID(u int64) {
  46175. if m.addorganization_id != nil {
  46176. *m.addorganization_id += u
  46177. } else {
  46178. m.addorganization_id = &u
  46179. }
  46180. }
  46181. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46182. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  46183. v := m.addorganization_id
  46184. if v == nil {
  46185. return
  46186. }
  46187. return *v, true
  46188. }
  46189. // ResetOrganizationID resets all changes to the "organization_id" field.
  46190. func (m *XunjiMutation) ResetOrganizationID() {
  46191. m.organization_id = nil
  46192. m.addorganization_id = nil
  46193. }
  46194. // Where appends a list predicates to the XunjiMutation builder.
  46195. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  46196. m.predicates = append(m.predicates, ps...)
  46197. }
  46198. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  46199. // users can use type-assertion to append predicates that do not depend on any generated package.
  46200. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  46201. p := make([]predicate.Xunji, len(ps))
  46202. for i := range ps {
  46203. p[i] = ps[i]
  46204. }
  46205. m.Where(p...)
  46206. }
  46207. // Op returns the operation name.
  46208. func (m *XunjiMutation) Op() Op {
  46209. return m.op
  46210. }
  46211. // SetOp allows setting the mutation operation.
  46212. func (m *XunjiMutation) SetOp(op Op) {
  46213. m.op = op
  46214. }
  46215. // Type returns the node type of this mutation (Xunji).
  46216. func (m *XunjiMutation) Type() string {
  46217. return m.typ
  46218. }
  46219. // Fields returns all fields that were changed during this mutation. Note that in
  46220. // order to get all numeric fields that were incremented/decremented, call
  46221. // AddedFields().
  46222. func (m *XunjiMutation) Fields() []string {
  46223. fields := make([]string, 0, 10)
  46224. if m.created_at != nil {
  46225. fields = append(fields, xunji.FieldCreatedAt)
  46226. }
  46227. if m.updated_at != nil {
  46228. fields = append(fields, xunji.FieldUpdatedAt)
  46229. }
  46230. if m.status != nil {
  46231. fields = append(fields, xunji.FieldStatus)
  46232. }
  46233. if m.deleted_at != nil {
  46234. fields = append(fields, xunji.FieldDeletedAt)
  46235. }
  46236. if m.app_key != nil {
  46237. fields = append(fields, xunji.FieldAppKey)
  46238. }
  46239. if m.app_secret != nil {
  46240. fields = append(fields, xunji.FieldAppSecret)
  46241. }
  46242. if m.token != nil {
  46243. fields = append(fields, xunji.FieldToken)
  46244. }
  46245. if m.encoding_key != nil {
  46246. fields = append(fields, xunji.FieldEncodingKey)
  46247. }
  46248. if m.agent_id != nil {
  46249. fields = append(fields, xunji.FieldAgentID)
  46250. }
  46251. if m.organization_id != nil {
  46252. fields = append(fields, xunji.FieldOrganizationID)
  46253. }
  46254. return fields
  46255. }
  46256. // Field returns the value of a field with the given name. The second boolean
  46257. // return value indicates that this field was not set, or was not defined in the
  46258. // schema.
  46259. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  46260. switch name {
  46261. case xunji.FieldCreatedAt:
  46262. return m.CreatedAt()
  46263. case xunji.FieldUpdatedAt:
  46264. return m.UpdatedAt()
  46265. case xunji.FieldStatus:
  46266. return m.Status()
  46267. case xunji.FieldDeletedAt:
  46268. return m.DeletedAt()
  46269. case xunji.FieldAppKey:
  46270. return m.AppKey()
  46271. case xunji.FieldAppSecret:
  46272. return m.AppSecret()
  46273. case xunji.FieldToken:
  46274. return m.Token()
  46275. case xunji.FieldEncodingKey:
  46276. return m.EncodingKey()
  46277. case xunji.FieldAgentID:
  46278. return m.AgentID()
  46279. case xunji.FieldOrganizationID:
  46280. return m.OrganizationID()
  46281. }
  46282. return nil, false
  46283. }
  46284. // OldField returns the old value of the field from the database. An error is
  46285. // returned if the mutation operation is not UpdateOne, or the query to the
  46286. // database failed.
  46287. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46288. switch name {
  46289. case xunji.FieldCreatedAt:
  46290. return m.OldCreatedAt(ctx)
  46291. case xunji.FieldUpdatedAt:
  46292. return m.OldUpdatedAt(ctx)
  46293. case xunji.FieldStatus:
  46294. return m.OldStatus(ctx)
  46295. case xunji.FieldDeletedAt:
  46296. return m.OldDeletedAt(ctx)
  46297. case xunji.FieldAppKey:
  46298. return m.OldAppKey(ctx)
  46299. case xunji.FieldAppSecret:
  46300. return m.OldAppSecret(ctx)
  46301. case xunji.FieldToken:
  46302. return m.OldToken(ctx)
  46303. case xunji.FieldEncodingKey:
  46304. return m.OldEncodingKey(ctx)
  46305. case xunji.FieldAgentID:
  46306. return m.OldAgentID(ctx)
  46307. case xunji.FieldOrganizationID:
  46308. return m.OldOrganizationID(ctx)
  46309. }
  46310. return nil, fmt.Errorf("unknown Xunji field %s", name)
  46311. }
  46312. // SetField sets the value of a field with the given name. It returns an error if
  46313. // the field is not defined in the schema, or if the type mismatched the field
  46314. // type.
  46315. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  46316. switch name {
  46317. case xunji.FieldCreatedAt:
  46318. v, ok := value.(time.Time)
  46319. if !ok {
  46320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46321. }
  46322. m.SetCreatedAt(v)
  46323. return nil
  46324. case xunji.FieldUpdatedAt:
  46325. v, ok := value.(time.Time)
  46326. if !ok {
  46327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46328. }
  46329. m.SetUpdatedAt(v)
  46330. return nil
  46331. case xunji.FieldStatus:
  46332. v, ok := value.(uint8)
  46333. if !ok {
  46334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46335. }
  46336. m.SetStatus(v)
  46337. return nil
  46338. case xunji.FieldDeletedAt:
  46339. v, ok := value.(time.Time)
  46340. if !ok {
  46341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46342. }
  46343. m.SetDeletedAt(v)
  46344. return nil
  46345. case xunji.FieldAppKey:
  46346. v, ok := value.(string)
  46347. if !ok {
  46348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46349. }
  46350. m.SetAppKey(v)
  46351. return nil
  46352. case xunji.FieldAppSecret:
  46353. v, ok := value.(string)
  46354. if !ok {
  46355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46356. }
  46357. m.SetAppSecret(v)
  46358. return nil
  46359. case xunji.FieldToken:
  46360. v, ok := value.(string)
  46361. if !ok {
  46362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46363. }
  46364. m.SetToken(v)
  46365. return nil
  46366. case xunji.FieldEncodingKey:
  46367. v, ok := value.(string)
  46368. if !ok {
  46369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46370. }
  46371. m.SetEncodingKey(v)
  46372. return nil
  46373. case xunji.FieldAgentID:
  46374. v, ok := value.(uint64)
  46375. if !ok {
  46376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46377. }
  46378. m.SetAgentID(v)
  46379. return nil
  46380. case xunji.FieldOrganizationID:
  46381. v, ok := value.(uint64)
  46382. if !ok {
  46383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46384. }
  46385. m.SetOrganizationID(v)
  46386. return nil
  46387. }
  46388. return fmt.Errorf("unknown Xunji field %s", name)
  46389. }
  46390. // AddedFields returns all numeric fields that were incremented/decremented during
  46391. // this mutation.
  46392. func (m *XunjiMutation) AddedFields() []string {
  46393. var fields []string
  46394. if m.addstatus != nil {
  46395. fields = append(fields, xunji.FieldStatus)
  46396. }
  46397. if m.addagent_id != nil {
  46398. fields = append(fields, xunji.FieldAgentID)
  46399. }
  46400. if m.addorganization_id != nil {
  46401. fields = append(fields, xunji.FieldOrganizationID)
  46402. }
  46403. return fields
  46404. }
  46405. // AddedField returns the numeric value that was incremented/decremented on a field
  46406. // with the given name. The second boolean return value indicates that this field
  46407. // was not set, or was not defined in the schema.
  46408. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  46409. switch name {
  46410. case xunji.FieldStatus:
  46411. return m.AddedStatus()
  46412. case xunji.FieldAgentID:
  46413. return m.AddedAgentID()
  46414. case xunji.FieldOrganizationID:
  46415. return m.AddedOrganizationID()
  46416. }
  46417. return nil, false
  46418. }
  46419. // AddField adds the value to the field with the given name. It returns an error if
  46420. // the field is not defined in the schema, or if the type mismatched the field
  46421. // type.
  46422. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  46423. switch name {
  46424. case xunji.FieldStatus:
  46425. v, ok := value.(int8)
  46426. if !ok {
  46427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46428. }
  46429. m.AddStatus(v)
  46430. return nil
  46431. case xunji.FieldAgentID:
  46432. v, ok := value.(int64)
  46433. if !ok {
  46434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46435. }
  46436. m.AddAgentID(v)
  46437. return nil
  46438. case xunji.FieldOrganizationID:
  46439. v, ok := value.(int64)
  46440. if !ok {
  46441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46442. }
  46443. m.AddOrganizationID(v)
  46444. return nil
  46445. }
  46446. return fmt.Errorf("unknown Xunji numeric field %s", name)
  46447. }
  46448. // ClearedFields returns all nullable fields that were cleared during this
  46449. // mutation.
  46450. func (m *XunjiMutation) ClearedFields() []string {
  46451. var fields []string
  46452. if m.FieldCleared(xunji.FieldStatus) {
  46453. fields = append(fields, xunji.FieldStatus)
  46454. }
  46455. if m.FieldCleared(xunji.FieldDeletedAt) {
  46456. fields = append(fields, xunji.FieldDeletedAt)
  46457. }
  46458. return fields
  46459. }
  46460. // FieldCleared returns a boolean indicating if a field with the given name was
  46461. // cleared in this mutation.
  46462. func (m *XunjiMutation) FieldCleared(name string) bool {
  46463. _, ok := m.clearedFields[name]
  46464. return ok
  46465. }
  46466. // ClearField clears the value of the field with the given name. It returns an
  46467. // error if the field is not defined in the schema.
  46468. func (m *XunjiMutation) ClearField(name string) error {
  46469. switch name {
  46470. case xunji.FieldStatus:
  46471. m.ClearStatus()
  46472. return nil
  46473. case xunji.FieldDeletedAt:
  46474. m.ClearDeletedAt()
  46475. return nil
  46476. }
  46477. return fmt.Errorf("unknown Xunji nullable field %s", name)
  46478. }
  46479. // ResetField resets all changes in the mutation for the field with the given name.
  46480. // It returns an error if the field is not defined in the schema.
  46481. func (m *XunjiMutation) ResetField(name string) error {
  46482. switch name {
  46483. case xunji.FieldCreatedAt:
  46484. m.ResetCreatedAt()
  46485. return nil
  46486. case xunji.FieldUpdatedAt:
  46487. m.ResetUpdatedAt()
  46488. return nil
  46489. case xunji.FieldStatus:
  46490. m.ResetStatus()
  46491. return nil
  46492. case xunji.FieldDeletedAt:
  46493. m.ResetDeletedAt()
  46494. return nil
  46495. case xunji.FieldAppKey:
  46496. m.ResetAppKey()
  46497. return nil
  46498. case xunji.FieldAppSecret:
  46499. m.ResetAppSecret()
  46500. return nil
  46501. case xunji.FieldToken:
  46502. m.ResetToken()
  46503. return nil
  46504. case xunji.FieldEncodingKey:
  46505. m.ResetEncodingKey()
  46506. return nil
  46507. case xunji.FieldAgentID:
  46508. m.ResetAgentID()
  46509. return nil
  46510. case xunji.FieldOrganizationID:
  46511. m.ResetOrganizationID()
  46512. return nil
  46513. }
  46514. return fmt.Errorf("unknown Xunji field %s", name)
  46515. }
  46516. // AddedEdges returns all edge names that were set/added in this mutation.
  46517. func (m *XunjiMutation) AddedEdges() []string {
  46518. edges := make([]string, 0, 0)
  46519. return edges
  46520. }
  46521. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46522. // name in this mutation.
  46523. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  46524. return nil
  46525. }
  46526. // RemovedEdges returns all edge names that were removed in this mutation.
  46527. func (m *XunjiMutation) RemovedEdges() []string {
  46528. edges := make([]string, 0, 0)
  46529. return edges
  46530. }
  46531. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46532. // the given name in this mutation.
  46533. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  46534. return nil
  46535. }
  46536. // ClearedEdges returns all edge names that were cleared in this mutation.
  46537. func (m *XunjiMutation) ClearedEdges() []string {
  46538. edges := make([]string, 0, 0)
  46539. return edges
  46540. }
  46541. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46542. // was cleared in this mutation.
  46543. func (m *XunjiMutation) EdgeCleared(name string) bool {
  46544. return false
  46545. }
  46546. // ClearEdge clears the value of the edge with the given name. It returns an error
  46547. // if that edge is not defined in the schema.
  46548. func (m *XunjiMutation) ClearEdge(name string) error {
  46549. return fmt.Errorf("unknown Xunji unique edge %s", name)
  46550. }
  46551. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46552. // It returns an error if the edge is not defined in the schema.
  46553. func (m *XunjiMutation) ResetEdge(name string) error {
  46554. return fmt.Errorf("unknown Xunji edge %s", name)
  46555. }
  46556. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  46557. type XunjiServiceMutation struct {
  46558. config
  46559. op Op
  46560. typ string
  46561. id *uint64
  46562. created_at *time.Time
  46563. updated_at *time.Time
  46564. status *uint8
  46565. addstatus *int8
  46566. deleted_at *time.Time
  46567. xunji_id *uint64
  46568. addxunji_id *int64
  46569. organization_id *uint64
  46570. addorganization_id *int64
  46571. wxid *string
  46572. api_base *string
  46573. api_key *string
  46574. clearedFields map[string]struct{}
  46575. agent *uint64
  46576. clearedagent bool
  46577. done bool
  46578. oldValue func(context.Context) (*XunjiService, error)
  46579. predicates []predicate.XunjiService
  46580. }
  46581. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  46582. // xunjiserviceOption allows management of the mutation configuration using functional options.
  46583. type xunjiserviceOption func(*XunjiServiceMutation)
  46584. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  46585. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  46586. m := &XunjiServiceMutation{
  46587. config: c,
  46588. op: op,
  46589. typ: TypeXunjiService,
  46590. clearedFields: make(map[string]struct{}),
  46591. }
  46592. for _, opt := range opts {
  46593. opt(m)
  46594. }
  46595. return m
  46596. }
  46597. // withXunjiServiceID sets the ID field of the mutation.
  46598. func withXunjiServiceID(id uint64) xunjiserviceOption {
  46599. return func(m *XunjiServiceMutation) {
  46600. var (
  46601. err error
  46602. once sync.Once
  46603. value *XunjiService
  46604. )
  46605. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  46606. once.Do(func() {
  46607. if m.done {
  46608. err = errors.New("querying old values post mutation is not allowed")
  46609. } else {
  46610. value, err = m.Client().XunjiService.Get(ctx, id)
  46611. }
  46612. })
  46613. return value, err
  46614. }
  46615. m.id = &id
  46616. }
  46617. }
  46618. // withXunjiService sets the old XunjiService of the mutation.
  46619. func withXunjiService(node *XunjiService) xunjiserviceOption {
  46620. return func(m *XunjiServiceMutation) {
  46621. m.oldValue = func(context.Context) (*XunjiService, error) {
  46622. return node, nil
  46623. }
  46624. m.id = &node.ID
  46625. }
  46626. }
  46627. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46628. // executed in a transaction (ent.Tx), a transactional client is returned.
  46629. func (m XunjiServiceMutation) Client() *Client {
  46630. client := &Client{config: m.config}
  46631. client.init()
  46632. return client
  46633. }
  46634. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46635. // it returns an error otherwise.
  46636. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  46637. if _, ok := m.driver.(*txDriver); !ok {
  46638. return nil, errors.New("ent: mutation is not running in a transaction")
  46639. }
  46640. tx := &Tx{config: m.config}
  46641. tx.init()
  46642. return tx, nil
  46643. }
  46644. // SetID sets the value of the id field. Note that this
  46645. // operation is only accepted on creation of XunjiService entities.
  46646. func (m *XunjiServiceMutation) SetID(id uint64) {
  46647. m.id = &id
  46648. }
  46649. // ID returns the ID value in the mutation. Note that the ID is only available
  46650. // if it was provided to the builder or after it was returned from the database.
  46651. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  46652. if m.id == nil {
  46653. return
  46654. }
  46655. return *m.id, true
  46656. }
  46657. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46658. // That means, if the mutation is applied within a transaction with an isolation level such
  46659. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46660. // or updated by the mutation.
  46661. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  46662. switch {
  46663. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46664. id, exists := m.ID()
  46665. if exists {
  46666. return []uint64{id}, nil
  46667. }
  46668. fallthrough
  46669. case m.op.Is(OpUpdate | OpDelete):
  46670. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  46671. default:
  46672. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46673. }
  46674. }
  46675. // SetCreatedAt sets the "created_at" field.
  46676. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  46677. m.created_at = &t
  46678. }
  46679. // CreatedAt returns the value of the "created_at" field in the mutation.
  46680. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  46681. v := m.created_at
  46682. if v == nil {
  46683. return
  46684. }
  46685. return *v, true
  46686. }
  46687. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  46688. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46690. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46691. if !m.op.Is(OpUpdateOne) {
  46692. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46693. }
  46694. if m.id == nil || m.oldValue == nil {
  46695. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46696. }
  46697. oldValue, err := m.oldValue(ctx)
  46698. if err != nil {
  46699. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46700. }
  46701. return oldValue.CreatedAt, nil
  46702. }
  46703. // ResetCreatedAt resets all changes to the "created_at" field.
  46704. func (m *XunjiServiceMutation) ResetCreatedAt() {
  46705. m.created_at = nil
  46706. }
  46707. // SetUpdatedAt sets the "updated_at" field.
  46708. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  46709. m.updated_at = &t
  46710. }
  46711. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46712. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  46713. v := m.updated_at
  46714. if v == nil {
  46715. return
  46716. }
  46717. return *v, true
  46718. }
  46719. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  46720. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46722. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46723. if !m.op.Is(OpUpdateOne) {
  46724. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46725. }
  46726. if m.id == nil || m.oldValue == nil {
  46727. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46728. }
  46729. oldValue, err := m.oldValue(ctx)
  46730. if err != nil {
  46731. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46732. }
  46733. return oldValue.UpdatedAt, nil
  46734. }
  46735. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46736. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  46737. m.updated_at = nil
  46738. }
  46739. // SetStatus sets the "status" field.
  46740. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  46741. m.status = &u
  46742. m.addstatus = nil
  46743. }
  46744. // Status returns the value of the "status" field in the mutation.
  46745. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  46746. v := m.status
  46747. if v == nil {
  46748. return
  46749. }
  46750. return *v, true
  46751. }
  46752. // OldStatus returns the old "status" field's value of the XunjiService entity.
  46753. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46755. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46756. if !m.op.Is(OpUpdateOne) {
  46757. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46758. }
  46759. if m.id == nil || m.oldValue == nil {
  46760. return v, errors.New("OldStatus requires an ID field in the mutation")
  46761. }
  46762. oldValue, err := m.oldValue(ctx)
  46763. if err != nil {
  46764. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46765. }
  46766. return oldValue.Status, nil
  46767. }
  46768. // AddStatus adds u to the "status" field.
  46769. func (m *XunjiServiceMutation) AddStatus(u int8) {
  46770. if m.addstatus != nil {
  46771. *m.addstatus += u
  46772. } else {
  46773. m.addstatus = &u
  46774. }
  46775. }
  46776. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46777. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  46778. v := m.addstatus
  46779. if v == nil {
  46780. return
  46781. }
  46782. return *v, true
  46783. }
  46784. // ClearStatus clears the value of the "status" field.
  46785. func (m *XunjiServiceMutation) ClearStatus() {
  46786. m.status = nil
  46787. m.addstatus = nil
  46788. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  46789. }
  46790. // StatusCleared returns if the "status" field was cleared in this mutation.
  46791. func (m *XunjiServiceMutation) StatusCleared() bool {
  46792. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  46793. return ok
  46794. }
  46795. // ResetStatus resets all changes to the "status" field.
  46796. func (m *XunjiServiceMutation) ResetStatus() {
  46797. m.status = nil
  46798. m.addstatus = nil
  46799. delete(m.clearedFields, xunjiservice.FieldStatus)
  46800. }
  46801. // SetDeletedAt sets the "deleted_at" field.
  46802. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  46803. m.deleted_at = &t
  46804. }
  46805. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46806. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  46807. v := m.deleted_at
  46808. if v == nil {
  46809. return
  46810. }
  46811. return *v, true
  46812. }
  46813. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  46814. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46816. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46817. if !m.op.Is(OpUpdateOne) {
  46818. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46819. }
  46820. if m.id == nil || m.oldValue == nil {
  46821. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46822. }
  46823. oldValue, err := m.oldValue(ctx)
  46824. if err != nil {
  46825. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46826. }
  46827. return oldValue.DeletedAt, nil
  46828. }
  46829. // ClearDeletedAt clears the value of the "deleted_at" field.
  46830. func (m *XunjiServiceMutation) ClearDeletedAt() {
  46831. m.deleted_at = nil
  46832. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  46833. }
  46834. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46835. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  46836. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  46837. return ok
  46838. }
  46839. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46840. func (m *XunjiServiceMutation) ResetDeletedAt() {
  46841. m.deleted_at = nil
  46842. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  46843. }
  46844. // SetXunjiID sets the "xunji_id" field.
  46845. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  46846. m.xunji_id = &u
  46847. m.addxunji_id = nil
  46848. }
  46849. // XunjiID returns the value of the "xunji_id" field in the mutation.
  46850. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  46851. v := m.xunji_id
  46852. if v == nil {
  46853. return
  46854. }
  46855. return *v, true
  46856. }
  46857. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  46858. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46860. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  46861. if !m.op.Is(OpUpdateOne) {
  46862. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  46863. }
  46864. if m.id == nil || m.oldValue == nil {
  46865. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  46866. }
  46867. oldValue, err := m.oldValue(ctx)
  46868. if err != nil {
  46869. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  46870. }
  46871. return oldValue.XunjiID, nil
  46872. }
  46873. // AddXunjiID adds u to the "xunji_id" field.
  46874. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  46875. if m.addxunji_id != nil {
  46876. *m.addxunji_id += u
  46877. } else {
  46878. m.addxunji_id = &u
  46879. }
  46880. }
  46881. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  46882. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  46883. v := m.addxunji_id
  46884. if v == nil {
  46885. return
  46886. }
  46887. return *v, true
  46888. }
  46889. // ResetXunjiID resets all changes to the "xunji_id" field.
  46890. func (m *XunjiServiceMutation) ResetXunjiID() {
  46891. m.xunji_id = nil
  46892. m.addxunji_id = nil
  46893. }
  46894. // SetAgentID sets the "agent_id" field.
  46895. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  46896. m.agent = &u
  46897. }
  46898. // AgentID returns the value of the "agent_id" field in the mutation.
  46899. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  46900. v := m.agent
  46901. if v == nil {
  46902. return
  46903. }
  46904. return *v, true
  46905. }
  46906. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  46907. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46909. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46910. if !m.op.Is(OpUpdateOne) {
  46911. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46912. }
  46913. if m.id == nil || m.oldValue == nil {
  46914. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46915. }
  46916. oldValue, err := m.oldValue(ctx)
  46917. if err != nil {
  46918. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46919. }
  46920. return oldValue.AgentID, nil
  46921. }
  46922. // ResetAgentID resets all changes to the "agent_id" field.
  46923. func (m *XunjiServiceMutation) ResetAgentID() {
  46924. m.agent = nil
  46925. }
  46926. // SetOrganizationID sets the "organization_id" field.
  46927. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  46928. m.organization_id = &u
  46929. m.addorganization_id = nil
  46930. }
  46931. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46932. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  46933. v := m.organization_id
  46934. if v == nil {
  46935. return
  46936. }
  46937. return *v, true
  46938. }
  46939. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  46940. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46942. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46943. if !m.op.Is(OpUpdateOne) {
  46944. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46945. }
  46946. if m.id == nil || m.oldValue == nil {
  46947. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46948. }
  46949. oldValue, err := m.oldValue(ctx)
  46950. if err != nil {
  46951. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46952. }
  46953. return oldValue.OrganizationID, nil
  46954. }
  46955. // AddOrganizationID adds u to the "organization_id" field.
  46956. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  46957. if m.addorganization_id != nil {
  46958. *m.addorganization_id += u
  46959. } else {
  46960. m.addorganization_id = &u
  46961. }
  46962. }
  46963. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46964. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  46965. v := m.addorganization_id
  46966. if v == nil {
  46967. return
  46968. }
  46969. return *v, true
  46970. }
  46971. // ResetOrganizationID resets all changes to the "organization_id" field.
  46972. func (m *XunjiServiceMutation) ResetOrganizationID() {
  46973. m.organization_id = nil
  46974. m.addorganization_id = nil
  46975. }
  46976. // SetWxid sets the "wxid" field.
  46977. func (m *XunjiServiceMutation) SetWxid(s string) {
  46978. m.wxid = &s
  46979. }
  46980. // Wxid returns the value of the "wxid" field in the mutation.
  46981. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  46982. v := m.wxid
  46983. if v == nil {
  46984. return
  46985. }
  46986. return *v, true
  46987. }
  46988. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  46989. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46991. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  46992. if !m.op.Is(OpUpdateOne) {
  46993. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46994. }
  46995. if m.id == nil || m.oldValue == nil {
  46996. return v, errors.New("OldWxid requires an ID field in the mutation")
  46997. }
  46998. oldValue, err := m.oldValue(ctx)
  46999. if err != nil {
  47000. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47001. }
  47002. return oldValue.Wxid, nil
  47003. }
  47004. // ResetWxid resets all changes to the "wxid" field.
  47005. func (m *XunjiServiceMutation) ResetWxid() {
  47006. m.wxid = nil
  47007. }
  47008. // SetAPIBase sets the "api_base" field.
  47009. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  47010. m.api_base = &s
  47011. }
  47012. // APIBase returns the value of the "api_base" field in the mutation.
  47013. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  47014. v := m.api_base
  47015. if v == nil {
  47016. return
  47017. }
  47018. return *v, true
  47019. }
  47020. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  47021. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47023. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47024. if !m.op.Is(OpUpdateOne) {
  47025. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47026. }
  47027. if m.id == nil || m.oldValue == nil {
  47028. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47029. }
  47030. oldValue, err := m.oldValue(ctx)
  47031. if err != nil {
  47032. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47033. }
  47034. return oldValue.APIBase, nil
  47035. }
  47036. // ClearAPIBase clears the value of the "api_base" field.
  47037. func (m *XunjiServiceMutation) ClearAPIBase() {
  47038. m.api_base = nil
  47039. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  47040. }
  47041. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47042. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  47043. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  47044. return ok
  47045. }
  47046. // ResetAPIBase resets all changes to the "api_base" field.
  47047. func (m *XunjiServiceMutation) ResetAPIBase() {
  47048. m.api_base = nil
  47049. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  47050. }
  47051. // SetAPIKey sets the "api_key" field.
  47052. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  47053. m.api_key = &s
  47054. }
  47055. // APIKey returns the value of the "api_key" field in the mutation.
  47056. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  47057. v := m.api_key
  47058. if v == nil {
  47059. return
  47060. }
  47061. return *v, true
  47062. }
  47063. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  47064. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47066. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47067. if !m.op.Is(OpUpdateOne) {
  47068. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47069. }
  47070. if m.id == nil || m.oldValue == nil {
  47071. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47072. }
  47073. oldValue, err := m.oldValue(ctx)
  47074. if err != nil {
  47075. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47076. }
  47077. return oldValue.APIKey, nil
  47078. }
  47079. // ClearAPIKey clears the value of the "api_key" field.
  47080. func (m *XunjiServiceMutation) ClearAPIKey() {
  47081. m.api_key = nil
  47082. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  47083. }
  47084. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47085. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  47086. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  47087. return ok
  47088. }
  47089. // ResetAPIKey resets all changes to the "api_key" field.
  47090. func (m *XunjiServiceMutation) ResetAPIKey() {
  47091. m.api_key = nil
  47092. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  47093. }
  47094. // ClearAgent clears the "agent" edge to the Agent entity.
  47095. func (m *XunjiServiceMutation) ClearAgent() {
  47096. m.clearedagent = true
  47097. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  47098. }
  47099. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47100. func (m *XunjiServiceMutation) AgentCleared() bool {
  47101. return m.clearedagent
  47102. }
  47103. // AgentIDs returns the "agent" edge IDs in the mutation.
  47104. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47105. // AgentID instead. It exists only for internal usage by the builders.
  47106. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  47107. if id := m.agent; id != nil {
  47108. ids = append(ids, *id)
  47109. }
  47110. return
  47111. }
  47112. // ResetAgent resets all changes to the "agent" edge.
  47113. func (m *XunjiServiceMutation) ResetAgent() {
  47114. m.agent = nil
  47115. m.clearedagent = false
  47116. }
  47117. // Where appends a list predicates to the XunjiServiceMutation builder.
  47118. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  47119. m.predicates = append(m.predicates, ps...)
  47120. }
  47121. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  47122. // users can use type-assertion to append predicates that do not depend on any generated package.
  47123. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  47124. p := make([]predicate.XunjiService, len(ps))
  47125. for i := range ps {
  47126. p[i] = ps[i]
  47127. }
  47128. m.Where(p...)
  47129. }
  47130. // Op returns the operation name.
  47131. func (m *XunjiServiceMutation) Op() Op {
  47132. return m.op
  47133. }
  47134. // SetOp allows setting the mutation operation.
  47135. func (m *XunjiServiceMutation) SetOp(op Op) {
  47136. m.op = op
  47137. }
  47138. // Type returns the node type of this mutation (XunjiService).
  47139. func (m *XunjiServiceMutation) Type() string {
  47140. return m.typ
  47141. }
  47142. // Fields returns all fields that were changed during this mutation. Note that in
  47143. // order to get all numeric fields that were incremented/decremented, call
  47144. // AddedFields().
  47145. func (m *XunjiServiceMutation) Fields() []string {
  47146. fields := make([]string, 0, 10)
  47147. if m.created_at != nil {
  47148. fields = append(fields, xunjiservice.FieldCreatedAt)
  47149. }
  47150. if m.updated_at != nil {
  47151. fields = append(fields, xunjiservice.FieldUpdatedAt)
  47152. }
  47153. if m.status != nil {
  47154. fields = append(fields, xunjiservice.FieldStatus)
  47155. }
  47156. if m.deleted_at != nil {
  47157. fields = append(fields, xunjiservice.FieldDeletedAt)
  47158. }
  47159. if m.xunji_id != nil {
  47160. fields = append(fields, xunjiservice.FieldXunjiID)
  47161. }
  47162. if m.agent != nil {
  47163. fields = append(fields, xunjiservice.FieldAgentID)
  47164. }
  47165. if m.organization_id != nil {
  47166. fields = append(fields, xunjiservice.FieldOrganizationID)
  47167. }
  47168. if m.wxid != nil {
  47169. fields = append(fields, xunjiservice.FieldWxid)
  47170. }
  47171. if m.api_base != nil {
  47172. fields = append(fields, xunjiservice.FieldAPIBase)
  47173. }
  47174. if m.api_key != nil {
  47175. fields = append(fields, xunjiservice.FieldAPIKey)
  47176. }
  47177. return fields
  47178. }
  47179. // Field returns the value of a field with the given name. The second boolean
  47180. // return value indicates that this field was not set, or was not defined in the
  47181. // schema.
  47182. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  47183. switch name {
  47184. case xunjiservice.FieldCreatedAt:
  47185. return m.CreatedAt()
  47186. case xunjiservice.FieldUpdatedAt:
  47187. return m.UpdatedAt()
  47188. case xunjiservice.FieldStatus:
  47189. return m.Status()
  47190. case xunjiservice.FieldDeletedAt:
  47191. return m.DeletedAt()
  47192. case xunjiservice.FieldXunjiID:
  47193. return m.XunjiID()
  47194. case xunjiservice.FieldAgentID:
  47195. return m.AgentID()
  47196. case xunjiservice.FieldOrganizationID:
  47197. return m.OrganizationID()
  47198. case xunjiservice.FieldWxid:
  47199. return m.Wxid()
  47200. case xunjiservice.FieldAPIBase:
  47201. return m.APIBase()
  47202. case xunjiservice.FieldAPIKey:
  47203. return m.APIKey()
  47204. }
  47205. return nil, false
  47206. }
  47207. // OldField returns the old value of the field from the database. An error is
  47208. // returned if the mutation operation is not UpdateOne, or the query to the
  47209. // database failed.
  47210. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47211. switch name {
  47212. case xunjiservice.FieldCreatedAt:
  47213. return m.OldCreatedAt(ctx)
  47214. case xunjiservice.FieldUpdatedAt:
  47215. return m.OldUpdatedAt(ctx)
  47216. case xunjiservice.FieldStatus:
  47217. return m.OldStatus(ctx)
  47218. case xunjiservice.FieldDeletedAt:
  47219. return m.OldDeletedAt(ctx)
  47220. case xunjiservice.FieldXunjiID:
  47221. return m.OldXunjiID(ctx)
  47222. case xunjiservice.FieldAgentID:
  47223. return m.OldAgentID(ctx)
  47224. case xunjiservice.FieldOrganizationID:
  47225. return m.OldOrganizationID(ctx)
  47226. case xunjiservice.FieldWxid:
  47227. return m.OldWxid(ctx)
  47228. case xunjiservice.FieldAPIBase:
  47229. return m.OldAPIBase(ctx)
  47230. case xunjiservice.FieldAPIKey:
  47231. return m.OldAPIKey(ctx)
  47232. }
  47233. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  47234. }
  47235. // SetField sets the value of a field with the given name. It returns an error if
  47236. // the field is not defined in the schema, or if the type mismatched the field
  47237. // type.
  47238. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  47239. switch name {
  47240. case xunjiservice.FieldCreatedAt:
  47241. v, ok := value.(time.Time)
  47242. if !ok {
  47243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47244. }
  47245. m.SetCreatedAt(v)
  47246. return nil
  47247. case xunjiservice.FieldUpdatedAt:
  47248. v, ok := value.(time.Time)
  47249. if !ok {
  47250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47251. }
  47252. m.SetUpdatedAt(v)
  47253. return nil
  47254. case xunjiservice.FieldStatus:
  47255. v, ok := value.(uint8)
  47256. if !ok {
  47257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47258. }
  47259. m.SetStatus(v)
  47260. return nil
  47261. case xunjiservice.FieldDeletedAt:
  47262. v, ok := value.(time.Time)
  47263. if !ok {
  47264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47265. }
  47266. m.SetDeletedAt(v)
  47267. return nil
  47268. case xunjiservice.FieldXunjiID:
  47269. v, ok := value.(uint64)
  47270. if !ok {
  47271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47272. }
  47273. m.SetXunjiID(v)
  47274. return nil
  47275. case xunjiservice.FieldAgentID:
  47276. v, ok := value.(uint64)
  47277. if !ok {
  47278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47279. }
  47280. m.SetAgentID(v)
  47281. return nil
  47282. case xunjiservice.FieldOrganizationID:
  47283. v, ok := value.(uint64)
  47284. if !ok {
  47285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47286. }
  47287. m.SetOrganizationID(v)
  47288. return nil
  47289. case xunjiservice.FieldWxid:
  47290. v, ok := value.(string)
  47291. if !ok {
  47292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47293. }
  47294. m.SetWxid(v)
  47295. return nil
  47296. case xunjiservice.FieldAPIBase:
  47297. v, ok := value.(string)
  47298. if !ok {
  47299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47300. }
  47301. m.SetAPIBase(v)
  47302. return nil
  47303. case xunjiservice.FieldAPIKey:
  47304. v, ok := value.(string)
  47305. if !ok {
  47306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47307. }
  47308. m.SetAPIKey(v)
  47309. return nil
  47310. }
  47311. return fmt.Errorf("unknown XunjiService field %s", name)
  47312. }
  47313. // AddedFields returns all numeric fields that were incremented/decremented during
  47314. // this mutation.
  47315. func (m *XunjiServiceMutation) AddedFields() []string {
  47316. var fields []string
  47317. if m.addstatus != nil {
  47318. fields = append(fields, xunjiservice.FieldStatus)
  47319. }
  47320. if m.addxunji_id != nil {
  47321. fields = append(fields, xunjiservice.FieldXunjiID)
  47322. }
  47323. if m.addorganization_id != nil {
  47324. fields = append(fields, xunjiservice.FieldOrganizationID)
  47325. }
  47326. return fields
  47327. }
  47328. // AddedField returns the numeric value that was incremented/decremented on a field
  47329. // with the given name. The second boolean return value indicates that this field
  47330. // was not set, or was not defined in the schema.
  47331. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  47332. switch name {
  47333. case xunjiservice.FieldStatus:
  47334. return m.AddedStatus()
  47335. case xunjiservice.FieldXunjiID:
  47336. return m.AddedXunjiID()
  47337. case xunjiservice.FieldOrganizationID:
  47338. return m.AddedOrganizationID()
  47339. }
  47340. return nil, false
  47341. }
  47342. // AddField adds the value to the field with the given name. It returns an error if
  47343. // the field is not defined in the schema, or if the type mismatched the field
  47344. // type.
  47345. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  47346. switch name {
  47347. case xunjiservice.FieldStatus:
  47348. v, ok := value.(int8)
  47349. if !ok {
  47350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47351. }
  47352. m.AddStatus(v)
  47353. return nil
  47354. case xunjiservice.FieldXunjiID:
  47355. v, ok := value.(int64)
  47356. if !ok {
  47357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47358. }
  47359. m.AddXunjiID(v)
  47360. return nil
  47361. case xunjiservice.FieldOrganizationID:
  47362. v, ok := value.(int64)
  47363. if !ok {
  47364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47365. }
  47366. m.AddOrganizationID(v)
  47367. return nil
  47368. }
  47369. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  47370. }
  47371. // ClearedFields returns all nullable fields that were cleared during this
  47372. // mutation.
  47373. func (m *XunjiServiceMutation) ClearedFields() []string {
  47374. var fields []string
  47375. if m.FieldCleared(xunjiservice.FieldStatus) {
  47376. fields = append(fields, xunjiservice.FieldStatus)
  47377. }
  47378. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  47379. fields = append(fields, xunjiservice.FieldDeletedAt)
  47380. }
  47381. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  47382. fields = append(fields, xunjiservice.FieldAPIBase)
  47383. }
  47384. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  47385. fields = append(fields, xunjiservice.FieldAPIKey)
  47386. }
  47387. return fields
  47388. }
  47389. // FieldCleared returns a boolean indicating if a field with the given name was
  47390. // cleared in this mutation.
  47391. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  47392. _, ok := m.clearedFields[name]
  47393. return ok
  47394. }
  47395. // ClearField clears the value of the field with the given name. It returns an
  47396. // error if the field is not defined in the schema.
  47397. func (m *XunjiServiceMutation) ClearField(name string) error {
  47398. switch name {
  47399. case xunjiservice.FieldStatus:
  47400. m.ClearStatus()
  47401. return nil
  47402. case xunjiservice.FieldDeletedAt:
  47403. m.ClearDeletedAt()
  47404. return nil
  47405. case xunjiservice.FieldAPIBase:
  47406. m.ClearAPIBase()
  47407. return nil
  47408. case xunjiservice.FieldAPIKey:
  47409. m.ClearAPIKey()
  47410. return nil
  47411. }
  47412. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  47413. }
  47414. // ResetField resets all changes in the mutation for the field with the given name.
  47415. // It returns an error if the field is not defined in the schema.
  47416. func (m *XunjiServiceMutation) ResetField(name string) error {
  47417. switch name {
  47418. case xunjiservice.FieldCreatedAt:
  47419. m.ResetCreatedAt()
  47420. return nil
  47421. case xunjiservice.FieldUpdatedAt:
  47422. m.ResetUpdatedAt()
  47423. return nil
  47424. case xunjiservice.FieldStatus:
  47425. m.ResetStatus()
  47426. return nil
  47427. case xunjiservice.FieldDeletedAt:
  47428. m.ResetDeletedAt()
  47429. return nil
  47430. case xunjiservice.FieldXunjiID:
  47431. m.ResetXunjiID()
  47432. return nil
  47433. case xunjiservice.FieldAgentID:
  47434. m.ResetAgentID()
  47435. return nil
  47436. case xunjiservice.FieldOrganizationID:
  47437. m.ResetOrganizationID()
  47438. return nil
  47439. case xunjiservice.FieldWxid:
  47440. m.ResetWxid()
  47441. return nil
  47442. case xunjiservice.FieldAPIBase:
  47443. m.ResetAPIBase()
  47444. return nil
  47445. case xunjiservice.FieldAPIKey:
  47446. m.ResetAPIKey()
  47447. return nil
  47448. }
  47449. return fmt.Errorf("unknown XunjiService field %s", name)
  47450. }
  47451. // AddedEdges returns all edge names that were set/added in this mutation.
  47452. func (m *XunjiServiceMutation) AddedEdges() []string {
  47453. edges := make([]string, 0, 1)
  47454. if m.agent != nil {
  47455. edges = append(edges, xunjiservice.EdgeAgent)
  47456. }
  47457. return edges
  47458. }
  47459. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47460. // name in this mutation.
  47461. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  47462. switch name {
  47463. case xunjiservice.EdgeAgent:
  47464. if id := m.agent; id != nil {
  47465. return []ent.Value{*id}
  47466. }
  47467. }
  47468. return nil
  47469. }
  47470. // RemovedEdges returns all edge names that were removed in this mutation.
  47471. func (m *XunjiServiceMutation) RemovedEdges() []string {
  47472. edges := make([]string, 0, 1)
  47473. return edges
  47474. }
  47475. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47476. // the given name in this mutation.
  47477. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  47478. return nil
  47479. }
  47480. // ClearedEdges returns all edge names that were cleared in this mutation.
  47481. func (m *XunjiServiceMutation) ClearedEdges() []string {
  47482. edges := make([]string, 0, 1)
  47483. if m.clearedagent {
  47484. edges = append(edges, xunjiservice.EdgeAgent)
  47485. }
  47486. return edges
  47487. }
  47488. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47489. // was cleared in this mutation.
  47490. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  47491. switch name {
  47492. case xunjiservice.EdgeAgent:
  47493. return m.clearedagent
  47494. }
  47495. return false
  47496. }
  47497. // ClearEdge clears the value of the edge with the given name. It returns an error
  47498. // if that edge is not defined in the schema.
  47499. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  47500. switch name {
  47501. case xunjiservice.EdgeAgent:
  47502. m.ClearAgent()
  47503. return nil
  47504. }
  47505. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  47506. }
  47507. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47508. // It returns an error if the edge is not defined in the schema.
  47509. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  47510. switch name {
  47511. case xunjiservice.EdgeAgent:
  47512. m.ResetAgent()
  47513. return nil
  47514. }
  47515. return fmt.Errorf("unknown XunjiService edge %s", name)
  47516. }